2014-10-10 Robert Dewar <dewar@adacore.com>
[official-gcc.git] / gcc / ada / gnat_rm.texi
blobb0bed4b15cb5bd227e036d9c181b8c0f26b2e8e7
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.Memory (s-memory.ads)::
665 * System.Multiprocessors (s-multip.ads)::
666 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
667 * System.Partition_Interface (s-parint.ads)::
668 * System.Pool_Global (s-pooglo.ads)::
669 * System.Pool_Local (s-pooloc.ads)::
670 * System.Restrictions (s-restri.ads)::
671 * System.Rident (s-rident.ads)::
672 * System.Strings.Stream_Ops (s-ststop.ads)::
673 * System.Unsigned_Types (s-unstyp.ads)::
674 * System.Wch_Cnv (s-wchcnv.ads)::
675 * System.Wch_Con (s-wchcon.ads)::
677 Text_IO
679 * Text_IO Stream Pointer Positioning::
680 * Text_IO Reading and Writing Non-Regular Files::
681 * Get_Immediate::
682 * Treating Text_IO Files as Streams::
683 * Text_IO Extensions::
684 * Text_IO Facilities for Unbounded Strings::
686 Wide_Text_IO
688 * Wide_Text_IO Stream Pointer Positioning::
689 * Wide_Text_IO Reading and Writing Non-Regular Files::
691 Wide_Wide_Text_IO
693 * Wide_Wide_Text_IO Stream Pointer Positioning::
694 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
696 Interfacing to Other Languages
698 * Interfacing to C::
699 * Interfacing to C++::
700 * Interfacing to COBOL::
701 * Interfacing to Fortran::
702 * Interfacing to non-GNAT Ada code::
704 Specialized Needs Annexes
706 Implementation of Specific Ada Features
707 * Machine Code Insertions::
708 * GNAT Implementation of Tasking::
709 * GNAT Implementation of Shared Passive Packages::
710 * Code Generation for Array Aggregates::
711 * The Size of Discriminated Records with Default Discriminants::
712 * Strict Conformance to the Ada Reference Manual::
714 Implementation of Ada 2012 Features
716 Obsolescent Features
718 GNU Free Documentation License
720 Index
721 @end detailmenu
722 @end menu
724 @end ifnottex
726 @node About This Guide
727 @unnumbered About This Guide
729 @noindent
730 This manual contains useful information in writing programs using the
731 @value{EDITION} compiler.  It includes information on implementation dependent
732 characteristics of @value{EDITION}, including all the information required by
733 Annex M of the Ada language standard.
735 @value{EDITION} implements Ada 95, Ada 2005 and Ada 2012, and it may also be
736 invoked in Ada 83 compatibility mode.
737 By default, @value{EDITION} assumes Ada 2012,
738 but you can override with a compiler switch
739 to explicitly specify the language version.
740 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
741 @value{EDITION} User's Guide}, for details on these switches.)
742 Throughout this manual, references to ``Ada'' without a year suffix
743 apply to all the Ada versions of the language.
745 Ada is designed to be highly portable.
746 In general, a program will have the same effect even when compiled by
747 different compilers on different platforms.
748 However, since Ada is designed to be used in a
749 wide variety of applications, it also contains a number of system
750 dependent features to be used in interfacing to the external world.
751 @cindex Implementation-dependent features
752 @cindex Portability
754 Note: Any program that makes use of implementation-dependent features
755 may be non-portable.  You should follow good programming practice and
756 isolate and clearly document any sections of your program that make use
757 of these features in a non-portable manner.
759 @ifset PROEDITION
760 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
761 ``GNAT'' in the remainder of this document.
762 @end ifset
764 @menu
765 * What This Reference Manual Contains::
766 * Conventions::
767 * Related Information::
768 @end menu
770 @node What This Reference Manual Contains
771 @unnumberedsec What This Reference Manual Contains
773 @noindent
774 This reference manual contains the following chapters:
776 @itemize @bullet
777 @item
778 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
779 pragmas, which can be used to extend and enhance the functionality of the
780 compiler.
782 @item
783 @ref{Implementation Defined Attributes}, lists GNAT
784 implementation-dependent attributes, which can be used to extend and
785 enhance the functionality of the compiler.
787 @item
788 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
789 implementation-dependent restrictions, which can be used to extend and
790 enhance the functionality of the compiler.
792 @item
793 @ref{Implementation Advice}, provides information on generally
794 desirable behavior which are not requirements that all compilers must
795 follow since it cannot be provided on all systems, or which may be
796 undesirable on some systems.
798 @item
799 @ref{Implementation Defined Characteristics}, provides a guide to
800 minimizing implementation dependent features.
802 @item
803 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
804 implemented by GNAT, and how they can be imported into user
805 application programs.
807 @item
808 @ref{Representation Clauses and Pragmas}, describes in detail the
809 way that GNAT represents data, and in particular the exact set
810 of representation clauses and pragmas that is accepted.
812 @item
813 @ref{Standard Library Routines}, provides a listing of packages and a
814 brief description of the functionality that is provided by Ada's
815 extensive set of standard library routines as implemented by GNAT@.
817 @item
818 @ref{The Implementation of Standard I/O}, details how the GNAT
819 implementation of the input-output facilities.
821 @item
822 @ref{The GNAT Library}, is a catalog of packages that complement
823 the Ada predefined library.
825 @item
826 @ref{Interfacing to Other Languages}, describes how programs
827 written in Ada using GNAT can be interfaced to other programming
828 languages.
830 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
831 of the specialized needs annexes.
833 @item
834 @ref{Implementation of Specific Ada Features}, discusses issues related
835 to GNAT's implementation of machine code insertions, tasking, and several
836 other features.
838 @item
839 @ref{Implementation of Ada 2012 Features}, describes the status of the
840 GNAT implementation of the Ada 2012 language standard.
842 @item
843 @ref{Obsolescent Features} documents implementation dependent features,
844 including pragmas and attributes, which are considered obsolescent, since
845 there are other preferred ways of achieving the same results. These
846 obsolescent forms are retained for backwards compatibility.
848 @end itemize
850 @cindex Ada 95 Language Reference Manual
851 @cindex Ada 2005 Language Reference Manual
852 @noindent
853 This reference manual assumes a basic familiarity with the Ada 95 language, as
854 described in the International Standard ANSI/ISO/IEC-8652:1995,
855 January 1995.
856 It does not require knowledge of the new features introduced by Ada 2005,
857 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
858 and Amendment 1).
859 Both reference manuals are included in the GNAT documentation
860 package.
862 @node Conventions
863 @unnumberedsec Conventions
864 @cindex Conventions, typographical
865 @cindex Typographical conventions
867 @noindent
868 Following are examples of the typographical and graphic conventions used
869 in this guide:
871 @itemize @bullet
872 @item
873 @code{Functions}, @code{utility program names}, @code{standard names},
874 and @code{classes}.
876 @item
877 @code{Option flags}
879 @item
880 @file{File names}, @samp{button names}, and @samp{field names}.
882 @item
883 @code{Variables}, @env{environment variables}, and @var{metasyntactic
884 variables}.
886 @item
887 @emph{Emphasis}.
889 @item
890 [optional information or parameters]
892 @item
893 Examples are described by text
894 @smallexample
895 and then shown this way.
896 @end smallexample
897 @end itemize
899 @noindent
900 Commands that are entered by the user are preceded in this manual by the
901 characters @samp{$ } (dollar sign followed by space).  If your system uses this
902 sequence as a prompt, then the commands will appear exactly as you see them
903 in the manual.  If your system uses some other prompt, then the command will
904 appear with the @samp{$} replaced by whatever prompt character you are using.
906 @node Related Information
907 @unnumberedsec Related Information
908 @noindent
909 See the following documents for further information on GNAT:
911 @itemize @bullet
912 @item
913 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
914 @value{EDITION} User's Guide}, which provides information on how to use the
915 GNAT compiler system.
917 @item
918 @cite{Ada 95 Reference Manual}, which contains all reference
919 material for the Ada 95 programming language.
921 @item
922 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
923 of the Ada 95 standard.  The annotations describe
924 detailed aspects of the design decision, and in particular contain useful
925 sections on Ada 83 compatibility.
927 @item
928 @cite{Ada 2005 Reference Manual}, which contains all reference
929 material for the Ada 2005 programming language.
931 @item
932 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
933 of the Ada 2005 standard.  The annotations describe
934 detailed aspects of the design decision, and in particular contain useful
935 sections on Ada 83 and Ada 95 compatibility.
937 @item
938 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
939 which contains specific information on compatibility between GNAT and
940 DEC Ada 83 systems.
942 @item
943 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
944 describes in detail the pragmas and attributes provided by the DEC Ada 83
945 compiler system.
947 @end itemize
949 @node Implementation Defined Pragmas
950 @chapter Implementation Defined Pragmas
952 @noindent
953 Ada defines a set of pragmas that can be used to supply additional
954 information to the compiler.  These language defined pragmas are
955 implemented in GNAT and work as described in the Ada Reference Manual.
957 In addition, Ada allows implementations to define additional pragmas
958 whose meaning is defined by the implementation.  GNAT provides a number
959 of these implementation-defined pragmas, which can be used to extend
960 and enhance the functionality of the compiler.  This section of the GNAT
961 Reference Manual describes these additional pragmas.
963 Note that any program using these pragmas might not be portable to other
964 compilers (although GNAT implements this set of pragmas on all
965 platforms).  Therefore if portability to other compilers is an important
966 consideration, the use of these pragmas should be minimized.
968 @menu
969 * Pragma Abort_Defer::
970 * Pragma Abstract_State::
971 * Pragma Ada_83::
972 * Pragma Ada_95::
973 * Pragma Ada_05::
974 * Pragma Ada_2005::
975 * Pragma Ada_12::
976 * Pragma Ada_2012::
977 * Pragma Allow_Integer_Address::
978 * Pragma Annotate::
979 * Pragma Assert::
980 * Pragma Assert_And_Cut::
981 * Pragma Assertion_Policy::
982 * Pragma Assume::
983 * Pragma Assume_No_Invalid_Values::
984 * Pragma AST_Entry::
985 * Pragma Async_Readers::
986 * Pragma Async_Writers::
987 * Pragma Attribute_Definition::
988 * Pragma C_Pass_By_Copy::
989 * Pragma Check::
990 * Pragma Check_Float_Overflow::
991 * Pragma Check_Name::
992 * Pragma Check_Policy::
993 * Pragma CIL_Constructor::
994 * Pragma Comment::
995 * Pragma Common_Object::
996 * Pragma Compile_Time_Error::
997 * Pragma Compile_Time_Warning::
998 * Pragma Compiler_Unit::
999 * Pragma Compiler_Unit_Warning::
1000 * Pragma Complete_Representation::
1001 * Pragma Complex_Representation::
1002 * Pragma Component_Alignment::
1003 * Pragma Contract_Cases::
1004 * Pragma Convention_Identifier::
1005 * Pragma CPP_Class::
1006 * Pragma CPP_Constructor::
1007 * Pragma CPP_Virtual::
1008 * Pragma CPP_Vtable::
1009 * Pragma CPU::
1010 * Pragma Debug::
1011 * Pragma Debug_Policy::
1012 * Pragma Default_Scalar_Storage_Order::
1013 * Pragma Default_Storage_Pool::
1014 * Pragma Depends::
1015 * Pragma Detect_Blocking::
1016 * Pragma Disable_Atomic_Synchronization::
1017 * Pragma Dispatching_Domain::
1018 * Pragma Effective_Reads::
1019 * Pragma Effective_Writes::
1020 * Pragma Elaboration_Checks::
1021 * Pragma Eliminate::
1022 * Pragma Enable_Atomic_Synchronization::
1023 * Pragma Export_Exception::
1024 * Pragma Export_Function::
1025 * Pragma Export_Object::
1026 * Pragma Export_Procedure::
1027 * Pragma Export_Value::
1028 * Pragma Export_Valued_Procedure::
1029 * Pragma Extend_System::
1030 * Pragma Extensions_Allowed::
1031 * Pragma External::
1032 * Pragma External_Name_Casing::
1033 * Pragma Fast_Math::
1034 * Pragma Favor_Top_Level::
1035 * Pragma Finalize_Storage_Only::
1036 * Pragma Float_Representation::
1037 * Pragma Global::
1038 * Pragma Ident::
1039 * Pragma Implementation_Defined::
1040 * Pragma Implemented::
1041 * Pragma Implicit_Packing::
1042 * Pragma Import_Exception::
1043 * Pragma Import_Function::
1044 * Pragma Import_Object::
1045 * Pragma Import_Procedure::
1046 * Pragma Import_Valued_Procedure::
1047 * Pragma Independent::
1048 * Pragma Independent_Components::
1049 * Pragma Initial_Condition::
1050 * Pragma Initialize_Scalars::
1051 * Pragma Initializes::
1052 * Pragma Inline_Always::
1053 * Pragma Inline_Generic::
1054 * Pragma Interface::
1055 * Pragma Interface_Name::
1056 * Pragma Interrupt_Handler::
1057 * Pragma Interrupt_State::
1058 * Pragma Invariant::
1059 * Pragma Java_Constructor::
1060 * Pragma Java_Interface::
1061 * Pragma Keep_Names::
1062 * Pragma License::
1063 * Pragma Link_With::
1064 * Pragma Linker_Alias::
1065 * Pragma Linker_Constructor::
1066 * Pragma Linker_Destructor::
1067 * Pragma Linker_Section::
1068 * Pragma Lock_Free::
1069 * Pragma Long_Float::
1070 * Pragma Loop_Invariant::
1071 * Pragma Loop_Optimize::
1072 * Pragma Loop_Variant::
1073 * Pragma Machine_Attribute::
1074 * Pragma Main::
1075 * Pragma Main_Storage::
1076 * Pragma No_Body::
1077 * Pragma No_Elaboration_Code_All::
1078 * Pragma No_Inline::
1079 * Pragma No_Return::
1080 * Pragma No_Run_Time::
1081 * Pragma No_Strict_Aliasing::
1082 * Pragma Normalize_Scalars::
1083 * Pragma Obsolescent::
1084 * Pragma Optimize_Alignment::
1085 * Pragma Ordered::
1086 * Pragma Overflow_Mode::
1087 * Pragma Overriding_Renamings::
1088 * Pragma Partition_Elaboration_Policy::
1089 * Pragma Part_Of::
1090 * Pragma Passive::
1091 * Pragma Persistent_BSS::
1092 * Pragma Polling::
1093 * Pragma Post::
1094 * Pragma Postcondition::
1095 * Pragma Post_Class::
1096 * Pragma Pre::
1097 * Pragma Precondition::
1098 * Pragma Predicate::
1099 * Pragma Preelaborable_Initialization::
1100 * Pragma Prefix_Exception_Messages::
1101 * Pragma Pre_Class::
1102 * Pragma Priority_Specific_Dispatching::
1103 * Pragma Profile::
1104 * Pragma Profile_Warnings::
1105 * Pragma Propagate_Exceptions::
1106 * Pragma Provide_Shift_Operators::
1107 * Pragma Psect_Object::
1108 * Pragma Pure_Function::
1109 * Pragma Rational::
1110 * Pragma Ravenscar::
1111 * Pragma Refined_Depends::
1112 * Pragma Refined_Global::
1113 * Pragma Refined_Post::
1114 * Pragma Refined_State::
1115 * Pragma Relative_Deadline::
1116 * Pragma Remote_Access_Type::
1117 * Pragma Restricted_Run_Time::
1118 * Pragma Restriction_Warnings::
1119 * Pragma Reviewable::
1120 * Pragma Share_Generic::
1121 * Pragma Shared::
1122 * Pragma Short_Circuit_And_Or::
1123 * Pragma Short_Descriptors::
1124 * Pragma Simple_Storage_Pool_Type::
1125 * Pragma Source_File_Name::
1126 * Pragma Source_File_Name_Project::
1127 * Pragma Source_Reference::
1128 * Pragma SPARK_Mode::
1129 * Pragma Static_Elaboration_Desired::
1130 * Pragma Stream_Convert::
1131 * Pragma Style_Checks::
1132 * Pragma Subtitle::
1133 * Pragma Suppress::
1134 * Pragma Suppress_All::
1135 * Pragma Suppress_Debug_Info::
1136 * Pragma Suppress_Exception_Locations::
1137 * Pragma Suppress_Initialization::
1138 * Pragma Task_Name::
1139 * Pragma Task_Storage::
1140 * Pragma Test_Case::
1141 * Pragma Thread_Local_Storage::
1142 * Pragma Time_Slice::
1143 * Pragma Title::
1144 * Pragma Type_Invariant::
1145 * Pragma Type_Invariant_Class::
1146 * Pragma Unchecked_Union::
1147 * Pragma Unevaluated_Use_Of_Old::
1148 * Pragma Unimplemented_Unit::
1149 * Pragma Universal_Aliasing ::
1150 * Pragma Universal_Data::
1151 * Pragma Unmodified::
1152 * Pragma Unreferenced::
1153 * Pragma Unreferenced_Objects::
1154 * Pragma Unreserve_All_Interrupts::
1155 * Pragma Unsuppress::
1156 * Pragma Use_VADS_Size::
1157 * Pragma Validity_Checks::
1158 * Pragma Volatile::
1159 * Pragma Warning_As_Error::
1160 * Pragma Warnings::
1161 * Pragma Weak_External::
1162 * Pragma Wide_Character_Encoding::
1163 @end menu
1165 @node Pragma Abort_Defer
1166 @unnumberedsec Pragma Abort_Defer
1167 @findex Abort_Defer
1168 @cindex Deferring aborts
1169 @noindent
1170 Syntax:
1171 @smallexample
1172 pragma Abort_Defer;
1173 @end smallexample
1175 @noindent
1176 This pragma must appear at the start of the statement sequence of a
1177 handled sequence of statements (right after the @code{begin}).  It has
1178 the effect of deferring aborts for the sequence of statements (but not
1179 for the declarations or handlers, if any, associated with this statement
1180 sequence).
1182 @node Pragma Abstract_State
1183 @unnumberedsec Pragma Abstract_State
1184 @findex Abstract_State
1185 @noindent
1186 For the description of this pragma, see SPARK 2014 Reference Manual,
1187 section 7.1.4.
1189 @node Pragma Ada_83
1190 @unnumberedsec Pragma Ada_83
1191 @findex Ada_83
1192 @noindent
1193 Syntax:
1194 @smallexample @c ada
1195 pragma Ada_83;
1196 @end smallexample
1198 @noindent
1199 A configuration pragma that establishes Ada 83 mode for the unit to
1200 which it applies, regardless of the mode set by the command line
1201 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
1202 the syntax and semantics of Ada 83, as defined in the original Ada
1203 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
1204 and Ada 2005 are not recognized, optional package bodies are allowed,
1205 and generics may name types with unknown discriminants without using
1206 the @code{(<>)} notation.  In addition, some but not all of the additional
1207 restrictions of Ada 83 are enforced.
1209 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
1210 Ada 83 code to be compiled and adapted to GNAT with less effort.
1211 Secondly, it aids in keeping code backwards compatible with Ada 83.
1212 However, there is no guarantee that code that is processed correctly
1213 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1214 83 compiler, since GNAT does not enforce all the additional checks
1215 required by Ada 83.
1217 @node Pragma Ada_95
1218 @unnumberedsec Pragma Ada_95
1219 @findex Ada_95
1220 @noindent
1221 Syntax:
1222 @smallexample @c ada
1223 pragma Ada_95;
1224 @end smallexample
1226 @noindent
1227 A configuration pragma that establishes Ada 95 mode for the unit to which
1228 it applies, regardless of the mode set by the command line switches.
1229 This mode is set automatically for the @code{Ada} and @code{System}
1230 packages and their children, so you need not specify it in these
1231 contexts.  This pragma is useful when writing a reusable component that
1232 itself uses Ada 95 features, but which is intended to be usable from
1233 either Ada 83 or Ada 95 programs.
1235 @node Pragma Ada_05
1236 @unnumberedsec Pragma Ada_05
1237 @findex Ada_05
1238 @noindent
1239 Syntax:
1240 @smallexample @c ada
1241 pragma Ada_05;
1242 pragma Ada_05 (local_NAME);
1243 @end smallexample
1245 @noindent
1246 A configuration pragma that establishes Ada 2005 mode for the unit to which
1247 it applies, regardless of the mode set by the command line switches.
1248 This pragma is useful when writing a reusable component that
1249 itself uses Ada 2005 features, but which is intended to be usable from
1250 either Ada 83 or Ada 95 programs.
1252 The one argument form (which is not a configuration pragma)
1253 is used for managing the transition from
1254 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
1255 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
1256 mode will generate a warning. In addition, in Ada_83 or Ada_95
1257 mode, a preference rule is established which does not choose
1258 such an entity unless it is unambiguously specified. This avoids
1259 extra subprograms marked this way from generating ambiguities in
1260 otherwise legal pre-Ada_2005 programs. The one argument form is
1261 intended for exclusive use in the GNAT run-time library.
1263 @node Pragma Ada_2005
1264 @unnumberedsec Pragma Ada_2005
1265 @findex Ada_2005
1266 @noindent
1267 Syntax:
1268 @smallexample @c ada
1269 pragma Ada_2005;
1270 @end smallexample
1272 @noindent
1273 This configuration pragma is a synonym for pragma Ada_05 and has the
1274 same syntax and effect.
1276 @node Pragma Ada_12
1277 @unnumberedsec Pragma Ada_12
1278 @findex Ada_12
1279 @noindent
1280 Syntax:
1281 @smallexample @c ada
1282 pragma Ada_12;
1283 pragma Ada_12 (local_NAME);
1284 @end smallexample
1286 @noindent
1287 A configuration pragma that establishes Ada 2012 mode for the unit to which
1288 it applies, regardless of the mode set by the command line switches.
1289 This mode is set automatically for the @code{Ada} and @code{System}
1290 packages and their children, so you need not specify it in these
1291 contexts.  This pragma is useful when writing a reusable component that
1292 itself uses Ada 2012 features, but which is intended to be usable from
1293 Ada 83, Ada 95, or Ada 2005 programs.
1295 The one argument form, which is not a configuration pragma,
1296 is used for managing the transition from Ada
1297 2005 to Ada 2012 in the run-time library. If an entity is marked
1298 as Ada_201 only, then referencing the entity in any pre-Ada_2012
1299 mode will generate a warning. In addition, in any pre-Ada_2012
1300 mode, a preference rule is established which does not choose
1301 such an entity unless it is unambiguously specified. This avoids
1302 extra subprograms marked this way from generating ambiguities in
1303 otherwise legal pre-Ada_2012 programs. The one argument form is
1304 intended for exclusive use in the GNAT run-time library.
1306 @node Pragma Ada_2012
1307 @unnumberedsec Pragma Ada_2012
1308 @findex Ada_2005
1309 @noindent
1310 Syntax:
1311 @smallexample @c ada
1312 pragma Ada_2012;
1313 @end smallexample
1315 @noindent
1316 This configuration pragma is a synonym for pragma Ada_12 and has the
1317 same syntax and effect.
1319 @node Pragma Allow_Integer_Address
1320 @unnumberedsec Pragma Allow_Integer_Address
1321 @findex Allow_Integer_Address
1322 @noindent
1323 Syntax:
1324 @smallexample @c ada
1325 pragma Allow_Integer_Address;
1326 @end smallexample
1328 @noindent
1329 In almost all versions of GNAT, @code{System.Address} is a private
1330 type in accordance with the implementation advice in the RM. This
1331 means that integer values,
1332 in particular integer literals, are not allowed as address values.
1333 If the configuration pragma
1334 @code{Allow_Integer_Address} is given, then integer expressions may
1335 be used anywhere a value of type @code{System.Address} is required.
1336 The effect is to introduce an implicit unchecked conversion from the
1337 integer value to type @code{System.Address}. The reverse case of using
1338 an address where an integer type is required is handled analogously.
1339 The following example compiles without errors:
1341 @smallexample @c ada
1342 pragma Allow_Integer_Address;
1343 with System; use System;
1344 package AddrAsInt is
1345    X : Integer;
1346    Y : Integer;
1347    for X'Address use 16#1240#;
1348    for Y use at 16#3230#;
1349    m : Address := 16#4000#;
1350    n : constant Address := 4000;
1351    p : constant Address := Address (X + Y);
1352    v : Integer := y'Address;
1353    w : constant Integer := Integer (Y'Address);
1354    type R is new integer;
1355    RR : R := 1000;
1356    Z : Integer;
1357    for Z'Address use RR;
1358 end AddrAsInt;
1359 @end smallexample
1361 @noindent
1362 Note that pragma @code{Allow_Integer_Address} is ignored if
1363 @code{System.Address}
1364 is not a private type. In implementations of @code{GNAT} where
1365 System.Address is a visible integer type (notably the implementations
1366 for @code{OpenVMS}), this pragma serves no purpose but is ignored
1367 rather than rejected to allow common sets of sources to be used
1368 in the two situations.
1370 @node Pragma Annotate
1371 @unnumberedsec Pragma Annotate
1372 @findex Annotate
1373 @noindent
1374 Syntax:
1375 @smallexample @c ada
1376 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}] [entity => local_NAME]);
1378 ARG ::= NAME | EXPRESSION
1379 @end smallexample
1381 @noindent
1382 This pragma is used to annotate programs.  @var{identifier} identifies
1383 the type of annotation.  GNAT verifies that it is an identifier, but does
1384 not otherwise analyze it. The second optional identifier is also left
1385 unanalyzed, and by convention is used to control the action of the tool to
1386 which the annotation is addressed.  The remaining @var{arg} arguments
1387 can be either string literals or more generally expressions.
1388 String literals are assumed to be either of type
1389 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1390 depending on the character literals they contain.
1391 All other kinds of arguments are analyzed as expressions, and must be
1392 unambiguous. The last argument if present must have the identifier
1393 @code{Entity} and GNAT verifies that a local name is given.
1395 The analyzed pragma is retained in the tree, but not otherwise processed
1396 by any part of the GNAT compiler, except to generate corresponding note
1397 lines in the generated ALI file. For the format of these note lines, see
1398 the compiler source file lib-writ.ads. This pragma is intended for use by
1399 external tools, including ASIS@. The use of pragma Annotate does not
1400 affect the compilation process in any way. This pragma may be used as
1401 a configuration pragma.
1403 @node Pragma Assert
1404 @unnumberedsec Pragma Assert
1405 @findex Assert
1406 @noindent
1407 Syntax:
1408 @smallexample @c ada
1409 pragma Assert (
1410   boolean_EXPRESSION
1411   [, string_EXPRESSION]);
1412 @end smallexample
1414 @noindent
1415 The effect of this pragma depends on whether the corresponding command
1416 line switch is set to activate assertions.  The pragma expands into code
1417 equivalent to the following:
1419 @smallexample @c ada
1420 if assertions-enabled then
1421    if not boolean_EXPRESSION then
1422       System.Assertions.Raise_Assert_Failure
1423         (string_EXPRESSION);
1424    end if;
1425 end if;
1426 @end smallexample
1428 @noindent
1429 The string argument, if given, is the message that will be associated
1430 with the exception occurrence if the exception is raised.  If no second
1431 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1432 where @var{file} is the name of the source file containing the assert,
1433 and @var{nnn} is the line number of the assert.  A pragma is not a
1434 statement, so if a statement sequence contains nothing but a pragma
1435 assert, then a null statement is required in addition, as in:
1437 @smallexample @c ada
1438 @dots{}
1439 if J > 3 then
1440    pragma Assert (K > 3, "Bad value for K");
1441    null;
1442 end if;
1443 @end smallexample
1445 @noindent
1446 Note that, as with the @code{if} statement to which it is equivalent, the
1447 type of the expression is either @code{Standard.Boolean}, or any type derived
1448 from this standard type.
1450 Assert checks can be either checked or ignored. By default they are ignored.
1451 They will be checked if either the command line switch @option{-gnata} is
1452 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1453 to enable @code{Assert_Checks}.
1455 If assertions are ignored, then there
1456 is no run-time effect (and in particular, any side effects from the
1457 expression will not occur at run time).  (The expression is still
1458 analyzed at compile time, and may cause types to be frozen if they are
1459 mentioned here for the first time).
1461 If assertions are checked, then the given expression is tested, and if
1462 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1463 which results in the raising of @code{Assert_Failure} with the given message.
1465 You should generally avoid side effects in the expression arguments of
1466 this pragma, because these side effects will turn on and off with the
1467 setting of the assertions mode, resulting in assertions that have an
1468 effect on the program.  However, the expressions are analyzed for
1469 semantic correctness whether or not assertions are enabled, so turning
1470 assertions on and off cannot affect the legality of a program.
1472 Note that the implementation defined policy @code{DISABLE}, given in a
1473 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1475 Note: this is a standard language-defined pragma in versions
1476 of Ada from 2005 on. In GNAT, it is implemented in all versions
1477 of Ada, and the DISABLE policy is an implementation-defined
1478 addition.
1480 @node Pragma Assert_And_Cut
1481 @unnumberedsec Pragma Assert_And_Cut
1482 @findex Assert_And_Cut
1483 @noindent
1484 Syntax:
1485 @smallexample @c ada
1486 pragma Assert_And_Cut (
1487   boolean_EXPRESSION
1488   [, string_EXPRESSION]);
1489 @end smallexample
1491 @noindent
1492 The effect of this pragma is identical to that of pragma @code{Assert},
1493 except that in an @code{Assertion_Policy} pragma, the identifier
1494 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1495 (or disabled).
1497 The intention is that this be used within a subprogram when the
1498 given test expresion sums up all the work done so far in the
1499 subprogram, so that the rest of the subprogram can be verified
1500 (informally or formally) using only the entry preconditions,
1501 and the expression in this pragma. This allows dividing up
1502 a subprogram into sections for the purposes of testing or
1503 formal verification. The pragma also serves as useful
1504 documentation.
1506 @node Pragma Assertion_Policy
1507 @unnumberedsec Pragma Assertion_Policy
1508 @findex Assertion_Policy
1509 @noindent
1510 Syntax:
1511 @smallexample @c ada
1512 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1514 pragma Assertion_Policy (
1515     ASSERTION_KIND => POLICY_IDENTIFIER
1516  @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1518 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1520 RM_ASSERTION_KIND ::= Assert               |
1521                       Static_Predicate     |
1522                       Dynamic_Predicate    |
1523                       Pre                  |
1524                       Pre'Class            |
1525                       Post                 |
1526                       Post'Class           |
1527                       Type_Invariant       |
1528                       Type_Invariant'Class
1530 ID_ASSERTION_KIND ::= Assertions           |
1531                       Assert_And_Cut       |
1532                       Assume               |
1533                       Contract_Cases       |
1534                       Debug                |
1535                       Invariant            |
1536                       Invariant'Class      |
1537                       Loop_Invariant       |
1538                       Loop_Variant         |
1539                       Postcondition        |
1540                       Precondition         |
1541                       Predicate            |
1542                       Refined_Post         |
1543                       Statement_Assertions
1545 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1546 @end smallexample
1548 @noindent
1549 This is a standard Ada 2012 pragma that is available as an
1550 implementation-defined pragma in earlier versions of Ada.
1551 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1552 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1553 are implementation defined additions recognized by the GNAT compiler.
1555 The pragma applies in both cases to pragmas and aspects with matching
1556 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1557 applies to both the @code{Precondition} pragma
1558 and the aspect @code{Precondition}. Note that the identifiers for
1559 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
1560 Pre_Class and Post_Class), since these pragmas are intended to be
1561 identical to the corresponding aspects).
1563 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1564 the corresponding pragma or aspect is activated.
1565 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1566 the corresponding pragma or aspect is deactivated.
1567 This pragma overrides the effect of the @option{-gnata} switch on the
1568 command line.
1570 The implementation defined policy @code{DISABLE} is like
1571 @code{IGNORE} except that it completely disables semantic
1572 checking of the corresponding pragma or aspect. This is
1573 useful when the pragma or aspect argument references subprograms
1574 in a with'ed package which is replaced by a dummy package
1575 for the final build.
1577 The implementation defined assertion kind @code{Assertions} applies to all
1578 assertion kinds. The form with no assertion kind given implies this
1579 choice, so it applies to all assertion kinds (RM defined, and
1580 implementation defined).
1582 The implementation defined assertion kind @code{Statement_Assertions}
1583 applies to @code{Assert}, @code{Assert_And_Cut},
1584 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
1586 @node Pragma Assume
1587 @unnumberedsec Pragma Assume
1588 @findex Assume
1589 @noindent
1590 Syntax:
1591 @smallexample @c ada
1592 pragma Assume (
1593   boolean_EXPRESSION
1594   [, string_EXPRESSION]);
1595 @end smallexample
1597 @noindent
1598 The effect of this pragma is identical to that of pragma @code{Assert},
1599 except that in an @code{Assertion_Policy} pragma, the identifier
1600 @code{Assume} is used to control whether it is ignored or checked
1601 (or disabled).
1603 The intention is that this be used for assumptions about the
1604 external environment. So you cannot expect to verify formally
1605 or informally that the condition is met, this must be
1606 established by examining things outside the program itself.
1607 For example, we may have code that depends on the size of
1608 @code{Long_Long_Integer} being at least 64. So we could write:
1610 @smallexample @c ada
1611 pragma Assume (Long_Long_Integer'Size >= 64);
1612 @end smallexample
1614 @noindent
1615 This assumption cannot be proved from the program itself,
1616 but it acts as a useful run-time check that the assumption
1617 is met, and documents the need to ensure that it is met by
1618 reference to information outside the program.
1620 @node Pragma Assume_No_Invalid_Values
1621 @unnumberedsec Pragma Assume_No_Invalid_Values
1622 @findex Assume_No_Invalid_Values
1623 @cindex Invalid representations
1624 @cindex Invalid values
1625 @noindent
1626 Syntax:
1627 @smallexample @c ada
1628 pragma Assume_No_Invalid_Values (On | Off);
1629 @end smallexample
1631 @noindent
1632 This is a configuration pragma that controls the assumptions made by the
1633 compiler about the occurrence of invalid representations (invalid values)
1634 in the code.
1636 The default behavior (corresponding to an Off argument for this pragma), is
1637 to assume that values may in general be invalid unless the compiler can
1638 prove they are valid. Consider the following example:
1640 @smallexample @c ada
1641 V1 : Integer range 1 .. 10;
1642 V2 : Integer range 11 .. 20;
1644 for J in V2 .. V1 loop
1645    ...
1646 end loop;
1647 @end smallexample
1649 @noindent
1650 if V1 and V2 have valid values, then the loop is known at compile
1651 time not to execute since the lower bound must be greater than the
1652 upper bound. However in default mode, no such assumption is made,
1653 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1654 is given, the compiler will assume that any occurrence of a variable
1655 other than in an explicit @code{'Valid} test always has a valid
1656 value, and the loop above will be optimized away.
1658 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1659 you know your code is free of uninitialized variables and other
1660 possible sources of invalid representations, and may result in
1661 more efficient code. A program that accesses an invalid representation
1662 with this pragma in effect is erroneous, so no guarantees can be made
1663 about its behavior.
1665 It is peculiar though permissible to use this pragma in conjunction
1666 with validity checking (-gnatVa). In such cases, accessing invalid
1667 values will generally give an exception, though formally the program
1668 is erroneous so there are no guarantees that this will always be the
1669 case, and it is recommended that these two options not be used together.
1671 @node Pragma Async_Readers
1672 @unnumberedsec Pragma Async_Readers
1673 @findex Async_Readers
1674 @noindent
1675 For the description of this pragma, see SPARK 2014 Reference Manual,
1676 section 7.1.2.
1678 @node Pragma Async_Writers
1679 @unnumberedsec Pragma Async_Writers
1680 @findex Async_Writers
1681 @noindent
1682 For the description of this pragma, see SPARK 2014 Reference Manual,
1683 section 7.1.2.
1685 @node Pragma AST_Entry
1686 @unnumberedsec Pragma AST_Entry
1687 @cindex OpenVMS
1688 @findex AST_Entry
1689 @noindent
1690 Syntax:
1691 @smallexample @c ada
1692 pragma AST_Entry (entry_IDENTIFIER);
1693 @end smallexample
1695 @noindent
1696 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1697 argument is the simple name of a single entry; at most one @code{AST_Entry}
1698 pragma is allowed for any given entry.  This pragma must be used in
1699 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1700 the entry declaration and in the same task type specification or single task
1701 as the entry to which it applies.  This pragma specifies that the given entry
1702 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1703 resulting from an OpenVMS system service call.  The pragma does not affect
1704 normal use of the entry.  For further details on this pragma, see the
1705 DEC Ada Language Reference Manual, section 9.12a.
1707 @node Pragma Attribute_Definition
1708 @unnumberedsec Pragma Attribute_Definition
1709 @findex Attribute_Definition
1710 @noindent
1711 Syntax:
1712 @smallexample @c ada
1713 pragma Attribute_Definition
1714   ([Attribute  =>] ATTRIBUTE_DESIGNATOR,
1715    [Entity     =>] LOCAL_NAME,
1716    [Expression =>] EXPRESSION | NAME);
1717 @end smallexample
1719 @noindent
1720 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1721 the attribute definition clause:
1723 @smallexample @c ada
1724   for Entity'Attribute use Expression;
1725 @end smallexample
1727 If @code{Attribute} is not a recognized attribute name, the pragma is
1728 ignored, and a warning is emitted. This allows source
1729 code to be written that takes advantage of some new attribute, while remaining
1730 compilable with earlier compilers.
1732 @node Pragma C_Pass_By_Copy
1733 @unnumberedsec Pragma C_Pass_By_Copy
1734 @cindex Passing by copy
1735 @findex C_Pass_By_Copy
1736 @noindent
1737 Syntax:
1738 @smallexample @c ada
1739 pragma C_Pass_By_Copy
1740   ([Max_Size =>] static_integer_EXPRESSION);
1741 @end smallexample
1743 @noindent
1744 Normally the default mechanism for passing C convention records to C
1745 convention subprograms is to pass them by reference, as suggested by RM
1746 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1747 this default, by requiring that record formal parameters be passed by
1748 copy if all of the following conditions are met:
1750 @itemize @bullet
1751 @item
1752 The size of the record type does not exceed the value specified for
1753 @code{Max_Size}.
1754 @item
1755 The record type has @code{Convention C}.
1756 @item
1757 The formal parameter has this record type, and the subprogram has a
1758 foreign (non-Ada) convention.
1759 @end itemize
1761 @noindent
1762 If these conditions are met the argument is passed by copy, i.e.@: in a
1763 manner consistent with what C expects if the corresponding formal in the
1764 C prototype is a struct (rather than a pointer to a struct).
1766 You can also pass records by copy by specifying the convention
1767 @code{C_Pass_By_Copy} for the record type, or by using the extended
1768 @code{Import} and @code{Export} pragmas, which allow specification of
1769 passing mechanisms on a parameter by parameter basis.
1771 @node Pragma Check
1772 @unnumberedsec Pragma Check
1773 @cindex Assertions
1774 @cindex Named assertions
1775 @findex Check
1776 @noindent
1777 Syntax:
1778 @smallexample @c ada
1779 pragma Check (
1780      [Name    =>] CHECK_KIND,
1781      [Check   =>] Boolean_EXPRESSION
1782   [, [Message =>] string_EXPRESSION] );
1784 CHECK_KIND ::= IDENTIFIER           |
1785                Pre'Class            |
1786                Post'Class           |
1787                Type_Invariant'Class |
1788                Invariant'Class
1789 @end smallexample
1791 @noindent
1792 This pragma is similar to the predefined pragma @code{Assert} except that an
1793 extra identifier argument is present. In conjunction with pragma
1794 @code{Check_Policy}, this can be used to define groups of assertions that can
1795 be independently controlled. The identifier @code{Assertion} is special, it
1796 refers to the normal set of pragma @code{Assert} statements.
1798 Checks introduced by this pragma are normally deactivated by default. They can
1799 be activated either by the command line option @option{-gnata}, which turns on
1800 all checks, or individually controlled using pragma @code{Check_Policy}.
1802 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1803 permitted as check kinds, since this would cause confusion with the use
1804 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1805 pragmas, where they are used to refer to sets of assertions.
1807 @node Pragma Check_Float_Overflow
1808 @unnumberedsec Pragma Check_Float_Overflow
1809 @cindex Floating-point overflow
1810 @findex Check_Float_Overflow
1811 @noindent
1812 Syntax:
1813 @smallexample @c ada
1814 pragma Check_Float_Overflow;
1815 @end smallexample
1817 @noindent
1818 In Ada, the predefined floating-point types (@code{Short_Float},
1819 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1820 defined to be @emph{unconstrained}. This means that even though each
1821 has a well-defined base range, an operation that delivers a result
1822 outside this base range is not required to raise an exception.
1823 This implementation permission accommodates the notion
1824 of infinities in IEEE floating-point, and corresponds to the
1825 efficient execution mode on most machines. GNAT will not raise
1826 overflow exceptions on these machines; instead it will generate
1827 infinities and NaN's as defined in the IEEE standard.
1829 Generating infinities, although efficient, is not always desirable.
1830 Often the preferable approach is to check for overflow, even at the
1831 (perhaps considerable) expense of run-time performance.
1832 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1833 range constraints -- and indeed such a subtype
1834 can have the same base range as its base type. For example:
1836 @smallexample @c ada
1837 subtype My_Float is Float range Float'Range;
1838 @end smallexample
1840 @noindent
1841 Here @code{My_Float} has the same range as
1842 @code{Float} but is constrained, so operations on
1843 @code{My_Float} values will be checked for overflow
1844 against this range.
1846 This style will achieve the desired goal, but
1847 it is often more convenient to be able to simply use
1848 the standard predefined floating-point types as long
1849 as overflow checking could be guaranteed.
1850 The @code{Check_Float_Overflow}
1851 configuration pragma achieves this effect. If a unit is compiled
1852 subject to this configuration pragma, then all operations
1853 on predefined floating-point types including operations on
1854 base types of these floating-point types will be treated as
1855 though those types were constrained, and overflow checks
1856 will be generated. The @code{Constraint_Error}
1857 exception is raised if the result is out of range.
1859 This mode can also be set by use of the compiler
1860 switch @option{-gnateF}.
1862 @node Pragma Check_Name
1863 @unnumberedsec Pragma Check_Name
1864 @cindex Defining check names
1865 @cindex Check names, defining
1866 @findex Check_Name
1867 @noindent
1868 Syntax:
1869 @smallexample @c ada
1870 pragma Check_Name (check_name_IDENTIFIER);
1871 @end smallexample
1873 @noindent
1874 This is a configuration pragma that defines a new implementation
1875 defined check name (unless IDENTIFIER matches one of the predefined
1876 check names, in which case the pragma has no effect). Check names
1877 are global to a partition, so if two or more configuration pragmas
1878 are present in a partition mentioning the same name, only one new
1879 check name is introduced.
1881 An implementation defined check name introduced with this pragma may
1882 be used in only three contexts: @code{pragma Suppress},
1883 @code{pragma Unsuppress},
1884 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1885 any of these three cases, the check name must be visible. A check
1886 name is visible if it is in the configuration pragmas applying to
1887 the current unit, or if it appears at the start of any unit that
1888 is part of the dependency set of the current unit (e.g., units that
1889 are mentioned in @code{with} clauses).
1891 Check names introduced by this pragma are subject to control by compiler
1892 switches (in particular -gnatp) in the usual manner.
1894 @node Pragma Check_Policy
1895 @unnumberedsec Pragma Check_Policy
1896 @cindex Controlling assertions
1897 @cindex Assertions, control
1898 @cindex Check pragma control
1899 @cindex Named assertions
1900 @findex Check
1901 @noindent
1902 Syntax:
1903 @smallexample @c ada
1904 pragma Check_Policy
1905  ([Name   =>] CHECK_KIND,
1906   [Policy =>] POLICY_IDENTIFIER);
1908 pragma Check_Policy (
1909     CHECK_KIND => POLICY_IDENTIFIER
1910  @{, CHECK_KIND => POLICY_IDENTIFIER@});
1912 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1914 CHECK_KIND ::= IDENTIFIER           |
1915                Pre'Class            |
1916                Post'Class           |
1917                Type_Invariant'Class |
1918                Invariant'Class
1920 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1921 avoids confusion between the two possible syntax forms for this pragma.
1923 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1924 @end smallexample
1926 @noindent
1927 This pragma is used to set the checking policy for assertions (specified
1928 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1929 to be checked using the @code{Check} pragma. It may appear either as
1930 a configuration pragma, or within a declarative part of package. In the
1931 latter case, it applies from the point where it appears to the end of
1932 the declarative region (like pragma @code{Suppress}).
1934 The @code{Check_Policy} pragma is similar to the
1935 predefined @code{Assertion_Policy} pragma,
1936 and if the check kind corresponds to one of the assertion kinds that
1937 are allowed by @code{Assertion_Policy}, then the effect is identical.
1939 If the first argument is Debug, then the policy applies to Debug pragmas,
1940 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1941 @code{IGNORE}, and allowing them to execute with normal semantics if
1942 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1943 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1944 be totally ignored and not analyzed semantically.
1946 Finally the first argument may be some other identifier than the above
1947 possibilities, in which case it controls a set of named assertions
1948 that can be checked using pragma @code{Check}. For example, if the pragma:
1950 @smallexample @c ada
1951 pragma Check_Policy (Critical_Error, OFF);
1952 @end smallexample
1954 @noindent
1955 is given, then subsequent @code{Check} pragmas whose first argument is also
1956 @code{Critical_Error} will be disabled.
1958 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1959 to turn on corresponding checks. The default for a set of checks for which no
1960 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1961 @option{-gnata} is given, which turns on all checks by default.
1963 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1964 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1965 compatibility with the standard @code{Assertion_Policy} pragma. The check
1966 policy setting @code{DISABLE} causes the second argument of a corresponding
1967 @code{Check} pragma to be completely ignored and not analyzed.
1969 @node Pragma CIL_Constructor
1970 @unnumberedsec Pragma CIL_Constructor
1971 @findex CIL_Constructor
1972 @noindent
1973 Syntax:
1975 @smallexample @c ada
1976 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1977 @end smallexample
1979 @noindent
1980 This pragma is used to assert that the specified Ada function should be
1981 mapped to the .NET constructor for some Ada tagged record type.
1983 See section 4.1 of the
1984 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1985 for related information.
1987 @node Pragma Comment
1988 @unnumberedsec Pragma Comment
1989 @findex Comment
1990 @noindent
1991 Syntax:
1993 @smallexample @c ada
1994 pragma Comment (static_string_EXPRESSION);
1995 @end smallexample
1997 @noindent
1998 This is almost identical in effect to pragma @code{Ident}.  It allows the
1999 placement of a comment into the object file and hence into the
2000 executable file if the operating system permits such usage.  The
2001 difference is that @code{Comment}, unlike @code{Ident}, has
2002 no limitations on placement of the pragma (it can be placed
2003 anywhere in the main source unit), and if more than one pragma
2004 is used, all comments are retained.
2006 @node Pragma Common_Object
2007 @unnumberedsec Pragma Common_Object
2008 @findex Common_Object
2009 @noindent
2010 Syntax:
2012 @smallexample @c ada
2013 pragma Common_Object (
2014      [Internal =>] LOCAL_NAME
2015   [, [External =>] EXTERNAL_SYMBOL]
2016   [, [Size     =>] EXTERNAL_SYMBOL] );
2018 EXTERNAL_SYMBOL ::=
2019   IDENTIFIER
2020 | static_string_EXPRESSION
2021 @end smallexample
2023 @noindent
2024 This pragma enables the shared use of variables stored in overlaid
2025 linker areas corresponding to the use of @code{COMMON}
2026 in Fortran.  The single
2027 object @var{LOCAL_NAME} is assigned to the area designated by
2028 the @var{External} argument.
2029 You may define a record to correspond to a series
2030 of fields.  The @var{Size} argument
2031 is syntax checked in GNAT, but otherwise ignored.
2033 @code{Common_Object} is not supported on all platforms.  If no
2034 support is available, then the code generator will issue a message
2035 indicating that the necessary attribute for implementation of this
2036 pragma is not available.
2038 @node Pragma Compile_Time_Error
2039 @unnumberedsec Pragma Compile_Time_Error
2040 @findex Compile_Time_Error
2041 @noindent
2042 Syntax:
2044 @smallexample @c ada
2045 pragma Compile_Time_Error
2046          (boolean_EXPRESSION, static_string_EXPRESSION);
2047 @end smallexample
2049 @noindent
2050 This pragma can be used to generate additional compile time
2051 error messages. It
2052 is particularly useful in generics, where errors can be issued for
2053 specific problematic instantiations. The first parameter is a boolean
2054 expression. The pragma is effective only if the value of this expression
2055 is known at compile time, and has the value True. The set of expressions
2056 whose values are known at compile time includes all static boolean
2057 expressions, and also other values which the compiler can determine
2058 at compile time (e.g., the size of a record type set by an explicit
2059 size representation clause, or the value of a variable which was
2060 initialized to a constant and is known not to have been modified).
2061 If these conditions are met, an error message is generated using
2062 the value given as the second argument. This string value may contain
2063 embedded ASCII.LF characters to break the message into multiple lines.
2065 @node Pragma Compile_Time_Warning
2066 @unnumberedsec Pragma Compile_Time_Warning
2067 @findex Compile_Time_Warning
2068 @noindent
2069 Syntax:
2071 @smallexample @c ada
2072 pragma Compile_Time_Warning
2073          (boolean_EXPRESSION, static_string_EXPRESSION);
2074 @end smallexample
2076 @noindent
2077 Same as pragma Compile_Time_Error, except a warning is issued instead
2078 of an error message. Note that if this pragma is used in a package that
2079 is with'ed by a client, the client will get the warning even though it
2080 is issued by a with'ed package (normally warnings in with'ed units are
2081 suppressed, but this is a special exception to that rule).
2083 One typical use is within a generic where compile time known characteristics
2084 of formal parameters are tested, and warnings given appropriately. Another use
2085 with a first parameter of True is to warn a client about use of a package,
2086 for example that it is not fully implemented.
2088 @node Pragma Compiler_Unit
2089 @unnumberedsec Pragma Compiler_Unit
2090 @findex Compiler_Unit
2091 @noindent
2092 Syntax:
2094 @smallexample @c ada
2095 pragma Compiler_Unit;
2096 @end smallexample
2098 @noindent
2099 This pragma is obsolete. It is equivalent to Compiler_Unit_Warning. It is
2100 retained so that old versions of the GNAT run-time that use this pragma can
2101 be compiled with newer versions of the compiler.
2103 @node Pragma Compiler_Unit_Warning
2104 @unnumberedsec Pragma Compiler_Unit_Warning
2105 @findex Compiler_Unit_Warning
2106 @noindent
2107 Syntax:
2109 @smallexample @c ada
2110 pragma Compiler_Unit_Warning;
2111 @end smallexample
2113 @noindent
2114 This pragma is intended only for internal use in the GNAT run-time library.
2115 It indicates that the unit is used as part of the compiler build. The effect
2116 is to generate warnings for the use of constructs (for example, conditional
2117 expressions) that would cause trouble when bootstrapping using an older
2118 version of GNAT. For the exact list of restrictions, see the compiler sources
2119 and references to Check_Compiler_Unit.
2121 @node Pragma Complete_Representation
2122 @unnumberedsec Pragma Complete_Representation
2123 @findex Complete_Representation
2124 @noindent
2125 Syntax:
2127 @smallexample @c ada
2128 pragma Complete_Representation;
2129 @end smallexample
2131 @noindent
2132 This pragma must appear immediately within a record representation
2133 clause. Typical placements are before the first component clause
2134 or after the last component clause. The effect is to give an error
2135 message if any component is missing a component clause. This pragma
2136 may be used to ensure that a record representation clause is
2137 complete, and that this invariant is maintained if fields are
2138 added to the record in the future.
2140 @node Pragma Complex_Representation
2141 @unnumberedsec Pragma Complex_Representation
2142 @findex Complex_Representation
2143 @noindent
2144 Syntax:
2146 @smallexample @c ada
2147 pragma Complex_Representation
2148         ([Entity =>] LOCAL_NAME);
2149 @end smallexample
2151 @noindent
2152 The @var{Entity} argument must be the name of a record type which has
2153 two fields of the same floating-point type.  The effect of this pragma is
2154 to force gcc to use the special internal complex representation form for
2155 this record, which may be more efficient.  Note that this may result in
2156 the code for this type not conforming to standard ABI (application
2157 binary interface) requirements for the handling of record types.  For
2158 example, in some environments, there is a requirement for passing
2159 records by pointer, and the use of this pragma may result in passing
2160 this type in floating-point registers.
2162 @node Pragma Component_Alignment
2163 @unnumberedsec Pragma Component_Alignment
2164 @cindex Alignments of components
2165 @findex Component_Alignment
2166 @noindent
2167 Syntax:
2169 @smallexample @c ada
2170 pragma Component_Alignment (
2171      [Form =>] ALIGNMENT_CHOICE
2172   [, [Name =>] type_LOCAL_NAME]);
2174 ALIGNMENT_CHOICE ::=
2175   Component_Size
2176 | Component_Size_4
2177 | Storage_Unit
2178 | Default
2179 @end smallexample
2181 @noindent
2182 Specifies the alignment of components in array or record types.
2183 The meaning of the @var{Form} argument is as follows:
2185 @table @code
2186 @findex Component_Size
2187 @item Component_Size
2188 Aligns scalar components and subcomponents of the array or record type
2189 on boundaries appropriate to their inherent size (naturally
2190 aligned).  For example, 1-byte components are aligned on byte boundaries,
2191 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2192 integer components are aligned on 4-byte boundaries and so on.  These
2193 alignment rules correspond to the normal rules for C compilers on all
2194 machines except the VAX@.
2196 @findex Component_Size_4
2197 @item Component_Size_4
2198 Naturally aligns components with a size of four or fewer
2199 bytes.  Components that are larger than 4 bytes are placed on the next
2200 4-byte boundary.
2202 @findex Storage_Unit
2203 @item Storage_Unit
2204 Specifies that array or record components are byte aligned, i.e.@:
2205 aligned on boundaries determined by the value of the constant
2206 @code{System.Storage_Unit}.
2208 @cindex OpenVMS
2209 @item Default
2210 Specifies that array or record components are aligned on default
2211 boundaries, appropriate to the underlying hardware or operating system or
2212 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
2213 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
2214 the @code{Default} choice is the same as @code{Component_Size} (natural
2215 alignment).
2216 @end table
2218 @noindent
2219 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2220 refer to a local record or array type, and the specified alignment
2221 choice applies to the specified type.  The use of
2222 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2223 @code{Component_Alignment} pragma to be ignored.  The use of
2224 @code{Component_Alignment} together with a record representation clause
2225 is only effective for fields not specified by the representation clause.
2227 If the @code{Name} parameter is absent, the pragma can be used as either
2228 a configuration pragma, in which case it applies to one or more units in
2229 accordance with the normal rules for configuration pragmas, or it can be
2230 used within a declarative part, in which case it applies to types that
2231 are declared within this declarative part, or within any nested scope
2232 within this declarative part.  In either case it specifies the alignment
2233 to be applied to any record or array type which has otherwise standard
2234 representation.
2236 If the alignment for a record or array type is not specified (using
2237 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2238 clause), the GNAT uses the default alignment as described previously.
2240 @node Pragma Contract_Cases
2241 @unnumberedsec Pragma Contract_Cases
2242 @cindex Contract cases
2243 @findex Contract_Cases
2244 @noindent
2245 Syntax:
2247 @smallexample @c ada
2248 pragma Contract_Cases (
2249    Condition => Consequence
2250  @{,Condition => Consequence@});
2251 @end smallexample
2253 @noindent
2254 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2255 that can complement or replace the contract given by a precondition and a
2256 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2257 by testing and formal verification tools. The compiler checks its validity and,
2258 depending on the assertion policy at the point of declaration of the pragma,
2259 it may insert a check in the executable. For code generation, the contract
2260 cases
2262 @smallexample @c ada
2263 pragma Contract_Cases (
2264   Cond1 => Pred1,
2265   Cond2 => Pred2);
2266 @end smallexample
2268 @noindent
2269 are equivalent to
2271 @smallexample @c ada
2272 C1 : constant Boolean := Cond1;  --  evaluated at subprogram entry
2273 C2 : constant Boolean := Cond2;  --  evaluated at subprogram entry
2274 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2275 pragma Postcondition (if C1 then Pred1);
2276 pragma Postcondition (if C2 then Pred2);
2277 @end smallexample
2279 @noindent
2280 The precondition ensures that one and only one of the conditions is
2281 satisfied on entry to the subprogram.
2282 The postcondition ensures that for the condition that was True on entry,
2283 the corrresponding consequence is True on exit. Other consequence expressions
2284 are not evaluated.
2286 A precondition @code{P} and postcondition @code{Q} can also be
2287 expressed as contract cases:
2289 @smallexample @c ada
2290 pragma Contract_Cases (P => Q);
2291 @end smallexample
2293 The placement and visibility rules for @code{Contract_Cases} pragmas are
2294 identical to those described for preconditions and postconditions.
2296 The compiler checks that boolean expressions given in conditions and
2297 consequences are valid, where the rules for conditions are the same as
2298 the rule for an expression in @code{Precondition} and the rules for
2299 consequences are the same as the rule for an expression in
2300 @code{Postcondition}. In particular, attributes @code{'Old} and
2301 @code{'Result} can only be used within consequence expressions.
2302 The condition for the last contract case may be @code{others}, to denote
2303 any case not captured by the previous cases. The
2304 following is an example of use within a package spec:
2306 @smallexample @c ada
2307 package Math_Functions is
2308    ...
2309    function Sqrt (Arg : Float) return Float;
2310    pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2311                           Arg >= 100       => Sqrt'Result >= 10,
2312                           others           => Sqrt'Result = 0);
2313    ...
2314 end Math_Functions;
2315 @end smallexample
2317 @noindent
2318 The meaning of contract cases is that only one case should apply at each
2319 call, as determined by the corresponding condition evaluating to True,
2320 and that the consequence for this case should hold when the subprogram
2321 returns.
2323 @node Pragma Convention_Identifier
2324 @unnumberedsec Pragma Convention_Identifier
2325 @findex Convention_Identifier
2326 @cindex Conventions, synonyms
2327 @noindent
2328 Syntax:
2330 @smallexample @c ada
2331 pragma Convention_Identifier (
2332          [Name =>]       IDENTIFIER,
2333          [Convention =>] convention_IDENTIFIER);
2334 @end smallexample
2336 @noindent
2337 This pragma provides a mechanism for supplying synonyms for existing
2338 convention identifiers. The @code{Name} identifier can subsequently
2339 be used as a synonym for the given convention in other pragmas (including
2340 for example pragma @code{Import} or another @code{Convention_Identifier}
2341 pragma). As an example of the use of this, suppose you had legacy code
2342 which used Fortran77 as the identifier for Fortran. Then the pragma:
2344 @smallexample @c ada
2345 pragma Convention_Identifier (Fortran77, Fortran);
2346 @end smallexample
2348 @noindent
2349 would allow the use of the convention identifier @code{Fortran77} in
2350 subsequent code, avoiding the need to modify the sources. As another
2351 example, you could use this to parameterize convention requirements
2352 according to systems. Suppose you needed to use @code{Stdcall} on
2353 windows systems, and @code{C} on some other system, then you could
2354 define a convention identifier @code{Library} and use a single
2355 @code{Convention_Identifier} pragma to specify which convention
2356 would be used system-wide.
2358 @node Pragma CPP_Class
2359 @unnumberedsec Pragma CPP_Class
2360 @findex CPP_Class
2361 @cindex Interfacing with C++
2362 @noindent
2363 Syntax:
2365 @smallexample @c ada
2366 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2367 @end smallexample
2369 @noindent
2370 The argument denotes an entity in the current declarative region that is
2371 declared as a record type. It indicates that the type corresponds to an
2372 externally declared C++ class type, and is to be laid out the same way
2373 that C++ would lay out the type. If the C++ class has virtual primitives
2374 then the record must be declared as a tagged record type.
2376 Types for which @code{CPP_Class} is specified do not have assignment or
2377 equality operators defined (such operations can be imported or declared
2378 as subprograms as required). Initialization is allowed only by constructor
2379 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2380 limited if not explicitly declared as limited or derived from a limited
2381 type, and an error is issued in that case.
2383 See @ref{Interfacing to C++} for related information.
2385 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2386 for backward compatibility but its functionality is available
2387 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2389 @node Pragma CPP_Constructor
2390 @unnumberedsec Pragma CPP_Constructor
2391 @cindex Interfacing with C++
2392 @findex CPP_Constructor
2393 @noindent
2394 Syntax:
2396 @smallexample @c ada
2397 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2398   [, [External_Name =>] static_string_EXPRESSION ]
2399   [, [Link_Name     =>] static_string_EXPRESSION ]);
2400 @end smallexample
2402 @noindent
2403 This pragma identifies an imported function (imported in the usual way
2404 with pragma @code{Import}) as corresponding to a C++ constructor. If
2405 @code{External_Name} and @code{Link_Name} are not specified then the
2406 @code{Entity} argument is a name that must have been previously mentioned
2407 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2408 must be of one of the following forms:
2410 @itemize @bullet
2411 @item
2412 @code{function @var{Fname} return @var{T}}
2414 @itemize @bullet
2415 @item
2416 @code{function @var{Fname} return @var{T}'Class}
2418 @item
2419 @code{function @var{Fname} (@dots{}) return @var{T}}
2420 @end itemize
2422 @item
2423 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2424 @end itemize
2426 @noindent
2427 where @var{T} is a limited record type imported from C++ with pragma
2428 @code{Import} and @code{Convention} = @code{CPP}.
2430 The first two forms import the default constructor, used when an object
2431 of type @var{T} is created on the Ada side with no explicit constructor.
2432 The latter two forms cover all the non-default constructors of the type.
2433 See the @value{EDITION} User's Guide for details.
2435 If no constructors are imported, it is impossible to create any objects
2436 on the Ada side and the type is implicitly declared abstract.
2438 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2439 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2440 GCC switch).
2441 See @ref{Interfacing to C++} for more related information.
2443 Note: The use of functions returning class-wide types for constructors is
2444 currently obsolete. They are supported for backward compatibility. The
2445 use of functions returning the type T leave the Ada sources more clear
2446 because the imported C++ constructors always return an object of type T;
2447 that is, they never return an object whose type is a descendant of type T.
2449 @node Pragma CPP_Virtual
2450 @unnumberedsec Pragma CPP_Virtual
2451 @cindex Interfacing to C++
2452 @findex CPP_Virtual
2453 @noindent
2454 This pragma is now obsolete and, other than generating a warning if warnings
2455 on obsolescent features are enabled, is completely ignored.
2456 It is retained for compatibility
2457 purposes. It used to be required to ensure compoatibility with C++, but
2458 is no longer required for that purpose because GNAT generates
2459 the same object layout as the G++ compiler by default.
2461 See @ref{Interfacing to C++} for related information.
2463 @node Pragma CPP_Vtable
2464 @unnumberedsec Pragma CPP_Vtable
2465 @cindex Interfacing with C++
2466 @findex CPP_Vtable
2467 @noindent
2468 This pragma is now obsolete and, other than generating a warning if warnings
2469 on obsolescent features are enabled, is completely ignored.
2470 It used to be required to ensure compatibility with C++, but
2471 is no longer required for that purpose because GNAT generates
2472 the same object layout as the G++ compiler by default.
2474 See @ref{Interfacing to C++} for related information.
2476 @node Pragma CPU
2477 @unnumberedsec Pragma CPU
2478 @findex CPU
2479 @noindent
2480 Syntax:
2482 @smallexample @c ada
2483 pragma CPU (EXPRESSION);
2484 @end smallexample
2486 @noindent
2487 This pragma is standard in Ada 2012, but is available in all earlier
2488 versions of Ada as an implementation-defined pragma.
2489 See Ada 2012 Reference Manual for details.
2491 @node Pragma Debug
2492 @unnumberedsec Pragma Debug
2493 @findex Debug
2494 @noindent
2495 Syntax:
2497 @smallexample @c ada
2498 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2500 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2501   PROCEDURE_NAME
2502 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2503 @end smallexample
2505 @noindent
2506 The procedure call argument has the syntactic form of an expression, meeting
2507 the syntactic requirements for pragmas.
2509 If debug pragmas are not enabled or if the condition is present and evaluates
2510 to False, this pragma has no effect. If debug pragmas are enabled, the
2511 semantics of the pragma is exactly equivalent to the procedure call statement
2512 corresponding to the argument with a terminating semicolon. Pragmas are
2513 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2514 intersperse calls to debug procedures in the middle of declarations. Debug
2515 pragmas can be enabled either by use of the command line switch @option{-gnata}
2516 or by use of the pragma @code{Check_Policy} with a first argument of
2517 @code{Debug}.
2519 @node Pragma Debug_Policy
2520 @unnumberedsec Pragma Debug_Policy
2521 @findex Debug_Policy
2522 @noindent
2523 Syntax:
2525 @smallexample @c ada
2526 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2527 @end smallexample
2529 @noindent
2530 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2531 with a first argument of @code{Debug}. It is retained for historical
2532 compatibility reasons.
2534 @node Pragma Default_Scalar_Storage_Order
2535 @unnumberedsec Pragma Default_Scalar_Storage_Order
2536 @cindex Default_Scalar_Storage_Order
2537 @cindex Scalar_Storage_Order
2538 @findex Default_Scalar_Storage_Order
2539 @noindent
2540 Syntax:
2542 @smallexample @c ada
2543 pragma Default_Scalar_Storage_Order (High_Order_First | Low_Order_First);
2544 @end smallexample
2546 @noindent
2547 Normally if no explicit @code{Scalar_Storage_Order} is given for a record
2548 type or array type, then the scalar storage order defaults to the ordinary
2549 default for the target. But this default may be overridden using this pragma.
2550 The pragma may appear as a configuration pragma, or locally within a package
2551 spec or declarative part. In the latter case, it applies to all subsequent
2552 types declared within that package spec or declarative part.
2554 If this pragma is used as a configuration pragma which appears within a
2555 configuration pragma file (as opposed to appearing explicitly at the start
2556 of a single unit), then the binder will require that all units in a partition
2557 be compiled in a similar manner, including all units in the run-time that
2558 are included in the partition.
2560 The following example shows the use of this pragma:
2562 @smallexample @c ada
2563 pragma Default_Scalar_Storage_Order (High_Order_First);
2564 with System; use System;
2565 package DSSO1 is
2566    type H1 is record
2567       a : Integer;
2568    end record;
2570    type L2 is record
2571       a : Integer;
2572    end record;
2573    for L2'Scalar_Storage_Order use Low_Order_First;
2575    type L2a is new L2;
2577    package Inner is
2578       type H3 is record
2579          a : Integer;
2580       end record;
2582       pragma Default_Scalar_Storage_Order (Low_Order_First);
2584       type L4 is record
2585          a : Integer;
2586       end record;
2587    end Inner;
2589    type H4a is new Inner.L4;
2591    type H5 is record
2592       a : Integer;
2593    end record;
2594 end DSSO1;
2595 @end smallexample
2597 @noindent
2598 In this example record types L.. have @code{Low_Order_First} scalar
2599 storage order, and record types H.. have @code{High_Order_First}.
2600 Note that in the case of @code{H4a}, the order is not inherited
2601 from the parent type. Only an explicitly set @code{Scalar_Storage_Order}
2602 gets inherited on type derivation.
2604 @node Pragma Default_Storage_Pool
2605 @unnumberedsec Pragma Default_Storage_Pool
2606 @cindex Default_Storage_Pool
2607 @findex Default_Storage_Pool
2608 @noindent
2609 Syntax:
2611 @smallexample @c ada
2612 pragma Default_Storage_Pool (storage_pool_NAME | null);
2613 @end smallexample
2615 @noindent
2616 This pragma is standard in Ada 2012, but is available in all earlier
2617 versions of Ada as an implementation-defined pragma.
2618 See Ada 2012 Reference Manual for details.
2620 @node Pragma Depends
2621 @unnumberedsec Pragma Depends
2622 @findex Depends
2623 @noindent
2624 For the description of this pragma, see SPARK 2014 Reference Manual,
2625 section 6.1.5.
2627 @node Pragma Detect_Blocking
2628 @unnumberedsec Pragma Detect_Blocking
2629 @findex Detect_Blocking
2630 @noindent
2631 Syntax:
2633 @smallexample @c ada
2634 pragma Detect_Blocking;
2635 @end smallexample
2637 @noindent
2638 This is a standard pragma in Ada 2005, that is available in all earlier
2639 versions of Ada as an implementation-defined pragma.
2641 This is a configuration pragma that forces the detection of potentially
2642 blocking operations within a protected operation, and to raise Program_Error
2643 if that happens.
2645 @node Pragma Disable_Atomic_Synchronization
2646 @unnumberedsec Pragma Disable_Atomic_Synchronization
2647 @cindex Atomic Synchronization
2648 @findex Disable_Atomic_Synchronization
2649 @noindent
2650 Syntax:
2652 @smallexample @c ada
2653 pragma Disable_Atomic_Synchronization [(Entity)];
2654 @end smallexample
2656 @noindent
2657 Ada requires that accesses (reads or writes) of an atomic variable be
2658 regarded as synchronization points in the case of multiple tasks.
2659 Particularly in the case of multi-processors this may require special
2660 handling, e.g. the generation of memory barriers. This capability may
2661 be turned off using this pragma in cases where it is known not to be
2662 required.
2664 The placement and scope rules for this pragma are the same as those
2665 for @code{pragma Suppress}. In particular it can be used as a
2666 configuration  pragma, or in a declaration sequence where it applies
2667 till the end of the scope. If an @code{Entity} argument is present,
2668 the action applies only to that entity.
2670 @node Pragma Dispatching_Domain
2671 @unnumberedsec Pragma Dispatching_Domain
2672 @findex Dispatching_Domain
2673 @noindent
2674 Syntax:
2676 @smallexample @c ada
2677 pragma Dispatching_Domain (EXPRESSION);
2678 @end smallexample
2680 @noindent
2681 This pragma is standard in Ada 2012, but is available in all earlier
2682 versions of Ada as an implementation-defined pragma.
2683 See Ada 2012 Reference Manual for details.
2685 @node Pragma Effective_Reads
2686 @unnumberedsec Pragma Effective_Reads
2687 @findex Effective_Reads
2688 @noindent
2689 For the description of this pragma, see SPARK 2014 Reference Manual,
2690 section 7.1.2.
2692 @node Pragma Effective_Writes
2693 @unnumberedsec Pragma Effective_Writes
2694 @findex Effective_Writes
2695 @noindent
2696 For the description of this pragma, see SPARK 2014 Reference Manual,
2697 section 7.1.2.
2699 @node Pragma Elaboration_Checks
2700 @unnumberedsec Pragma Elaboration_Checks
2701 @cindex Elaboration control
2702 @findex Elaboration_Checks
2703 @noindent
2704 Syntax:
2706 @smallexample @c ada
2707 pragma Elaboration_Checks (Dynamic | Static);
2708 @end smallexample
2710 @noindent
2711 This is a configuration pragma that provides control over the
2712 elaboration model used by the compilation affected by the
2713 pragma.  If the parameter is @code{Dynamic},
2714 then the dynamic elaboration
2715 model described in the Ada Reference Manual is used, as though
2716 the @option{-gnatE} switch had been specified on the command
2717 line.  If the parameter is @code{Static}, then the default GNAT static
2718 model is used.  This configuration pragma overrides the setting
2719 of the command line.  For full details on the elaboration models
2720 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2721 gnat_ugn, @value{EDITION} User's Guide}.
2723 @node Pragma Eliminate
2724 @unnumberedsec Pragma Eliminate
2725 @cindex Elimination of unused subprograms
2726 @findex Eliminate
2727 @noindent
2728 Syntax:
2730 @smallexample @c ada
2731 pragma Eliminate ([Entity          =>] DEFINING_DESIGNATOR,
2732                   [Source_Location =>] STRING_LITERAL);
2733 @end smallexample
2735 @noindent
2736 The string literal given for the source location is a string which
2737 specifies the line number of the occurrence of the entity, using
2738 the syntax for SOURCE_TRACE given below:
2740 @smallexample @c ada
2741  SOURCE_TRACE     ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2743  LBRACKET         ::= [
2744  RBRACKET         ::= ]
2746  SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2748  LINE_NUMBER      ::= DIGIT @{DIGIT@}
2749 @end smallexample
2751 @noindent
2752 Spaces around the colon in a @code{Source_Reference} are optional.
2754 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2755 explicit subprogram declaration, where the @code{entity} name in this
2756 designator appears on the source line specified by the source location.
2758 The source trace that is given as the @code{Source_Location} shall obey the
2759 following rules. The @code{FILE_NAME} is the short name (with no directory
2760 information) of an Ada source file, given using exactly the required syntax
2761 for the underlying file system (e.g. case is important if the underlying
2762 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2763 number of the occurrence of the @code{entity}
2764 as a decimal literal without an exponent or point. If an @code{entity} is not
2765 declared in a generic instantiation (this includes generic subprogram
2766 instances), the source trace includes only one source reference. If an entity
2767 is declared inside a generic instantiation, its source trace (when parsing
2768 from left to right) starts with the source location of the declaration of the
2769 entity in the generic unit and ends with the source location of the
2770 instantiation (it is given in square brackets). This approach is recursively
2771 used in case of nested instantiations: the rightmost (nested most deeply in
2772 square brackets) element of the source trace is the location of the outermost
2773 instantiation, the next to left element is the location of the next (first
2774 nested) instantiation in the code of the corresponding generic unit, and so
2775 on, and the leftmost element (that is out of any square brackets) is the
2776 location of the declaration of the entity to eliminate in a generic unit.
2778 Note that the @code{Source_Location} argument specifies which of a set of
2779 similarly named entities is being eliminated, dealing both with overloading,
2780 and also appearance of the same entity name in different scopes.
2782 This pragma indicates that the given entity is not used in the program to be
2783 compiled and built. The effect of the pragma is to allow the compiler to
2784 eliminate the code or data associated with the named entity. Any reference to
2785 an eliminated entity causes a compile-time or link-time error.
2787 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2788 in a system-independent manner, with unused entities eliminated, without
2789 needing to modify the source text. Normally the required set of
2790 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2792 Any source file change that removes, splits, or
2793 adds lines may make the set of Eliminate pragmas invalid because their
2794 @code{Source_Location} argument values may get out of date.
2796 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2797 operation. In this case all the subprograms to which the given operation can
2798 dispatch are considered to be unused (are never called as a result of a direct
2799 or a dispatching call).
2801 @node Pragma Enable_Atomic_Synchronization
2802 @unnumberedsec Pragma Enable_Atomic_Synchronization
2803 @cindex Atomic Synchronization
2804 @findex Enable_Atomic_Synchronization
2805 @noindent
2806 Syntax:
2808 @smallexample @c ada
2809 pragma Enable_Atomic_Synchronization [(Entity)];
2810 @end smallexample
2812 @noindent
2813 Ada requires that accesses (reads or writes) of an atomic variable be
2814 regarded as synchronization points in the case of multiple tasks.
2815 Particularly in the case of multi-processors this may require special
2816 handling, e.g. the generation of memory barriers. This synchronization
2817 is performed by default, but can be turned off using
2818 @code{pragma Disable_Atomic_Synchronization}. The
2819 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2820 it back on.
2822 The placement and scope rules for this pragma are the same as those
2823 for @code{pragma Unsuppress}. In particular it can be used as a
2824 configuration  pragma, or in a declaration sequence where it applies
2825 till the end of the scope. If an @code{Entity} argument is present,
2826 the action applies only to that entity.
2828 @node Pragma Export_Exception
2829 @unnumberedsec Pragma Export_Exception
2830 @cindex OpenVMS
2831 @findex Export_Exception
2832 @noindent
2833 Syntax:
2835 @smallexample @c ada
2836 pragma Export_Exception (
2837      [Internal =>] LOCAL_NAME
2838   [, [External =>] EXTERNAL_SYMBOL]
2839   [, [Form     =>] Ada | VMS]
2840   [, [Code     =>] static_integer_EXPRESSION]);
2842 EXTERNAL_SYMBOL ::=
2843   IDENTIFIER
2844 | static_string_EXPRESSION
2845 @end smallexample
2847 @noindent
2848 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
2849 causes the specified exception to be propagated outside of the Ada program,
2850 so that it can be handled by programs written in other OpenVMS languages.
2851 This pragma establishes an external name for an Ada exception and makes the
2852 name available to the OpenVMS Linker as a global symbol.  For further details
2853 on this pragma, see the
2854 DEC Ada Language Reference Manual, section 13.9a3.2.
2856 @node Pragma Export_Function
2857 @unnumberedsec Pragma Export_Function
2858 @cindex Argument passing mechanisms
2859 @findex Export_Function
2861 @noindent
2862 Syntax:
2864 @smallexample @c ada
2865 pragma Export_Function (
2866      [Internal         =>] LOCAL_NAME
2867   [, [External         =>] EXTERNAL_SYMBOL]
2868   [, [Parameter_Types  =>] PARAMETER_TYPES]
2869   [, [Result_Type      =>] result_SUBTYPE_MARK]
2870   [, [Mechanism        =>] MECHANISM]
2871   [, [Result_Mechanism =>] MECHANISM_NAME]);
2873 EXTERNAL_SYMBOL ::=
2874   IDENTIFIER
2875 | static_string_EXPRESSION
2876 | ""
2878 PARAMETER_TYPES ::=
2879   null
2880 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2882 TYPE_DESIGNATOR ::=
2883   subtype_NAME
2884 | subtype_Name ' Access
2886 MECHANISM ::=
2887   MECHANISM_NAME
2888 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2890 MECHANISM_ASSOCIATION ::=
2891   [formal_parameter_NAME =>] MECHANISM_NAME
2893 MECHANISM_NAME ::= Value | Reference
2894 @end smallexample
2896 @noindent
2897 Use this pragma to make a function externally callable and optionally
2898 provide information on mechanisms to be used for passing parameter and
2899 result values.  We recommend, for the purposes of improving portability,
2900 this pragma always be used in conjunction with a separate pragma
2901 @code{Export}, which must precede the pragma @code{Export_Function}.
2902 GNAT does not require a separate pragma @code{Export}, but if none is
2903 present, @code{Convention Ada} is assumed, which is usually
2904 not what is wanted, so it is usually appropriate to use this
2905 pragma in conjunction with a @code{Export} or @code{Convention}
2906 pragma that specifies the desired foreign convention.
2907 Pragma @code{Export_Function}
2908 (and @code{Export}, if present) must appear in the same declarative
2909 region as the function to which they apply.
2911 @var{internal_name} must uniquely designate the function to which the
2912 pragma applies.  If more than one function name exists of this name in
2913 the declarative part you must use the @code{Parameter_Types} and
2914 @code{Result_Type} parameters is mandatory to achieve the required
2915 unique designation.  @var{subtype_mark}s in these parameters must
2916 exactly match the subtypes in the corresponding function specification,
2917 using positional notation to match parameters with subtype marks.
2918 The form with an @code{'Access} attribute can be used to match an
2919 anonymous access parameter.
2921 @cindex Suppressing external name
2922 Special treatment is given if the EXTERNAL is an explicit null
2923 string or a static string expressions that evaluates to the null
2924 string. In this case, no external name is generated. This form
2925 still allows the specification of parameter mechanisms.
2927 @node Pragma Export_Object
2928 @unnumberedsec Pragma Export_Object
2929 @findex Export_Object
2930 @noindent
2931 Syntax:
2933 @smallexample @c ada
2934 pragma Export_Object
2935       [Internal =>] LOCAL_NAME
2936    [, [External =>] EXTERNAL_SYMBOL]
2937    [, [Size     =>] EXTERNAL_SYMBOL]
2939 EXTERNAL_SYMBOL ::=
2940   IDENTIFIER
2941 | static_string_EXPRESSION
2942 @end smallexample
2944 @noindent
2945 This pragma designates an object as exported, and apart from the
2946 extended rules for external symbols, is identical in effect to the use of
2947 the normal @code{Export} pragma applied to an object.  You may use a
2948 separate Export pragma (and you probably should from the point of view
2949 of portability), but it is not required.  @var{Size} is syntax checked,
2950 but otherwise ignored by GNAT@.
2952 @node Pragma Export_Procedure
2953 @unnumberedsec Pragma Export_Procedure
2954 @findex Export_Procedure
2955 @noindent
2956 Syntax:
2958 @smallexample @c ada
2959 pragma Export_Procedure (
2960      [Internal        =>] LOCAL_NAME
2961   [, [External        =>] EXTERNAL_SYMBOL]
2962   [, [Parameter_Types =>] PARAMETER_TYPES]
2963   [, [Mechanism       =>] MECHANISM]);
2965 EXTERNAL_SYMBOL ::=
2966   IDENTIFIER
2967 | static_string_EXPRESSION
2968 | ""
2970 PARAMETER_TYPES ::=
2971   null
2972 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2974 TYPE_DESIGNATOR ::=
2975   subtype_NAME
2976 | subtype_Name ' Access
2978 MECHANISM ::=
2979   MECHANISM_NAME
2980 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2982 MECHANISM_ASSOCIATION ::=
2983   [formal_parameter_NAME =>] MECHANISM_NAME
2985 MECHANISM_NAME ::= Value | Reference
2986 @end smallexample
2988 @noindent
2989 This pragma is identical to @code{Export_Function} except that it
2990 applies to a procedure rather than a function and the parameters
2991 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2992 GNAT does not require a separate pragma @code{Export}, but if none is
2993 present, @code{Convention Ada} is assumed, which is usually
2994 not what is wanted, so it is usually appropriate to use this
2995 pragma in conjunction with a @code{Export} or @code{Convention}
2996 pragma that specifies the desired foreign convention.
2998 @cindex Suppressing external name
2999 Special treatment is given if the EXTERNAL is an explicit null
3000 string or a static string expressions that evaluates to the null
3001 string. In this case, no external name is generated. This form
3002 still allows the specification of parameter mechanisms.
3004 @node Pragma Export_Value
3005 @unnumberedsec Pragma Export_Value
3006 @findex Export_Value
3007 @noindent
3008 Syntax:
3010 @smallexample @c ada
3011 pragma Export_Value (
3012   [Value     =>] static_integer_EXPRESSION,
3013   [Link_Name =>] static_string_EXPRESSION);
3014 @end smallexample
3016 @noindent
3017 This pragma serves to export a static integer value for external use.
3018 The first argument specifies the value to be exported. The Link_Name
3019 argument specifies the symbolic name to be associated with the integer
3020 value. This pragma is useful for defining a named static value in Ada
3021 that can be referenced in assembly language units to be linked with
3022 the application. This pragma is currently supported only for the
3023 AAMP target and is ignored for other targets.
3025 @node Pragma Export_Valued_Procedure
3026 @unnumberedsec Pragma Export_Valued_Procedure
3027 @findex Export_Valued_Procedure
3028 @noindent
3029 Syntax:
3031 @smallexample @c ada
3032 pragma Export_Valued_Procedure (
3033      [Internal        =>] LOCAL_NAME
3034   [, [External        =>] EXTERNAL_SYMBOL]
3035   [, [Parameter_Types =>] PARAMETER_TYPES]
3036   [, [Mechanism       =>] MECHANISM]);
3038 EXTERNAL_SYMBOL ::=
3039   IDENTIFIER
3040 | static_string_EXPRESSION
3041 | ""
3043 PARAMETER_TYPES ::=
3044   null
3045 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3047 TYPE_DESIGNATOR ::=
3048   subtype_NAME
3049 | subtype_Name ' Access
3051 MECHANISM ::=
3052   MECHANISM_NAME
3053 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3055 MECHANISM_ASSOCIATION ::=
3056   [formal_parameter_NAME =>] MECHANISM_NAME
3058 MECHANISM_NAME ::= Value | Reference
3059 @end smallexample
3061 @noindent
3062 This pragma is identical to @code{Export_Procedure} except that the
3063 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3064 mode @code{OUT}, and externally the subprogram is treated as a function
3065 with this parameter as the result of the function.  GNAT provides for
3066 this capability to allow the use of @code{OUT} and @code{IN OUT}
3067 parameters in interfacing to external functions (which are not permitted
3068 in Ada functions).
3069 GNAT does not require a separate pragma @code{Export}, but if none is
3070 present, @code{Convention Ada} is assumed, which is almost certainly
3071 not what is wanted since the whole point of this pragma is to interface
3072 with foreign language functions, so it is usually appropriate to use this
3073 pragma in conjunction with a @code{Export} or @code{Convention}
3074 pragma that specifies the desired foreign convention.
3076 @cindex Suppressing external name
3077 Special treatment is given if the EXTERNAL is an explicit null
3078 string or a static string expressions that evaluates to the null
3079 string. In this case, no external name is generated. This form
3080 still allows the specification of parameter mechanisms.
3082 @node Pragma Extend_System
3083 @unnumberedsec Pragma Extend_System
3084 @cindex @code{system}, extending
3085 @cindex Dec Ada 83
3086 @findex Extend_System
3087 @noindent
3088 Syntax:
3090 @smallexample @c ada
3091 pragma Extend_System ([Name =>] IDENTIFIER);
3092 @end smallexample
3094 @noindent
3095 This pragma is used to provide backwards compatibility with other
3096 implementations that extend the facilities of package @code{System}.  In
3097 GNAT, @code{System} contains only the definitions that are present in
3098 the Ada RM@.  However, other implementations, notably the DEC Ada 83
3099 implementation, provide many extensions to package @code{System}.
3101 For each such implementation accommodated by this pragma, GNAT provides a
3102 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
3103 implementation, which provides the required additional definitions.  You
3104 can use this package in two ways.  You can @code{with} it in the normal
3105 way and access entities either by selection or using a @code{use}
3106 clause.  In this case no special processing is required.
3108 However, if existing code contains references such as
3109 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
3110 definitions provided in package @code{System}, you may use this pragma
3111 to extend visibility in @code{System} in a non-standard way that
3112 provides greater compatibility with the existing code.  Pragma
3113 @code{Extend_System} is a configuration pragma whose single argument is
3114 the name of the package containing the extended definition
3115 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
3116 control of this pragma will be processed using special visibility
3117 processing that looks in package @code{System.Aux_@var{xxx}} where
3118 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
3119 package @code{System}, but not found in package @code{System}.
3121 You can use this pragma either to access a predefined @code{System}
3122 extension supplied with the compiler, for example @code{Aux_DEC} or
3123 you can construct your own extension unit following the above
3124 definition.  Note that such a package is a child of @code{System}
3125 and thus is considered part of the implementation.
3126 To compile it you will have to use the @option{-gnatg} switch,
3127 or the @option{/GNAT_INTERNAL} qualifier on OpenVMS,
3128 for compiling System units, as explained in the
3129 @value{EDITION} User's Guide.
3131 @node Pragma Extensions_Allowed
3132 @unnumberedsec Pragma Extensions_Allowed
3133 @cindex Ada Extensions
3134 @cindex GNAT Extensions
3135 @findex Extensions_Allowed
3136 @noindent
3137 Syntax:
3139 @smallexample @c ada
3140 pragma Extensions_Allowed (On | Off);
3141 @end smallexample
3143 @noindent
3144 This configuration pragma enables or disables the implementation
3145 extension mode (the use of Off as a parameter cancels the effect
3146 of the @option{-gnatX} command switch).
3148 In extension mode, the latest version of the Ada language is
3149 implemented (currently Ada 2012), and in addition a small number
3150 of GNAT specific extensions are recognized as follows:
3152 @table @asis
3153 @item Constrained attribute for generic objects
3154 The @code{Constrained} attribute is permitted for objects of
3155 generic types. The result indicates if the corresponding actual
3156 is constrained.
3158 @end table
3160 @node Pragma External
3161 @unnumberedsec Pragma External
3162 @findex External
3163 @noindent
3164 Syntax:
3166 @smallexample @c ada
3167 pragma External (
3168   [   Convention    =>] convention_IDENTIFIER,
3169   [   Entity        =>] LOCAL_NAME
3170   [, [External_Name =>] static_string_EXPRESSION ]
3171   [, [Link_Name     =>] static_string_EXPRESSION ]);
3172 @end smallexample
3174 @noindent
3175 This pragma is identical in syntax and semantics to pragma
3176 @code{Export} as defined in the Ada Reference Manual.  It is
3177 provided for compatibility with some Ada 83 compilers that
3178 used this pragma for exactly the same purposes as pragma
3179 @code{Export} before the latter was standardized.
3181 @node Pragma External_Name_Casing
3182 @unnumberedsec Pragma External_Name_Casing
3183 @cindex Dec Ada 83 casing compatibility
3184 @cindex External Names, casing
3185 @cindex Casing of External names
3186 @findex External_Name_Casing
3187 @noindent
3188 Syntax:
3190 @smallexample @c ada
3191 pragma External_Name_Casing (
3192   Uppercase | Lowercase
3193   [, Uppercase | Lowercase | As_Is]);
3194 @end smallexample
3196 @noindent
3197 This pragma provides control over the casing of external names associated
3198 with Import and Export pragmas.  There are two cases to consider:
3200 @table @asis
3201 @item Implicit external names
3202 Implicit external names are derived from identifiers.  The most common case
3203 arises when a standard Ada Import or Export pragma is used with only two
3204 arguments, as in:
3206 @smallexample @c ada
3207    pragma Import (C, C_Routine);
3208 @end smallexample
3210 @noindent
3211 Since Ada is a case-insensitive language, the spelling of the identifier in
3212 the Ada source program does not provide any information on the desired
3213 casing of the external name, and so a convention is needed.  In GNAT the
3214 default treatment is that such names are converted to all lower case
3215 letters.  This corresponds to the normal C style in many environments.
3216 The first argument of pragma @code{External_Name_Casing} can be used to
3217 control this treatment.  If @code{Uppercase} is specified, then the name
3218 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3219 then the normal default of all lower case letters will be used.
3221 This same implicit treatment is also used in the case of extended DEC Ada 83
3222 compatible Import and Export pragmas where an external name is explicitly
3223 specified using an identifier rather than a string.
3225 @item Explicit external names
3226 Explicit external names are given as string literals.  The most common case
3227 arises when a standard Ada Import or Export pragma is used with three
3228 arguments, as in:
3230 @smallexample @c ada
3231 pragma Import (C, C_Routine, "C_routine");
3232 @end smallexample
3234 @noindent
3235 In this case, the string literal normally provides the exact casing required
3236 for the external name.  The second argument of pragma
3237 @code{External_Name_Casing} may be used to modify this behavior.
3238 If @code{Uppercase} is specified, then the name
3239 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3240 then the name will be forced to all lowercase letters.  A specification of
3241 @code{As_Is} provides the normal default behavior in which the casing is
3242 taken from the string provided.
3243 @end table
3245 @noindent
3246 This pragma may appear anywhere that a pragma is valid.  In particular, it
3247 can be used as a configuration pragma in the @file{gnat.adc} file, in which
3248 case it applies to all subsequent compilations, or it can be used as a program
3249 unit pragma, in which case it only applies to the current unit, or it can
3250 be used more locally to control individual Import/Export pragmas.
3252 It is primarily intended for use with OpenVMS systems, where many
3253 compilers convert all symbols to upper case by default.  For interfacing to
3254 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3255 the pragma:
3257 @smallexample @c ada
3258 pragma External_Name_Casing (Uppercase, Uppercase);
3259 @end smallexample
3261 @noindent
3262 to enforce the upper casing of all external symbols.
3264 @node Pragma Fast_Math
3265 @unnumberedsec Pragma Fast_Math
3266 @findex Fast_Math
3267 @noindent
3268 Syntax:
3270 @smallexample @c ada
3271 pragma Fast_Math;
3272 @end smallexample
3274 @noindent
3275 This is a configuration pragma which activates a mode in which speed is
3276 considered more important for floating-point operations than absolutely
3277 accurate adherence to the requirements of the standard. Currently the
3278 following operations are affected:
3280 @table @asis
3281 @item Complex Multiplication
3282 The normal simple formula for complex multiplication can result in intermediate
3283 overflows for numbers near the end of the range. The Ada standard requires that
3284 this situation be detected and corrected by scaling, but in Fast_Math mode such
3285 cases will simply result in overflow. Note that to take advantage of this you
3286 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3287 under control of the pragma, rather than use the preinstantiated versions.
3288 @end table
3290 @node Pragma Favor_Top_Level
3291 @unnumberedsec Pragma Favor_Top_Level
3292 @findex Favor_Top_Level
3293 @noindent
3294 Syntax:
3296 @smallexample @c ada
3297 pragma Favor_Top_Level (type_NAME);
3298 @end smallexample
3300 @noindent
3301 The named type must be an access-to-subprogram type. This pragma is an
3302 efficiency hint to the compiler, regarding the use of 'Access or
3303 'Unrestricted_Access on nested (non-library-level) subprograms. The
3304 pragma means that nested subprograms are not used with this type, or
3305 are rare, so that the generated code should be efficient in the
3306 top-level case. When this pragma is used, dynamically generated
3307 trampolines may be used on some targets for nested subprograms.
3308 See also the No_Implicit_Dynamic_Code restriction.
3310 @node Pragma Finalize_Storage_Only
3311 @unnumberedsec Pragma Finalize_Storage_Only
3312 @findex Finalize_Storage_Only
3313 @noindent
3314 Syntax:
3316 @smallexample @c ada
3317 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3318 @end smallexample
3320 @noindent
3321 This pragma allows the compiler not to emit a Finalize call for objects
3322 defined at the library level.  This is mostly useful for types where
3323 finalization is only used to deal with storage reclamation since in most
3324 environments it is not necessary to reclaim memory just before terminating
3325 execution, hence the name.
3327 @node Pragma Float_Representation
3328 @unnumberedsec Pragma Float_Representation
3329 @cindex OpenVMS
3330 @findex Float_Representation
3331 @noindent
3332 Syntax:
3334 @smallexample @c ada
3335 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3337 FLOAT_REP ::= VAX_Float | IEEE_Float
3338 @end smallexample
3340 @noindent
3341 In the one argument form, this pragma is a configuration pragma which
3342 allows control over the internal representation chosen for the predefined
3343 floating point types declared in the packages @code{Standard} and
3344 @code{System}. On all systems other than OpenVMS, the argument must
3345 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3346 argument may be @code{VAX_Float} to specify the use of the VAX float
3347 format for the floating-point types in Standard. This requires that
3348 the standard runtime libraries be recompiled.
3350 The two argument form specifies the representation to be used for
3351 the specified floating-point type. On all systems other than OpenVMS,
3352 the argument must
3353 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3355 @itemize @bullet
3356 @item
3357 For a digits value of 6, 32-bit IEEE short format will be used.
3358 @item
3359 For a digits value of 15, 64-bit IEEE long format will be used.
3360 @item
3361 No other value of digits is permitted.
3362 @end itemize
3364 On OpenVMS, the
3365 argument may be @code{VAX_Float} to specify the use of the VAX float
3366 format, as follows:
3368 @itemize @bullet
3369 @item
3370 For digits values up to 6, F float format will be used.
3371 @item
3372 For digits values from 7 to 9, D float format will be used.
3373 @item
3374 For digits values from 10 to 15, G float format will be used.
3375 @item
3376 Digits values above 15 are not allowed.
3377 @end itemize
3379 @node Pragma Global
3380 @unnumberedsec Pragma Global
3381 @findex Global
3382 @noindent
3383 For the description of this pragma, see SPARK 2014 Reference Manual,
3384 section 6.1.4.
3386 @node Pragma Ident
3387 @unnumberedsec Pragma Ident
3388 @findex Ident
3389 @noindent
3390 Syntax:
3392 @smallexample @c ada
3393 pragma Ident (static_string_EXPRESSION);
3394 @end smallexample
3396 @noindent
3397 This pragma is identical in effect to pragma @code{Comment}. It is provided
3398 for compatibility with other Ada compilers providing this pragma.
3400 @node Pragma Implementation_Defined
3401 @unnumberedsec Pragma Implementation_Defined
3402 @findex Implementation_Defined
3403 @noindent
3404 Syntax:
3406 @smallexample @c ada
3407 pragma Implementation_Defined (local_NAME);
3408 @end smallexample
3410 @noindent
3411 This pragma marks a previously declared entioty as implementation-defined.
3412 For an overloaded entity, applies to the most recent homonym.
3414 @smallexample @c ada
3415 pragma Implementation_Defined;
3416 @end smallexample
3418 @noindent
3419 The form with no arguments appears anywhere within a scope, most
3420 typically a package spec, and indicates that all entities that are
3421 defined within the package spec are Implementation_Defined.
3423 This pragma is used within the GNAT runtime library to identify
3424 implementation-defined entities introduced in language-defined units,
3425 for the purpose of implementing the No_Implementation_Identifiers
3426 restriction.
3428 @node Pragma Implemented
3429 @unnumberedsec Pragma Implemented
3430 @findex Implemented
3431 @noindent
3432 Syntax:
3434 @smallexample @c ada
3435 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3437 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3438 @end smallexample
3440 @noindent
3441 This is an Ada 2012 representation pragma which applies to protected, task
3442 and synchronized interface primitives. The use of pragma Implemented provides
3443 a way to impose a static requirement on the overriding operation by adhering
3444 to one of the three implementation kinds: entry, protected procedure or any of
3445 the above. This pragma is available in all earlier versions of Ada as an
3446 implementation-defined pragma.
3448 @smallexample @c ada
3449 type Synch_Iface is synchronized interface;
3450 procedure Prim_Op (Obj : in out Iface) is abstract;
3451 pragma Implemented (Prim_Op, By_Protected_Procedure);
3453 protected type Prot_1 is new Synch_Iface with
3454    procedure Prim_Op;  --  Legal
3455 end Prot_1;
3457 protected type Prot_2 is new Synch_Iface with
3458    entry Prim_Op;      --  Illegal
3459 end Prot_2;
3461 task type Task_Typ is new Synch_Iface with
3462    entry Prim_Op;      --  Illegal
3463 end Task_Typ;
3464 @end smallexample
3466 @noindent
3467 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3468 Implemented determines the runtime behavior of the requeue. Implementation kind
3469 By_Entry guarantees that the action of requeueing will proceed from an entry to
3470 another entry. Implementation kind By_Protected_Procedure transforms the
3471 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3472 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3473 the target's overriding subprogram kind.
3475 @node Pragma Implicit_Packing
3476 @unnumberedsec Pragma Implicit_Packing
3477 @findex Implicit_Packing
3478 @cindex Rational Profile
3479 @noindent
3480 Syntax:
3482 @smallexample @c ada
3483 pragma Implicit_Packing;
3484 @end smallexample
3486 @noindent
3487 This is a configuration pragma that requests implicit packing for packed
3488 arrays for which a size clause is given but no explicit pragma Pack or
3489 specification of Component_Size is present. It also applies to records
3490 where no record representation clause is present. Consider this example:
3492 @smallexample @c ada
3493 type R is array (0 .. 7) of Boolean;
3494 for R'Size use 8;
3495 @end smallexample
3497 @noindent
3498 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3499 does not change the layout of a composite object. So the Size clause in the
3500 above example is normally rejected, since the default layout of the array uses
3501 8-bit components, and thus the array requires a minimum of 64 bits.
3503 If this declaration is compiled in a region of code covered by an occurrence
3504 of the configuration pragma Implicit_Packing, then the Size clause in this
3505 and similar examples will cause implicit packing and thus be accepted. For
3506 this implicit packing to occur, the type in question must be an array of small
3507 components whose size is known at compile time, and the Size clause must
3508 specify the exact size that corresponds to the number of elements in the array
3509 multiplied by the size in bits of the component type (both single and
3510 multi-dimensioned arrays can be controlled with this pragma).
3512 @cindex Array packing
3514 Similarly, the following example shows the use in the record case
3516 @smallexample @c ada
3517 type r is record
3518    a, b, c, d, e, f, g, h : boolean;
3519    chr                    : character;
3520 end record;
3521 for r'size use 16;
3522 @end smallexample
3524 @noindent
3525 Without a pragma Pack, each Boolean field requires 8 bits, so the
3526 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3527 sufficient. The use of pragma Implicit_Packing allows this record
3528 declaration to compile without an explicit pragma Pack.
3529 @node Pragma Import_Exception
3530 @unnumberedsec Pragma Import_Exception
3531 @cindex OpenVMS
3532 @findex Import_Exception
3533 @noindent
3534 Syntax:
3536 @smallexample @c ada
3537 pragma Import_Exception (
3538      [Internal =>] LOCAL_NAME
3539   [, [External =>] EXTERNAL_SYMBOL]
3540   [, [Form     =>] Ada | VMS]
3541   [, [Code     =>] static_integer_EXPRESSION]);
3543 EXTERNAL_SYMBOL ::=
3544   IDENTIFIER
3545 | static_string_EXPRESSION
3546 @end smallexample
3548 @noindent
3549 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3550 It allows OpenVMS conditions (for example, from OpenVMS system services or
3551 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3552 The pragma specifies that the exception associated with an exception
3553 declaration in an Ada program be defined externally (in non-Ada code).
3554 For further details on this pragma, see the
3555 DEC Ada Language Reference Manual, section 13.9a.3.1.
3557 @node Pragma Import_Function
3558 @unnumberedsec Pragma Import_Function
3559 @findex Import_Function
3560 @noindent
3561 Syntax:
3563 @smallexample @c ada
3564 pragma Import_Function (
3565      [Internal                 =>] LOCAL_NAME,
3566   [, [External                 =>] EXTERNAL_SYMBOL]
3567   [, [Parameter_Types          =>] PARAMETER_TYPES]
3568   [, [Result_Type              =>] SUBTYPE_MARK]
3569   [, [Mechanism                =>] MECHANISM]
3570   [, [Result_Mechanism         =>] MECHANISM_NAME]);
3572 EXTERNAL_SYMBOL ::=
3573   IDENTIFIER
3574 | static_string_EXPRESSION
3576 PARAMETER_TYPES ::=
3577   null
3578 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3580 TYPE_DESIGNATOR ::=
3581   subtype_NAME
3582 | subtype_Name ' Access
3584 MECHANISM ::=
3585   MECHANISM_NAME
3586 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3588 MECHANISM_ASSOCIATION ::=
3589   [formal_parameter_NAME =>] MECHANISM_NAME
3591 MECHANISM_NAME ::=
3592   Value
3593 | Reference
3594 @end smallexample
3596 @noindent
3597 This pragma is used in conjunction with a pragma @code{Import} to
3598 specify additional information for an imported function.  The pragma
3599 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3600 @code{Import_Function} pragma and both must appear in the same
3601 declarative part as the function specification.
3603 The @var{Internal} argument must uniquely designate
3604 the function to which the
3605 pragma applies.  If more than one function name exists of this name in
3606 the declarative part you must use the @code{Parameter_Types} and
3607 @var{Result_Type} parameters to achieve the required unique
3608 designation.  Subtype marks in these parameters must exactly match the
3609 subtypes in the corresponding function specification, using positional
3610 notation to match parameters with subtype marks.
3611 The form with an @code{'Access} attribute can be used to match an
3612 anonymous access parameter.
3614 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3615 parameters to specify passing mechanisms for the
3616 parameters and result.  If you specify a single mechanism name, it
3617 applies to all parameters.  Otherwise you may specify a mechanism on a
3618 parameter by parameter basis using either positional or named
3619 notation.  If the mechanism is not specified, the default mechanism
3620 is used.
3622 @node Pragma Import_Object
3623 @unnumberedsec Pragma Import_Object
3624 @findex Import_Object
3625 @noindent
3626 Syntax:
3628 @smallexample @c ada
3629 pragma Import_Object
3630      [Internal =>] LOCAL_NAME
3631   [, [External =>] EXTERNAL_SYMBOL]
3632   [, [Size     =>] EXTERNAL_SYMBOL]);
3634 EXTERNAL_SYMBOL ::=
3635   IDENTIFIER
3636 | static_string_EXPRESSION
3637 @end smallexample
3639 @noindent
3640 This pragma designates an object as imported, and apart from the
3641 extended rules for external symbols, is identical in effect to the use of
3642 the normal @code{Import} pragma applied to an object.  Unlike the
3643 subprogram case, you need not use a separate @code{Import} pragma,
3644 although you may do so (and probably should do so from a portability
3645 point of view).  @var{size} is syntax checked, but otherwise ignored by
3646 GNAT@.
3648 @node Pragma Import_Procedure
3649 @unnumberedsec Pragma Import_Procedure
3650 @findex Import_Procedure
3651 @noindent
3652 Syntax:
3654 @smallexample @c ada
3655 pragma Import_Procedure (
3656      [Internal                 =>] LOCAL_NAME
3657   [, [External                 =>] EXTERNAL_SYMBOL]
3658   [, [Parameter_Types          =>] PARAMETER_TYPES]
3659   [, [Mechanism                =>] MECHANISM]);
3661 EXTERNAL_SYMBOL ::=
3662   IDENTIFIER
3663 | static_string_EXPRESSION
3665 PARAMETER_TYPES ::=
3666   null
3667 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3669 TYPE_DESIGNATOR ::=
3670   subtype_NAME
3671 | subtype_Name ' Access
3673 MECHANISM ::=
3674   MECHANISM_NAME
3675 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3677 MECHANISM_ASSOCIATION ::=
3678   [formal_parameter_NAME =>] MECHANISM_NAME
3680 MECHANISM_NAME ::= Value | Reference
3681 @end smallexample
3683 @noindent
3684 This pragma is identical to @code{Import_Function} except that it
3685 applies to a procedure rather than a function and the parameters
3686 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3688 @node Pragma Import_Valued_Procedure
3689 @unnumberedsec Pragma Import_Valued_Procedure
3690 @findex Import_Valued_Procedure
3691 @noindent
3692 Syntax:
3694 @smallexample @c ada
3695 pragma Import_Valued_Procedure (
3696      [Internal                 =>] LOCAL_NAME
3697   [, [External                 =>] EXTERNAL_SYMBOL]
3698   [, [Parameter_Types          =>] PARAMETER_TYPES]
3699   [, [Mechanism                =>] MECHANISM]);
3701 EXTERNAL_SYMBOL ::=
3702   IDENTIFIER
3703 | static_string_EXPRESSION
3705 PARAMETER_TYPES ::=
3706   null
3707 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3709 TYPE_DESIGNATOR ::=
3710   subtype_NAME
3711 | subtype_Name ' Access
3713 MECHANISM ::=
3714   MECHANISM_NAME
3715 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3717 MECHANISM_ASSOCIATION ::=
3718   [formal_parameter_NAME =>] MECHANISM_NAME
3720 MECHANISM_NAME ::= Value | Reference
3721 @end smallexample
3723 @noindent
3724 This pragma is identical to @code{Import_Procedure} except that the
3725 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3726 mode @code{OUT}, and externally the subprogram is treated as a function
3727 with this parameter as the result of the function.  The purpose of this
3728 capability is to allow the use of @code{OUT} and @code{IN OUT}
3729 parameters in interfacing to external functions (which are not permitted
3730 in Ada functions).  You may optionally use the @code{Mechanism}
3731 parameters to specify passing mechanisms for the parameters.
3732 If you specify a single mechanism name, it applies to all parameters.
3733 Otherwise you may specify a mechanism on a parameter by parameter
3734 basis using either positional or named notation.  If the mechanism is not
3735 specified, the default mechanism is used.
3737 Note that it is important to use this pragma in conjunction with a separate
3738 pragma Import that specifies the desired convention, since otherwise the
3739 default convention is Ada, which is almost certainly not what is required.
3741 @node Pragma Independent
3742 @unnumberedsec Pragma Independent
3743 @findex Independent
3744 @noindent
3745 Syntax:
3747 @smallexample @c ada
3748 pragma Independent (Local_NAME);
3749 @end smallexample
3751 @noindent
3752 This pragma is standard in Ada 2012 mode (which also provides an aspect
3753 of the same name). It is also available as an implementation-defined
3754 pragma in all earlier versions. It specifies that the
3755 designated object or all objects of the designated type must be
3756 independently addressable. This means that separate tasks can safely
3757 manipulate such objects. For example, if two components of a record are
3758 independent, then two separate tasks may access these two components.
3759 This may place
3760 constraints on the representation of the object (for instance prohibiting
3761 tight packing).
3763 @node Pragma Independent_Components
3764 @unnumberedsec Pragma Independent_Components
3765 @findex Independent_Components
3766 @noindent
3767 Syntax:
3769 @smallexample @c ada
3770 pragma Independent_Components (Local_NAME);
3771 @end smallexample
3773 @noindent
3774 This pragma is standard in Ada 2012 mode (which also provides an aspect
3775 of the same name). It is also available as an implementation-defined
3776 pragma in all earlier versions. It specifies that the components of the
3777 designated object, or the components of each object of the designated
3778 type, must be
3779 independently addressable. This means that separate tasks can safely
3780 manipulate separate components in the composite object. This may place
3781 constraints on the representation of the object (for instance prohibiting
3782 tight packing).
3784 @node Pragma Initial_Condition
3785 @unnumberedsec Pragma Initial_Condition
3786 @findex Initial_Condition
3787 @noindent
3788 For the description of this pragma, see SPARK 2014 Reference Manual,
3789 section 7.1.6.
3791 @node Pragma Initialize_Scalars
3792 @unnumberedsec Pragma Initialize_Scalars
3793 @findex Initialize_Scalars
3794 @cindex debugging with Initialize_Scalars
3795 @noindent
3796 Syntax:
3798 @smallexample @c ada
3799 pragma Initialize_Scalars;
3800 @end smallexample
3802 @noindent
3803 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3804 two important differences.  First, there is no requirement for the pragma
3805 to be used uniformly in all units of a partition, in particular, it is fine
3806 to use this just for some or all of the application units of a partition,
3807 without needing to recompile the run-time library.
3809 In the case where some units are compiled with the pragma, and some without,
3810 then a declaration of a variable where the type is defined in package
3811 Standard or is locally declared will always be subject to initialization,
3812 as will any declaration of a scalar variable.  For composite variables,
3813 whether the variable is initialized may also depend on whether the package
3814 in which the type of the variable is declared is compiled with the pragma.
3816 The other important difference is that you can control the value used
3817 for initializing scalar objects.  At bind time, you can select several
3818 options for initialization. You can
3819 initialize with invalid values (similar to Normalize_Scalars, though for
3820 Initialize_Scalars it is not always possible to determine the invalid
3821 values in complex cases like signed component fields with non-standard
3822 sizes). You can also initialize with high or
3823 low values, or with a specified bit pattern.  See the @value{EDITION}
3824 User's Guide for binder options for specifying these cases.
3826 This means that you can compile a program, and then without having to
3827 recompile the program, you can run it with different values being used
3828 for initializing otherwise uninitialized values, to test if your program
3829 behavior depends on the choice.  Of course the behavior should not change,
3830 and if it does, then most likely you have an incorrect reference to an
3831 uninitialized value.
3833 It is even possible to change the value at execution time eliminating even
3834 the need to rebind with a different switch using an environment variable.
3835 See the @value{EDITION} User's Guide for details.
3837 Note that pragma @code{Initialize_Scalars} is particularly useful in
3838 conjunction with the enhanced validity checking that is now provided
3839 in GNAT, which checks for invalid values under more conditions.
3840 Using this feature (see description of the @option{-gnatV} flag in the
3841 @value{EDITION} User's Guide) in conjunction with
3842 pragma @code{Initialize_Scalars}
3843 provides a powerful new tool to assist in the detection of problems
3844 caused by uninitialized variables.
3846 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3847 effect on the generated code. This may cause your code to be
3848 substantially larger. It may also cause an increase in the amount
3849 of stack required, so it is probably a good idea to turn on stack
3850 checking (see description of stack checking in the @value{EDITION}
3851 User's Guide) when using this pragma.
3853 @node Pragma Initializes
3854 @unnumberedsec Pragma Initializes
3855 @findex Initializes
3856 @noindent
3857 For the description of this pragma, see SPARK 2014 Reference Manual,
3858 section 7.1.5.
3860 @node Pragma Inline_Always
3861 @unnumberedsec Pragma Inline_Always
3862 @findex Inline_Always
3863 @noindent
3864 Syntax:
3866 @smallexample @c ada
3867 pragma Inline_Always (NAME [, NAME]);
3868 @end smallexample
3870 @noindent
3871 Similar to pragma @code{Inline} except that inlining is not subject to
3872 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3873 happens regardless of whether these options are used.
3875 @node Pragma Inline_Generic
3876 @unnumberedsec Pragma Inline_Generic
3877 @findex Inline_Generic
3878 @noindent
3879 Syntax:
3881 @smallexample @c ada
3882 pragma Inline_Generic (GNAME @{, GNAME@});
3884 GNAME ::= generic_unit_NAME | generic_instance_NAME
3885 @end smallexample
3887 @noindent
3888 This pragma is provided for compatibility with Dec Ada 83. It has
3889 no effect in @code{GNAT} (which always inlines generics), other
3890 than to check that the given names are all names of generic units or
3891 generic instances.
3893 @node Pragma Interface
3894 @unnumberedsec Pragma Interface
3895 @findex Interface
3896 @noindent
3897 Syntax:
3899 @smallexample @c ada
3900 pragma Interface (
3901      [Convention    =>] convention_identifier,
3902      [Entity        =>] local_NAME
3903   [, [External_Name =>] static_string_expression]
3904   [, [Link_Name     =>] static_string_expression]);
3905 @end smallexample
3907 @noindent
3908 This pragma is identical in syntax and semantics to
3909 the standard Ada pragma @code{Import}.  It is provided for compatibility
3910 with Ada 83.  The definition is upwards compatible both with pragma
3911 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3912 with some extended implementations of this pragma in certain Ada 83
3913 implementations.  The only difference between pragma @code{Interface}
3914 and pragma @code{Import} is that there is special circuitry to allow
3915 both pragmas to appear for the same subprogram entity (normally it
3916 is illegal to have multiple @code{Import} pragmas. This is useful in
3917 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3918 Ada 83 compilers.
3920 @node Pragma Interface_Name
3921 @unnumberedsec Pragma Interface_Name
3922 @findex Interface_Name
3923 @noindent
3924 Syntax:
3926 @smallexample @c ada
3927 pragma Interface_Name (
3928      [Entity        =>] LOCAL_NAME
3929   [, [External_Name =>] static_string_EXPRESSION]
3930   [, [Link_Name     =>] static_string_EXPRESSION]);
3931 @end smallexample
3933 @noindent
3934 This pragma provides an alternative way of specifying the interface name
3935 for an interfaced subprogram, and is provided for compatibility with Ada
3936 83 compilers that use the pragma for this purpose.  You must provide at
3937 least one of @var{External_Name} or @var{Link_Name}.
3939 @node Pragma Interrupt_Handler
3940 @unnumberedsec Pragma Interrupt_Handler
3941 @findex Interrupt_Handler
3942 @noindent
3943 Syntax:
3945 @smallexample @c ada
3946 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3947 @end smallexample
3949 @noindent
3950 This program unit pragma is supported for parameterless protected procedures
3951 as described in Annex C of the Ada Reference Manual. On the AAMP target
3952 the pragma can also be specified for nonprotected parameterless procedures
3953 that are declared at the library level (which includes procedures
3954 declared at the top level of a library package). In the case of AAMP,
3955 when this pragma is applied to a nonprotected procedure, the instruction
3956 @code{IERET} is generated for returns from the procedure, enabling
3957 maskable interrupts, in place of the normal return instruction.
3959 @node Pragma Interrupt_State
3960 @unnumberedsec Pragma Interrupt_State
3961 @findex Interrupt_State
3962 @noindent
3963 Syntax:
3965 @smallexample @c ada
3966 pragma Interrupt_State
3967  ([Name  =>] value,
3968   [State =>] SYSTEM | RUNTIME | USER);
3969 @end smallexample
3971 @noindent
3972 Normally certain interrupts are reserved to the implementation.  Any attempt
3973 to attach an interrupt causes Program_Error to be raised, as described in
3974 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3975 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3976 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3977 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
3978 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3979 Ada exceptions, or used to implement run-time functions such as the
3980 @code{abort} statement and stack overflow checking.
3982 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3983 such uses of interrupts.  It subsumes the functionality of pragma
3984 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
3985 available on Windows or VMS.  On all other platforms than VxWorks,
3986 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3987 and may be used to mark interrupts required by the board support package
3988 as reserved.
3990 Interrupts can be in one of three states:
3991 @itemize @bullet
3992 @item System
3994 The interrupt is reserved (no Ada handler can be installed), and the
3995 Ada run-time may not install a handler. As a result you are guaranteed
3996 standard system default action if this interrupt is raised.
3998 @item Runtime
4000 The interrupt is reserved (no Ada handler can be installed). The run time
4001 is allowed to install a handler for internal control purposes, but is
4002 not required to do so.
4004 @item User
4006 The interrupt is unreserved.  The user may install a handler to provide
4007 some other action.
4008 @end itemize
4010 @noindent
4011 These states are the allowed values of the @code{State} parameter of the
4012 pragma.  The @code{Name} parameter is a value of the type
4013 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
4014 @code{Ada.Interrupts.Names}.
4016 This is a configuration pragma, and the binder will check that there
4017 are no inconsistencies between different units in a partition in how a
4018 given interrupt is specified. It may appear anywhere a pragma is legal.
4020 The effect is to move the interrupt to the specified state.
4022 By declaring interrupts to be SYSTEM, you guarantee the standard system
4023 action, such as a core dump.
4025 By declaring interrupts to be USER, you guarantee that you can install
4026 a handler.
4028 Note that certain signals on many operating systems cannot be caught and
4029 handled by applications.  In such cases, the pragma is ignored.  See the
4030 operating system documentation, or the value of the array @code{Reserved}
4031 declared in the spec of package @code{System.OS_Interface}.
4033 Overriding the default state of signals used by the Ada runtime may interfere
4034 with an application's runtime behavior in the cases of the synchronous signals,
4035 and in the case of the signal used to implement the @code{abort} statement.
4037 @node Pragma Invariant
4038 @unnumberedsec Pragma Invariant
4039 @findex Invariant
4040 @noindent
4041 Syntax:
4043 @smallexample @c ada
4044 pragma Invariant
4045   ([Entity =>]    private_type_LOCAL_NAME,
4046    [Check  =>]    EXPRESSION
4047    [,[Message =>] String_Expression]);
4048 @end smallexample
4050 @noindent
4051 This pragma provides exactly the same capabilities as the Type_Invariant aspect
4052 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
4053 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
4054 requires the use of the aspect syntax, which is not available except in 2012
4055 mode, it is not possible to use the Type_Invariant aspect in earlier versions
4056 of Ada. However the Invariant pragma may be used in any version of Ada. Also
4057 note that the aspect Invariant is a synonym in GNAT for the aspect
4058 Type_Invariant, but there is no pragma Type_Invariant.
4060 The pragma must appear within the visible part of the package specification,
4061 after the type to which its Entity argument appears. As with the Invariant
4062 aspect, the Check expression is not analyzed until the end of the visible
4063 part of the package, so it may contain forward references. The Message
4064 argument, if present, provides the exception message used if the invariant
4065 is violated. If no Message parameter is provided, a default message that
4066 identifies the line on which the pragma appears is used.
4068 It is permissible to have multiple Invariants for the same type entity, in
4069 which case they are and'ed together. It is permissible to use this pragma
4070 in Ada 2012 mode, but you cannot have both an invariant aspect and an
4071 invariant pragma for the same entity.
4073 For further details on the use of this pragma, see the Ada 2012 documentation
4074 of the Type_Invariant aspect.
4076 @node Pragma Java_Constructor
4077 @unnumberedsec Pragma Java_Constructor
4078 @findex Java_Constructor
4079 @noindent
4080 Syntax:
4082 @smallexample @c ada
4083 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
4084 @end smallexample
4086 @noindent
4087 This pragma is used to assert that the specified Ada function should be
4088 mapped to the Java constructor for some Ada tagged record type.
4090 See section 7.3.2 of the
4091 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4092 for related information.
4094 @node Pragma Java_Interface
4095 @unnumberedsec Pragma Java_Interface
4096 @findex Java_Interface
4097 @noindent
4098 Syntax:
4100 @smallexample @c ada
4101 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
4102 @end smallexample
4104 @noindent
4105 This pragma is used to assert that the specified Ada abstract tagged type
4106 is to be mapped to a Java interface name.
4108 See sections 7.1 and 7.2 of the
4109 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4110 for related information.
4112 @node Pragma Keep_Names
4113 @unnumberedsec Pragma Keep_Names
4114 @findex Keep_Names
4115 @noindent
4116 Syntax:
4118 @smallexample @c ada
4119 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4120 @end smallexample
4122 @noindent
4123 The @var{LOCAL_NAME} argument
4124 must refer to an enumeration first subtype
4125 in the current declarative part. The effect is to retain the enumeration
4126 literal names for use by @code{Image} and @code{Value} even if a global
4127 @code{Discard_Names} pragma applies. This is useful when you want to
4128 generally suppress enumeration literal names and for example you therefore
4129 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
4130 want to retain the names for specific enumeration types.
4132 @node Pragma License
4133 @unnumberedsec Pragma License
4134 @findex License
4135 @cindex License checking
4136 @noindent
4137 Syntax:
4139 @smallexample @c ada
4140 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4141 @end smallexample
4143 @noindent
4144 This pragma is provided to allow automated checking for appropriate license
4145 conditions with respect to the standard and modified GPL@.  A pragma
4146 @code{License}, which is a configuration pragma that typically appears at
4147 the start of a source file or in a separate @file{gnat.adc} file, specifies
4148 the licensing conditions of a unit as follows:
4150 @itemize @bullet
4151 @item Unrestricted
4152 This is used for a unit that can be freely used with no license restrictions.
4153 Examples of such units are public domain units, and units from the Ada
4154 Reference Manual.
4156 @item GPL
4157 This is used for a unit that is licensed under the unmodified GPL, and which
4158 therefore cannot be @code{with}'ed by a restricted unit.
4160 @item Modified_GPL
4161 This is used for a unit licensed under the GNAT modified GPL that includes
4162 a special exception paragraph that specifically permits the inclusion of
4163 the unit in programs without requiring the entire program to be released
4164 under the GPL@.
4166 @item Restricted
4167 This is used for a unit that is restricted in that it is not permitted to
4168 depend on units that are licensed under the GPL@.  Typical examples are
4169 proprietary code that is to be released under more restrictive license
4170 conditions.  Note that restricted units are permitted to @code{with} units
4171 which are licensed under the modified GPL (this is the whole point of the
4172 modified GPL).
4174 @end itemize
4176 @noindent
4177 Normally a unit with no @code{License} pragma is considered to have an
4178 unknown license, and no checking is done.  However, standard GNAT headers
4179 are recognized, and license information is derived from them as follows.
4181 A GNAT license header starts with a line containing 78 hyphens.  The following
4182 comment text is searched for the appearance of any of the following strings.
4184 If the string ``GNU General Public License'' is found, then the unit is assumed
4185 to have GPL license, unless the string ``As a special exception'' follows, in
4186 which case the license is assumed to be modified GPL@.
4188 If one of the strings
4189 ``This specification is adapted from the Ada Semantic Interface'' or
4190 ``This specification is derived from the Ada Reference Manual'' is found
4191 then the unit is assumed to be unrestricted.
4193 @noindent
4194 These default actions means that a program with a restricted license pragma
4195 will automatically get warnings if a GPL unit is inappropriately
4196 @code{with}'ed.  For example, the program:
4198 @smallexample @c ada
4199 with Sem_Ch3;
4200 with GNAT.Sockets;
4201 procedure Secret_Stuff is
4202   @dots{}
4203 end Secret_Stuff
4204 @end smallexample
4206 @noindent
4207 if compiled with pragma @code{License} (@code{Restricted}) in a
4208 @file{gnat.adc} file will generate the warning:
4210 @smallexample
4211 1.  with Sem_Ch3;
4212         |
4213    >>> license of withed unit "Sem_Ch3" is incompatible
4215 2.  with GNAT.Sockets;
4216 3.  procedure Secret_Stuff is
4217 @end smallexample
4219 @noindent
4220 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4221 compiler and is licensed under the
4222 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4223 run time, and is therefore licensed under the modified GPL@.
4225 @node Pragma Link_With
4226 @unnumberedsec Pragma Link_With
4227 @findex Link_With
4228 @noindent
4229 Syntax:
4231 @smallexample @c ada
4232 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4233 @end smallexample
4235 @noindent
4236 This pragma is provided for compatibility with certain Ada 83 compilers.
4237 It has exactly the same effect as pragma @code{Linker_Options} except
4238 that spaces occurring within one of the string expressions are treated
4239 as separators. For example, in the following case:
4241 @smallexample @c ada
4242 pragma Link_With ("-labc -ldef");
4243 @end smallexample
4245 @noindent
4246 results in passing the strings @code{-labc} and @code{-ldef} as two
4247 separate arguments to the linker. In addition pragma Link_With allows
4248 multiple arguments, with the same effect as successive pragmas.
4250 @node Pragma Linker_Alias
4251 @unnumberedsec Pragma Linker_Alias
4252 @findex Linker_Alias
4253 @noindent
4254 Syntax:
4256 @smallexample @c ada
4257 pragma Linker_Alias (
4258   [Entity =>] LOCAL_NAME,
4259   [Target =>] static_string_EXPRESSION);
4260 @end smallexample
4262 @noindent
4263 @var{LOCAL_NAME} must refer to an object that is declared at the library
4264 level. This pragma establishes the given entity as a linker alias for the
4265 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4266 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4267 @var{static_string_EXPRESSION} in the object file, that is to say no space
4268 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4269 to the same address as @var{static_string_EXPRESSION} by the linker.
4271 The actual linker name for the target must be used (e.g.@: the fully
4272 encoded name with qualification in Ada, or the mangled name in C++),
4273 or it must be declared using the C convention with @code{pragma Import}
4274 or @code{pragma Export}.
4276 Not all target machines support this pragma. On some of them it is accepted
4277 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4279 @smallexample @c ada
4280 --  Example of the use of pragma Linker_Alias
4282 package p is
4283   i : Integer := 1;
4284   pragma Export (C, i);
4286   new_name_for_i : Integer;
4287   pragma Linker_Alias (new_name_for_i, "i");
4288 end p;
4289 @end smallexample
4291 @node Pragma Linker_Constructor
4292 @unnumberedsec Pragma Linker_Constructor
4293 @findex Linker_Constructor
4294 @noindent
4295 Syntax:
4297 @smallexample @c ada
4298 pragma Linker_Constructor (procedure_LOCAL_NAME);
4299 @end smallexample
4301 @noindent
4302 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4303 is declared at the library level. A procedure to which this pragma is
4304 applied will be treated as an initialization routine by the linker.
4305 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4306 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4307 of the executable is called (or immediately after the shared library is
4308 loaded if the procedure is linked in a shared library), in particular
4309 before the Ada run-time environment is set up.
4311 Because of these specific contexts, the set of operations such a procedure
4312 can perform is very limited and the type of objects it can manipulate is
4313 essentially restricted to the elementary types. In particular, it must only
4314 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4316 This pragma is used by GNAT to implement auto-initialization of shared Stand
4317 Alone Libraries, which provides a related capability without the restrictions
4318 listed above. Where possible, the use of Stand Alone Libraries is preferable
4319 to the use of this pragma.
4321 @node Pragma Linker_Destructor
4322 @unnumberedsec Pragma Linker_Destructor
4323 @findex Linker_Destructor
4324 @noindent
4325 Syntax:
4327 @smallexample @c ada
4328 pragma Linker_Destructor (procedure_LOCAL_NAME);
4329 @end smallexample
4331 @noindent
4332 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4333 is declared at the library level. A procedure to which this pragma is
4334 applied will be treated as a finalization routine by the linker.
4335 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4336 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4337 of the executable has exited (or immediately before the shared library
4338 is unloaded if the procedure is linked in a shared library), in particular
4339 after the Ada run-time environment is shut down.
4341 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4342 because of these specific contexts.
4344 @node Pragma Linker_Section
4345 @unnumberedsec Pragma Linker_Section
4346 @findex Linker_Section
4347 @noindent
4348 Syntax:
4350 @smallexample @c ada
4351 pragma Linker_Section (
4352   [Entity  =>] LOCAL_NAME,
4353   [Section =>] static_string_EXPRESSION);
4354 @end smallexample
4356 @noindent
4357 @var{LOCAL_NAME} must refer to an object, type, or subprogram that is
4358 declared at the library level. This pragma specifies the name of the
4359 linker section for the given entity. It is equivalent to
4360 @code{__attribute__((section))} in GNU C and causes @var{LOCAL_NAME} to
4361 be placed in the @var{static_string_EXPRESSION} section of the
4362 executable (assuming the linker doesn't rename the section).
4363 GNAT also provides an implementation defined aspect of the same name.
4365 In the case of specifying this aspect for a type, the effect is to
4366 specify the corresponding for all library level objects of the type which
4367 do not have an explicit linker section set. Note that this only applies to
4368 whole objects, not to components of composite objects.
4370 In the case of a subprogram, the linker section applies to all previously
4371 declared matching overloaded subprograms in the current declarative part
4372 which do not already have a linker section assigned. The linker section
4373 aspect is useful in this case for specifying different linker sections
4374 for different elements of such an overloaded set.
4376 Note that an empty string specifies that no linker section is specified.
4377 This is not quite the same as omitting the pragma or aspect, since it
4378 can be used to specify that one element of an overloaded set of subprograms
4379 has the default linker section, or that one object of a type for which a
4380 linker section is specified should has the default linker section.
4382 The compiler normally places library-level entities in standard sections
4383 depending on the class: procedures and functions generally go in the
4384 @code{.text} section, initialized variables in the @code{.data} section
4385 and uninitialized variables in the @code{.bss} section.
4387 Other, special sections may exist on given target machines to map special
4388 hardware, for example I/O ports or flash memory. This pragma is a means to
4389 defer the final layout of the executable to the linker, thus fully working
4390 at the symbolic level with the compiler.
4392 Some file formats do not support arbitrary sections so not all target
4393 machines support this pragma. The use of this pragma may cause a program
4394 execution to be erroneous if it is used to place an entity into an
4395 inappropriate section (e.g.@: a modified variable into the @code{.text}
4396 section). See also @code{pragma Persistent_BSS}.
4398 @smallexample @c ada
4399 --  Example of the use of pragma Linker_Section
4401 package IO_Card is
4402   Port_A : Integer;
4403   pragma Volatile (Port_A);
4404   pragma Linker_Section (Port_A, ".bss.port_a");
4406   Port_B : Integer;
4407   pragma Volatile (Port_B);
4408   pragma Linker_Section (Port_B, ".bss.port_b");
4410   type Port_Type is new Integer with Linker_Section => ".bss";
4411   PA : Port_Type with Linker_Section => ".bss.PA";
4412   PB : Port_Type; --  ends up in linker section ".bss"
4414   procedure Q with Linker_Section => "Qsection";
4415 end IO_Card;
4416 @end smallexample
4418 @node Pragma Lock_Free
4419 @unnumberedsec Pragma Lock_Free
4420 @findex Lock_Free
4421 @noindent
4422 Syntax:
4423 This pragma may be specified for protected types or objects. It specifies that
4424 the implementation of protected operations must be implemented without locks.
4425 Compilation fails if the compiler cannot generate lock-free code for the
4426 operations.
4428 @node Pragma Long_Float
4429 @unnumberedsec Pragma Long_Float
4430 @cindex OpenVMS
4431 @findex Long_Float
4432 @noindent
4433 Syntax:
4435 @smallexample @c ada
4436 pragma Long_Float (FLOAT_FORMAT);
4438 FLOAT_FORMAT ::= D_Float | G_Float
4439 @end smallexample
4441 @noindent
4442 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4443 It allows control over the internal representation chosen for the predefined
4444 type @code{Long_Float} and for floating point type representations with
4445 @code{digits} specified in the range 7 through 15.
4446 For further details on this pragma, see the
4447 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
4448 this pragma, the standard runtime libraries must be recompiled.
4450 @node Pragma Loop_Invariant
4451 @unnumberedsec Pragma Loop_Invariant
4452 @findex Loop_Invariant
4453 @noindent
4454 Syntax:
4456 @smallexample @c ada
4457 pragma Loop_Invariant ( boolean_EXPRESSION );
4458 @end smallexample
4460 @noindent
4461 The effect of this pragma is similar to that of pragma @code{Assert},
4462 except that in an @code{Assertion_Policy} pragma, the identifier
4463 @code{Loop_Invariant} is used to control whether it is ignored or checked
4464 (or disabled).
4466 @code{Loop_Invariant} can only appear as one of the items in the sequence
4467 of statements of a loop body, or nested inside block statements that
4468 appear in the sequence of statements of a loop body.
4469 The intention is that it be used to
4470 represent a "loop invariant" assertion, i.e. something that is true each
4471 time through the loop, and which can be used to show that the loop is
4472 achieving its purpose.
4474 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4475 apply to the same loop should be grouped in the same sequence of
4476 statements.
4478 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4479 may be used to refer to the value of an expression on entry to the loop. This
4480 attribute can only be used within the expression of a @code{Loop_Invariant}
4481 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4483 @node Pragma Loop_Optimize
4484 @unnumberedsec Pragma Loop_Optimize
4485 @findex Loop_Optimize
4486 @noindent
4487 Syntax:
4489 @smallexample @c ada
4490 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4492 OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
4493 @end smallexample
4495 @noindent
4496 This pragma must appear immediately within a loop statement.  It allows the
4497 programmer to specify optimization hints for the enclosing loop.  The hints
4498 are not mutually exclusive and can be freely mixed, but not all combinations
4499 will yield a sensible outcome.
4501 There are five supported optimization hints for a loop:
4503 @itemize @bullet
4504 @item Ivdep
4506 The programmer asserts that there are no loop-carried dependencies
4507 which would prevent consecutive iterations of the loop from being
4508 executed simultaneously.
4510 @item No_Unroll
4512 The loop must not be unrolled.  This is a strong hint: the compiler will not
4513 unroll a loop marked with this hint.
4515 @item Unroll
4517 The loop should be unrolled.  This is a weak hint: the compiler will try to
4518 apply unrolling to this loop preferably to other optimizations, notably
4519 vectorization, but there is no guarantee that the loop will be unrolled.
4521 @item No_Vector
4523 The loop must not be vectorized.  This is a strong hint: the compiler will not
4524 vectorize a loop marked with this hint.
4526 @item Vector
4528 The loop should be vectorized.  This is a weak hint: the compiler will try to
4529 apply vectorization to this loop preferably to other optimizations, notably
4530 unrolling, but there is no guarantee that the loop will be vectorized.
4532 @end itemize
4534 These hints do not remove the need to pass the appropriate switches to the
4535 compiler in order to enable the relevant optimizations, that is to say
4536 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4537 vectorization.
4539 @node Pragma Loop_Variant
4540 @unnumberedsec Pragma Loop_Variant
4541 @findex Loop_Variant
4542 @noindent
4543 Syntax:
4545 @smallexample @c ada
4546 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4547 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4548 CHANGE_DIRECTION ::= Increases | Decreases
4549 @end smallexample
4551 @noindent
4552 @code{Loop_Variant} can only appear as one of the items in the sequence
4553 of statements of a loop body, or nested inside block statements that
4554 appear in the sequence of statements of a loop body.
4555 It allows the specification of quantities which must always
4556 decrease or increase in successive iterations of the loop. In its simplest
4557 form, just one expression is specified, whose value must increase or decrease
4558 on each iteration of the loop.
4560 In a more complex form, multiple arguments can be given which are intepreted
4561 in a nesting lexicographic manner. For example:
4563 @smallexample @c ada
4564 pragma Loop_Variant (Increases => X, Decreases => Y);
4565 @end smallexample
4567 @noindent
4568 specifies that each time through the loop either X increases, or X stays
4569 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4570 loop is making progress. It can be useful in helping to show informally
4571 or prove formally that the loop always terminates.
4573 @code{Loop_Variant} is an assertion whose effect can be controlled using
4574 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4575 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4576 to ignore the check (in which case the pragma has no effect on the program),
4577 or @code{Disable} in which case the pragma is not even checked for correct
4578 syntax.
4580 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4581 apply to the same loop should be grouped in the same sequence of
4582 statements.
4584 The @code{Loop_Entry} attribute may be used within the expressions of the
4585 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4587 @node Pragma Machine_Attribute
4588 @unnumberedsec Pragma Machine_Attribute
4589 @findex Machine_Attribute
4590 @noindent
4591 Syntax:
4593 @smallexample @c ada
4594 pragma Machine_Attribute (
4595      [Entity         =>] LOCAL_NAME,
4596      [Attribute_Name =>] static_string_EXPRESSION
4597   [, [Info           =>] static_EXPRESSION] );
4598 @end smallexample
4600 @noindent
4601 Machine-dependent attributes can be specified for types and/or
4602 declarations.  This pragma is semantically equivalent to
4603 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4604 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4605 in GNU C, where @code{@var{attribute_name}} is recognized by the
4606 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4607 specific macro.  A string literal for the optional parameter @var{info}
4608 is transformed into an identifier, which may make this pragma unusable
4609 for some attributes.  @xref{Target Attributes,, Defining target-specific
4610 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4611 Internals}, further information.
4613 @node Pragma Main
4614 @unnumberedsec Pragma Main
4615 @cindex OpenVMS
4616 @findex Main
4617 @noindent
4618 Syntax:
4620 @smallexample @c ada
4621 pragma Main
4622  (MAIN_OPTION [, MAIN_OPTION]);
4624 MAIN_OPTION ::=
4625   [Stack_Size              =>] static_integer_EXPRESSION
4626 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4627 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
4628 @end smallexample
4630 @noindent
4631 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4632 no effect in GNAT, other than being syntax checked.
4634 @node Pragma Main_Storage
4635 @unnumberedsec Pragma Main_Storage
4636 @cindex OpenVMS
4637 @findex Main_Storage
4638 @noindent
4639 Syntax:
4641 @smallexample @c ada
4642 pragma Main_Storage
4643   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4645 MAIN_STORAGE_OPTION ::=
4646   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4647 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
4648 @end smallexample
4650 @noindent
4651 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4652 no effect in GNAT, other than being syntax checked.  Note that the pragma
4653 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4655 @node Pragma No_Body
4656 @unnumberedsec Pragma No_Body
4657 @findex No_Body
4658 @noindent
4659 Syntax:
4661 @smallexample @c ada
4662 pragma No_Body;
4663 @end smallexample
4665 @noindent
4666 There are a number of cases in which a package spec does not require a body,
4667 and in fact a body is not permitted. GNAT will not permit the spec to be
4668 compiled if there is a body around. The pragma No_Body allows you to provide
4669 a body file, even in a case where no body is allowed. The body file must
4670 contain only comments and a single No_Body pragma. This is recognized by
4671 the compiler as indicating that no body is logically present.
4673 This is particularly useful during maintenance when a package is modified in
4674 such a way that a body needed before is no longer needed. The provision of a
4675 dummy body with a No_Body pragma ensures that there is no interference from
4676 earlier versions of the package body.
4678 @node Pragma No_Elaboration_Code_All
4679 @unnumberedsec Pragma No_Elaboration_Code_All
4680 @findex No_Elaboration_Code_All
4681 @noindent
4682 Syntax:
4684 @smallexample @c ada
4685 pragma No_Elaboration_Code_All [(program_unit_NAME)];
4686 @end smallexample
4688 @noindent
4689 This is a program unit pragma (there is also an equivalent aspect of the
4690 same name) that establishes the restriction @code{No_Elaboration_Code} for
4691 the current unit and any extended main source units (body and subunits.
4692 It also has has the effect of enforcing a transitive application of this
4693 aspect, so that if any unit is implicitly or explicitly WITH'ed by the
4694 current unit, it must also have the No_Elaboration_Code_All aspect set.
4696 @node Pragma No_Inline
4697 @unnumberedsec Pragma No_Inline
4698 @findex No_Inline
4699 @noindent
4700 Syntax:
4702 @smallexample @c ada
4703 pragma No_Inline (NAME @{, NAME@});
4704 @end smallexample
4706 @noindent
4707 This pragma suppresses inlining for the callable entity or the instances of
4708 the generic subprogram designated by @var{NAME}, including inlining that
4709 results from the use of pragma @code{Inline}.  This pragma is always active,
4710 in particular it is not subject to the use of option @option{-gnatn} or
4711 @option{-gnatN}.  It is illegal to specify both pragma @code{No_Inline} and
4712 pragma @code{Inline_Always} for the same @var{NAME}.
4714 @node Pragma No_Return
4715 @unnumberedsec Pragma No_Return
4716 @findex No_Return
4717 @noindent
4718 Syntax:
4720 @smallexample @c ada
4721 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4722 @end smallexample
4724 @noindent
4725 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4726 declarations in the current declarative part.  A procedure to which this
4727 pragma is applied may not contain any explicit @code{return} statements.
4728 In addition, if the procedure contains any implicit returns from falling
4729 off the end of a statement sequence, then execution of that implicit
4730 return will cause Program_Error to be raised.
4732 One use of this pragma is to identify procedures whose only purpose is to raise
4733 an exception. Another use of this pragma is to suppress incorrect warnings
4734 about missing returns in functions, where the last statement of a function
4735 statement sequence is a call to such a procedure.
4737 Note that in Ada 2005 mode, this pragma is part of the language. It is
4738 available in all earlier versions of Ada as an implementation-defined
4739 pragma.
4741 @node Pragma No_Run_Time
4742 @unnumberedsec Pragma No_Run_Time
4743 @findex No_Run_Time
4744 @noindent
4745 Syntax:
4747 @smallexample @c ada
4748 pragma No_Run_Time;
4749 @end smallexample
4751 @noindent
4752 This is an obsolete configuration pragma that historically was used to
4753 set up a runtime library with no object code. It is now used only for
4754 internal testing. The pragma has been superseded by the reconfigurable
4755 runtime capability of @code{GNAT}.
4757 @node Pragma No_Strict_Aliasing
4758 @unnumberedsec Pragma No_Strict_Aliasing
4759 @findex No_Strict_Aliasing
4760 @noindent
4761 Syntax:
4763 @smallexample @c ada
4764 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4765 @end smallexample
4767 @noindent
4768 @var{type_LOCAL_NAME} must refer to an access type
4769 declaration in the current declarative part.  The effect is to inhibit
4770 strict aliasing optimization for the given type.  The form with no
4771 arguments is a configuration pragma which applies to all access types
4772 declared in units to which the pragma applies. For a detailed
4773 description of the strict aliasing optimization, and the situations
4774 in which it must be suppressed, see @ref{Optimization and Strict
4775 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4777 This pragma currently has no effects on access to unconstrained array types.
4779 @node Pragma Normalize_Scalars
4780 @unnumberedsec Pragma Normalize_Scalars
4781 @findex Normalize_Scalars
4782 @noindent
4783 Syntax:
4785 @smallexample @c ada
4786 pragma Normalize_Scalars;
4787 @end smallexample
4789 @noindent
4790 This is a language defined pragma which is fully implemented in GNAT@.  The
4791 effect is to cause all scalar objects that are not otherwise initialized
4792 to be initialized.  The initial values are implementation dependent and
4793 are as follows:
4795 @table @code
4796 @item Standard.Character
4797 @noindent
4798 Objects whose root type is Standard.Character are initialized to
4799 Character'Last unless the subtype range excludes NUL (in which case
4800 NUL is used). This choice will always generate an invalid value if
4801 one exists.
4803 @item Standard.Wide_Character
4804 @noindent
4805 Objects whose root type is Standard.Wide_Character are initialized to
4806 Wide_Character'Last unless the subtype range excludes NUL (in which case
4807 NUL is used). This choice will always generate an invalid value if
4808 one exists.
4810 @item Standard.Wide_Wide_Character
4811 @noindent
4812 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4813 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4814 which case NUL is used). This choice will always generate an invalid value if
4815 one exists.
4817 @item Integer types
4818 @noindent
4819 Objects of an integer type are treated differently depending on whether
4820 negative values are present in the subtype. If no negative values are
4821 present, then all one bits is used as the initial value except in the
4822 special case where zero is excluded from the subtype, in which case
4823 all zero bits are used. This choice will always generate an invalid
4824 value if one exists.
4826 For subtypes with negative values present, the largest negative number
4827 is used, except in the unusual case where this largest negative number
4828 is in the subtype, and the largest positive number is not, in which case
4829 the largest positive value is used. This choice will always generate
4830 an invalid value if one exists.
4832 @item Floating-Point Types
4833 Objects of all floating-point types are initialized to all 1-bits. For
4834 standard IEEE format, this corresponds to a NaN (not a number) which is
4835 indeed an invalid value.
4837 @item Fixed-Point Types
4838 Objects of all fixed-point types are treated as described above for integers,
4839 with the rules applying to the underlying integer value used to represent
4840 the fixed-point value.
4842 @item Modular types
4843 Objects of a modular type are initialized to all one bits, except in
4844 the special case where zero is excluded from the subtype, in which
4845 case all zero bits are used. This choice will always generate an
4846 invalid value if one exists.
4848 @item Enumeration types
4849 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4850 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4851 whose Pos value is zero, in which case a code of zero is used. This choice
4852 will always generate an invalid value if one exists.
4854 @end table
4856 @node Pragma Obsolescent
4857 @unnumberedsec Pragma Obsolescent
4858 @findex Obsolescent
4859 @noindent
4860 Syntax:
4862 @smallexample @c ada
4863 pragma Obsolescent;
4865 pragma Obsolescent (
4866   [Message =>] static_string_EXPRESSION
4867 [,[Version =>] Ada_05]]);
4869 pragma Obsolescent (
4870   [Entity  =>] NAME
4871 [,[Message =>] static_string_EXPRESSION
4872 [,[Version =>] Ada_05]] );
4873 @end smallexample
4875 @noindent
4876 This pragma can occur immediately following a declaration of an entity,
4877 including the case of a record component. If no Entity argument is present,
4878 then this declaration is the one to which the pragma applies. If an Entity
4879 parameter is present, it must either match the name of the entity in this
4880 declaration, or alternatively, the pragma can immediately follow an enumeration
4881 type declaration, where the Entity argument names one of the enumeration
4882 literals.
4884 This pragma is used to indicate that the named entity
4885 is considered obsolescent and should not be used. Typically this is
4886 used when an API must be modified by eventually removing or modifying
4887 existing subprograms or other entities. The pragma can be used at an
4888 intermediate stage when the entity is still present, but will be
4889 removed later.
4891 The effect of this pragma is to output a warning message on a reference to
4892 an entity thus marked that the subprogram is obsolescent if the appropriate
4893 warning option in the compiler is activated. If the Message parameter is
4894 present, then a second warning message is given containing this text. In
4895 addition, a reference to the entity is considered to be a violation of pragma
4896 Restrictions (No_Obsolescent_Features).
4898 This pragma can also be used as a program unit pragma for a package,
4899 in which case the entity name is the name of the package, and the
4900 pragma indicates that the entire package is considered
4901 obsolescent. In this case a client @code{with}'ing such a package
4902 violates the restriction, and the @code{with} statement is
4903 flagged with warnings if the warning option is set.
4905 If the Version parameter is present (which must be exactly
4906 the identifier Ada_05, no other argument is allowed), then the
4907 indication of obsolescence applies only when compiling in Ada 2005
4908 mode. This is primarily intended for dealing with the situations
4909 in the predefined library where subprograms or packages
4910 have become defined as obsolescent in Ada 2005
4911 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4913 The following examples show typical uses of this pragma:
4915 @smallexample @c ada
4916 package p is
4917    pragma Obsolescent (p, Message => "use pp instead of p");
4918 end p;
4920 package q is
4921    procedure q2;
4922    pragma Obsolescent ("use q2new instead");
4924    type R is new integer;
4925    pragma Obsolescent
4926      (Entity  => R,
4927       Message => "use RR in Ada 2005",
4928       Version => Ada_05);
4930    type M is record
4931       F1 : Integer;
4932       F2 : Integer;
4933       pragma Obsolescent;
4934       F3 : Integer;
4935    end record;
4937    type E is (a, bc, 'd', quack);
4938    pragma Obsolescent (Entity => bc)
4939    pragma Obsolescent (Entity => 'd')
4941    function "+"
4942      (a, b : character) return character;
4943    pragma Obsolescent (Entity => "+");
4944 end;
4945 @end smallexample
4947 @noindent
4948 Note that, as for all pragmas, if you use a pragma argument identifier,
4949 then all subsequent parameters must also use a pragma argument identifier.
4950 So if you specify "Entity =>" for the Entity argument, and a Message
4951 argument is present, it must be preceded by "Message =>".
4953 @node Pragma Optimize_Alignment
4954 @unnumberedsec Pragma Optimize_Alignment
4955 @findex Optimize_Alignment
4956 @cindex Alignment, default settings
4957 @noindent
4958 Syntax:
4960 @smallexample @c ada
4961 pragma Optimize_Alignment (TIME | SPACE | OFF);
4962 @end smallexample
4964 @noindent
4965 This is a configuration pragma which affects the choice of default alignments
4966 for types and objects where no alignment is explicitly specified. There is a
4967 time/space trade-off in the selection of these values. Large alignments result
4968 in more efficient code, at the expense of larger data space, since sizes have
4969 to be increased to match these alignments. Smaller alignments save space, but
4970 the access code is slower. The normal choice of default alignments for types
4971 and individual alignment promotions for objects (which is what you get if you
4972 do not use this pragma, or if you use an argument of OFF), tries to balance
4973 these two requirements.
4975 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4976 First any packed record is given an alignment of 1. Second, if a size is given
4977 for the type, then the alignment is chosen to avoid increasing this size. For
4978 example, consider:
4980 @smallexample @c ada
4981    type R is record
4982       X : Integer;
4983       Y : Character;
4984    end record;
4986    for R'Size use 5*8;
4987 @end smallexample
4989 @noindent
4990 In the default mode, this type gets an alignment of 4, so that access to the
4991 Integer field X are efficient. But this means that objects of the type end up
4992 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4993 allowed to be bigger than the size of the type, but it can waste space if for
4994 example fields of type R appear in an enclosing record. If the above type is
4995 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4997 However, there is one case in which SPACE is ignored. If a variable length
4998 record (that is a discriminated record with a component which is an array
4999 whose length depends on a discriminant), has a pragma Pack, then it is not
5000 in general possible to set the alignment of such a record to one, so the
5001 pragma is ignored in this case (with a warning).
5003 Specifying SPACE also disables alignment promotions for standalone objects,
5004 which occur when the compiler increases the alignment of a specific object
5005 without changing the alignment of its type.
5007 Specifying TIME causes larger default alignments to be chosen in the case of
5008 small types with sizes that are not a power of 2. For example, consider:
5010 @smallexample @c ada
5011    type R is record
5012       A : Character;
5013       B : Character;
5014       C : Boolean;
5015    end record;
5017    pragma Pack (R);
5018    for R'Size use 17;
5019 @end smallexample
5021 @noindent
5022 The default alignment for this record is normally 1, but if this type is
5023 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
5024 to 4, which wastes space for objects of the type, since they are now 4 bytes
5025 long, but results in more efficient access when the whole record is referenced.
5027 As noted above, this is a configuration pragma, and there is a requirement
5028 that all units in a partition be compiled with a consistent setting of the
5029 optimization setting. This would normally be achieved by use of a configuration
5030 pragma file containing the appropriate setting. The exception to this rule is
5031 that units with an explicit configuration pragma in the same file as the source
5032 unit are excluded from the consistency check, as are all predefined units. The
5033 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
5034 pragma appears at the start of the file.
5036 @node Pragma Ordered
5037 @unnumberedsec Pragma Ordered
5038 @findex Ordered
5039 @findex pragma @code{Ordered}
5040 @noindent
5041 Syntax:
5043 @smallexample @c ada
5044 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
5045 @end smallexample
5047 @noindent
5048 Most enumeration types are from a conceptual point of view unordered.
5049 For example, consider:
5051 @smallexample @c ada
5052 type Color is (Red, Blue, Green, Yellow);
5053 @end smallexample
5055 @noindent
5056 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
5057 but really these relations make no sense; the enumeration type merely
5058 specifies a set of possible colors, and the order is unimportant.
5060 For unordered enumeration types, it is generally a good idea if
5061 clients avoid comparisons (other than equality or inequality) and
5062 explicit ranges. (A @emph{client} is a unit where the type is referenced,
5063 other than the unit where the type is declared, its body, and its subunits.)
5064 For example, if code buried in some client says:
5066 @smallexample @c ada
5067 if Current_Color < Yellow then ...
5068 if Current_Color in Blue .. Green then ...
5069 @end smallexample
5071 @noindent
5072 then the client code is relying on the order, which is undesirable.
5073 It makes the code hard to read and creates maintenance difficulties if
5074 entries have to be added to the enumeration type. Instead,
5075 the code in the client should list the possibilities, or an
5076 appropriate subtype should be declared in the unit that declares
5077 the original enumeration type. E.g., the following subtype could
5078 be declared along with the type @code{Color}:
5080 @smallexample @c ada
5081 subtype RBG is Color range Red .. Green;
5082 @end smallexample
5084 @noindent
5085 and then the client could write:
5087 @smallexample @c ada
5088 if Current_Color in RBG then ...
5089 if Current_Color = Blue or Current_Color = Green then ...
5090 @end smallexample
5092 @noindent
5093 However, some enumeration types are legitimately ordered from a conceptual
5094 point of view. For example, if you declare:
5096 @smallexample @c ada
5097 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
5098 @end smallexample
5100 @noindent
5101 then the ordering imposed by the language is reasonable, and
5102 clients can depend on it, writing for example:
5104 @smallexample @c ada
5105 if D in Mon .. Fri then ...
5106 if D < Wed then ...
5107 @end smallexample
5109 @noindent
5110 The pragma @option{Ordered} is provided to mark enumeration types that
5111 are conceptually ordered, alerting the reader that clients may depend
5112 on the ordering. GNAT provides a pragma to mark enumerations as ordered
5113 rather than one to mark them as unordered, since in our experience,
5114 the great majority of enumeration types are conceptually unordered.
5116 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
5117 and @code{Wide_Wide_Character}
5118 are considered to be ordered types, so each is declared with a
5119 pragma @code{Ordered} in package @code{Standard}.
5121 Normally pragma @code{Ordered} serves only as documentation and a guide for
5122 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
5123 requests warnings for inappropriate uses (comparisons and explicit
5124 subranges) for unordered types. If this switch is used, then any
5125 enumeration type not marked with pragma @code{Ordered} will be considered
5126 as unordered, and will generate warnings for inappropriate uses.
5128 For additional information please refer to the description of the
5129 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
5131 @node Pragma Overflow_Mode
5132 @unnumberedsec Pragma Overflow_Mode
5133 @findex Overflow checks
5134 @findex Overflow mode
5135 @findex pragma @code{Overflow_Mode}
5136 @noindent
5137 Syntax:
5139 @smallexample @c ada
5140 pragma Overflow_Mode
5141  (  [General    =>] MODE
5142   [,[Assertions =>] MODE]);
5144 MODE ::= STRICT | MINIMIZED | ELIMINATED
5145 @end smallexample
5147 @noindent
5148 This pragma sets the current overflow mode to the given setting. For details
5149 of the meaning of these modes, please refer to the
5150 ``Overflow Check Handling in GNAT'' appendix in the
5151 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
5152 the given mode applies to all expressions. If both parameters are present,
5153 the @code{General} mode applies to expressions outside assertions, and
5154 the @code{Eliminated} mode applies to expressions within assertions.
5156 The case of the @code{MODE} parameter is ignored,
5157 so @code{MINIMIZED}, @code{Minimized} and
5158 @code{minimized} all have the same effect.
5160 The @code{Overflow_Mode} pragma has the same scoping and placement
5161 rules as pragma @code{Suppress}, so it can occur either as a
5162 configuration pragma, specifying a default for the whole
5163 program, or in a declarative scope, where it applies to the
5164 remaining declarations and statements in that scope.
5166 The pragma @code{Suppress (Overflow_Check)} suppresses
5167 overflow checking, but does not affect the overflow mode.
5169 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
5170 overflow checking, but does not affect the overflow mode.
5172 @node Pragma Overriding_Renamings
5173 @unnumberedsec Pragma Overriding_Renamings
5174 @findex Overriding_Renamings
5175 @cindex Rational profile
5176 @cindex Rational compatibility
5177 @noindent
5178 Syntax:
5180 @smallexample @c ada
5181 pragma Overriding_Renamings;
5182 @end smallexample
5184 @noindent
5185 This is a GNAT configuration pragma to simplify porting
5186 legacy code accepted by the Rational
5187 Ada compiler. In the presence of this pragma, a renaming declaration that
5188 renames an inherited operation declared in the same scope is legal if selected
5189 notation is used as in:
5191 @smallexample @c ada
5192 pragma Overriding_Renamings;
5194 package R is
5195   function F (..);
5196   ...
5197   function F (..) renames R.F;
5198 end R;
5199 @end smallexample
5201 even though
5202 RM 8.3 (15) stipulates that an overridden operation is not visible within the
5203 declaration of the overriding operation.
5205 @node Pragma Partition_Elaboration_Policy
5206 @unnumberedsec Pragma Partition_Elaboration_Policy
5207 @findex Partition_Elaboration_Policy
5208 @noindent
5209 Syntax:
5211 @smallexample @c ada
5212 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
5214 POLICY_IDENTIFIER ::= Concurrent | Sequential
5215 @end smallexample
5217 @noindent
5218 This pragma is standard in Ada 2005, but is available in all earlier
5219 versions of Ada as an implementation-defined pragma.
5220 See Ada 2012 Reference Manual for details.
5222 @node Pragma Part_Of
5223 @unnumberedsec Pragma Part_Of
5224 @findex Part_Of
5225 @noindent
5226 For the description of this pragma, see SPARK 2014 Reference Manual,
5227 section 7.2.6.
5229 @node Pragma Passive
5230 @unnumberedsec Pragma Passive
5231 @findex Passive
5232 @noindent
5233 Syntax:
5235 @smallexample @c ada
5236 pragma Passive [(Semaphore | No)];
5237 @end smallexample
5239 @noindent
5240 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
5241 compatibility with DEC Ada 83 implementations, where it is used within a
5242 task definition to request that a task be made passive.  If the argument
5243 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
5244 treats the pragma as an assertion that the containing task is passive
5245 and that optimization of context switch with this task is permitted and
5246 desired.  If the argument @code{No} is present, the task must not be
5247 optimized.  GNAT does not attempt to optimize any tasks in this manner
5248 (since protected objects are available in place of passive tasks).
5250 For more information on the subject of passive tasks, see the section
5251 ``Passive Task Optimization'' in the GNAT Users Guide.
5253 @node Pragma Persistent_BSS
5254 @unnumberedsec Pragma Persistent_BSS
5255 @findex Persistent_BSS
5256 @noindent
5257 Syntax:
5259 @smallexample @c ada
5260 pragma Persistent_BSS [(LOCAL_NAME)]
5261 @end smallexample
5263 @noindent
5264 This pragma allows selected objects to be placed in the @code{.persistent_bss}
5265 section. On some targets the linker and loader provide for special
5266 treatment of this section, allowing a program to be reloaded without
5267 affecting the contents of this data (hence the name persistent).
5269 There are two forms of usage. If an argument is given, it must be the
5270 local name of a library level object, with no explicit initialization
5271 and whose type is potentially persistent. If no argument is given, then
5272 the pragma is a configuration pragma, and applies to all library level
5273 objects with no explicit initialization of potentially persistent types.
5275 A potentially persistent type is a scalar type, or an untagged,
5276 non-discriminated record, all of whose components have no explicit
5277 initialization and are themselves of a potentially persistent type,
5278 or an array, all of whose constraints are static, and whose component
5279 type is potentially persistent.
5281 If this pragma is used on a target where this feature is not supported,
5282 then the pragma will be ignored. See also @code{pragma Linker_Section}.
5284 @node Pragma Polling
5285 @unnumberedsec Pragma Polling
5286 @findex Polling
5287 @noindent
5288 Syntax:
5290 @smallexample @c ada
5291 pragma Polling (ON | OFF);
5292 @end smallexample
5294 @noindent
5295 This pragma controls the generation of polling code.  This is normally off.
5296 If @code{pragma Polling (ON)} is used then periodic calls are generated to
5297 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
5298 runtime library, and can be found in file @file{a-excpol.adb}.
5300 Pragma @code{Polling} can appear as a configuration pragma (for example it
5301 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
5302 can be used in the statement or declaration sequence to control polling
5303 more locally.
5305 A call to the polling routine is generated at the start of every loop and
5306 at the start of every subprogram call.  This guarantees that the @code{Poll}
5307 routine is called frequently, and places an upper bound (determined by
5308 the complexity of the code) on the period between two @code{Poll} calls.
5310 The primary purpose of the polling interface is to enable asynchronous
5311 aborts on targets that cannot otherwise support it (for example Windows
5312 NT), but it may be used for any other purpose requiring periodic polling.
5313 The standard version is null, and can be replaced by a user program.  This
5314 will require re-compilation of the @code{Ada.Exceptions} package that can
5315 be found in files @file{a-except.ads} and @file{a-except.adb}.
5317 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
5318 distribution) is used to enable the asynchronous abort capability on
5319 targets that do not normally support the capability.  The version of
5320 @code{Poll} in this file makes a call to the appropriate runtime routine
5321 to test for an abort condition.
5323 Note that polling can also be enabled by use of the @option{-gnatP} switch.
5324 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
5325 details.
5327 @node Pragma Post
5328 @unnumberedsec Pragma Post
5329 @cindex Post
5330 @cindex Checks, postconditions
5331 @findex Postconditions
5332 @noindent
5333 Syntax:
5335 @smallexample @c ada
5336 pragma Post (Boolean_Expression);
5337 @end smallexample
5339 @noindent
5340 The @code{Post} pragma is intended to be an exact replacement for
5341 the language-defined
5342 @code{Post} aspect, and shares its restrictions and semantics.
5343 It must appear either immediately following the corresponding
5344 subprogram declaration (only other pragmas may intervene), or
5345 if there is no separate subprogram declaration, then it can
5346 appear at the start of the declarations in a subprogram body
5347 (preceded only by other pragmas).
5349 @node Pragma Postcondition
5350 @unnumberedsec Pragma Postcondition
5351 @cindex Postcondition
5352 @cindex Checks, postconditions
5353 @findex Postconditions
5354 @noindent
5355 Syntax:
5357 @smallexample @c ada
5358 pragma Postcondition (
5359    [Check   =>] Boolean_Expression
5360  [,[Message =>] String_Expression]);
5361 @end smallexample
5363 @noindent
5364 The @code{Postcondition} pragma allows specification of automatic
5365 postcondition checks for subprograms. These checks are similar to
5366 assertions, but are automatically inserted just prior to the return
5367 statements of the subprogram with which they are associated (including
5368 implicit returns at the end of procedure bodies and associated
5369 exception handlers).
5371 In addition, the boolean expression which is the condition which
5372 must be true may contain references to function'Result in the case
5373 of a function to refer to the returned value.
5375 @code{Postcondition} pragmas may appear either immediately following the
5376 (separate) declaration of a subprogram, or at the start of the
5377 declarations of a subprogram body. Only other pragmas may intervene
5378 (that is appear between the subprogram declaration and its
5379 postconditions, or appear before the postcondition in the
5380 declaration sequence in a subprogram body). In the case of a
5381 postcondition appearing after a subprogram declaration, the
5382 formal arguments of the subprogram are visible, and can be
5383 referenced in the postcondition expressions.
5385 The postconditions are collected and automatically tested just
5386 before any return (implicit or explicit) in the subprogram body.
5387 A postcondition is only recognized if postconditions are active
5388 at the time the pragma is encountered. The compiler switch @option{gnata}
5389 turns on all postconditions by default, and pragma @code{Check_Policy}
5390 with an identifier of @code{Postcondition} can also be used to
5391 control whether postconditions are active.
5393 The general approach is that postconditions are placed in the spec
5394 if they represent functional aspects which make sense to the client.
5395 For example we might have:
5397 @smallexample @c ada
5398    function Direction return Integer;
5399    pragma Postcondition
5400     (Direction'Result = +1
5401        or else
5402      Direction'Result = -1);
5403 @end smallexample
5405 @noindent
5406 which serves to document that the result must be +1 or -1, and
5407 will test that this is the case at run time if postcondition
5408 checking is active.
5410 Postconditions within the subprogram body can be used to
5411 check that some internal aspect of the implementation,
5412 not visible to the client, is operating as expected.
5413 For instance if a square root routine keeps an internal
5414 counter of the number of times it is called, then we
5415 might have the following postcondition:
5417 @smallexample @c ada
5418    Sqrt_Calls : Natural := 0;
5420    function Sqrt (Arg : Float) return Float is
5421      pragma Postcondition
5422        (Sqrt_Calls = Sqrt_Calls'Old + 1);
5423      ...
5424    end Sqrt
5425 @end smallexample
5427 @noindent
5428 As this example, shows, the use of the @code{Old} attribute
5429 is often useful in postconditions to refer to the state on
5430 entry to the subprogram.
5432 Note that postconditions are only checked on normal returns
5433 from the subprogram. If an abnormal return results from
5434 raising an exception, then the postconditions are not checked.
5436 If a postcondition fails, then the exception
5437 @code{System.Assertions.Assert_Failure} is raised. If
5438 a message argument was supplied, then the given string
5439 will be used as the exception message. If no message
5440 argument was supplied, then the default message has
5441 the form "Postcondition failed at file:line". The
5442 exception is raised in the context of the subprogram
5443 body, so it is possible to catch postcondition failures
5444 within the subprogram body itself.
5446 Within a package spec, normal visibility rules
5447 in Ada would prevent forward references within a
5448 postcondition pragma to functions defined later in
5449 the same package. This would introduce undesirable
5450 ordering constraints. To avoid this problem, all
5451 postcondition pragmas are analyzed at the end of
5452 the package spec, allowing forward references.
5454 The following example shows that this even allows
5455 mutually recursive postconditions as in:
5457 @smallexample @c ada
5458 package Parity_Functions is
5459    function Odd  (X : Natural) return Boolean;
5460    pragma Postcondition
5461      (Odd'Result =
5462         (x = 1
5463           or else
5464         (x /= 0 and then Even (X - 1))));
5466    function Even (X : Natural) return Boolean;
5467    pragma Postcondition
5468      (Even'Result =
5469         (x = 0
5470           or else
5471         (x /= 1 and then Odd (X - 1))));
5473 end Parity_Functions;
5474 @end smallexample
5476 @noindent
5477 There are no restrictions on the complexity or form of
5478 conditions used within @code{Postcondition} pragmas.
5479 The following example shows that it is even possible
5480 to verify performance behavior.
5482 @smallexample @c ada
5483 package Sort is
5485    Performance : constant Float;
5486    --  Performance constant set by implementation
5487    --  to match target architecture behavior.
5489    procedure Treesort (Arg : String);
5490    --  Sorts characters of argument using N*logN sort
5491    pragma Postcondition
5492      (Float (Clock - Clock'Old) <=
5493         Float (Arg'Length) *
5494         log (Float (Arg'Length)) *
5495         Performance);
5496 end Sort;
5497 @end smallexample
5499 @noindent
5500 Note: postcondition pragmas associated with subprograms that are
5501 marked as Inline_Always, or those marked as Inline with front-end
5502 inlining (-gnatN option set) are accepted and legality-checked
5503 by the compiler, but are ignored at run-time even if postcondition
5504 checking is enabled.
5506 Note that pragma @code{Postcondition} differs from the language-defined
5507 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
5508 multiple occurrences, allowing occurences in the body even if there
5509 is a separate spec, and allowing a second string parameter, and the
5510 use of the pragma identifier @code{Check}. Historically, pragma
5511 @code{Postcondition} was implemented prior to the development of
5512 Ada 2012, and has been retained in its original form for
5513 compatibility purposes.
5515 @node Pragma Post_Class
5516 @unnumberedsec Pragma Post_Class
5517 @cindex Post
5518 @cindex Checks, postconditions
5519 @findex Postconditions
5520 @noindent
5521 Syntax:
5523 @smallexample @c ada
5524 pragma Post_Class (Boolean_Expression);
5525 @end smallexample
5527 @noindent
5528 The @code{Post_Class} pragma is intended to be an exact replacement for
5529 the language-defined
5530 @code{Post'Class} aspect, and shares its restrictions and semantics.
5531 It must appear either immediately following the corresponding
5532 subprogram declaration (only other pragmas may intervene), or
5533 if there is no separate subprogram declaration, then it can
5534 appear at the start of the declarations in a subprogram body
5535 (preceded only by other pragmas).
5537 Note: This pragma is called @code{Post_Class} rather than
5538 @code{Post'Class} because the latter would not be strictly
5539 conforming to the allowed syntax for pragmas. The motivation
5540 for provinding pragmas equivalent to the aspects is to allow a program
5541 to be written using the pragmas, and then compiled if necessary
5542 using an Ada compiler that does not recognize the pragmas or
5543 aspects, but is prepared to ignore the pragmas. The assertion
5544 policy that controls this pragma is @code{Post'Class}, not
5545 @code{Post_Class}.
5547 @node Pragma Pre
5548 @unnumberedsec Pragma Pre
5549 @cindex Pre
5550 @cindex Checks, preconditions
5551 @findex Preconditions
5552 @noindent
5553 Syntax:
5555 @smallexample @c ada
5556 pragma Pre (Boolean_Expression);
5557 @end smallexample
5559 @noindent
5560 The @code{Pre} pragma is intended to be an exact replacement for
5561 the language-defined
5562 @code{Pre} aspect, and shares its restrictions and semantics.
5563 It must appear either immediately following the corresponding
5564 subprogram declaration (only other pragmas may intervene), or
5565 if there is no separate subprogram declaration, then it can
5566 appear at the start of the declarations in a subprogram body
5567 (preceded only by other pragmas).
5569 @node Pragma Precondition
5570 @unnumberedsec Pragma Precondition
5571 @cindex Preconditions
5572 @cindex Checks, preconditions
5573 @findex Preconditions
5574 @noindent
5575 Syntax:
5577 @smallexample @c ada
5578 pragma Precondition (
5579    [Check   =>] Boolean_Expression
5580  [,[Message =>] String_Expression]);
5581 @end smallexample
5583 @noindent
5584 The @code{Precondition} pragma is similar to @code{Postcondition}
5585 except that the corresponding checks take place immediately upon
5586 entry to the subprogram, and if a precondition fails, the exception
5587 is raised in the context of the caller, and the attribute 'Result
5588 cannot be used within the precondition expression.
5590 Otherwise, the placement and visibility rules are identical to those
5591 described for postconditions. The following is an example of use
5592 within a package spec:
5594 @smallexample @c ada
5595 package Math_Functions is
5596    ...
5597    function Sqrt (Arg : Float) return Float;
5598    pragma Precondition (Arg >= 0.0)
5599    ...
5600 end Math_Functions;
5601 @end smallexample
5603 @noindent
5604 @code{Precondition} pragmas may appear either immediately following the
5605 (separate) declaration of a subprogram, or at the start of the
5606 declarations of a subprogram body. Only other pragmas may intervene
5607 (that is appear between the subprogram declaration and its
5608 postconditions, or appear before the postcondition in the
5609 declaration sequence in a subprogram body).
5611 Note: precondition pragmas associated with subprograms that are
5612 marked as Inline_Always, or those marked as Inline with front-end
5613 inlining (-gnatN option set) are accepted and legality-checked
5614 by the compiler, but are ignored at run-time even if precondition
5615 checking is enabled.
5617 Note that pragma @code{Precondition} differs from the language-defined
5618 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
5619 multiple occurrences, allowing occurences in the body even if there
5620 is a separate spec, and allowing a second string parameter, and the
5621 use of the pragma identifier @code{Check}. Historically, pragma
5622 @code{Precondition} was implemented prior to the development of
5623 Ada 2012, and has been retained in its original form for
5624 compatibility purposes.
5626 @node Pragma Predicate
5627 @unnumberedsec Pragma Predicate
5628 @findex Predicate
5629 @findex Predicate pragma
5630 @noindent
5631 Syntax:
5633 @smallexample @c ada
5634 pragma Predicate
5635   ([Entity =>] type_LOCAL_NAME,
5636    [Check  =>] EXPRESSION);
5637 @end smallexample
5639 @noindent
5640 This pragma (available in all versions of Ada in GNAT) encompasses both
5641 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
5642 Ada 2012. A predicate is regarded as static if it has an allowed form
5643 for @code{Static_Predicate} and is otherwise treated as a
5644 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
5645 pragma behave exactly as described in the Ada 2012 reference manual.
5646 For example, if we have
5648 @smallexample @c ada
5649 type R is range 1 .. 10;
5650 subtype S is R;
5651 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5652 subtype Q is R
5653 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5654 @end smallexample
5656 @noindent
5657 the effect is identical to the following Ada 2012 code:
5659 @smallexample @c ada
5660 type R is range 1 .. 10;
5661 subtype S is R with
5662   Static_Predicate => S not in 4 .. 6;
5663 subtype Q is R with
5664   Dynamic_Predicate => F(Q) or G(Q);
5665 @end smallexample
5667 Note that there is are no pragmas @code{Dynamic_Predicate}
5668 or @code{Static_Predicate}. That is
5669 because these pragmas would affect legality and semantics of
5670 the program and thus do not have a neutral effect if ignored.
5671 The motivation behind providing pragmas equivalent to
5672 corresponding aspects is to allow a program to be written
5673 using the pragmas, and then compiled with a compiler that
5674 will ignore the pragmas. That doesn't work in the case of
5675 static and dynamic predicates, since if the corresponding
5676 pragmas are ignored, then the behavior of the program is
5677 fundamentally changed (for example a membership test
5678 @code{A in B} would not take into account a predicate
5679 defined for subtype B). When following this approach, the
5680 use of predicates should be avoided.
5682 @node Pragma Preelaborable_Initialization
5683 @unnumberedsec Pragma Preelaborable_Initialization
5684 @findex Preelaborable_Initialization
5685 @noindent
5686 Syntax:
5688 @smallexample @c ada
5689 pragma Preelaborable_Initialization (DIRECT_NAME);
5690 @end smallexample
5692 @noindent
5693 This pragma is standard in Ada 2005, but is available in all earlier
5694 versions of Ada as an implementation-defined pragma.
5695 See Ada 2012 Reference Manual for details.
5697 @node Pragma Prefix_Exception_Messages
5698 @unnumberedsec Pragma Prefix_Exception_Messages
5699 @cindex Prefix_Exception_Messages
5700 @cindex exception
5701 @cindex Exception_Message
5702 @findex Exceptions
5703 @noindent
5704 Syntax:
5706 @smallexample @c ada
5707 pragma Prefix_Exception_Messages;
5708 @end smallexample
5710 @noindent
5711 This is an implementation-defined configuration pragma that affects the
5712 behavior of raise statements with a message given as a static string
5713 constant (typically a string literal). In such cases, the string will
5714 be automatically prefixed by the name of the enclosing entity (giving
5715 the package and subprogram containing the raise statement). This helps
5716 to identify where messages are coming from, and this mode is automatic
5717 for the run-time library.
5719 The pragma has no effect if the message is computed with an expression other
5720 than a static string constant, since the assumption in this case is that
5721 the program computes exactly the string it wants. If you still want the
5722 prefixing in this case, you can always call
5723 @code{GNAT.Source_Info.Enclosing_Entity} and prepend the string manually.
5725 @node Pragma Pre_Class
5726 @unnumberedsec Pragma Pre_Class
5727 @cindex Pre_Class
5728 @cindex Checks, preconditions
5729 @findex Preconditions
5730 @noindent
5731 Syntax:
5733 @smallexample @c ada
5734 pragma Pre_Class (Boolean_Expression);
5735 @end smallexample
5737 @noindent
5738 The @code{Pre_Class} pragma is intended to be an exact replacement for
5739 the language-defined
5740 @code{Pre'Class} aspect, and shares its restrictions and semantics.
5741 It must appear either immediately following the corresponding
5742 subprogram declaration (only other pragmas may intervene), or
5743 if there is no separate subprogram declaration, then it can
5744 appear at the start of the declarations in a subprogram body
5745 (preceded only by other pragmas).
5747 Note: This pragma is called @code{Pre_Class} rather than
5748 @code{Pre'Class} because the latter would not be strictly
5749 conforming to the allowed syntax for pragmas. The motivation
5750 for providing pragmas equivalent to the aspects is to allow a program
5751 to be written using the pragmas, and then compiled if necessary
5752 using an Ada compiler that does not recognize the pragmas or
5753 aspects, but is prepared to ignore the pragmas. The assertion
5754 policy that controls this pragma is @code{Pre'Class}, not
5755 @code{Pre_Class}.
5757 @node Pragma Priority_Specific_Dispatching
5758 @unnumberedsec Pragma Priority_Specific_Dispatching
5759 @findex Priority_Specific_Dispatching
5760 @noindent
5761 Syntax:
5763 @smallexample @c ada
5764 pragma Priority_Specific_Dispatching (
5765    POLICY_IDENTIFIER,
5766    first_priority_EXPRESSION,
5767    last_priority_EXPRESSION)
5769 POLICY_IDENTIFIER ::=
5770    EDF_Across_Priorities            |
5771    FIFO_Within_Priorities           |
5772    Non_Preemptive_Within_Priorities |
5773    Round_Robin_Within_Priorities
5774 @end smallexample
5776 @noindent
5777 This pragma is standard in Ada 2005, but is available in all earlier
5778 versions of Ada as an implementation-defined pragma.
5779 See Ada 2012 Reference Manual for details.
5781 @node Pragma Profile
5782 @unnumberedsec Pragma Profile
5783 @findex Profile
5784 @noindent
5785 Syntax:
5787 @smallexample @c ada
5788 pragma Profile (Ravenscar | Restricted | Rational);
5789 @end smallexample
5791 @noindent
5792 This pragma is standard in Ada 2005, but is available in all earlier
5793 versions of Ada as an implementation-defined pragma. This is a
5794 configuration pragma that establishes a set of configiuration pragmas
5795 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5796 The other two possibilities (@code{Restricted} or @code{Rational})
5797 are implementation-defined. The set of configuration pragmas
5798 is defined in the following sections.
5800 @itemize
5802 @item Pragma Profile (Ravenscar)
5803 @findex Ravenscar
5804 @noindent
5806 The @code{Ravenscar} profile is standard in Ada 2005,
5807 but is available in all earlier
5808 versions of Ada as an implementation-defined pragma. This profile
5809 establishes the following set of configuration pragmas:
5811 @table @code
5812 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5813 [RM D.2.2] Tasks are dispatched following a preemptive
5814 priority-ordered scheduling policy.
5816 @item Locking_Policy (Ceiling_Locking)
5817 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5818 the ceiling priority of the corresponding protected object.
5820 @item Detect_Blocking
5821 This pragma forces the detection of potentially blocking operations within a
5822 protected operation, and to raise Program_Error if that happens.
5823 @end table
5824 @noindent
5826 plus the following set of restrictions:
5828 @table @code
5829 @item Max_Entry_Queue_Length => 1
5830 No task can be queued on a protected entry.
5831 @item Max_Protected_Entries => 1
5832 @item Max_Task_Entries => 0
5833 No rendezvous statements are allowed.
5834 @item No_Abort_Statements
5835 @item No_Dynamic_Attachment
5836 @item No_Dynamic_Priorities
5837 @item No_Implicit_Heap_Allocations
5838 @item No_Local_Protected_Objects
5839 @item No_Local_Timing_Events
5840 @item No_Protected_Type_Allocators
5841 @item No_Relative_Delay
5842 @item No_Requeue_Statements
5843 @item No_Select_Statements
5844 @item No_Specific_Termination_Handlers
5845 @item No_Task_Allocators
5846 @item No_Task_Hierarchy
5847 @item No_Task_Termination
5848 @item Simple_Barriers
5849 @end table
5850 @noindent
5852 The Ravenscar profile also includes the following restrictions that specify
5853 that there are no semantic dependences on the corresponding predefined
5854 packages:
5856 @table @code
5857 @item No_Dependence => Ada.Asynchronous_Task_Control
5858 @item No_Dependence => Ada.Calendar
5859 @item No_Dependence => Ada.Execution_Time.Group_Budget
5860 @item No_Dependence => Ada.Execution_Time.Timers
5861 @item No_Dependence => Ada.Task_Attributes
5862 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5863 @end table
5865 @noindent
5867 This set of configuration pragmas and restrictions correspond to the
5868 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5869 published by the @cite{International Real-Time Ada Workshop}, 1997,
5870 and whose most recent description is available at
5871 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5873 The original definition of the profile was revised at subsequent IRTAW
5874 meetings. It has been included in the ISO
5875 @cite{Guide for the Use of the Ada Programming Language in High
5876 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5877 the next revision of the standard. The formal definition given by
5878 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5879 AI-305) available at
5880 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5881 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5883 The above set is a superset of the restrictions provided by pragma
5884 @code{Profile (Restricted)}, it includes six additional restrictions
5885 (@code{Simple_Barriers}, @code{No_Select_Statements},
5886 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5887 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
5888 that pragma @code{Profile (Ravenscar)}, like the pragma
5889 @code{Profile (Restricted)},
5890 automatically causes the use of a simplified,
5891 more efficient version of the tasking run-time system.
5893 @item Pragma Profile (Restricted)
5894 @findex Restricted Run Time
5895 @noindent
5896 This profile corresponds to the GNAT restricted run time. It
5897 establishes the following set of restrictions:
5899 @itemize @bullet
5900 @item No_Abort_Statements
5901 @item No_Entry_Queue
5902 @item No_Task_Hierarchy
5903 @item No_Task_Allocators
5904 @item No_Dynamic_Priorities
5905 @item No_Terminate_Alternatives
5906 @item No_Dynamic_Attachment
5907 @item No_Protected_Type_Allocators
5908 @item No_Local_Protected_Objects
5909 @item No_Requeue_Statements
5910 @item No_Task_Attributes_Package
5911 @item Max_Asynchronous_Select_Nesting =  0
5912 @item Max_Task_Entries =  0
5913 @item Max_Protected_Entries = 1
5914 @item Max_Select_Alternatives = 0
5915 @end itemize
5917 @noindent
5918 This set of restrictions causes the automatic selection of a simplified
5919 version of the run time that provides improved performance for the
5920 limited set of tasking functionality permitted by this set of restrictions.
5922 @item Pragma Profile (Rational)
5923 @findex Rational compatibility mode
5924 @noindent
5925 The Rational profile is intended to facilitate porting legacy code that
5926 compiles with the Rational APEX compiler, even when the code includes non-
5927 conforming Ada constructs.  The profile enables the following three pragmas:
5929 @itemize @bullet
5930 @item pragma Implicit_Packing
5931 @item pragma Overriding_Renamings
5932 @item pragma Use_VADS_Size
5933 @end itemize
5935 @end itemize
5937 @node Pragma Profile_Warnings
5938 @unnumberedsec Pragma Profile_Warnings
5939 @findex Profile_Warnings
5940 @noindent
5941 Syntax:
5943 @smallexample @c ada
5944 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5945 @end smallexample
5947 @noindent
5948 This is an implementation-defined pragma that is similar in
5949 effect to @code{pragma Profile} except that instead of
5950 generating @code{Restrictions} pragmas, it generates
5951 @code{Restriction_Warnings} pragmas. The result is that
5952 violations of the profile generate warning messages instead
5953 of error messages.
5955 @node Pragma Propagate_Exceptions
5956 @unnumberedsec Pragma Propagate_Exceptions
5957 @cindex Interfacing to C++
5958 @findex Propagate_Exceptions
5959 @noindent
5960 Syntax:
5962 @smallexample @c ada
5963 pragma Propagate_Exceptions;
5964 @end smallexample
5966 @noindent
5967 This pragma is now obsolete and, other than generating a warning if warnings
5968 on obsolescent features are enabled, is ignored.
5969 It is retained for compatibility
5970 purposes. It used to be used in connection with optimization of
5971 a now-obsolete mechanism for implementation of exceptions.
5973 @node Pragma Provide_Shift_Operators
5974 @unnumberedsec Pragma Provide_Shift_Operators
5975 @cindex Shift operators
5976 @findex Provide_Shift_Operators
5977 @noindent
5978 Syntax:
5980 @smallexample @c ada
5981 pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
5982 @end smallexample
5984 @noindent
5985 This pragma can be applied to a first subtype local name that specifies
5986 either an unsigned or signed type. It has the effect of providing the
5987 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
5988 Rotate_Left and Rotate_Right) for the given type. It is similar to
5989 including the function declarations for these five operators, together
5990 with the pragma Import (Intrinsic, ...) statements.
5992 @node Pragma Psect_Object
5993 @unnumberedsec Pragma Psect_Object
5994 @findex Psect_Object
5995 @noindent
5996 Syntax:
5998 @smallexample @c ada
5999 pragma Psect_Object (
6000      [Internal =>] LOCAL_NAME,
6001   [, [External =>] EXTERNAL_SYMBOL]
6002   [, [Size     =>] EXTERNAL_SYMBOL]);
6004 EXTERNAL_SYMBOL ::=
6005   IDENTIFIER
6006 | static_string_EXPRESSION
6007 @end smallexample
6009 @noindent
6010 This pragma is identical in effect to pragma @code{Common_Object}.
6012 @node Pragma Pure_Function
6013 @unnumberedsec Pragma Pure_Function
6014 @findex Pure_Function
6015 @noindent
6016 Syntax:
6018 @smallexample @c ada
6019 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
6020 @end smallexample
6022 @noindent
6023 This pragma appears in the same declarative part as a function
6024 declaration (or a set of function declarations if more than one
6025 overloaded declaration exists, in which case the pragma applies
6026 to all entities).  It specifies that the function @code{Entity} is
6027 to be considered pure for the purposes of code generation.  This means
6028 that the compiler can assume that there are no side effects, and
6029 in particular that two calls with identical arguments produce the
6030 same result.  It also means that the function can be used in an
6031 address clause.
6033 Note that, quite deliberately, there are no static checks to try
6034 to ensure that this promise is met, so @code{Pure_Function} can be used
6035 with functions that are conceptually pure, even if they do modify
6036 global variables.  For example, a square root function that is
6037 instrumented to count the number of times it is called is still
6038 conceptually pure, and can still be optimized, even though it
6039 modifies a global variable (the count).  Memo functions are another
6040 example (where a table of previous calls is kept and consulted to
6041 avoid re-computation).
6043 Note also that the normal rules excluding optimization of subprograms
6044 in pure units (when parameter types are descended from System.Address,
6045 or when the full view of a parameter type is limited), do not apply
6046 for the Pure_Function case. If you explicitly specify Pure_Function,
6047 the compiler may optimize away calls with identical arguments, and
6048 if that results in unexpected behavior, the proper action is not to
6049 use the pragma for subprograms that are not (conceptually) pure.
6051 @findex Pure
6052 Note: Most functions in a @code{Pure} package are automatically pure, and
6053 there is no need to use pragma @code{Pure_Function} for such functions.  One
6054 exception is any function that has at least one formal of type
6055 @code{System.Address} or a type derived from it.  Such functions are not
6056 considered pure by default, since the compiler assumes that the
6057 @code{Address} parameter may be functioning as a pointer and that the
6058 referenced data may change even if the address value does not.
6059 Similarly, imported functions are not considered to be pure by default,
6060 since there is no way of checking that they are in fact pure.  The use
6061 of pragma @code{Pure_Function} for such a function will override these default
6062 assumption, and cause the compiler to treat a designated subprogram as pure
6063 in these cases.
6065 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
6066 applies to the underlying renamed function.  This can be used to
6067 disambiguate cases of overloading where some but not all functions
6068 in a set of overloaded functions are to be designated as pure.
6070 If pragma @code{Pure_Function} is applied to a library level function, the
6071 function is also considered pure from an optimization point of view, but the
6072 unit is not a Pure unit in the categorization sense. So for example, a function
6073 thus marked is free to @code{with} non-pure units.
6075 @node Pragma Rational
6076 @unnumberedsec Pragma Rational
6077 @findex Rational
6078 @noindent
6079 Syntax:
6081 @smallexample @c ada
6082 pragma Rational;
6083 @end smallexample
6085 @noindent
6086 This pragma is considered obsolescent, but is retained for
6087 compatibility purposes. It is equivalent to:
6089 @smallexample @c ada
6090 pragma Profile (Rational);
6091 @end smallexample
6093 @node Pragma Ravenscar
6094 @unnumberedsec Pragma Ravenscar
6095 @findex Pragma Ravenscar
6096 @noindent
6097 Syntax:
6099 @smallexample @c ada
6100 pragma Ravenscar;
6101 @end smallexample
6103 @noindent
6104 This pragma is considered obsolescent, but is retained for
6105 compatibility purposes. It is equivalent to:
6107 @smallexample @c ada
6108 pragma Profile (Ravenscar);
6109 @end smallexample
6111 @noindent
6112 which is the preferred method of setting the @code{Ravenscar} profile.
6114 @node Pragma Refined_Depends
6115 @unnumberedsec Pragma Refined_Depends
6116 @findex Refined_Depends
6117 @noindent
6118 For the description of this pragma, see SPARK 2014 Reference Manual,
6119 section 6.1.5.
6121 @node Pragma Refined_Global
6122 @unnumberedsec Pragma Refined_Global
6123 @findex Refined_Global
6124 @noindent
6125 For the description of this pragma, see SPARK 2014 Reference Manual,
6126 section 6.1.4.
6128 @node Pragma Refined_Post
6129 @unnumberedsec Pragma Refined_Post
6130 @findex Refined_Post
6131 @noindent
6132 For the description of this pragma, see SPARK 2014 Reference Manual,
6133 section 7.2.7.
6135 @node Pragma Refined_State
6136 @unnumberedsec Pragma Refined_State
6137 @findex Refined_State
6138 @noindent
6139 For the description of this pragma, see SPARK 2014 Reference Manual,
6140 section 7.2.2.
6142 @node Pragma Relative_Deadline
6143 @unnumberedsec Pragma Relative_Deadline
6144 @findex Relative_Deadline
6145 @noindent
6146 Syntax:
6148 @smallexample @c ada
6149 pragma Relative_Deadline (time_span_EXPRESSION);
6150 @end smallexample
6152 @noindent
6153 This pragma is standard in Ada 2005, but is available in all earlier
6154 versions of Ada as an implementation-defined pragma.
6155 See Ada 2012 Reference Manual for details.
6157 @node Pragma Remote_Access_Type
6158 @unnumberedsec Pragma Remote_Access_Type
6159 @findex Remote_Access_Type
6160 @noindent
6161 Syntax:
6163 @smallexample @c ada
6164 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
6165 @end smallexample
6167 @noindent
6168 This pragma appears in the formal part of a generic declaration.
6169 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
6170 the use of a remote access to class-wide type as actual for a formal
6171 access type.
6173 When this pragma applies to a formal access type @code{Entity}, that
6174 type is treated as a remote access to class-wide type in the generic.
6175 It must be a formal general access type, and its designated type must
6176 be the class-wide type of a formal tagged limited private type from the
6177 same generic declaration.
6179 In the generic unit, the formal type is subject to all restrictions
6180 pertaining to remote access to class-wide types. At instantiation, the
6181 actual type must be a remote access to class-wide type.
6183 @node Pragma Restricted_Run_Time
6184 @unnumberedsec Pragma Restricted_Run_Time
6185 @findex Pragma Restricted_Run_Time
6186 @noindent
6187 Syntax:
6189 @smallexample @c ada
6190 pragma Restricted_Run_Time;
6191 @end smallexample
6193 @noindent
6194 This pragma is considered obsolescent, but is retained for
6195 compatibility purposes. It is equivalent to:
6197 @smallexample @c ada
6198 pragma Profile (Restricted);
6199 @end smallexample
6201 @noindent
6202 which is the preferred method of setting the restricted run time
6203 profile.
6205 @node Pragma Restriction_Warnings
6206 @unnumberedsec Pragma Restriction_Warnings
6207 @findex Restriction_Warnings
6208 @noindent
6209 Syntax:
6211 @smallexample @c ada
6212 pragma Restriction_Warnings
6213   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
6214 @end smallexample
6216 @noindent
6217 This pragma allows a series of restriction identifiers to be
6218 specified (the list of allowed identifiers is the same as for
6219 pragma @code{Restrictions}). For each of these identifiers
6220 the compiler checks for violations of the restriction, but
6221 generates a warning message rather than an error message
6222 if the restriction is violated.
6224 One use of this is in situations where you want to know
6225 about violations of a restriction, but you want to ignore some of
6226 these violations. Consider this example, where you want to set
6227 Ada_95 mode and enable style checks, but you want to know about
6228 any other use of implementation pragmas:
6230 @smallexample @c ada
6231 pragma Restriction_Warnings (No_Implementation_Pragmas);
6232 7 (Off, "violation of*No_Implementation_Pragmas*");
6233 pragma Ada_95;
6234 pragma Style_Checks ("2bfhkM160");
6235 pragma Warnings (On, "violation of*No_Implementation_Pragmas*");
6236 @end smallexample
6238 @noindent
6239 By including the above lines in a configuration pragmas file,
6240 the Ada_95 and Style_Checks pragmas are accepted without
6241 generating a warning, but any other use of implementation
6242 defined pragmas will cause a warning to be generated.
6244 @node Pragma Reviewable
6245 @unnumberedsec Pragma Reviewable
6246 @findex Reviewable
6247 @noindent
6248 Syntax:
6250 @smallexample @c ada
6251 pragma Reviewable;
6252 @end smallexample
6254 @noindent
6255 This pragma is an RM-defined standard pragma, but has no effect on the
6256 program being compiled, or on the code generated for the program.
6258 To obtain the required output specified in RM H.3.1, the compiler must be
6259 run with various special switches as follows:
6261 @table @i
6263 @item Where compiler-generated run-time checks remain
6265 The switch @option{-gnatGL}
6266 @findex @option{-gnatGL}
6267 may be used to list the expanded code in pseudo-Ada form.
6268 Runtime checks show up in the listing either as explicit
6269 checks or operators marked with @{@} to indicate a check is present.
6271 @item An identification of known exceptions at compile time
6273 If the program is compiled with @option{-gnatwa},
6274 @findex @option{-gnatwa}
6275 the compiler warning messages will indicate all cases where the compiler
6276 detects that an exception is certain to occur at run time.
6278 @item Possible reads of uninitialized variables
6280 The compiler warns of many such cases, but its output is incomplete.
6281 @ifclear FSFEDITION
6282 The CodePeer analysis tool
6283 @findex CodePeer static analysis tool
6284 @end ifclear
6285 @ifset FSFEDITION
6286 A supplemental static analysis tool
6287 @end ifset
6288 may be used to obtain a comprehensive list of all
6289 possible points at which uninitialized data may be read.
6291 @item Where run-time support routines are implicitly invoked
6293 In the output from @option{-gnatGL},
6294 @findex @option{-gnatGL}
6295 run-time calls are explicitly listed as calls to the relevant
6296 run-time routine.
6298 @item Object code listing
6300 This may be obtained either by using the @option{-S} switch,
6301 @findex @option{-S}
6302 or the objdump utility.
6303 @findex objdump
6305 @item Constructs known to be erroneous at compile time
6307 These are identified by warnings issued by the compiler (use @option{-gnatwa}).
6308 @findex @option{-gnatwa}
6310 @item Stack usage information
6312 Static stack usage data (maximum per-subprogram) can be obtained via the
6313 @option{-fstack-usage} switch to the compiler.
6314 @findex @option{-fstack-usage}
6315 Dynamic stack usage data (per task) can be obtained via the @option{-u} switch
6316 to gnatbind
6317 @findex @option{-u}
6318 @ifclear FSFEDITION
6319 The gnatstack utility
6320 @findex gnatstack
6321 can be used to provide additional information on stack usage.
6322 @end ifclear
6324 @item Object code listing of entire partition
6326 This can be obtained by compiling the partition with @option{-S},
6327 @findex @option{-S}
6328 or by applying objdump
6329 @findex objdump
6330 to all the object files that are part of the partition.
6332 @item A description of the run-time model
6334 The full sources of the run-time are available, and the documentation of
6335 these routines describes how these run-time routines interface to the
6336 underlying operating system facilities.
6338 @item Control and data-flow information
6340 @ifclear FSFEDITION
6341 The CodePeer tool
6342 @findex CodePeer static analysis tool
6343 @end ifclear
6344 @ifset FSFEDITION
6345 A supplemental static analysis tool
6346 @end ifset
6347 may be used to obtain complete control and data-flow information, as well as
6348 comprehensive messages identifying possible problems based on this
6349 information.
6350 @end table
6352 @node Pragma Share_Generic
6353 @unnumberedsec Pragma Share_Generic
6354 @findex Share_Generic
6355 @noindent
6356 Syntax:
6358 @smallexample @c ada
6359 pragma Share_Generic (GNAME @{, GNAME@});
6361 GNAME ::= generic_unit_NAME | generic_instance_NAME
6362 @end smallexample
6364 @noindent
6365 This pragma is provided for compatibility with Dec Ada 83. It has
6366 no effect in @code{GNAT} (which does not implement shared generics), other
6367 than to check that the given names are all names of generic units or
6368 generic instances.
6370 @node Pragma Shared
6371 @unnumberedsec Pragma Shared
6372 @findex Shared
6374 @noindent
6375 This pragma is provided for compatibility with Ada 83. The syntax and
6376 semantics are identical to pragma Atomic.
6378 @node Pragma Short_Circuit_And_Or
6379 @unnumberedsec Pragma Short_Circuit_And_Or
6380 @findex Short_Circuit_And_Or
6381 @noindent
6382 Syntax:
6384 @smallexample @c ada
6385 pragma Short_Circuit_And_Or;
6386 @end smallexample
6388 @noindent
6389 This configuration pragma causes any occurrence of the AND operator applied to
6390 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
6391 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
6392 may be useful in the context of certification protocols requiring the use of
6393 short-circuited logical operators. If this configuration pragma occurs locally
6394 within the file being compiled, it applies only to the file being compiled.
6395 There is no requirement that all units in a partition use this option.
6397 @node Pragma Short_Descriptors
6398 @unnumberedsec Pragma Short_Descriptors
6399 @findex Short_Descriptors
6400 @noindent
6401 Syntax:
6403 @smallexample @c ada
6404 pragma Short_Descriptors
6405 @end smallexample
6407 @noindent
6408 This pragma is provided for compatibility with other Ada implementations. It
6409 is recognized but ignored by all current versions of GNAT.
6411 @node Pragma Simple_Storage_Pool_Type
6412 @unnumberedsec Pragma Simple_Storage_Pool_Type
6413 @findex Simple_Storage_Pool_Type
6414 @cindex Storage pool, simple
6415 @cindex Simple storage pool
6416 @noindent
6417 Syntax:
6419 @smallexample @c ada
6420 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
6421 @end smallexample
6423 @noindent
6424 A type can be established as a ``simple storage pool type'' by applying
6425 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
6426 A type named in the pragma must be a library-level immutably limited record
6427 type or limited tagged type declared immediately within a package declaration.
6428 The type can also be a limited private type whose full type is allowed as
6429 a simple storage pool type.
6431 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
6432 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
6433 are subtype conformant with the following subprogram declarations:
6435 @smallexample @c ada
6436 procedure Allocate
6437   (Pool                     : in out SSP;
6438    Storage_Address          : out System.Address;
6439    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6440    Alignment                : System.Storage_Elements.Storage_Count);
6442 procedure Deallocate
6443   (Pool : in out SSP;
6444    Storage_Address          : System.Address;
6445    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6446    Alignment                : System.Storage_Elements.Storage_Count);
6448 function Storage_Size (Pool : SSP)
6449   return System.Storage_Elements.Storage_Count;
6450 @end smallexample
6452 @noindent
6453 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
6454 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
6455 applying an unchecked deallocation has no effect other than to set its actual
6456 parameter to null. If @code{Storage_Size} is not declared, then the
6457 @code{Storage_Size} attribute applied to an access type associated with
6458 a pool object of type SSP returns zero. Additional operations can be declared
6459 for a simple storage pool type (such as for supporting a mark/release
6460 storage-management discipline).
6462 An object of a simple storage pool type can be associated with an access
6463 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
6465 @smallexample @c ada
6467 My_Pool : My_Simple_Storage_Pool_Type;
6469 type Acc is access My_Data_Type;
6471 for Acc'Simple_Storage_Pool use My_Pool;
6473 @end smallexample
6475 @noindent
6476 See attribute @code{Simple_Storage_Pool} for further details.
6478 @node Pragma Source_File_Name
6479 @unnumberedsec Pragma Source_File_Name
6480 @findex Source_File_Name
6481 @noindent
6482 Syntax:
6484 @smallexample @c ada
6485 pragma Source_File_Name (
6486   [Unit_Name   =>] unit_NAME,
6487   Spec_File_Name =>  STRING_LITERAL,
6488   [Index => INTEGER_LITERAL]);
6490 pragma Source_File_Name (
6491   [Unit_Name   =>] unit_NAME,
6492   Body_File_Name =>  STRING_LITERAL,
6493   [Index => INTEGER_LITERAL]);
6494 @end smallexample
6496 @noindent
6497 Use this to override the normal naming convention.  It is a configuration
6498 pragma, and so has the usual applicability of configuration pragmas
6499 (i.e.@: it applies to either an entire partition, or to all units in a
6500 compilation, or to a single unit, depending on how it is used.
6501 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
6502 the second argument is required, and indicates whether this is the file
6503 name for the spec or for the body.
6505 The optional Index argument should be used when a file contains multiple
6506 units, and when you do not want to use @code{gnatchop} to separate then
6507 into multiple files (which is the recommended procedure to limit the
6508 number of recompilations that are needed when some sources change).
6509 For instance, if the source file @file{source.ada} contains
6511 @smallexample @c ada
6512 package B is
6514 end B;
6516 with B;
6517 procedure A is
6518 begin
6519    ..
6520 end A;
6521 @end smallexample
6523 you could use the following configuration pragmas:
6525 @smallexample @c ada
6526 pragma Source_File_Name
6527   (B, Spec_File_Name => "source.ada", Index => 1);
6528 pragma Source_File_Name
6529   (A, Body_File_Name => "source.ada", Index => 2);
6530 @end smallexample
6532 Note that the @code{gnatname} utility can also be used to generate those
6533 configuration pragmas.
6535 Another form of the @code{Source_File_Name} pragma allows
6536 the specification of patterns defining alternative file naming schemes
6537 to apply to all files.
6539 @smallexample @c ada
6540 pragma Source_File_Name
6541   (  [Spec_File_Name  =>] STRING_LITERAL
6542    [,[Casing          =>] CASING_SPEC]
6543    [,[Dot_Replacement =>] STRING_LITERAL]);
6545 pragma Source_File_Name
6546   (  [Body_File_Name  =>] STRING_LITERAL
6547    [,[Casing          =>] CASING_SPEC]
6548    [,[Dot_Replacement =>] STRING_LITERAL]);
6550 pragma Source_File_Name
6551   (  [Subunit_File_Name =>] STRING_LITERAL
6552    [,[Casing            =>] CASING_SPEC]
6553    [,[Dot_Replacement   =>] STRING_LITERAL]);
6555 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
6556 @end smallexample
6558 @noindent
6559 The first argument is a pattern that contains a single asterisk indicating
6560 the point at which the unit name is to be inserted in the pattern string
6561 to form the file name.  The second argument is optional.  If present it
6562 specifies the casing of the unit name in the resulting file name string.
6563 The default is lower case.  Finally the third argument allows for systematic
6564 replacement of any dots in the unit name by the specified string literal.
6566 Note that Source_File_Name pragmas should not be used if you are using
6567 project files. The reason for this rule is that the project manager is not
6568 aware of these pragmas, and so other tools that use the projet file would not
6569 be aware of the intended naming conventions. If you are using project files,
6570 file naming is controlled by Source_File_Name_Project pragmas, which are
6571 usually supplied automatically by the project manager. A pragma
6572 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
6574 For more details on the use of the @code{Source_File_Name} pragma,
6575 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
6576 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
6577 User's Guide}.
6579 @node Pragma Source_File_Name_Project
6580 @unnumberedsec Pragma Source_File_Name_Project
6581 @findex Source_File_Name_Project
6582 @noindent
6584 This pragma has the same syntax and semantics as pragma Source_File_Name.
6585 It is only allowed as a stand alone configuration pragma.
6586 It cannot appear after a @ref{Pragma Source_File_Name}, and
6587 most importantly, once pragma Source_File_Name_Project appears,
6588 no further Source_File_Name pragmas are allowed.
6590 The intention is that Source_File_Name_Project pragmas are always
6591 generated by the Project Manager in a manner consistent with the naming
6592 specified in a project file, and when naming is controlled in this manner,
6593 it is not permissible to attempt to modify this naming scheme using
6594 Source_File_Name or Source_File_Name_Project pragmas (which would not be
6595 known to the project manager).
6597 @node Pragma Source_Reference
6598 @unnumberedsec Pragma Source_Reference
6599 @findex Source_Reference
6600 @noindent
6601 Syntax:
6603 @smallexample @c ada
6604 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
6605 @end smallexample
6607 @noindent
6608 This pragma must appear as the first line of a source file.
6609 @var{integer_literal} is the logical line number of the line following
6610 the pragma line (for use in error messages and debugging
6611 information).  @var{string_literal} is a static string constant that
6612 specifies the file name to be used in error messages and debugging
6613 information.  This is most notably used for the output of @code{gnatchop}
6614 with the @option{-r} switch, to make sure that the original unchopped
6615 source file is the one referred to.
6617 The second argument must be a string literal, it cannot be a static
6618 string expression other than a string literal.  This is because its value
6619 is needed for error messages issued by all phases of the compiler.
6621 @node Pragma SPARK_Mode
6622 @unnumberedsec Pragma SPARK_Mode
6623 @findex SPARK_Mode
6624 @noindent
6625 Syntax:
6627 @smallexample @c ada
6628 pragma SPARK_Mode [(On | Off)] ;
6629 @end smallexample
6631 @noindent
6632 In general a program can have some parts that are in SPARK 2014 (and
6633 follow all the rules in the SPARK Reference Manual), and some parts
6634 that are full Ada 2012.
6636 The SPARK_Mode pragma is used to identify which parts are in SPARK
6637 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
6638 be used in the following places:
6640 @itemize @bullet
6642 @item
6643 As a configuration pragma, in which case it sets the default mode for
6644 all units compiled with this pragma.
6646 @item
6647 Immediately following a library-level subprogram spec
6649 @item
6650 Immediately within a library-level package body
6652 @item
6653 Immediately following the @code{private} keyword of a library-level
6654 package spec
6656 @item
6657 Immediately following the @code{begin} keyword of a library-level
6658 package body
6660 @item
6661 Immediately within a library-level subprogram body
6663 @end itemize
6665 @noindent
6666 Normally a subprogram or package spec/body inherits the current mode
6667 that is active at the point it is declared. But this can be overridden
6668 by pragma within the spec or body as above.
6670 The basic consistency rule is that you can't turn SPARK_Mode back
6671 @code{On}, once you have explicitly (with a pragma) turned if
6672 @code{Off}. So the following rules apply:
6674 @noindent
6675 If a subprogram spec has SPARK_Mode @code{Off}, then the body must
6676 also have SPARK_Mode @code{Off}.
6678 @noindent
6679 For a package, we have four parts:
6681 @itemize
6682 @item
6683 the package public declarations
6684 @item
6685 the package private part
6686 @item
6687 the body of the package
6688 @item
6689 the elaboration code after @code{begin}
6690 @end itemize
6692 @noindent
6693 For a package, the rule is that if you explicitly turn SPARK_Mode
6694 @code{Off} for any part, then all the following parts must have
6695 SPARK_Mode @code{Off}. Note that this may require repeating a pragma
6696 SPARK_Mode (@code{Off}) in the body. For example, if we have a
6697 configuration pragma SPARK_Mode (@code{On}) that turns the mode on by
6698 default everywhere, and one particular package spec has pragma
6699 SPARK_Mode (@code{Off}), then that pragma will need to be repeated in
6700 the package body.
6702 @node Pragma Static_Elaboration_Desired
6703 @unnumberedsec Pragma Static_Elaboration_Desired
6704 @findex Static_Elaboration_Desired
6705 @noindent
6706 Syntax:
6708 @smallexample @c ada
6709 pragma Static_Elaboration_Desired;
6710 @end smallexample
6712 @noindent
6713 This pragma is used to indicate that the compiler should attempt to initialize
6714 statically the objects declared in the library unit to which the pragma applies,
6715 when these objects are initialized (explicitly or implicitly) by an aggregate.
6716 In the absence of this pragma, aggregates in object declarations are expanded
6717 into assignments and loops, even when the aggregate components are static
6718 constants. When the aggregate is present the compiler builds a static expression
6719 that requires no run-time code, so that the initialized object can be placed in
6720 read-only data space. If the components are not static, or the aggregate has
6721 more that 100 components, the compiler emits a warning that the pragma cannot
6722 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6723 construction of larger aggregates with static components that include an others
6724 choice.)
6726 @node Pragma Stream_Convert
6727 @unnumberedsec Pragma Stream_Convert
6728 @findex Stream_Convert
6729 @noindent
6730 Syntax:
6732 @smallexample @c ada
6733 pragma Stream_Convert (
6734   [Entity =>] type_LOCAL_NAME,
6735   [Read   =>] function_NAME,
6736   [Write  =>] function_NAME);
6737 @end smallexample
6739 @noindent
6740 This pragma provides an efficient way of providing user-defined stream
6741 attributes.  Not only is it simpler to use than specifying the attributes
6742 directly, but more importantly, it allows the specification to be made in such
6743 a way that the predefined unit Ada.Streams is not loaded unless it is actually
6744 needed (i.e. unless the stream attributes are actually used); the use of
6745 the Stream_Convert pragma adds no overhead at all, unless the stream
6746 attributes are actually used on the designated type.
6748 The first argument specifies the type for which stream functions are
6749 provided.  The second parameter provides a function used to read values
6750 of this type.  It must name a function whose argument type may be any
6751 subtype, and whose returned type must be the type given as the first
6752 argument to the pragma.
6754 The meaning of the @var{Read} parameter is that if a stream attribute directly
6755 or indirectly specifies reading of the type given as the first parameter,
6756 then a value of the type given as the argument to the Read function is
6757 read from the stream, and then the Read function is used to convert this
6758 to the required target type.
6760 Similarly the @var{Write} parameter specifies how to treat write attributes
6761 that directly or indirectly apply to the type given as the first parameter.
6762 It must have an input parameter of the type specified by the first parameter,
6763 and the return type must be the same as the input type of the Read function.
6764 The effect is to first call the Write function to convert to the given stream
6765 type, and then write the result type to the stream.
6767 The Read and Write functions must not be overloaded subprograms.  If necessary
6768 renamings can be supplied to meet this requirement.
6769 The usage of this attribute is best illustrated by a simple example, taken
6770 from the GNAT implementation of package Ada.Strings.Unbounded:
6772 @smallexample @c ada
6773 function To_Unbounded (S : String)
6774            return Unbounded_String
6775   renames To_Unbounded_String;
6777 pragma Stream_Convert
6778   (Unbounded_String, To_Unbounded, To_String);
6779 @end smallexample
6781 @noindent
6782 The specifications of the referenced functions, as given in the Ada
6783 Reference Manual are:
6785 @smallexample @c ada
6786 function To_Unbounded_String (Source : String)
6787   return Unbounded_String;
6789 function To_String (Source : Unbounded_String)
6790   return String;
6791 @end smallexample
6793 @noindent
6794 The effect is that if the value of an unbounded string is written to a stream,
6795 then the representation of the item in the stream is in the same format that
6796 would be used for @code{Standard.String'Output}, and this same representation
6797 is expected when a value of this type is read from the stream. Note that the
6798 value written always includes the bounds, even for Unbounded_String'Write,
6799 since Unbounded_String is not an array type.
6801 Note that the @code{Stream_Convert} pragma is not effective in the case of
6802 a derived type of a non-limited tagged type. If such a type is specified then
6803 the pragma is silently ignored, and the default implementation of the stream
6804 attributes is used instead.
6806 @node Pragma Style_Checks
6807 @unnumberedsec Pragma Style_Checks
6808 @findex Style_Checks
6809 @noindent
6810 Syntax:
6812 @smallexample @c ada
6813 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6814                      On | Off [, LOCAL_NAME]);
6815 @end smallexample
6817 @noindent
6818 This pragma is used in conjunction with compiler switches to control the
6819 built in style checking provided by GNAT@.  The compiler switches, if set,
6820 provide an initial setting for the switches, and this pragma may be used
6821 to modify these settings, or the settings may be provided entirely by
6822 the use of the pragma.  This pragma can be used anywhere that a pragma
6823 is legal, including use as a configuration pragma (including use in
6824 the @file{gnat.adc} file).
6826 The form with a string literal specifies which style options are to be
6827 activated.  These are additive, so they apply in addition to any previously
6828 set style check options.  The codes for the options are the same as those
6829 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6830 For example the following two methods can be used to enable
6831 layout checking:
6833 @itemize @bullet
6834 @item
6835 @smallexample @c ada
6836 pragma Style_Checks ("l");
6837 @end smallexample
6839 @item
6840 @smallexample
6841 gcc -c -gnatyl @dots{}
6842 @end smallexample
6843 @end itemize
6845 @noindent
6846 The form ALL_CHECKS activates all standard checks (its use is equivalent
6847 to the use of the @code{gnaty} switch with no options.  @xref{Top,
6848 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6849 @value{EDITION} User's Guide}, for details.)
6851 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6852 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6853 options (i.e. equivalent to -gnatyg).
6855 The forms with @code{Off} and @code{On}
6856 can be used to temporarily disable style checks
6857 as shown in the following example:
6859 @smallexample @c ada
6860 @iftex
6861 @leftskip=0cm
6862 @end iftex
6863 pragma Style_Checks ("k"); -- requires keywords in lower case
6864 pragma Style_Checks (Off); -- turn off style checks
6865 NULL;                      -- this will not generate an error message
6866 pragma Style_Checks (On);  -- turn style checks back on
6867 NULL;                      -- this will generate an error message
6868 @end smallexample
6870 @noindent
6871 Finally the two argument form is allowed only if the first argument is
6872 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
6873 for the specified entity, as shown in the following example:
6875 @smallexample @c ada
6876 @iftex
6877 @leftskip=0cm
6878 @end iftex
6879 pragma Style_Checks ("r"); -- require consistency of identifier casing
6880 Arg : Integer;
6881 Rf1 : Integer := ARG;      -- incorrect, wrong case
6882 pragma Style_Checks (Off, Arg);
6883 Rf2 : Integer := ARG;      -- OK, no error
6884 @end smallexample
6886 @node Pragma Subtitle
6887 @unnumberedsec Pragma Subtitle
6888 @findex Subtitle
6889 @noindent
6890 Syntax:
6892 @smallexample @c ada
6893 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6894 @end smallexample
6896 @noindent
6897 This pragma is recognized for compatibility with other Ada compilers
6898 but is ignored by GNAT@.
6900 @node Pragma Suppress
6901 @unnumberedsec Pragma Suppress
6902 @findex Suppress
6903 @noindent
6904 Syntax:
6906 @smallexample @c ada
6907 pragma Suppress (Identifier [, [On =>] Name]);
6908 @end smallexample
6910 @noindent
6911 This is a standard pragma, and supports all the check names required in
6912 the RM. It is included here because GNAT recognizes some additional check
6913 names that are implementation defined (as permitted by the RM):
6915 @itemize @bullet
6917 @item
6918 @code{Alignment_Check} can be used to suppress alignment checks
6919 on addresses used in address clauses. Such checks can also be suppressed
6920 by suppressing range checks, but the specific use of @code{Alignment_Check}
6921 allows suppression of alignment checks without suppressing other range checks.
6923 @item
6924 @code{Atomic_Synchronization} can be used to suppress the special memory
6925 synchronization instructions that are normally generated for access to
6926 @code{Atomic} variables to ensure correct synchronization between tasks
6927 that use such variables for synchronization purposes.
6929 @item
6930 @code{Duplicated_Tag_Check} Can be used to suppress the check that is generated
6931 for a duplicated tag value when a tagged type is declared.
6933 @item
6934 @code{Predicate_Check} can be used to control whether predicate checks are
6935 active. It is applicable only to predicates for which the policy is
6936 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6937 predicate is ignored or checked for the whole program, the use of
6938 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6939 predicate to be turned on and off at specific points in the program.
6941 @item
6942 @code{Validity_Check} can be used specifically to control validity checks.
6943 If @code{Suppress} is used to suppress validity checks, then no validity
6944 checks are performed, including those specified by the appropriate compiler
6945 switch or the @code{Validity_Checks} pragma.
6947 @item
6948 Additional check names previously introduced by use of the @code{Check_Name}
6949 pragma are also allowed.
6951 @end itemize
6953 @noindent
6954 Note that pragma Suppress gives the compiler permission to omit
6955 checks, but does not require the compiler to omit checks. The compiler
6956 will generate checks if they are essentially free, even when they are
6957 suppressed. In particular, if the compiler can prove that a certain
6958 check will necessarily fail, it will generate code to do an
6959 unconditional ``raise'', even if checks are suppressed. The compiler
6960 warns in this case.
6962 Of course, run-time checks are omitted whenever the compiler can prove
6963 that they will not fail, whether or not checks are suppressed.
6965 @node Pragma Suppress_All
6966 @unnumberedsec Pragma Suppress_All
6967 @findex Suppress_All
6968 @noindent
6969 Syntax:
6971 @smallexample @c ada
6972 pragma Suppress_All;
6973 @end smallexample
6975 @noindent
6976 This pragma can appear anywhere within a unit.
6977 The effect is to apply @code{Suppress (All_Checks)} to the unit
6978 in which it appears.  This pragma is implemented for compatibility with DEC
6979 Ada 83 usage where it appears at the end of a unit, and for compatibility
6980 with Rational Ada, where it appears as a program unit pragma.
6981 The use of the standard Ada pragma @code{Suppress (All_Checks)}
6982 as a normal configuration pragma is the preferred usage in GNAT@.
6984 @node Pragma Suppress_Debug_Info
6985 @unnumberedsec Pragma Suppress_Debug_Info
6986 @findex Suppress_Debug_Info
6987 @noindent
6988 Syntax:
6990 @smallexample @c ada
6991 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
6992 @end smallexample
6994 @noindent
6995 This pragma can be used to suppress generation of debug information
6996 for the specified entity. It is intended primarily for use in debugging
6997 the debugger, and navigating around debugger problems.
6999 @node Pragma Suppress_Exception_Locations
7000 @unnumberedsec Pragma Suppress_Exception_Locations
7001 @findex Suppress_Exception_Locations
7002 @noindent
7003 Syntax:
7005 @smallexample @c ada
7006 pragma Suppress_Exception_Locations;
7007 @end smallexample
7009 @noindent
7010 In normal mode, a raise statement for an exception by default generates
7011 an exception message giving the file name and line number for the location
7012 of the raise. This is useful for debugging and logging purposes, but this
7013 entails extra space for the strings for the messages. The configuration
7014 pragma @code{Suppress_Exception_Locations} can be used to suppress the
7015 generation of these strings, with the result that space is saved, but the
7016 exception message for such raises is null. This configuration pragma may
7017 appear in a global configuration pragma file, or in a specific unit as
7018 usual. It is not required that this pragma be used consistently within
7019 a partition, so it is fine to have some units within a partition compiled
7020 with this pragma and others compiled in normal mode without it.
7022 @node Pragma Suppress_Initialization
7023 @unnumberedsec Pragma Suppress_Initialization
7024 @findex Suppress_Initialization
7025 @cindex Suppressing initialization
7026 @cindex Initialization, suppression of
7027 @noindent
7028 Syntax:
7030 @smallexample @c ada
7031 pragma Suppress_Initialization ([Entity =>] subtype_Name);
7032 @end smallexample
7034 @noindent
7035 Here subtype_Name is the name introduced by a type declaration
7036 or subtype declaration.
7037 This pragma suppresses any implicit or explicit initialization
7038 for all variables of the given type or subtype,
7039 including initialization resulting from the use of pragmas
7040 Normalize_Scalars or Initialize_Scalars.
7042 This is considered a representation item, so it cannot be given after
7043 the type is frozen. It applies to all subsequent object declarations,
7044 and also any allocator that creates objects of the type.
7046 If the pragma is given for the first subtype, then it is considered
7047 to apply to the base type and all its subtypes. If the pragma is given
7048 for other than a first subtype, then it applies only to the given subtype.
7049 The pragma may not be given after the type is frozen.
7051 Note that this includes eliminating initialization of discriminants
7052 for discriminated types, and tags for tagged types. In these cases,
7053 you will have to use some non-portable mechanism (e.g. address
7054 overlays or unchecked conversion) to achieve required initialization
7055 of these fields before accessing any object of the corresponding type.
7057 @node Pragma Task_Name
7058 @unnumberedsec Pragma Task_Name
7059 @findex Task_Name
7060 @noindent
7061 Syntax
7063 @smallexample @c ada
7064 pragma Task_Name (string_EXPRESSION);
7065 @end smallexample
7067 @noindent
7068 This pragma appears within a task definition (like pragma
7069 @code{Priority}) and applies to the task in which it appears.  The
7070 argument must be of type String, and provides a name to be used for
7071 the task instance when the task is created.  Note that this expression
7072 is not required to be static, and in particular, it can contain
7073 references to task discriminants.  This facility can be used to
7074 provide different names for different tasks as they are created,
7075 as illustrated in the example below.
7077 The task name is recorded internally in the run-time structures
7078 and is accessible to tools like the debugger.  In addition the
7079 routine @code{Ada.Task_Identification.Image} will return this
7080 string, with a unique task address appended.
7082 @smallexample @c ada
7083 --  Example of the use of pragma Task_Name
7085 with Ada.Task_Identification;
7086 use Ada.Task_Identification;
7087 with Text_IO; use Text_IO;
7088 procedure t3 is
7090    type Astring is access String;
7092    task type Task_Typ (Name : access String) is
7093       pragma Task_Name (Name.all);
7094    end Task_Typ;
7096    task body Task_Typ is
7097       Nam : constant String := Image (Current_Task);
7098    begin
7099       Put_Line ("-->" & Nam (1 .. 14) & "<--");
7100    end Task_Typ;
7102    type Ptr_Task is access Task_Typ;
7103    Task_Var : Ptr_Task;
7105 begin
7106    Task_Var :=
7107      new Task_Typ (new String'("This is task 1"));
7108    Task_Var :=
7109      new Task_Typ (new String'("This is task 2"));
7110 end;
7111 @end smallexample
7113 @node Pragma Task_Storage
7114 @unnumberedsec Pragma Task_Storage
7115 @findex Task_Storage
7116 Syntax:
7118 @smallexample @c ada
7119 pragma Task_Storage (
7120   [Task_Type =>] LOCAL_NAME,
7121   [Top_Guard =>] static_integer_EXPRESSION);
7122 @end smallexample
7124 @noindent
7125 This pragma specifies the length of the guard area for tasks.  The guard
7126 area is an additional storage area allocated to a task.  A value of zero
7127 means that either no guard area is created or a minimal guard area is
7128 created, depending on the target.  This pragma can appear anywhere a
7129 @code{Storage_Size} attribute definition clause is allowed for a task
7130 type.
7132 @node Pragma Test_Case
7133 @unnumberedsec Pragma Test_Case
7134 @cindex Test cases
7135 @findex Test_Case
7136 @noindent
7137 Syntax:
7139 @smallexample @c ada
7140 pragma Test_Case (
7141    [Name     =>] static_string_Expression
7142   ,[Mode     =>] (Nominal | Robustness)
7143  [, Requires =>  Boolean_Expression]
7144  [, Ensures  =>  Boolean_Expression]);
7145 @end smallexample
7147 @noindent
7148 The @code{Test_Case} pragma allows defining fine-grain specifications
7149 for use by testing tools.
7150 The compiler checks the validity of the @code{Test_Case} pragma, but its
7151 presence does not lead to any modification of the code generated by the
7152 compiler.
7154 @code{Test_Case} pragmas may only appear immediately following the
7155 (separate) declaration of a subprogram in a package declaration, inside
7156 a package spec unit. Only other pragmas may intervene (that is appear
7157 between the subprogram declaration and a test case).
7159 The compiler checks that boolean expressions given in @code{Requires} and
7160 @code{Ensures} are valid, where the rules for @code{Requires} are the
7161 same as the rule for an expression in @code{Precondition} and the rules
7162 for @code{Ensures} are the same as the rule for an expression in
7163 @code{Postcondition}. In particular, attributes @code{'Old} and
7164 @code{'Result} can only be used within the @code{Ensures}
7165 expression. The following is an example of use within a package spec:
7167 @smallexample @c ada
7168 package Math_Functions is
7169    ...
7170    function Sqrt (Arg : Float) return Float;
7171    pragma Test_Case (Name     => "Test 1",
7172                      Mode     => Nominal,
7173                      Requires => Arg < 10000,
7174                      Ensures  => Sqrt'Result < 10);
7175    ...
7176 end Math_Functions;
7177 @end smallexample
7179 @noindent
7180 The meaning of a test case is that there is at least one context where
7181 @code{Requires} holds such that, if the associated subprogram is executed in
7182 that context, then @code{Ensures} holds when the subprogram returns.
7183 Mode @code{Nominal} indicates that the input context should also satisfy the
7184 precondition of the subprogram, and the output context should also satisfy its
7185 postcondition. Mode @code{Robustness} indicates that the precondition and
7186 postcondition of the subprogram should be ignored for this test case.
7188 @node Pragma Thread_Local_Storage
7189 @unnumberedsec Pragma Thread_Local_Storage
7190 @findex Thread_Local_Storage
7191 @cindex Task specific storage
7192 @cindex TLS (Thread Local Storage)
7193 @cindex Task_Attributes
7194 Syntax:
7196 @smallexample @c ada
7197 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
7198 @end smallexample
7200 @noindent
7201 This pragma specifies that the specified entity, which must be
7202 a variable declared in a library level package, is to be marked as
7203 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
7204 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
7205 (and hence each Ada task) to see a distinct copy of the variable.
7207 The variable may not have default initialization, and if there is
7208 an explicit initialization, it must be either @code{null} for an
7209 access variable, or a static expression for a scalar variable.
7210 This provides a low level mechanism similar to that provided by
7211 the @code{Ada.Task_Attributes} package, but much more efficient
7212 and is also useful in writing interface code that will interact
7213 with foreign threads.
7215 If this pragma is used on a system where @code{TLS} is not supported,
7216 then an error message will be generated and the program will be rejected.
7218 @node Pragma Time_Slice
7219 @unnumberedsec Pragma Time_Slice
7220 @findex Time_Slice
7221 @noindent
7222 Syntax:
7224 @smallexample @c ada
7225 pragma Time_Slice (static_duration_EXPRESSION);
7226 @end smallexample
7228 @noindent
7229 For implementations of GNAT on operating systems where it is possible
7230 to supply a time slice value, this pragma may be used for this purpose.
7231 It is ignored if it is used in a system that does not allow this control,
7232 or if it appears in other than the main program unit.
7233 @cindex OpenVMS
7234 Note that the effect of this pragma is identical to the effect of the
7235 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
7237 @node Pragma Title
7238 @unnumberedsec Pragma Title
7239 @findex Title
7240 @noindent
7241 Syntax:
7243 @smallexample @c ada
7244 pragma Title (TITLING_OPTION [, TITLING OPTION]);
7246 TITLING_OPTION ::=
7247   [Title    =>] STRING_LITERAL,
7248 | [Subtitle =>] STRING_LITERAL
7249 @end smallexample
7251 @noindent
7252 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
7253 pragma used in DEC Ada 83 implementations to provide a title and/or
7254 subtitle for the program listing.  The program listing generated by GNAT
7255 does not have titles or subtitles.
7257 Unlike other pragmas, the full flexibility of named notation is allowed
7258 for this pragma, i.e.@: the parameters may be given in any order if named
7259 notation is used, and named and positional notation can be mixed
7260 following the normal rules for procedure calls in Ada.
7262 @node Pragma Type_Invariant
7263 @unnumberedsec Pragma Type_Invariant
7264 @findex Invariant
7265 @findex Type_Invariant pragma
7266 @noindent
7267 Syntax:
7269 @smallexample @c ada
7270 pragma Type_Invariant
7271   ([Entity =>] type_LOCAL_NAME,
7272    [Check  =>] EXPRESSION);
7273 @end smallexample
7275 @noindent
7276 The @code{Type_Invariant} pragma is intended to be an exact
7277 replacement for the language-defined @code{Type_Invariant}
7278 aspect, and shares its restrictions and semantics. It differs
7279 from the language defined @code{Invariant} pragma in that it
7280 does not permit a string parameter, and it is
7281 controlled by the assertion identifier @code{Type_Invariant}
7282 rather than @code{Invariant}.
7284 @node Pragma Type_Invariant_Class
7285 @unnumberedsec Pragma Type_Invariant_Class
7286 @findex Invariant
7287 @findex Type_Invariant_Class pragma
7288 @noindent
7289 Syntax:
7291 @smallexample @c ada
7292 pragma Type_Invariant_Class
7293   ([Entity =>] type_LOCAL_NAME,
7294    [Check  =>] EXPRESSION);
7295 @end smallexample
7297 @noindent
7298 The @code{Type_Invariant_Class} pragma is intended to be an exact
7299 replacement for the language-defined @code{Type_Invariant'Class}
7300 aspect, and shares its restrictions and semantics.
7302 Note: This pragma is called @code{Type_Invariant_Class} rather than
7303 @code{Type_Invariant'Class} because the latter would not be strictly
7304 conforming to the allowed syntax for pragmas. The motivation
7305 for providing pragmas equivalent to the aspects is to allow a program
7306 to be written using the pragmas, and then compiled if necessary
7307 using an Ada compiler that does not recognize the pragmas or
7308 aspects, but is prepared to ignore the pragmas. The assertion
7309 policy that controls this pragma is @code{Type_Invariant'Class},
7310 not @code{Type_Invariant_Class}.
7312 @node Pragma Unchecked_Union
7313 @unnumberedsec Pragma Unchecked_Union
7314 @cindex Unions in C
7315 @findex Unchecked_Union
7316 @noindent
7317 Syntax:
7319 @smallexample @c ada
7320 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
7321 @end smallexample
7323 @noindent
7324 This pragma is used to specify a representation of a record type that is
7325 equivalent to a C union. It was introduced as a GNAT implementation defined
7326 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
7327 pragma, making it language defined, and GNAT fully implements this extended
7328 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
7329 details, consult the Ada 2012 Reference Manual, section B.3.3.
7331 @node Pragma Unevaluated_Use_Of_Old
7332 @unnumberedsec Pragma Unevaluated_Use_Of_Old
7333 @cindex Attribute Old
7334 @cindex Attribute Loop_Entry
7335 @cindex Unevaluated_Use_Of_Old
7336 @findex Unevaluated_Use_Of_Old
7337 @noindent
7338 Syntax:
7340 @smallexample @c ada
7341 pragma Unevaluated_Use_Of_Old (Error | Warn | Allow);
7342 @end smallexample
7344 @noindent
7345 This pragma controls the processing of attributes Old and Loop_Entry.
7346 If either of these attributes is used in a potentially unevaluated
7347 expression  (e.g. the then or else parts of an if expression), then
7348 normally this usage is considered illegal if the prefix of the attribute
7349 is other than an entity name. The language requires this
7350 behavior for Old, and GNAT copies the same rule for Loop_Entry.
7352 The reason for this rule is that otherwise, we can have a situation
7353 where we save the Old value, and this results in an exception, even
7354 though we might not evaluate the attribute. Consider this example:
7356 @smallexample @c ada
7357 package UnevalOld is
7358    K : Character;
7359    procedure U (A : String; C : Boolean)  -- ERROR
7360      with Post => (if C then A(1)'Old = K else True);
7361 end;
7362 @end smallexample
7364 @noindent
7365 If procedure U is called with a string with a lower bound of 2, and
7366 C false, then an exception would be raised trying to evaluate A(1)
7367 on entry even though the value would not be actually used.
7369 Although the rule guarantees against this possibility, it is sometimes
7370 too restrictive. For example if we know that the string has a lower
7371 bound of 1, then we will never raise an exception.
7372 The pragma @code{Unevaluated_Use_Of_Old} can be
7373 used to modify this behavior. If the argument is @code{Error} then an
7374 error is given (this is the default RM behavior). If the argument is
7375 @code{Warn} then the usage is allowed as legal but with a warning
7376 that an exception might be raised. If the argument is @code{Allow}
7377 then the usage is allowed as legal without generating a warning.
7379 This pragma may appear as a configuration pragma, or in a declarative
7380 part or package specification. In the latter case it applies to
7381 uses up to the end of the corresponding statement sequence or
7382 sequence of package declarations.
7384 @node Pragma Unimplemented_Unit
7385 @unnumberedsec Pragma Unimplemented_Unit
7386 @findex Unimplemented_Unit
7387 @noindent
7388 Syntax:
7390 @smallexample @c ada
7391 pragma Unimplemented_Unit;
7392 @end smallexample
7394 @noindent
7395 If this pragma occurs in a unit that is processed by the compiler, GNAT
7396 aborts with the message @samp{@var{xxx} not implemented}, where
7397 @var{xxx} is the name of the current compilation unit.  This pragma is
7398 intended to allow the compiler to handle unimplemented library units in
7399 a clean manner.
7401 The abort only happens if code is being generated.  Thus you can use
7402 specs of unimplemented packages in syntax or semantic checking mode.
7404 @node Pragma Universal_Aliasing
7405 @unnumberedsec Pragma Universal_Aliasing
7406 @findex Universal_Aliasing
7407 @noindent
7408 Syntax:
7410 @smallexample @c ada
7411 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
7412 @end smallexample
7414 @noindent
7415 @var{type_LOCAL_NAME} must refer to a type declaration in the current
7416 declarative part.  The effect is to inhibit strict type-based aliasing
7417 optimization for the given type.  In other words, the effect is as though
7418 access types designating this type were subject to pragma No_Strict_Aliasing.
7419 For a detailed description of the strict aliasing optimization, and the
7420 situations in which it must be suppressed, @xref{Optimization and Strict
7421 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
7423 @node Pragma Universal_Data
7424 @unnumberedsec Pragma Universal_Data
7425 @findex Universal_Data
7426 @noindent
7427 Syntax:
7429 @smallexample @c ada
7430 pragma Universal_Data [(library_unit_Name)];
7431 @end smallexample
7433 @noindent
7434 This pragma is supported only for the AAMP target and is ignored for
7435 other targets. The pragma specifies that all library-level objects
7436 (Counter 0 data) associated with the library unit are to be accessed
7437 and updated using universal addressing (24-bit addresses for AAMP5)
7438 rather than the default of 16-bit Data Environment (DENV) addressing.
7439 Use of this pragma will generally result in less efficient code for
7440 references to global data associated with the library unit, but
7441 allows such data to be located anywhere in memory. This pragma is
7442 a library unit pragma, but can also be used as a configuration pragma
7443 (including use in the @file{gnat.adc} file). The functionality
7444 of this pragma is also available by applying the -univ switch on the
7445 compilations of units where universal addressing of the data is desired.
7447 @node Pragma Unmodified
7448 @unnumberedsec Pragma Unmodified
7449 @findex Unmodified
7450 @cindex Warnings, unmodified
7451 @noindent
7452 Syntax:
7454 @smallexample @c ada
7455 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
7456 @end smallexample
7458 @noindent
7459 This pragma signals that the assignable entities (variables,
7460 @code{out} parameters, @code{in out} parameters) whose names are listed are
7461 deliberately not assigned in the current source unit. This
7462 suppresses warnings about the
7463 entities being referenced but not assigned, and in addition a warning will be
7464 generated if one of these entities is in fact assigned in the
7465 same unit as the pragma (or in the corresponding body, or one
7466 of its subunits).
7468 This is particularly useful for clearly signaling that a particular
7469 parameter is not modified, even though the spec suggests that it might
7472 For the variable case, warnings are never given for unreferenced variables
7473 whose name contains one of the substrings
7474 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7475 are typically to be used in cases where such warnings are expected.
7476 Thus it is never necessary to use @code{pragma Unmodified} for such
7477 variables, though it is harmless to do so.
7479 @node Pragma Unreferenced
7480 @unnumberedsec Pragma Unreferenced
7481 @findex Unreferenced
7482 @cindex Warnings, unreferenced
7483 @noindent
7484 Syntax:
7486 @smallexample @c ada
7487 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
7488 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
7489 @end smallexample
7491 @noindent
7492 This pragma signals that the entities whose names are listed are
7493 deliberately not referenced in the current source unit after the
7494 occurrence of the pragma. This
7495 suppresses warnings about the
7496 entities being unreferenced, and in addition a warning will be
7497 generated if one of these entities is in fact subsequently referenced in the
7498 same unit as the pragma (or in the corresponding body, or one
7499 of its subunits).
7501 This is particularly useful for clearly signaling that a particular
7502 parameter is not referenced in some particular subprogram implementation
7503 and that this is deliberate. It can also be useful in the case of
7504 objects declared only for their initialization or finalization side
7505 effects.
7507 If @code{LOCAL_NAME} identifies more than one matching homonym in the
7508 current scope, then the entity most recently declared is the one to which
7509 the pragma applies. Note that in the case of accept formals, the pragma
7510 Unreferenced may appear immediately after the keyword @code{do} which
7511 allows the indication of whether or not accept formals are referenced
7512 or not to be given individually for each accept statement.
7514 The left hand side of an assignment does not count as a reference for the
7515 purpose of this pragma. Thus it is fine to assign to an entity for which
7516 pragma Unreferenced is given.
7518 Note that if a warning is desired for all calls to a given subprogram,
7519 regardless of whether they occur in the same unit as the subprogram
7520 declaration, then this pragma should not be used (calls from another
7521 unit would not be flagged); pragma Obsolescent can be used instead
7522 for this purpose, see @xref{Pragma Obsolescent}.
7524 The second form of pragma @code{Unreferenced} is used within a context
7525 clause. In this case the arguments must be unit names of units previously
7526 mentioned in @code{with} clauses (similar to the usage of pragma
7527 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
7528 units and unreferenced entities within these units.
7530 For the variable case, warnings are never given for unreferenced variables
7531 whose name contains one of the substrings
7532 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7533 are typically to be used in cases where such warnings are expected.
7534 Thus it is never necessary to use @code{pragma Unreferenced} for such
7535 variables, though it is harmless to do so.
7537 @node Pragma Unreferenced_Objects
7538 @unnumberedsec Pragma Unreferenced_Objects
7539 @findex Unreferenced_Objects
7540 @cindex Warnings, unreferenced
7541 @noindent
7542 Syntax:
7544 @smallexample @c ada
7545 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
7546 @end smallexample
7548 @noindent
7549 This pragma signals that for the types or subtypes whose names are
7550 listed, objects which are declared with one of these types or subtypes may
7551 not be referenced, and if no references appear, no warnings are given.
7553 This is particularly useful for objects which are declared solely for their
7554 initialization and finalization effect. Such variables are sometimes referred
7555 to as RAII variables (Resource Acquisition Is Initialization). Using this
7556 pragma on the relevant type (most typically a limited controlled type), the
7557 compiler will automatically suppress unwanted warnings about these variables
7558 not being referenced.
7560 @node Pragma Unreserve_All_Interrupts
7561 @unnumberedsec Pragma Unreserve_All_Interrupts
7562 @findex Unreserve_All_Interrupts
7563 @noindent
7564 Syntax:
7566 @smallexample @c ada
7567 pragma Unreserve_All_Interrupts;
7568 @end smallexample
7570 @noindent
7571 Normally certain interrupts are reserved to the implementation.  Any attempt
7572 to attach an interrupt causes Program_Error to be raised, as described in
7573 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
7574 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
7575 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
7576 interrupt execution.
7578 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
7579 a program, then all such interrupts are unreserved.  This allows the
7580 program to handle these interrupts, but disables their standard
7581 functions.  For example, if this pragma is used, then pressing
7582 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
7583 a program can then handle the @code{SIGINT} interrupt as it chooses.
7585 For a full list of the interrupts handled in a specific implementation,
7586 see the source code for the spec of @code{Ada.Interrupts.Names} in
7587 file @file{a-intnam.ads}.  This is a target dependent file that contains the
7588 list of interrupts recognized for a given target.  The documentation in
7589 this file also specifies what interrupts are affected by the use of
7590 the @code{Unreserve_All_Interrupts} pragma.
7592 For a more general facility for controlling what interrupts can be
7593 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
7594 of the @code{Unreserve_All_Interrupts} pragma.
7596 @node Pragma Unsuppress
7597 @unnumberedsec Pragma Unsuppress
7598 @findex Unsuppress
7599 @noindent
7600 Syntax:
7602 @smallexample @c ada
7603 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
7604 @end smallexample
7606 @noindent
7607 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
7608 there is no corresponding pragma @code{Suppress} in effect, it has no
7609 effect.  The range of the effect is the same as for pragma
7610 @code{Suppress}.  The meaning of the arguments is identical to that used
7611 in pragma @code{Suppress}.
7613 One important application is to ensure that checks are on in cases where
7614 code depends on the checks for its correct functioning, so that the code
7615 will compile correctly even if the compiler switches are set to suppress
7616 checks. For example, in a program that depends on external names of tagged
7617 types and wants to ensure that the duplicated tag check occurs even if all
7618 run-time checks are suppressed by a compiler switch, the following
7619 configuration pragma will ensure this test is not suppressed:
7621 @smallexample @c ada
7622 pragma Unsuppress (Duplicated_Tag_Check);
7623 @end smallexample
7625 @noindent
7626 This pragma is standard in Ada 2005. It is available in all earlier versions
7627 of Ada as an implementation-defined pragma.
7629 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
7630 a number of implementation-defined check names. See description of pragma
7631 @code{Suppress} for full details.
7633 @node Pragma Use_VADS_Size
7634 @unnumberedsec Pragma Use_VADS_Size
7635 @cindex @code{Size}, VADS compatibility
7636 @cindex Rational profile
7637 @findex Use_VADS_Size
7638 @noindent
7639 Syntax:
7641 @smallexample @c ada
7642 pragma Use_VADS_Size;
7643 @end smallexample
7645 @noindent
7646 This is a configuration pragma.  In a unit to which it applies, any use
7647 of the 'Size attribute is automatically interpreted as a use of the
7648 'VADS_Size attribute.  Note that this may result in incorrect semantic
7649 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
7650 the handling of existing code which depends on the interpretation of Size
7651 as implemented in the VADS compiler.  See description of the VADS_Size
7652 attribute for further details.
7654 @node Pragma Validity_Checks
7655 @unnumberedsec Pragma Validity_Checks
7656 @findex Validity_Checks
7657 @noindent
7658 Syntax:
7660 @smallexample @c ada
7661 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
7662 @end smallexample
7664 @noindent
7665 This pragma is used in conjunction with compiler switches to control the
7666 built-in validity checking provided by GNAT@.  The compiler switches, if set
7667 provide an initial setting for the switches, and this pragma may be used
7668 to modify these settings, or the settings may be provided entirely by
7669 the use of the pragma.  This pragma can be used anywhere that a pragma
7670 is legal, including use as a configuration pragma (including use in
7671 the @file{gnat.adc} file).
7673 The form with a string literal specifies which validity options are to be
7674 activated.  The validity checks are first set to include only the default
7675 reference manual settings, and then a string of letters in the string
7676 specifies the exact set of options required.  The form of this string
7677 is exactly as described for the @option{-gnatVx} compiler switch (see the
7678 @value{EDITION} User's Guide for details).  For example the following two
7679 methods can be used to enable validity checking for mode @code{in} and
7680 @code{in out} subprogram parameters:
7682 @itemize @bullet
7683 @item
7684 @smallexample @c ada
7685 pragma Validity_Checks ("im");
7686 @end smallexample
7688 @item
7689 @smallexample
7690 gcc -c -gnatVim @dots{}
7691 @end smallexample
7692 @end itemize
7694 @noindent
7695 The form ALL_CHECKS activates all standard checks (its use is equivalent
7696 to the use of the @code{gnatva} switch.
7698 The forms with @code{Off} and @code{On}
7699 can be used to temporarily disable validity checks
7700 as shown in the following example:
7702 @smallexample @c ada
7703 @iftex
7704 @leftskip=0cm
7705 @end iftex
7706 pragma Validity_Checks ("c"); -- validity checks for copies
7707 pragma Validity_Checks (Off); -- turn off validity checks
7708 A := B;                       -- B will not be validity checked
7709 pragma Validity_Checks (On);  -- turn validity checks back on
7710 A := C;                       -- C will be validity checked
7711 @end smallexample
7713 @node Pragma Volatile
7714 @unnumberedsec Pragma Volatile
7715 @findex Volatile
7716 @noindent
7717 Syntax:
7719 @smallexample @c ada
7720 pragma Volatile (LOCAL_NAME);
7721 @end smallexample
7723 @noindent
7724 This pragma is defined by the Ada Reference Manual, and the GNAT
7725 implementation is fully conformant with this definition.  The reason it
7726 is mentioned in this section is that a pragma of the same name was supplied
7727 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
7728 implementation of pragma Volatile is upwards compatible with the
7729 implementation in DEC Ada 83.
7731 @node Pragma Warning_As_Error
7732 @unnumberedsec Pragma Warning_As_Error
7733 @findex Warning_As_Error
7734 @noindent
7735 Syntax:
7737 @smallexample @c ada
7738 pragma Warning_As_Error (static_string_EXPRESSION);
7739 @end smallexample
7741 @noindent
7742 This configuration pragma allows the programmer to specify a set
7743 of warnings that will be treated as errors. Any warning which
7744 matches the pattern given by the pragma argument will be treated
7745 as an error. This gives much more precise control that -gnatwe
7746 which treats all warnings as errors.
7748 The pattern may contain asterisks, which match zero or more characters in
7749 the message. For example, you can use
7750 @code{pragma Warning_As_Error ("bits of*unused")} to treat the warning
7751 message @code{warning: 960 bits of "a" unused} as an error. No other regular
7752 expression notations are permitted. All characters other than asterisk in
7753 these three specific cases are treated as literal characters in the match.
7754 The match is case insensitive, for example XYZ matches xyz.
7756 Note that the pattern matches if it occurs anywhere within the warning
7757 message string (it is not necessary to put an asterisk at the start and
7758 the end of the message, since this is implied).
7760 Another possibility for the static_string_EXPRESSION which works whether
7761 or not error tags are enabled (@option{-gnatw.d}) is to use the
7762 @option{-gnatw} tag string, enclosed in brackets,
7763 as shown in the example below, to treat a class of warnings as errors.
7765 The above use of patterns to match the message applies only to warning
7766 messages generated by the front end. This pragma can also be applied to
7767 warnings provided by the back end and mentioned in @ref{Pragma Warnings}.
7768 By using a single full @option{-Wxxx} switch in the pragma, such warnings
7769 can also be treated as errors.
7771 The pragma can appear either in a global configuration pragma file
7772 (e.g. @file{gnat.adc}), or at the start of a file. Given a global
7773 configuration pragma file containing:
7775 @smallexample @c ada
7776 pragma Warning_As_Error ("[-gnatwj]");
7777 @end smallexample
7779 @noindent
7780 which will treat all obsolescent feature warnings as errors, the
7781 following program compiles as shown (compile options here are
7782 @option{-gnatwa.d -gnatl -gnatj55}).
7784 @smallexample @c ada
7785      1. pragma Warning_As_Error ("*never assigned*");
7786      2. function Warnerr return String is
7787      3.    X : Integer;
7788            |
7789         >>> error: variable "X" is never read and
7790             never assigned [-gnatwv] [warning-as-error]
7792      4.    Y : Integer;
7793            |
7794         >>> warning: variable "Y" is assigned but
7795             never read [-gnatwu]
7797      5. begin
7798      6.    Y := 0;
7799      7.    return %ABC%;
7800                   |
7801         >>> error: use of "%" is an obsolescent
7802             feature (RM J.2(4)), use """ instead
7803             [-gnatwj] [warning-as-error]
7805      8. end;
7807  8 lines: No errors, 3 warnings (2 treated as errors)
7808 @end smallexample
7810 @noindent
7811 Note that this pragma does not affect the set of warnings issued in
7812 any way, it merely changes the effect of a matching warning if one
7813 is produced as a result of other warnings options. As shown in this
7814 example, if the pragma results in a warning being treated as an error,
7815 the tag is changed from "warning:" to "error:" and the string
7816 "[warning-as-error]" is appended to the end of the message.
7818 @node Pragma Warnings
7819 @unnumberedsec Pragma Warnings
7820 @findex Warnings
7821 @noindent
7822 Syntax:
7824 @smallexample @c ada
7825 pragma Warnings (On | Off [,REASON]);
7826 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
7827 pragma Warnings (static_string_EXPRESSION [,REASON]);
7828 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
7830 REASON ::= Reason => STRING_LITERAL @{& STRING_LITERAL@}
7831 @end smallexample
7833 @noindent
7834 Normally warnings are enabled, with the output being controlled by
7835 the command line switch.  Warnings (@code{Off}) turns off generation of
7836 warnings until a Warnings (@code{On}) is encountered or the end of the
7837 current unit.  If generation of warnings is turned off using this
7838 pragma, then some or all of the warning messages are suppressed,
7839 regardless of the setting of the command line switches.
7841 The @code{Reason} parameter may optionally appear as the last argument
7842 in any of the forms of this pragma. It is intended purely for the
7843 purposes of documenting the reason for the @code{Warnings} pragma.
7844 The compiler will check that the argument is a static string but
7845 otherwise ignore this argument. Other tools may provide specialized
7846 processing for this string.
7848 The form with a single argument (or two arguments if Reason present),
7849 where the first argument is @code{ON} or @code{OFF}
7850 may be used as a configuration pragma.
7852 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
7853 the specified entity.  This suppression is effective from the point where
7854 it occurs till the end of the extended scope of the variable (similar to
7855 the scope of @code{Suppress}). This form cannot be used as a configuration
7856 pragma.
7858 In the case where the first argument is other than @code{ON} or
7859 @code{OFF},
7860 the third form with a single static_string_EXPRESSION argument (and possible
7861 reason) provides more precise
7862 control over which warnings are active. The string is a list of letters
7863 specifying which warnings are to be activated and which deactivated. The
7864 code for these letters is the same as the string used in the command
7865 line switch controlling warnings. For a brief summary, use the gnatmake
7866 command with no arguments, which will generate usage information containing
7867 the list of warnings switches supported. For
7868 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
7869 User's Guide}. This form can also be used as a configuration pragma.
7871 @noindent
7872 The warnings controlled by the @option{-gnatw} switch are generated by the
7873 front end of the compiler. The GCC back end can provide additional warnings
7874 and they are controlled by the @option{-W} switch. Such warnings can be
7875 identified by the appearance of a string of the form @code{[-Wxxx]} in the
7876 message which designates the @option{-Wxxx} switch that controls the message.
7877 The form with a single static_string_EXPRESSION argument also works for these
7878 warnings, but the string must be a single full @option{-Wxxx} switch in this
7879 case. The above reference lists a few examples of these additional warnings.
7881 @noindent
7882 The specified warnings will be in effect until the end of the program
7883 or another pragma Warnings is encountered. The effect of the pragma is
7884 cumulative. Initially the set of warnings is the standard default set
7885 as possibly modified by compiler switches. Then each pragma Warning
7886 modifies this set of warnings as specified. This form of the pragma may
7887 also be used as a configuration pragma.
7889 The fourth form, with an @code{On|Off} parameter and a string, is used to
7890 control individual messages, based on their text. The string argument
7891 is a pattern that is used to match against the text of individual
7892 warning messages (not including the initial "warning: " tag).
7894 The pattern may contain asterisks, which match zero or more characters in
7895 the message. For example, you can use
7896 @code{pragma Warnings (Off, "bits of*unused")} to suppress the warning
7897 message @code{warning: 960 bits of "a" unused}. No other regular
7898 expression notations are permitted. All characters other than asterisk in
7899 these three specific cases are treated as literal characters in the match.
7900 The match is case insensitive, for example XYZ matches xyz.
7902 Note that the pattern matches if it occurs anywhere within the warning
7903 message string (it is not necessary to put an asterisk at the start and
7904 the end of the message, since this is implied).
7906 The above use of patterns to match the message applies only to warning
7907 messages generated by the front end. This form of the pragma with a string
7908 argument can also be used to control warnings provided by the back end and
7909 mentioned above. By using a single full @option{-Wxxx} switch in the pragma,
7910 such warnings can be turned on and off.
7912 There are two ways to use the pragma in this form. The OFF form can be used
7913 as a configuration pragma. The effect is to suppress all warnings (if any)
7914 that match the pattern string throughout the compilation (or match the
7915 -W switch in the back end case).
7917 The second usage is to suppress a warning locally, and in this case, two
7918 pragmas must appear in sequence:
7920 @smallexample @c ada
7921 pragma Warnings (Off, Pattern);
7922 @dots{} code where given warning is to be suppressed
7923 pragma Warnings (On, Pattern);
7924 @end smallexample
7926 @noindent
7927 In this usage, the pattern string must match in the Off and On pragmas,
7928 and at least one matching warning must be suppressed.
7930 Note: to write a string that will match any warning, use the string
7931 @code{"***"}. It will not work to use a single asterisk or two asterisks
7932 since this looks like an operator name. This form with three asterisks
7933 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
7934 matching @code{pragma Warnings (On, "***")} will be required. This can be
7935 helpful in avoiding forgetting to turn warnings back on.
7937 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7938 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7939 be useful in checking whether obsolete pragmas in existing programs are hiding
7940 real problems.
7942 Note: pragma Warnings does not affect the processing of style messages. See
7943 separate entry for pragma Style_Checks for control of style messages.
7945 @node Pragma Weak_External
7946 @unnumberedsec Pragma Weak_External
7947 @findex Weak_External
7948 @noindent
7949 Syntax:
7951 @smallexample @c ada
7952 pragma Weak_External ([Entity =>] LOCAL_NAME);
7953 @end smallexample
7955 @noindent
7956 @var{LOCAL_NAME} must refer to an object that is declared at the library
7957 level. This pragma specifies that the given entity should be marked as a
7958 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
7959 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
7960 of a regular symbol, that is to say a symbol that does not have to be
7961 resolved by the linker if used in conjunction with a pragma Import.
7963 When a weak symbol is not resolved by the linker, its address is set to
7964 zero. This is useful in writing interfaces to external modules that may
7965 or may not be linked in the final executable, for example depending on
7966 configuration settings.
7968 If a program references at run time an entity to which this pragma has been
7969 applied, and the corresponding symbol was not resolved at link time, then
7970 the execution of the program is erroneous. It is not erroneous to take the
7971 Address of such an entity, for example to guard potential references,
7972 as shown in the example below.
7974 Some file formats do not support weak symbols so not all target machines
7975 support this pragma.
7977 @smallexample @c ada
7978 --  Example of the use of pragma Weak_External
7980 package External_Module is
7981   key : Integer;
7982   pragma Import (C, key);
7983   pragma Weak_External (key);
7984   function Present return boolean;
7985 end External_Module;
7987 with System; use System;
7988 package body External_Module is
7989   function Present return boolean is
7990   begin
7991     return key'Address /= System.Null_Address;
7992   end Present;
7993 end External_Module;
7994 @end smallexample
7996 @node Pragma Wide_Character_Encoding
7997 @unnumberedsec Pragma Wide_Character_Encoding
7998 @findex Wide_Character_Encoding
7999 @noindent
8000 Syntax:
8002 @smallexample @c ada
8003 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
8004 @end smallexample
8006 @noindent
8007 This pragma specifies the wide character encoding to be used in program
8008 source text appearing subsequently. It is a configuration pragma, but may
8009 also be used at any point that a pragma is allowed, and it is permissible
8010 to have more than one such pragma in a file, allowing multiple encodings
8011 to appear within the same file.
8013 The argument can be an identifier or a character literal. In the identifier
8014 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
8015 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
8016 case it is correspondingly one of the characters @samp{h}, @samp{u},
8017 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
8019 Note that when the pragma is used within a file, it affects only the
8020 encoding within that file, and does not affect withed units, specs,
8021 or subunits.
8023 @node Implementation Defined Aspects
8024 @chapter Implementation Defined Aspects
8025 Ada defines (throughout the Ada 2012 reference manual, summarized
8026 in Annex K) a set of aspects that can be specified for certain entities.
8027 These language defined aspects are implemented in GNAT in Ada 2012 mode
8028 and work as described in the Ada 2012 Reference Manual.
8030 In addition, Ada 2012 allows implementations to define additional aspects
8031 whose meaning is defined by the implementation.  GNAT provides
8032 a number of these implementation-defined aspects which can be used
8033 to extend and enhance the functionality of the compiler.  This section of
8034 the GNAT reference manual describes these additional aspects.
8036 Note that any program using these aspects may not be portable to
8037 other compilers (although GNAT implements this set of aspects on all
8038 platforms).  Therefore if portability to other compilers is an important
8039 consideration, you should minimize the use of these aspects.
8041 Note that for many of these aspects, the effect is essentially similar
8042 to the use of a pragma or attribute specification with the same name
8043 applied to the entity. For example, if we write:
8045 @smallexample @c ada
8046 type R is range 1 .. 100
8047   with Value_Size => 10;
8048 @end smallexample
8050 @noindent
8051 then the effect is the same as:
8053 @smallexample @c ada
8054 type R is range 1 .. 100;
8055 for R'Value_Size use 10;
8056 @end smallexample
8058 @noindent
8059 and if we write:
8061 @smallexample @c ada
8062 type R is new Integer
8063   with Shared => True;
8064 @end smallexample
8066 @noindent
8067 then the effect is the same as:
8069 @smallexample @c ada
8070 type R is new Integer;
8071 pragma Shared (R);
8072 @end smallexample
8074 @noindent
8075 In the documentation below, such cases are simply marked
8076 as being equivalent to the corresponding pragma or attribute definition
8077 clause.
8079 @menu
8080 * Aspect Abstract_State::
8081 * Aspect Annotate::
8082 * Aspect Async_Readers::
8083 * Aspect Async_Writers::
8084 * Aspect Contract_Cases::
8085 * Aspect Depends::
8086 * Aspect Dimension::
8087 * Aspect Dimension_System::
8088 * Aspect Effective_Reads::
8089 * Aspect Effective_Writes::
8090 * Aspect Favor_Top_Level::
8091 * Aspect Global::
8092 * Aspect Initial_Condition::
8093 * Aspect Initializes::
8094 * Aspect Inline_Always::
8095 * Aspect Invariant::
8096 * Aspect Invariant'Class::
8097 * Aspect Iterable::
8098 * Aspect Linker_Section::
8099 * Aspect Lock_Free::
8100 * Aspect No_Elaboration_Code_All::
8101 * Aspect Object_Size::
8102 * Aspect Obsolescent::
8103 * Aspect Part_Of::
8104 * Aspect Persistent_BSS::
8105 * Aspect Predicate::
8106 * Aspect Pure_Function::
8107 * Aspect Refined_Depends::
8108 * Aspect Refined_Global::
8109 * Aspect Refined_Post::
8110 * Aspect Refined_State::
8111 * Aspect Remote_Access_Type::
8112 * Aspect Scalar_Storage_Order::
8113 * Aspect Shared::
8114 * Aspect Simple_Storage_Pool::
8115 * Aspect Simple_Storage_Pool_Type::
8116 * Aspect SPARK_Mode::
8117 * Aspect Suppress_Debug_Info::
8118 * Aspect Test_Case::
8119 * Aspect Thread_Local_Storage::
8120 * Aspect Universal_Aliasing::
8121 * Aspect Universal_Data::
8122 * Aspect Unmodified::
8123 * Aspect Unreferenced::
8124 * Aspect Unreferenced_Objects::
8125 * Aspect Value_Size::
8126 * Aspect Warnings::
8127 @end menu
8129 @node Aspect Abstract_State
8130 @unnumberedsec Aspect Abstract_State
8131 @findex Abstract_State
8132 @noindent
8133 This aspect is equivalent to pragma @code{Abstract_State}.
8135 @node Aspect Annotate
8136 @unnumberedsec Annotate
8137 @findex Annotate
8138 @noindent
8139 There are three forms of this aspect (where ID is an identifier,
8140 and ARG is a general expression).
8142 @table @code
8143 @item Annotate => ID
8144 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
8146 @item Annotate => (ID)
8147 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
8149 @item Annotate => (ID ,ID @{, ARG@})
8150 Equivalent to @code{pragma Annotate (ID, ID @{, ARG@}, Entity => Name);}
8151 @end table
8153 @node Aspect Async_Readers
8154 @unnumberedsec Aspect Async_Readers
8155 @findex Async_Readers
8156 @noindent
8157 This aspect is equivalent to pragma @code{Async_Readers}.
8159 @node Aspect Async_Writers
8160 @unnumberedsec Aspect Async_Writers
8161 @findex Async_Writers
8162 @noindent
8163 This aspect is equivalent to pragma @code{Async_Writers}.
8165 @node Aspect Contract_Cases
8166 @unnumberedsec Aspect Contract_Cases
8167 @findex Contract_Cases
8168 @noindent
8169 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
8170 of clauses being enclosed in parentheses so that syntactically it is an
8171 aggregate.
8173 @node Aspect Depends
8174 @unnumberedsec Aspect Depends
8175 @findex Depends
8176 @noindent
8177 This aspect is equivalent to pragma @code{Depends}.
8179 @node Aspect Dimension
8180 @unnumberedsec Aspect Dimension
8181 @findex Dimension
8182 @noindent
8183 The @code{Dimension} aspect is used to specify the dimensions of a given
8184 subtype of a dimensioned numeric type. The aspect also specifies a symbol
8185 used when doing formatted output of dimensioned quantities. The syntax is:
8187 @smallexample @c ada
8188 with Dimension =>
8189   ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
8191 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
8193 DIMENSION_VALUE ::=
8194   RATIONAL
8195 | others               => RATIONAL
8196 | DISCRETE_CHOICE_LIST => RATIONAL
8198 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
8199 @end smallexample
8201 @noindent
8202 This aspect can only be applied to a subtype whose parent type has
8203 a @code{Dimension_Systen} aspect. The aspect must specify values for
8204 all dimensions of the system. The rational values are the powers of the
8205 corresponding dimensions that are used by the compiler to verify that
8206 physical (numeric) computations are dimensionally consistent. For example,
8207 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
8208 For further examples of the usage
8209 of this aspect, see package @code{System.Dim.Mks}.
8210 Note that when the dimensioned type is an integer type, then any
8211 dimension value must be an integer literal.
8213 @node Aspect Dimension_System
8214 @unnumberedsec Aspect Dimension_System
8215 @findex Dimension_System
8216 @noindent
8217 The @code{Dimension_System} aspect is used to define a system of
8218 dimensions that will be used in subsequent subtype declarations with
8219 @code{Dimension} aspects that reference this system. The syntax is:
8221 @smallexample @c ada
8222 with Dimension_System => (DIMENSION @{, DIMENSION@});
8224 DIMENSION ::= ([Unit_Name   =>] IDENTIFIER,
8225                [Unit_Symbol =>] SYMBOL,
8226                [Dim_Symbol  =>] SYMBOL)
8228 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
8229 @end smallexample
8231 @noindent
8232 This aspect is applied to a type, which must be a numeric derived type
8233 (typically a floating-point type), that
8234 will represent values within the dimension system. Each @code{DIMENSION}
8235 corresponds to one particular dimension. A maximum of 7 dimensions may
8236 be specified. @code{Unit_Name} is the name of the dimension (for example
8237 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
8238 of this dimension (for example @code{m} for @code{Meter}).
8239 @code{Dim_Symbol} gives
8240 the identification within the dimension system (typically this is a
8241 single letter, e.g. @code{L} standing for length for unit name @code{Meter}).
8242 The @code{Unit_Symbol} is used in formatted output of dimensioned quantities.
8243 The @code{Dim_Symbol} is used in error messages when numeric operations have
8244 inconsistent dimensions.
8246 GNAT provides the standard definition of the International MKS system in
8247 the run-time package @code{System.Dim.Mks}. You can easily define
8248 similar packages for cgs units or British units, and define conversion factors
8249 between values in different systems. The MKS system is characterized by the
8250 following aspect:
8252 @smallexample @c ada
8253    type Mks_Type is new Long_Long_Float with
8254      Dimension_System => (
8255        (Unit_Name => Meter,    Unit_Symbol => 'm',   Dim_Symbol => 'L'),
8256        (Unit_Name => Kilogram, Unit_Symbol => "kg",  Dim_Symbol => 'M'),
8257        (Unit_Name => Second,   Unit_Symbol => 's',   Dim_Symbol => 'T'),
8258        (Unit_Name => Ampere,   Unit_Symbol => 'A',   Dim_Symbol => 'I'),
8259        (Unit_Name => Kelvin,   Unit_Symbol => 'K',   Dim_Symbol => '@'),
8260        (Unit_Name => Mole,     Unit_Symbol => "mol", Dim_Symbol => 'N'),
8261        (Unit_Name => Candela,  Unit_Symbol => "cd",  Dim_Symbol => 'J'));
8262 @end smallexample
8264 @noindent
8265 Note that in the above type definition, we use the symbol @code{@@} to
8266 represent a theta character (avoiding the use of extended Latin-1
8267 characters in this context).
8269 See section ``Performing Dimensionality Analysis in GNAT'' in the GNAT Users
8270 Guide for detailed examples of use of the dimension system.
8272 @node Aspect Effective_Reads
8273 @unnumberedsec Aspect Effective_Reads
8274 @findex Effective_Reads
8275 @noindent
8276 This aspect is equivalent to pragma @code{Effective_Reads}.
8278 @node Aspect Effective_Writes
8279 @unnumberedsec Aspect Effective_Writes
8280 @findex Effective_Writes
8281 @noindent
8282 This aspect is equivalent to pragma @code{Effective_Writes}.
8284 @node Aspect Favor_Top_Level
8285 @unnumberedsec Aspect Favor_Top_Level
8286 @findex Favor_Top_Level
8287 @noindent
8288 This aspect is equivalent to pragma @code{Favor_Top_Level}.
8290 @node Aspect Global
8291 @unnumberedsec Aspect Global
8292 @findex Global
8293 @noindent
8294 This aspect is equivalent to pragma @code{Global}.
8296 @node Aspect Initial_Condition
8297 @unnumberedsec Aspect Initial_Condition
8298 @findex Initial_Condition
8299 @noindent
8300 This aspect is equivalent to pragma @code{Initial_Condition}.
8302 @node Aspect Initializes
8303 @unnumberedsec Aspect Initializes
8304 @findex Initializes
8305 @noindent
8306 This aspect is equivalent to pragma @code{Initializes}.
8308 @node Aspect Inline_Always
8309 @unnumberedsec Aspect Inline_Always
8310 @findex Inline_Always
8311 @noindent
8312 This aspect is equivalent to pragma @code{Inline_Always}.
8314 @node Aspect Invariant
8315 @unnumberedsec Aspect Invariant
8316 @findex Invariant
8317 @noindent
8318 This aspect is equivalent to pragma @code{Invariant}. It is a
8319 synonym for the language defined aspect @code{Type_Invariant} except
8320 that it is separately controllable using pragma @code{Assertion_Policy}.
8322 @node Aspect Invariant'Class
8323 @unnumberedsec Aspect Invariant'Class
8324 @findex Invariant'Class
8325 @noindent
8326 This aspect is equivalent to pragma @code{Type_Invariant_Class}. It is a
8327 synonym for the language defined aspect @code{Type_Invariant'Class} except
8328 that it is separately controllable using pragma @code{Assertion_Policy}.
8330 @node Aspect Iterable
8331 @unnumberedsec Aspect Iterable
8332 @findex Iterable
8333 @noindent
8334 This aspect is used in the GNAT-defined formal container packages, to provide
8335 a light-weight mechanism for loops over such containers, without the overhead
8336 imposed by the tampering checks of standard Ada2012 iterators. The value of the
8337 aspect is a aggregate with four named  components: First, Next, Has_Element,
8338 and Element. The following is a typical example of use:
8340 @smallexample @c ada
8341 type List is private with
8342     Iterable => (First        => First_Element,
8343                  Next         => Advance,
8344                  Has_Element  => Get_Element,
8345                  Element      => List_Element);
8346 @end smallexample
8347 @itemize @bullet
8348 @item The value denoted by @code{First} must denote a primitive operation of
8349 the  container type that returns a Cursor, which must a be a type declared in
8350 the container package.
8351 @item The value of @code{Next} is a primitive operation of the container type
8352 that takes a cursor and yields a cursor.
8353 @item @code{Has_Element} is an operation that applies to a cursor a yields an
8354 element of the container.
8355 @item @code{Element} is the type of the elements of the container type, and
8356 thus the result of the function denoted by Has_Element.
8357 @end itemize
8359 @node Aspect Linker_Section
8360 @unnumberedsec Aspect Linker_Section
8361 @findex Linker_Section
8362 @noindent
8363 This aspect is equivalent to an @code{Linker_Section} pragma.
8365 @node Aspect Lock_Free
8366 @unnumberedsec Aspect Lock_Free
8367 @findex Lock_Free
8368 @noindent
8369 This aspect is equivalent to pragma @code{Lock_Free}.
8371 @node Aspect No_Elaboration_Code_All
8372 @unnumberedsec Aspect No_Elaboration_Code_All
8373 @findex No_Elaboration_Code_All
8374 @noindent
8375 This aspect is equivalent to a @code{pragma No_Elaboration_Code_All}
8376 statement for a program unit.
8378 @node Aspect Object_Size
8379 @unnumberedsec Aspect Object_Size
8380 @findex Object_Size
8381 @noindent
8382 This aspect is equivalent to an @code{Object_Size} attribute definition
8383 clause.
8385 @node Aspect Obsolescent
8386 @unnumberedsec Aspect Obsolescent
8387 @findex Obsolsecent
8388 @noindent
8389 This aspect is equivalent to an @code{Obsolescent} pragma. Note that the
8390 evaluation of this aspect happens at the point of occurrence, it is not
8391 delayed until the freeze point.
8393 @node Aspect Part_Of
8394 @unnumberedsec Aspect Part_Of
8395 @findex Part_Of
8396 @noindent
8397 This aspect is equivalent to pragma @code{Part_Of}.
8399 @node Aspect Persistent_BSS
8400 @unnumberedsec Aspect Persistent_BSS
8401 @findex Persistent_BSS
8402 @noindent
8403 This aspect is equivalent to pragma @code{Persistent_BSS}.
8405 @node Aspect Predicate
8406 @unnumberedsec Aspect Predicate
8407 @findex Predicate
8408 @noindent
8409 This aspect is equivalent to pragma @code{Predicate}. It is thus
8410 similar to the language defined aspects @code{Dynamic_Predicate}
8411 and @code{Static_Predicate} except that whether the resulting
8412 predicate is static or dynamic is controlled by the form of the
8413 expression. It is also separately controllable using pragma
8414 @code{Assertion_Policy}.
8416 @node Aspect Pure_Function
8417 @unnumberedsec Aspect Pure_Function
8418 @findex Pure_Function
8419 @noindent
8420 This aspect is equivalent to pragma @code{Pure_Function}.
8422 @node Aspect Refined_Depends
8423 @unnumberedsec Aspect Refined_Depends
8424 @findex Refined_Depends
8425 @noindent
8426 This aspect is equivalent to pragma @code{Refined_Depends}.
8428 @node Aspect Refined_Global
8429 @unnumberedsec Aspect Refined_Global
8430 @findex Refined_Global
8431 @noindent
8432 This aspect is equivalent to pragma @code{Refined_Global}.
8434 @node Aspect Refined_Post
8435 @unnumberedsec Aspect Refined_Post
8436 @findex Refined_Post
8437 @noindent
8438 This aspect is equivalent to pragma @code{Refined_Post}.
8440 @node Aspect Refined_State
8441 @unnumberedsec Aspect Refined_State
8442 @findex Refined_State
8443 @noindent
8444 This aspect is equivalent to pragma @code{Refined_State}.
8446 @node Aspect Remote_Access_Type
8447 @unnumberedsec Aspect Remote_Access_Type
8448 @findex Remote_Access_Type
8449 @noindent
8450 This aspect is equivalent to pragma @code{Remote_Access_Type}.
8452 @node Aspect Scalar_Storage_Order
8453 @unnumberedsec Aspect Scalar_Storage_Order
8454 @findex Scalar_Storage_Order
8455 @noindent
8456 This aspect is equivalent to a @code{Scalar_Storage_Order}
8457 attribute definition clause.
8459 @node Aspect Shared
8460 @unnumberedsec Aspect Shared
8461 @findex Shared
8462 @noindent
8463 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
8464 for aspect @code{Atomic}.
8466 @node Aspect Simple_Storage_Pool
8467 @unnumberedsec Aspect Simple_Storage_Pool
8468 @findex Simple_Storage_Pool
8469 @noindent
8470 This aspect is equivalent to a @code{Simple_Storage_Pool}
8471 attribute definition clause.
8473 @node Aspect Simple_Storage_Pool_Type
8474 @unnumberedsec Aspect Simple_Storage_Pool_Type
8475 @findex Simple_Storage_Pool_Type
8476 @noindent
8477 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
8479 @node Aspect SPARK_Mode
8480 @unnumberedsec Aspect SPARK_Mode
8481 @findex SPARK_Mode
8482 @noindent
8483 This aspect is equivalent to pragma @code{SPARK_Mode} and
8484 may be specified for either or both of the specification and body
8485 of a subprogram or package.
8487 @node Aspect Suppress_Debug_Info
8488 @unnumberedsec Aspect Suppress_Debug_Info
8489 @findex Suppress_Debug_Info
8490 @noindent
8491 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
8493 @node Aspect Test_Case
8494 @unnumberedsec Aspect Test_Case
8495 @findex Test_Case
8496 @noindent
8497 This aspect is equivalent to pragma @code{Test_Case}.
8499 @node Aspect Thread_Local_Storage
8500 @unnumberedsec Aspect Thread_Local_Storage
8501 @findex Thread_Local_Storage
8502 @noindent
8503 This aspect is equivalent to pragma @code{Thread_Local_Storage}.
8505 @node Aspect Universal_Aliasing
8506 @unnumberedsec Aspect Universal_Aliasing
8507 @findex Universal_Aliasing
8508 @noindent
8509 This aspect is equivalent to pragma @code{Universal_Aliasing}.
8511 @node Aspect Universal_Data
8512 @unnumberedsec Aspect Universal_Data
8513 @findex Universal_Data
8514 @noindent
8515 This aspect is equivalent to pragma @code{Universal_Data}.
8517 @node Aspect Unmodified
8518 @unnumberedsec Aspect Unmodified
8519 @findex Unmodified
8520 @noindent
8521 This aspect is equivalent to pragma @code{Unmodified}.
8523 @node Aspect Unreferenced
8524 @unnumberedsec Aspect Unreferenced
8525 @findex Unreferenced
8526 @noindent
8527 This aspect is equivalent to pragma @code{Unreferenced}.
8529 @node Aspect Unreferenced_Objects
8530 @unnumberedsec Aspect Unreferenced_Objects
8531 @findex Unreferenced_Objects
8532 @noindent
8533 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
8535 @node Aspect Value_Size
8536 @unnumberedsec Aspect Value_Size
8537 @findex Value_Size
8538 @noindent
8539 This aspect is equivalent to a @code{Value_Size}
8540 attribute definition clause.
8542 @node Aspect Warnings
8543 @unnumberedsec Aspect Warnings
8544 @findex Warnings
8545 @noindent
8546 This aspect is equivalent to the two argument form of pragma @code{Warnings},
8547 where the first argument is @code{ON} or @code{OFF} and the second argument
8548 is the entity.
8551 @node Implementation Defined Attributes
8552 @chapter Implementation Defined Attributes
8553 Ada defines (throughout the Ada reference manual,
8554 summarized in Annex K),
8555 a set of attributes that provide useful additional functionality in all
8556 areas of the language.  These language defined attributes are implemented
8557 in GNAT and work as described in the Ada Reference Manual.
8559 In addition, Ada allows implementations to define additional
8560 attributes whose meaning is defined by the implementation.  GNAT provides
8561 a number of these implementation-dependent attributes which can be used
8562 to extend and enhance the functionality of the compiler.  This section of
8563 the GNAT reference manual describes these additional attributes.  It also
8564 describes additional implementation-dependent features of standard
8565 language-defined attributes.
8567 Note that any program using these attributes may not be portable to
8568 other compilers (although GNAT implements this set of attributes on all
8569 platforms).  Therefore if portability to other compilers is an important
8570 consideration, you should minimize the use of these attributes.
8572 @menu
8573 * Attribute Abort_Signal::
8574 * Attribute Address_Size::
8575 * Attribute Asm_Input::
8576 * Attribute Asm_Output::
8577 * Attribute AST_Entry::
8578 * Attribute Atomic_Always_Lock_Free::
8579 * Attribute Bit::
8580 * Attribute Bit_Position::
8581 * Attribute Code_Address::
8582 * Attribute Compiler_Version::
8583 * Attribute Constrained::
8584 * Attribute Default_Bit_Order::
8585 * Attribute Default_Scalar_Storage_Order::
8586 * Attribute Descriptor_Size::
8587 * Attribute Elaborated::
8588 * Attribute Elab_Body::
8589 * Attribute Elab_Spec::
8590 * Attribute Elab_Subp_Body::
8591 * Attribute Emax::
8592 * Attribute Enabled::
8593 * Attribute Enum_Rep::
8594 * Attribute Enum_Val::
8595 * Attribute Epsilon::
8596 * Attribute Fast_Math::
8597 * Attribute Fixed_Value::
8598 * Attribute From_Any::
8599 * Attribute Has_Access_Values::
8600 * Attribute Has_Discriminants::
8601 * Attribute Img::
8602 * Attribute Integer_Value::
8603 * Attribute Invalid_Value::
8604 * Attribute Iterable::
8605 * Attribute Large::
8606 * Attribute Library_Level::
8607 * Attribute Lock_Free::
8608 * Attribute Loop_Entry::
8609 * Attribute Machine_Size::
8610 * Attribute Mantissa::
8611 * Attribute Maximum_Alignment::
8612 * Attribute Mechanism_Code::
8613 * Attribute Null_Parameter::
8614 * Attribute Object_Size::
8615 * Attribute Old::
8616 * Attribute Passed_By_Reference::
8617 * Attribute Pool_Address::
8618 * Attribute Range_Length::
8619 * Attribute Ref::
8620 * Attribute Restriction_Set::
8621 * Attribute Result::
8622 * Attribute Safe_Emax::
8623 * Attribute Safe_Large::
8624 * Attribute Safe_Small::
8625 * Attribute Scalar_Storage_Order::
8626 * Attribute Simple_Storage_Pool::
8627 * Attribute Small::
8628 * Attribute Storage_Unit::
8629 * Attribute Stub_Type::
8630 * Attribute System_Allocator_Alignment::
8631 * Attribute Target_Name::
8632 * Attribute To_Address::
8633 * Attribute To_Any::
8634 * Attribute Type_Class::
8635 * Attribute Type_Key::
8636 * Attribute TypeCode::
8637 * Attribute UET_Address::
8638 * Attribute Unconstrained_Array::
8639 * Attribute Universal_Literal_String::
8640 * Attribute Unrestricted_Access::
8641 * Attribute Update::
8642 * Attribute VADS_Size::
8643 * Attribute Valid_Scalars::
8644 * Attribute Value_Size::
8645 * Attribute Wchar_T_Size::
8646 * Attribute Word_Size::
8647 @end menu
8649 @node Attribute Abort_Signal
8650 @unnumberedsec Attribute Abort_Signal
8651 @findex Abort_Signal
8652 @noindent
8653 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
8654 prefix) provides the entity for the special exception used to signal
8655 task abort or asynchronous transfer of control.  Normally this attribute
8656 should only be used in the tasking runtime (it is highly peculiar, and
8657 completely outside the normal semantics of Ada, for a user program to
8658 intercept the abort exception).
8660 @node Attribute Address_Size
8661 @unnumberedsec Attribute Address_Size
8662 @cindex Size of @code{Address}
8663 @findex Address_Size
8664 @noindent
8665 @code{Standard'Address_Size} (@code{Standard} is the only allowed
8666 prefix) is a static constant giving the number of bits in an
8667 @code{Address}. It is the same value as System.Address'Size,
8668 but has the advantage of being static, while a direct
8669 reference to System.Address'Size is non-static because Address
8670 is a private type.
8672 @node Attribute Asm_Input
8673 @unnumberedsec Attribute Asm_Input
8674 @findex Asm_Input
8675 @noindent
8676 The @code{Asm_Input} attribute denotes a function that takes two
8677 parameters.  The first is a string, the second is an expression of the
8678 type designated by the prefix.  The first (string) argument is required
8679 to be a static expression, and is the constraint for the parameter,
8680 (e.g.@: what kind of register is required).  The second argument is the
8681 value to be used as the input argument.  The possible values for the
8682 constant are the same as those used in the RTL, and are dependent on
8683 the configuration file used to built the GCC back end.
8684 @ref{Machine Code Insertions}
8686 @node Attribute Asm_Output
8687 @unnumberedsec Attribute Asm_Output
8688 @findex Asm_Output
8689 @noindent
8690 The @code{Asm_Output} attribute denotes a function that takes two
8691 parameters.  The first is a string, the second is the name of a variable
8692 of the type designated by the attribute prefix.  The first (string)
8693 argument is required to be a static expression and designates the
8694 constraint for the parameter (e.g.@: what kind of register is
8695 required).  The second argument is the variable to be updated with the
8696 result.  The possible values for constraint are the same as those used in
8697 the RTL, and are dependent on the configuration file used to build the
8698 GCC back end.  If there are no output operands, then this argument may
8699 either be omitted, or explicitly given as @code{No_Output_Operands}.
8700 @ref{Machine Code Insertions}
8702 @node Attribute AST_Entry
8703 @unnumberedsec Attribute AST_Entry
8704 @cindex OpenVMS
8705 @findex AST_Entry
8706 @noindent
8707 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
8708 the name of an entry, it yields a value of the predefined type AST_Handler
8709 (declared in the predefined package System, as extended by the use of
8710 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
8711 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
8712 Language Reference Manual}, section 9.12a.
8714 @node Attribute Atomic_Always_Lock_Free
8715 @unnumberedsec Attribute Atomic_Always_Lock_Free
8716 @findex Atomic_Always_Lock_Free
8717 @noindent
8719 The prefix of the @code{Atomic_Always_Lock_Free} attribute is a type.
8720 The result is a Boolean value which is True if the type has discriminants,
8721 and False otherwise.  The result indicate whether atomic operations are
8722 supported by the target for the given type.
8724 @node Attribute Bit
8725 @unnumberedsec Attribute Bit
8726 @findex Bit
8727 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
8728 offset within the storage unit (byte) that contains the first bit of
8729 storage allocated for the object.  The value of this attribute is of the
8730 type @code{Universal_Integer}, and is always a non-negative number not
8731 exceeding the value of @code{System.Storage_Unit}.
8733 For an object that is a variable or a constant allocated in a register,
8734 the value is zero.  (The use of this attribute does not force the
8735 allocation of a variable to memory).
8737 For an object that is a formal parameter, this attribute applies
8738 to either the matching actual parameter or to a copy of the
8739 matching actual parameter.
8741 For an access object the value is zero.  Note that
8742 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
8743 designated object.  Similarly for a record component
8744 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
8745 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
8746 are subject to index checks.
8748 This attribute is designed to be compatible with the DEC Ada 83 definition
8749 and implementation of the @code{Bit} attribute.
8751 @node Attribute Bit_Position
8752 @unnumberedsec Attribute Bit_Position
8753 @findex Bit_Position
8754 @noindent
8755 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
8756 of the fields of the record type, yields the bit
8757 offset within the record contains the first bit of
8758 storage allocated for the object.  The value of this attribute is of the
8759 type @code{Universal_Integer}.  The value depends only on the field
8760 @var{C} and is independent of the alignment of
8761 the containing record @var{R}.
8763 @node Attribute Code_Address
8764 @unnumberedsec Attribute Code_Address
8765 @findex Code_Address
8766 @cindex Subprogram address
8767 @cindex Address of subprogram code
8768 @noindent
8769 The @code{'Address}
8770 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
8771 intended effect seems to be to provide
8772 an address value which can be used to call the subprogram by means of
8773 an address clause as in the following example:
8775 @smallexample @c ada
8776 procedure K is @dots{}
8778 procedure L;
8779 for L'Address use K'Address;
8780 pragma Import (Ada, L);
8781 @end smallexample
8783 @noindent
8784 A call to @code{L} is then expected to result in a call to @code{K}@.
8785 In Ada 83, where there were no access-to-subprogram values, this was
8786 a common work-around for getting the effect of an indirect call.
8787 GNAT implements the above use of @code{Address} and the technique
8788 illustrated by the example code works correctly.
8790 However, for some purposes, it is useful to have the address of the start
8791 of the generated code for the subprogram.  On some architectures, this is
8792 not necessarily the same as the @code{Address} value described above.
8793 For example, the @code{Address} value may reference a subprogram
8794 descriptor rather than the subprogram itself.
8796 The @code{'Code_Address} attribute, which can only be applied to
8797 subprogram entities, always returns the address of the start of the
8798 generated code of the specified subprogram, which may or may not be
8799 the same value as is returned by the corresponding @code{'Address}
8800 attribute.
8802 @node Attribute Compiler_Version
8803 @unnumberedsec Attribute Compiler_Version
8804 @findex Compiler_Version
8805 @noindent
8806 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
8807 prefix) yields a static string identifying the version of the compiler
8808 being used to compile the unit containing the attribute reference. A
8809 typical result would be something like
8810 "@value{EDITION} @value{gnat_version} (20090221)".
8812 @node Attribute Constrained
8813 @unnumberedsec Attribute Constrained
8814 @findex Constrained
8815 @noindent
8816 In addition to the usage of this attribute in the Ada RM, @code{GNAT}
8817 also permits the use of the @code{'Constrained} attribute
8818 in a generic template
8819 for any type, including types without discriminants. The value of this
8820 attribute in the generic instance when applied to a scalar type or a
8821 record type without discriminants is always @code{True}. This usage is
8822 compatible with older Ada compilers, including notably DEC Ada.
8824 @node Attribute Default_Bit_Order
8825 @unnumberedsec Attribute Default_Bit_Order
8826 @cindex Big endian
8827 @cindex Little endian
8828 @findex Default_Bit_Order
8829 @noindent
8830 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
8831 permissible prefix), provides the value @code{System.Default_Bit_Order}
8832 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
8833 @code{Low_Order_First}).  This is used to construct the definition of
8834 @code{Default_Bit_Order} in package @code{System}.
8836 @node Attribute Default_Scalar_Storage_Order
8837 @unnumberedsec Attribute Default_Scalar_Storage_Order
8838 @cindex Big endian
8839 @cindex Little endian
8840 @findex Default_Scalar_Storage_Order
8841 @noindent
8842 @code{Standard'Default_Scalar_Storage_Order} (@code{Standard} is the only
8843 permissible prefix), provides the current value of the default scalar storage
8844 order (as specified using pragma @code{Default_Scalar_Storage_Order}, or
8845 equal to @code{Default_Bit_Order} if unspecified) as a
8846 @code{System.Bit_Order} value. This is a static attribute.
8848 @node Attribute Descriptor_Size
8849 @unnumberedsec Attribute Descriptor_Size
8850 @cindex Descriptor
8851 @cindex Dope vector
8852 @findex Descriptor_Size
8853 @noindent
8854 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
8855 descriptor allocated for a type.  The result is non-zero only for unconstrained
8856 array types and the returned value is of type universal integer.  In GNAT, an
8857 array descriptor contains bounds information and is located immediately before
8858 the first element of the array.
8860 @smallexample @c ada
8861 type Unconstr_Array is array (Positive range <>) of Boolean;
8862 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
8863 @end smallexample
8865 @noindent
8866 The attribute takes into account any additional padding due to type alignment.
8867 In the example above, the descriptor contains two values of type
8868 @code{Positive} representing the low and high bound.  Since @code{Positive} has
8869 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
8870 Positive'Size + 2} or 64 bits.
8872 @node Attribute Elaborated
8873 @unnumberedsec Attribute Elaborated
8874 @findex Elaborated
8875 @noindent
8876 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
8877 value is a Boolean which indicates whether or not the given unit has been
8878 elaborated.  This attribute is primarily intended for internal use by the
8879 generated code for dynamic elaboration checking, but it can also be used
8880 in user programs.  The value will always be True once elaboration of all
8881 units has been completed.  An exception is for units which need no
8882 elaboration, the value is always False for such units.
8884 @node Attribute Elab_Body
8885 @unnumberedsec Attribute Elab_Body
8886 @findex Elab_Body
8887 @noindent
8888 This attribute can only be applied to a program unit name.  It returns
8889 the entity for the corresponding elaboration procedure for elaborating
8890 the body of the referenced unit.  This is used in the main generated
8891 elaboration procedure by the binder and is not normally used in any
8892 other context.  However, there may be specialized situations in which it
8893 is useful to be able to call this elaboration procedure from Ada code,
8894 e.g.@: if it is necessary to do selective re-elaboration to fix some
8895 error.
8897 @node Attribute Elab_Spec
8898 @unnumberedsec Attribute Elab_Spec
8899 @findex Elab_Spec
8900 @noindent
8901 This attribute can only be applied to a program unit name.  It returns
8902 the entity for the corresponding elaboration procedure for elaborating
8903 the spec of the referenced unit.  This is used in the main
8904 generated elaboration procedure by the binder and is not normally used
8905 in any other context.  However, there may be specialized situations in
8906 which it is useful to be able to call this elaboration procedure from
8907 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
8908 some error.
8910 @node Attribute Elab_Subp_Body
8911 @unnumberedsec Attribute Elab_Subp_Body
8912 @findex Elab_Subp_Body
8913 @noindent
8914 This attribute can only be applied to a library level subprogram
8915 name and is only allowed in CodePeer mode. It returns the entity
8916 for the corresponding elaboration procedure for elaborating the body
8917 of the referenced subprogram unit. This is used in the main generated
8918 elaboration procedure by the binder in CodePeer mode only and is unrecognized
8919 otherwise.
8921 @node Attribute Emax
8922 @unnumberedsec Attribute Emax
8923 @cindex Ada 83 attributes
8924 @findex Emax
8925 @noindent
8926 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
8927 the Ada 83 reference manual for an exact description of the semantics of
8928 this attribute.
8930 @node Attribute Enabled
8931 @unnumberedsec Attribute Enabled
8932 @findex Enabled
8933 @noindent
8934 The @code{Enabled} attribute allows an application program to check at compile
8935 time to see if the designated check is currently enabled. The prefix is a
8936 simple identifier, referencing any predefined check name (other than
8937 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
8938 no argument is given for the attribute, the check is for the general state
8939 of the check, if an argument is given, then it is an entity name, and the
8940 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
8941 given naming the entity (if not, then the argument is ignored).
8943 Note that instantiations inherit the check status at the point of the
8944 instantiation, so a useful idiom is to have a library package that
8945 introduces a check name with @code{pragma Check_Name}, and then contains
8946 generic packages or subprograms which use the @code{Enabled} attribute
8947 to see if the check is enabled. A user of this package can then issue
8948 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
8949 the package or subprogram, controlling whether the check will be present.
8951 @node Attribute Enum_Rep
8952 @unnumberedsec Attribute Enum_Rep
8953 @cindex Representation of enums
8954 @findex Enum_Rep
8955 @noindent
8956 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
8957 function with the following spec:
8959 @smallexample @c ada
8960 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
8961   return @i{Universal_Integer};
8962 @end smallexample
8964 @noindent
8965 It is also allowable to apply @code{Enum_Rep} directly to an object of an
8966 enumeration type or to a non-overloaded enumeration
8967 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
8968 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
8969 enumeration literal or object.
8971 The function returns the representation value for the given enumeration
8972 value.  This will be equal to value of the @code{Pos} attribute in the
8973 absence of an enumeration representation clause.  This is a static
8974 attribute (i.e.@: the result is static if the argument is static).
8976 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
8977 in which case it simply returns the integer value.  The reason for this
8978 is to allow it to be used for @code{(<>)} discrete formal arguments in
8979 a generic unit that can be instantiated with either enumeration types
8980 or integer types.  Note that if @code{Enum_Rep} is used on a modular
8981 type whose upper bound exceeds the upper bound of the largest signed
8982 integer type, and the argument is a variable, so that the universal
8983 integer calculation is done at run time, then the call to @code{Enum_Rep}
8984 may raise @code{Constraint_Error}.
8986 @node Attribute Enum_Val
8987 @unnumberedsec Attribute Enum_Val
8988 @cindex Representation of enums
8989 @findex Enum_Val
8990 @noindent
8991 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
8992 function with the following spec:
8994 @smallexample @c ada
8995 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
8996   return @var{S}'Base};
8997 @end smallexample
8999 @noindent
9000 The function returns the enumeration value whose representation matches the
9001 argument, or raises Constraint_Error if no enumeration literal of the type
9002 has the matching value.
9003 This will be equal to value of the @code{Val} attribute in the
9004 absence of an enumeration representation clause.  This is a static
9005 attribute (i.e.@: the result is static if the argument is static).
9007 @node Attribute Epsilon
9008 @unnumberedsec Attribute Epsilon
9009 @cindex Ada 83 attributes
9010 @findex Epsilon
9011 @noindent
9012 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
9013 the Ada 83 reference manual for an exact description of the semantics of
9014 this attribute.
9016 @node Attribute Fast_Math
9017 @unnumberedsec Attribute Fast_Math
9018 @findex Fast_Math
9019 @noindent
9020 @code{Standard'Fast_Math} (@code{Standard} is the only allowed
9021 prefix) yields a static Boolean value that is True if pragma
9022 @code{Fast_Math} is active, and False otherwise.
9024 @node Attribute Fixed_Value
9025 @unnumberedsec Attribute Fixed_Value
9026 @findex Fixed_Value
9027 @noindent
9028 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
9029 function with the following specification:
9031 @smallexample @c ada
9032 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
9033   return @var{S};
9034 @end smallexample
9036 @noindent
9037 The value returned is the fixed-point value @var{V} such that
9039 @smallexample @c ada
9040 @var{V} = Arg * @var{S}'Small
9041 @end smallexample
9043 @noindent
9044 The effect is thus similar to first converting the argument to the
9045 integer type used to represent @var{S}, and then doing an unchecked
9046 conversion to the fixed-point type.  The difference is
9047 that there are full range checks, to ensure that the result is in range.
9048 This attribute is primarily intended for use in implementation of the
9049 input-output functions for fixed-point values.
9051 @node Attribute From_Any
9052 @unnumberedsec Attribute From_Any
9053 @findex From_Any
9054 @noindent
9055 This internal attribute is used for the generation of remote subprogram
9056 stubs in the context of the Distributed Systems Annex.
9058 @node Attribute Has_Access_Values
9059 @unnumberedsec Attribute Has_Access_Values
9060 @cindex Access values, testing for
9061 @findex Has_Access_Values
9062 @noindent
9063 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
9064 is a Boolean value which is True if the is an access type, or is a composite
9065 type with a component (at any nesting depth) that is an access type, and is
9066 False otherwise.
9067 The intended use of this attribute is in conjunction with generic
9068 definitions.  If the attribute is applied to a generic private type, it
9069 indicates whether or not the corresponding actual type has access values.
9071 @node Attribute Has_Discriminants
9072 @unnumberedsec Attribute Has_Discriminants
9073 @cindex Discriminants, testing for
9074 @findex Has_Discriminants
9075 @noindent
9076 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
9077 is a Boolean value which is True if the type has discriminants, and False
9078 otherwise.  The intended use of this attribute is in conjunction with generic
9079 definitions.  If the attribute is applied to a generic private type, it
9080 indicates whether or not the corresponding actual type has discriminants.
9082 @node Attribute Img
9083 @unnumberedsec Attribute Img
9084 @findex Img
9085 @noindent
9086 The @code{Img} attribute differs from @code{Image} in that it is applied
9087 directly to an object, and yields the same result as
9088 @code{Image} for the subtype of the object.  This is convenient for
9089 debugging:
9091 @smallexample @c ada
9092 Put_Line ("X = " & X'Img);
9093 @end smallexample
9095 @noindent
9096 has the same meaning as the more verbose:
9098 @smallexample @c ada
9099 Put_Line ("X = " & @var{T}'Image (X));
9100 @end smallexample
9102 @noindent
9103 where @var{T} is the (sub)type of the object @code{X}.
9105 Note that technically, in analogy to @code{Image},
9106 @code{X'Img} returns a parameterless function
9107 that returns the appropriate string when called. This means that
9108 @code{X'Img} can be renamed as a function-returning-string, or used
9109 in an instantiation as a function parameter.
9111 @node Attribute Integer_Value
9112 @unnumberedsec Attribute Integer_Value
9113 @findex Integer_Value
9114 @noindent
9115 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
9116 function with the following spec:
9118 @smallexample @c ada
9119 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
9120   return @var{S};
9121 @end smallexample
9123 @noindent
9124 The value returned is the integer value @var{V}, such that
9126 @smallexample @c ada
9127 Arg = @var{V} * @var{T}'Small
9128 @end smallexample
9130 @noindent
9131 where @var{T} is the type of @code{Arg}.
9132 The effect is thus similar to first doing an unchecked conversion from
9133 the fixed-point type to its corresponding implementation type, and then
9134 converting the result to the target integer type.  The difference is
9135 that there are full range checks, to ensure that the result is in range.
9136 This attribute is primarily intended for use in implementation of the
9137 standard input-output functions for fixed-point values.
9139 @node Attribute Invalid_Value
9140 @unnumberedsec Attribute Invalid_Value
9141 @findex Invalid_Value
9142 @noindent
9143 For every scalar type S, S'Invalid_Value returns an undefined value of the
9144 type. If possible this value is an invalid representation for the type. The
9145 value returned is identical to the value used to initialize an otherwise
9146 uninitialized value of the type if pragma Initialize_Scalars is used,
9147 including the ability to modify the value with the binder -Sxx flag and
9148 relevant environment variables at run time.
9150 @node Attribute Iterable
9151 @unnumberedsec Attribute Iterable
9152 @findex Iterable
9153 @noindent
9154 Equivalent to Aspect Iterable.
9156 @node Attribute Large
9157 @unnumberedsec Attribute Large
9158 @cindex Ada 83 attributes
9159 @findex Large
9160 @noindent
9161 The @code{Large} attribute is provided for compatibility with Ada 83.  See
9162 the Ada 83 reference manual for an exact description of the semantics of
9163 this attribute.
9165 @node Attribute Library_Level
9166 @unnumberedsec Attribute Library_Level
9167 @findex Library_Level
9168 @noindent
9169 @noindent
9170 @code{P'Library_Level}, where P is an entity name,
9171 returns a Boolean value which is True if the entity is declared
9172 at the library level, and False otherwise. Note that within a
9173 generic instantition, the name of the generic unit denotes the
9174 instance, which means that this attribute can be used to test
9175 if a generic is instantiated at the library level, as shown
9176 in this example:
9178 @smallexample @c ada
9179 generic
9180   ...
9181 package Gen is
9182   pragma Compile_Time_Error
9183     (not Gen'Library_Level,
9184      "Gen can only be instantiated at library level");
9185   ...
9186 end Gen;
9187 @end smallexample
9189 @node Attribute Lock_Free
9190 @unnumberedsec Attribute Lock_Free
9191 @findex Lock_Free
9192 @noindent
9193 @code{P'Lock_Free}, where P is a protected object, returns True if a
9194 pragma @code{Lock_Free} applies to P.
9196 @node Attribute Loop_Entry
9197 @unnumberedsec Attribute Loop_Entry
9198 @findex Loop_Entry
9199 @noindent
9200 Syntax:
9202 @smallexample @c ada
9203 X'Loop_Entry [(loop_name)]
9204 @end smallexample
9206 @noindent
9207 The @code{Loop_Entry} attribute is used to refer to the value that an
9208 expression had upon entry to a given loop in much the same way that the
9209 @code{Old} attribute in a subprogram postcondition can be used to refer
9210 to the value an expression had upon entry to the subprogram. The
9211 relevant loop is either identified by the given loop name, or it is the
9212 innermost enclosing loop when no loop name is given.
9214 @noindent
9215 A @code{Loop_Entry} attribute can only occur within a
9216 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
9217 @code{Loop_Entry} is to compare the current value of objects with their
9218 initial value at loop entry, in a @code{Loop_Invariant} pragma.
9220 @noindent
9221 The effect of using @code{X'Loop_Entry} is the same as declaring
9222 a constant initialized with the initial value of @code{X} at loop
9223 entry. This copy is not performed if the loop is not entered, or if the
9224 corresponding pragmas are ignored or disabled.
9226 @node Attribute Machine_Size
9227 @unnumberedsec Attribute Machine_Size
9228 @findex Machine_Size
9229 @noindent
9230 This attribute is identical to the @code{Object_Size} attribute.  It is
9231 provided for compatibility with the DEC Ada 83 attribute of this name.
9233 @node Attribute Mantissa
9234 @unnumberedsec Attribute Mantissa
9235 @cindex Ada 83 attributes
9236 @findex Mantissa
9237 @noindent
9238 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
9239 the Ada 83 reference manual for an exact description of the semantics of
9240 this attribute.
9242 @node Attribute Maximum_Alignment
9243 @unnumberedsec Attribute Maximum_Alignment
9244 @cindex Alignment, maximum
9245 @findex Maximum_Alignment
9246 @noindent
9247 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
9248 permissible prefix) provides the maximum useful alignment value for the
9249 target.  This is a static value that can be used to specify the alignment
9250 for an object, guaranteeing that it is properly aligned in all
9251 cases.
9253 @node Attribute Mechanism_Code
9254 @unnumberedsec Attribute Mechanism_Code
9255 @cindex Return values, passing mechanism
9256 @cindex Parameters, passing mechanism
9257 @findex Mechanism_Code
9258 @noindent
9259 @code{@var{function}'Mechanism_Code} yields an integer code for the
9260 mechanism used for the result of function, and
9261 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
9262 used for formal parameter number @var{n} (a static integer value with 1
9263 meaning the first parameter) of @var{subprogram}.  The code returned is:
9265 @table @asis
9266 @item 1
9267 by copy (value)
9268 @item 2
9269 by reference
9270 @end table
9272 @node Attribute Null_Parameter
9273 @unnumberedsec Attribute Null_Parameter
9274 @cindex Zero address, passing
9275 @findex Null_Parameter
9276 @noindent
9277 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
9278 type or subtype @var{T} allocated at machine address zero.  The attribute
9279 is allowed only as the default expression of a formal parameter, or as
9280 an actual expression of a subprogram call.  In either case, the
9281 subprogram must be imported.
9283 The identity of the object is represented by the address zero in the
9284 argument list, independent of the passing mechanism (explicit or
9285 default).
9287 This capability is needed to specify that a zero address should be
9288 passed for a record or other composite object passed by reference.
9289 There is no way of indicating this without the @code{Null_Parameter}
9290 attribute.
9292 @node Attribute Object_Size
9293 @unnumberedsec Attribute Object_Size
9294 @cindex Size, used for objects
9295 @findex Object_Size
9296 @noindent
9297 The size of an object is not necessarily the same as the size of the type
9298 of an object.  This is because by default object sizes are increased to be
9299 a multiple of the alignment of the object.  For example,
9300 @code{Natural'Size} is
9301 31, but by default objects of type @code{Natural} will have a size of 32 bits.
9302 Similarly, a record containing an integer and a character:
9304 @smallexample @c ada
9305 type Rec is record
9306    I : Integer;
9307    C : Character;
9308 end record;
9309 @end smallexample
9311 @noindent
9312 will have a size of 40 (that is @code{Rec'Size} will be 40).  The
9313 alignment will be 4, because of the
9314 integer field, and so the default size of record objects for this type
9315 will be 64 (8 bytes).
9317 If the alignment of the above record is specified to be 1, then the
9318 object size will be 40 (5 bytes). This is true by default, and also
9319 an object size of 40 can be explicitly specified in this case.
9321 A consequence of this capability is that different object sizes can be
9322 given to subtypes that would otherwise be considered in Ada to be
9323 statically matching.  But it makes no sense to consider such subtypes
9324 as statically matching.  Consequently, in @code{GNAT} we add a rule
9325 to the static matching rules that requires object sizes to match.
9326 Consider this example:
9328 @smallexample @c ada
9329  1. procedure BadAVConvert is
9330  2.    type R is new Integer;
9331  3.    subtype R1 is R range 1 .. 10;
9332  4.    subtype R2 is R range 1 .. 10;
9333  5.    for R1'Object_Size use 8;
9334  6.    for R2'Object_Size use 16;
9335  7.    type R1P is access all R1;
9336  8.    type R2P is access all R2;
9337  9.    R1PV : R1P := new R1'(4);
9338 10.    R2PV : R2P;
9339 11. begin
9340 12.    R2PV := R2P (R1PV);
9341                |
9342        >>> target designated subtype not compatible with
9343            type "R1" defined at line 3
9345 13. end;
9346 @end smallexample
9348 @noindent
9349 In the absence of lines 5 and 6,
9350 types @code{R1} and @code{R2} statically match and
9351 hence the conversion on line 12 is legal. But since lines 5 and 6
9352 cause the object sizes to differ, @code{GNAT} considers that types
9353 @code{R1} and @code{R2} are not statically matching, and line 12
9354 generates the diagnostic shown above.
9356 @noindent
9357 Similar additional checks are performed in other contexts requiring
9358 statically matching subtypes.
9360 @node Attribute Old
9361 @unnumberedsec Attribute Old
9362 @findex Old
9363 @noindent
9364 In addition to the usage of @code{Old} defined in the Ada 2012 RM (usage
9365 within @code{Post} aspect), GNAT also permits the use of this attribute
9366 in implementation defined pragmas @code{Postcondition},
9367 @code{Contract_Cases} and @code{Test_Case}. Also usages of
9368 @code{Old} which would be illegal according to the Ada 2012 RM
9369 definition are allowed under control of
9370 implementation defined pragma @code{Unevaluated_Use_Of_Old}.
9372 @node Attribute Passed_By_Reference
9373 @unnumberedsec Attribute Passed_By_Reference
9374 @cindex Parameters, when passed by reference
9375 @findex Passed_By_Reference
9376 @noindent
9377 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
9378 a value of type @code{Boolean} value that is @code{True} if the type is
9379 normally passed by reference and @code{False} if the type is normally
9380 passed by copy in calls.  For scalar types, the result is always @code{False}
9381 and is static.  For non-scalar types, the result is non-static.
9383 @node Attribute Pool_Address
9384 @unnumberedsec Attribute Pool_Address
9385 @cindex Parameters, when passed by reference
9386 @findex Pool_Address
9387 @noindent
9388 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
9389 of X within its storage pool. This is the same as
9390 @code{@var{X}'Address}, except that for an unconstrained array whose
9391 bounds are allocated just before the first component,
9392 @code{@var{X}'Pool_Address} returns the address of those bounds,
9393 whereas @code{@var{X}'Address} returns the address of the first
9394 component.
9396 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
9397 the object is allocated'', which could be a user-defined storage pool,
9398 the global heap, on the stack, or in a static memory area. For an
9399 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
9400 what is passed to @code{Allocate} and returned from @code{Deallocate}.
9402 @node Attribute Range_Length
9403 @unnumberedsec Attribute Range_Length
9404 @findex Range_Length
9405 @noindent
9406 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
9407 the number of values represented by the subtype (zero for a null
9408 range).  The result is static for static subtypes.  @code{Range_Length}
9409 applied to the index subtype of a one dimensional array always gives the
9410 same result as @code{Length} applied to the array itself.
9412 @node Attribute Ref
9413 @unnumberedsec Attribute Ref
9414 @findex Ref
9415 @noindent
9418 @node Attribute Restriction_Set
9419 @unnumberedsec Attribute Restriction_Set
9420 @findex Restriction_Set
9421 @cindex Restrictions
9422 @noindent
9423 This attribute allows compile time testing of restrictions that
9424 are currently in effect. It is primarily intended for specializing
9425 code in the run-time based on restrictions that are active (e.g.
9426 don't need to save fpt registers if restriction No_Floating_Point
9427 is known to be in effect), but can be used anywhere.
9429 There are two forms:
9431 @smallexample @c ada
9432 System'Restriction_Set (partition_boolean_restriction_NAME)
9433 System'Restriction_Set (No_Dependence => library_unit_NAME);
9434 @end smallexample
9436 @noindent
9437 In the case of the first form, the only restriction names
9438 allowed are parameterless restrictions that are checked
9439 for consistency at bind time. For a complete list see the
9440 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
9442 The result returned is True if the restriction is known to
9443 be in effect, and False if the restriction is known not to
9444 be in effect. An important guarantee is that the value of
9445 a Restriction_Set attribute is known to be consistent throughout
9446 all the code of a partition.
9448 This is trivially achieved if the entire partition is compiled
9449 with a consistent set of restriction pragmas. However, the
9450 compilation model does not require this. It is possible to
9451 compile one set of units with one set of pragmas, and another
9452 set of units with another set of pragmas. It is even possible
9453 to compile a spec with one set of pragmas, and then WITH the
9454 same spec with a different set of pragmas. Inconsistencies
9455 in the actual use of the restriction are checked at bind time.
9457 In order to achieve the guarantee of consistency for the
9458 Restriction_Set pragma, we consider that a use of the pragma
9459 that yields False is equivalent to a violation of the
9460 restriction.
9462 So for example if you write
9464 @smallexample @c ada
9465 if System'Restriction_Set (No_Floating_Point) then
9466    ...
9467 else
9468    ...
9469 end if;
9470 @end smallexample
9472 @noindent
9473 And the result is False, so that the else branch is executed,
9474 you can assume that this restriction is not set for any unit
9475 in the partition. This is checked by considering this use of
9476 the restriction pragma to be a violation of the restriction
9477 No_Floating_Point. This means that no other unit can attempt
9478 to set this restriction (if some unit does attempt to set it,
9479 the binder will refuse to bind the partition).
9481 Technical note: The restriction name and the unit name are
9482 intepreted entirely syntactically, as in the corresponding
9483 Restrictions pragma, they are not analyzed semantically,
9484 so they do not have a type.
9486 @node Attribute Result
9487 @unnumberedsec Attribute Result
9488 @findex Result
9489 @noindent
9490 @code{@var{function}'Result} can only be used with in a Postcondition pragma
9491 for a function. The prefix must be the name of the corresponding function. This
9492 is used to refer to the result of the function in the postcondition expression.
9493 For a further discussion of the use of this attribute and examples of its use,
9494 see the description of pragma Postcondition.
9496 @node Attribute Safe_Emax
9497 @unnumberedsec Attribute Safe_Emax
9498 @cindex Ada 83 attributes
9499 @findex Safe_Emax
9500 @noindent
9501 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
9502 the Ada 83 reference manual for an exact description of the semantics of
9503 this attribute.
9505 @node Attribute Safe_Large
9506 @unnumberedsec Attribute Safe_Large
9507 @cindex Ada 83 attributes
9508 @findex Safe_Large
9509 @noindent
9510 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
9511 the Ada 83 reference manual for an exact description of the semantics of
9512 this attribute.
9514 @node Attribute Safe_Small
9515 @unnumberedsec Attribute Safe_Small
9516 @cindex Ada 83 attributes
9517 @findex Safe_Small
9518 @noindent
9519 The @code{Safe_Small} attribute is provided for compatibility with Ada 83.  See
9520 the Ada 83 reference manual for an exact description of the semantics of
9521 this attribute.
9523 @node Attribute Scalar_Storage_Order
9524 @unnumberedsec Attribute Scalar_Storage_Order
9525 @cindex Endianness
9526 @cindex Scalar storage order
9527 @findex Scalar_Storage_Order
9528 @noindent
9529 For every array or record type @var{S}, the representation attribute
9530 @code{Scalar_Storage_Order} denotes the order in which storage elements
9531 that make up scalar components are ordered within S. The value given must
9532 be a static expression of type System.Bit_Order. The following is an example
9533 of the use of this feature:
9535 @smallexample @c ada
9536    --  Component type definitions
9538    subtype Yr_Type is Natural range 0 .. 127;
9539    subtype Mo_Type is Natural range 1 .. 12;
9540    subtype Da_Type is Natural range 1 .. 31;
9542    --  Record declaration
9544    type Date is record
9545       Years_Since_1980 : Yr_Type;
9546       Month            : Mo_Type;
9547       Day_Of_Month     : Da_Type;
9548    end record;
9550    --  Record representation clause
9552    for Date use record
9553       Years_Since_1980 at 0 range 0  ..  6;
9554       Month            at 0 range 7  .. 10;
9555       Day_Of_Month     at 0 range 11 .. 15;
9556    end record;
9558    --  Attribute definition clauses
9560    for Date'Bit_Order use System.High_Order_First;
9561    for Date'Scalar_Storage_Order use System.High_Order_First;
9562    --  If Scalar_Storage_Order is specified, it must be consistent with
9563    --  Bit_Order, so it's best to always define the latter explicitly if
9564    --  the former is used.
9565 @end smallexample
9567 @noindent
9568 Other properties are as for standard representation attribute @code{Bit_Order},
9569 as defined by Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
9571 For a record type @var{T}, if @code{@var{T}'Scalar_Storage_Order} is
9572 specified explicitly, it shall be equal to @code{@var{T}'Bit_Order}. Note:
9573 this means that if a @code{Scalar_Storage_Order} attribute definition
9574 clause is not confirming, then the type's @code{Bit_Order} shall be
9575 specified explicitly and set to the same value.
9577 Derived types inherit an explicitly set scalar storage order from their parent
9578 types. This may be overridden for the derived type by giving an explicit scalar
9579 storage order for the derived type. For a record extension, the derived type
9580 must have the same scalar storage order as the parent type.
9582 If a component of @var{T} is of a record or array type, then that type must
9583 also have a @code{Scalar_Storage_Order} attribute definition clause.
9585 A component of a record or array type that is a packed array, or that
9586 does not start on a byte boundary, must have the same scalar storage order
9587 as the enclosing record or array type.
9589 No component of a type that has an explicit @code{Scalar_Storage_Order}
9590 attribute definition may be aliased.
9592 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
9593 with a value equal to @code{System.Default_Bit_Order}) has no effect.
9595 If the opposite storage order is specified, then whenever the value of
9596 a scalar component of an object of type @var{S} is read, the storage
9597 elements of the enclosing machine scalar are first reversed (before
9598 retrieving the component value, possibly applying some shift and mask
9599 operatings on the enclosing machine scalar), and the opposite operation
9600 is done for writes.
9602 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
9603 are relaxed. Instead, the following rules apply:
9605 @itemize @bullet
9606 @item the underlying storage elements are those at positions
9607   @code{(position + first_bit / storage_element_size) ..
9608         (position + (last_bit + storage_element_size - 1) /
9609                     storage_element_size)}
9610 @item the sequence of underlying storage elements shall have
9611         a size no greater than the largest machine scalar
9612 @item the enclosing machine scalar is defined as the smallest machine
9613         scalar starting at a position no greater than
9614         @code{position + first_bit / storage_element_size} and covering
9615         storage elements at least up to @code{position + (last_bit +
9616         storage_element_size - 1) / storage_element_size}
9617 @item the position of the component is interpreted relative to that machine
9618  scalar.
9620 @end itemize
9622 If no scalar storage order is specified for a type (either directly, or by
9623 inheritance in the case of a derived type), then the default is normally
9624 the native ordering of the target, but this default can be overridden using
9625 pragma @code{Default_Scalar_Storage_Order}.
9627 @node Attribute Simple_Storage_Pool
9628 @unnumberedsec Attribute Simple_Storage_Pool
9629 @cindex Storage pool, simple
9630 @cindex Simple storage pool
9631 @findex Simple_Storage_Pool
9632 @noindent
9633 For every nonformal, nonderived access-to-object type @var{Acc}, the
9634 representation attribute @code{Simple_Storage_Pool} may be specified
9635 via an attribute_definition_clause (or by specifying the equivalent aspect):
9637 @smallexample @c ada
9639 My_Pool : My_Simple_Storage_Pool_Type;
9641 type Acc is access My_Data_Type;
9643 for Acc'Simple_Storage_Pool use My_Pool;
9645 @end smallexample
9647 @noindent
9648 The name given in an attribute_definition_clause for the
9649 @code{Simple_Storage_Pool} attribute shall denote a variable of
9650 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
9652 The use of this attribute is only allowed for a prefix denoting a type
9653 for which it has been specified. The type of the attribute is the type
9654 of the variable specified as the simple storage pool of the access type,
9655 and the attribute denotes that variable.
9657 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
9658 for the same access type.
9660 If the @code{Simple_Storage_Pool} attribute has been specified for an access
9661 type, then applying the @code{Storage_Pool} attribute to the type is flagged
9662 with a warning and its evaluation raises the exception @code{Program_Error}.
9664 If the Simple_Storage_Pool attribute has been specified for an access
9665 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
9666 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
9667 which is intended to indicate the number of storage elements reserved for
9668 the simple storage pool. If the Storage_Size function has not been defined
9669 for the simple storage pool type, then this attribute returns zero.
9671 If an access type @var{S} has a specified simple storage pool of type
9672 @var{SSP}, then the evaluation of an allocator for that access type calls
9673 the primitive @code{Allocate} procedure for type @var{SSP}, passing
9674 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
9675 semantics of such allocators is the same as those defined for allocators
9676 in section 13.11 of the Ada Reference Manual, with the term
9677 ``simple storage pool'' substituted for ``storage pool''.
9679 If an access type @var{S} has a specified simple storage pool of type
9680 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
9681 for that access type invokes the primitive @code{Deallocate} procedure
9682 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
9683 parameter. The detailed semantics of such unchecked deallocations is the same
9684 as defined in section 13.11.2 of the Ada Reference Manual, except that the
9685 term ``simple storage pool'' is substituted for ``storage pool''.
9687 @node Attribute Small
9688 @unnumberedsec Attribute Small
9689 @cindex Ada 83 attributes
9690 @findex Small
9691 @noindent
9692 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
9693 fixed-point types.
9694 GNAT also allows this attribute to be applied to floating-point types
9695 for compatibility with Ada 83.  See
9696 the Ada 83 reference manual for an exact description of the semantics of
9697 this attribute when applied to floating-point types.
9699 @node Attribute Storage_Unit
9700 @unnumberedsec Attribute Storage_Unit
9701 @findex Storage_Unit
9702 @noindent
9703 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
9704 prefix) provides the same value as @code{System.Storage_Unit}.
9706 @node Attribute Stub_Type
9707 @unnumberedsec Attribute Stub_Type
9708 @findex Stub_Type
9709 @noindent
9710 The GNAT implementation of remote access-to-classwide types is
9711 organized as described in AARM section E.4 (20.t): a value of an RACW type
9712 (designating a remote object) is represented as a normal access
9713 value, pointing to a "stub" object which in turn contains the
9714 necessary information to contact the designated remote object. A
9715 call on any dispatching operation of such a stub object does the
9716 remote call, if necessary, using the information in the stub object
9717 to locate the target partition, etc.
9719 For a prefix @code{T} that denotes a remote access-to-classwide type,
9720 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
9722 By construction, the layout of @code{T'Stub_Type} is identical to that of
9723 type @code{RACW_Stub_Type} declared in the internal implementation-defined
9724 unit @code{System.Partition_Interface}. Use of this attribute will create
9725 an implicit dependency on this unit.
9727 @node Attribute System_Allocator_Alignment
9728 @unnumberedsec Attribute System_Allocator_Alignment
9729 @cindex Alignment, allocator
9730 @findex System_Allocator_Alignment
9731 @noindent
9732 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
9733 permissible prefix) provides the observable guaranted to be honored by
9734 the system allocator (malloc). This is a static value that can be used
9735 in user storage pools based on malloc either to reject allocation
9736 with alignment too large or to enable a realignment circuitry if the
9737 alignment request is larger than this value.
9739 @node Attribute Target_Name
9740 @unnumberedsec Attribute Target_Name
9741 @findex Target_Name
9742 @noindent
9743 @code{Standard'Target_Name} (@code{Standard} is the only permissible
9744 prefix) provides a static string value that identifies the target
9745 for the current compilation. For GCC implementations, this is the
9746 standard gcc target name without the terminating slash (for
9747 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
9749 @node Attribute To_Address
9750 @unnumberedsec Attribute To_Address
9751 @findex To_Address
9752 @noindent
9753 The @code{System'To_Address}
9754 (@code{System} is the only permissible prefix)
9755 denotes a function identical to
9756 @code{System.Storage_Elements.To_Address} except that
9757 it is a static attribute.  This means that if its argument is
9758 a static expression, then the result of the attribute is a
9759 static expression.  This means that such an expression can be
9760 used in contexts (e.g.@: preelaborable packages) which require a
9761 static expression and where the function call could not be used
9762 (since the function call is always non-static, even if its
9763 argument is static). The argument must be in the range
9764 -(2**(m-1) .. 2**m-1, where m is the memory size
9765 (typically 32 or 64). Negative values are intepreted in a
9766 modular manner (e.g. -1 means the same as 16#FFFF_FFFF# on
9767 a 32 bits machine).
9769 @node Attribute To_Any
9770 @unnumberedsec Attribute To_Any
9771 @findex To_Any
9772 @noindent
9773 This internal attribute is used for the generation of remote subprogram
9774 stubs in the context of the Distributed Systems Annex.
9776 @node Attribute Type_Class
9777 @unnumberedsec Attribute Type_Class
9778 @findex Type_Class
9779 @noindent
9780 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
9781 the value of the type class for the full type of @var{type}.  If
9782 @var{type} is a generic formal type, the value is the value for the
9783 corresponding actual subtype.  The value of this attribute is of type
9784 @code{System.Aux_DEC.Type_Class}, which has the following definition:
9786 @smallexample @c ada
9787 type Type_Class is
9788   (Type_Class_Enumeration,
9789    Type_Class_Integer,
9790    Type_Class_Fixed_Point,
9791    Type_Class_Floating_Point,
9792    Type_Class_Array,
9793    Type_Class_Record,
9794    Type_Class_Access,
9795    Type_Class_Task,
9796    Type_Class_Address);
9797 @end smallexample
9799 @noindent
9800 Protected types yield the value @code{Type_Class_Task}, which thus
9801 applies to all concurrent types.  This attribute is designed to
9802 be compatible with the DEC Ada 83 attribute of the same name.
9804 @node Attribute Type_Key
9805 @unnumberedsec Attribute Type_Key
9806 @findex Type_Key
9807 @noindent
9808 The @code{Type_Key} attribute is applicable to a type or subtype and
9809 yields a value of type Standard.String containing encoded information
9810 about the type or subtype. This provides improved compatibility with
9811 other implementations that support this attribute.
9813 @node Attribute TypeCode
9814 @unnumberedsec Attribute TypeCode
9815 @findex TypeCode
9816 @noindent
9817 This internal attribute is used for the generation of remote subprogram
9818 stubs in the context of the Distributed Systems Annex.
9820 @node Attribute UET_Address
9821 @unnumberedsec Attribute UET_Address
9822 @findex UET_Address
9823 @noindent
9824 The @code{UET_Address} attribute can only be used for a prefix which
9825 denotes a library package.  It yields the address of the unit exception
9826 table when zero cost exception handling is used.  This attribute is
9827 intended only for use within the GNAT implementation.  See the unit
9828 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
9829 for details on how this attribute is used in the implementation.
9831 @node Attribute Unconstrained_Array
9832 @unnumberedsec Attribute Unconstrained_Array
9833 @findex Unconstrained_Array
9834 @noindent
9835 The @code{Unconstrained_Array} attribute can be used with a prefix that
9836 denotes any type or subtype. It is a static attribute that yields
9837 @code{True} if the prefix designates an unconstrained array,
9838 and @code{False} otherwise. In a generic instance, the result is
9839 still static, and yields the result of applying this test to the
9840 generic actual.
9842 @node Attribute Universal_Literal_String
9843 @unnumberedsec Attribute Universal_Literal_String
9844 @cindex Named numbers, representation of
9845 @findex Universal_Literal_String
9846 @noindent
9847 The prefix of @code{Universal_Literal_String} must be a named
9848 number.  The static result is the string consisting of the characters of
9849 the number as defined in the original source.  This allows the user
9850 program to access the actual text of named numbers without intermediate
9851 conversions and without the need to enclose the strings in quotes (which
9852 would preclude their use as numbers).
9854 For example, the following program prints the first 50 digits of pi:
9856 @smallexample @c ada
9857 with Text_IO; use Text_IO;
9858 with Ada.Numerics;
9859 procedure Pi is
9860 begin
9861    Put (Ada.Numerics.Pi'Universal_Literal_String);
9862 end;
9863 @end smallexample
9865 @node Attribute Unrestricted_Access
9866 @unnumberedsec Attribute Unrestricted_Access
9867 @cindex @code{Access}, unrestricted
9868 @findex Unrestricted_Access
9869 @noindent
9870 The @code{Unrestricted_Access} attribute is similar to @code{Access}
9871 except that all accessibility and aliased view checks are omitted.  This
9872 is a user-beware attribute.
9874 For objects, it is similar to @code{Address}, for which it is a
9875 desirable replacement where the value desired is an access type.
9876 In other words, its effect is similar to first applying the
9877 @code{Address} attribute and then doing an unchecked conversion to a
9878 desired access type.
9880 For subprograms, @code{P'Unrestricted_Access} may be used where
9881 @code{P'Access} would be illegal, to construct a value of a
9882 less-nested named access type that designates a more-nested
9883 subprogram. This value may be used in indirect calls, so long as the
9884 more-nested subprogram still exists; once the subprogram containing it
9885 has returned, such calls are erroneous. For example:
9887 @smallexample @c ada
9888 package body P is
9890    type Less_Nested is not null access procedure;
9891    Global : Less_Nested;
9893    procedure P1 is
9894    begin
9895       Global.all;
9896    end P1;
9898    procedure P2 is
9899       Local_Var : Integer;
9901       procedure More_Nested is
9902       begin
9903          ... Local_Var ...
9904       end More_Nested;
9905    begin
9906       Global := More_Nested'Unrestricted_Access;
9907       P1;
9908    end P2;
9910 end P;
9911 @end smallexample
9913 When P1 is called from P2, the call via Global is OK, but if P1 were
9914 called after P2 returns, it would be an erroneous use of a dangling
9915 pointer.
9917 For objects, it is possible to use @code{Unrestricted_Access} for any
9918 type, but care must be exercised if it is used to create pointers to
9919 unconstrained array objects.  In this case, the resulting pointer has
9920 the same scope as the context of the attribute, and may not be
9921 returned to some enclosing scope.  For instance, a function cannot use
9922 @code{Unrestricted_Access} to create a pointer to unconstrained and
9923 then return that value to the caller.  In addition, it is only valid
9924 to create pointers to unconstrained arrays using this attribute if the
9925 pointer has the normal default ``fat'' representation where a pointer
9926 has two components, one points to the array and one points to the
9927 bounds.  If a size clause is used to force ``thin'' representation for
9928 a pointer to unconstrained where there is only space for a single
9929 pointer, then the resulting pointer is not usable.
9931 In the simple case where a direct use of Unrestricted_Access attempts
9932 to make a thin pointer for a non-aliased object, the compiler will
9933 reject the use as illegal, as shown in the following example:
9935 @smallexample @c ada
9936 with System; use System;
9937 procedure SliceUA2 is
9938    type A is access all String;
9939    for A'Size use Standard'Address_Size;
9941    procedure P (Arg : A) is
9942    begin
9943       null;
9944    end P;
9946    X : String := "hello world!";
9947    X2 : aliased String := "hello world!";
9949    AV : A := X'Unrestricted_Access;    -- ERROR
9950              |
9951 >>> illegal use of Unrestricted_Access attribute
9952 >>> attempt to generate thin pointer to unaliased object
9954 begin
9955    P (X'Unrestricted_Access);          -- ERROR
9956       |
9957 >>> illegal use of Unrestricted_Access attribute
9958 >>> attempt to generate thin pointer to unaliased object
9960    P (X(7 .. 12)'Unrestricted_Access); -- ERROR
9961       |
9962 >>> illegal use of Unrestricted_Access attribute
9963 >>> attempt to generate thin pointer to unaliased object
9965    P (X2'Unrestricted_Access);         -- OK
9966 end;
9967 @end smallexample
9969 @noindent
9970 but other cases cannot be detected by the compiler, and are
9971 considered to be erroneous. Consider the following example:
9973 @smallexample @c ada
9974 with System; use System;
9975 with System; use System;
9976 procedure SliceUA is
9977    type AF is access all String;
9979    type A is access all String;
9980    for A'Size use Standard'Address_Size;
9982    procedure P (Arg : A) is
9983    begin
9984       if Arg'Length /= 6 then
9985          raise Program_Error;
9986       end if;
9987    end P;
9989    X : String := "hello world!";
9990    Y : AF := X (7 .. 12)'Unrestricted_Access;
9992 begin
9993    P (A (Y));
9994 end;
9995 @end smallexample
9997 @noindent
9998 A normal unconstrained array value
9999 or a constrained array object marked as aliased has the bounds in memory
10000 just before the array, so a thin pointer can retrieve both the data and
10001 the bounds.  But in this case, the non-aliased object @code{X} does not have the
10002 bounds before the string.  If the size clause for type @code{A}
10003 were not present, then the pointer
10004 would be a fat pointer, where one component is a pointer to the bounds,
10005 and all would be well.  But with the size clause present, the conversion from
10006 fat pointer to thin pointer in the call loses the bounds, and so this
10007 is erroneous, and the program likely raises a @code{Program_Error} exception.
10009 In general, it is advisable to completely
10010 avoid mixing the use of thin pointers and the use of
10011 @code{Unrestricted_Access} where the designated type is an
10012 unconstrained array.  The use of thin pointers should be restricted to
10013 cases of porting legacy code that implicitly assumes the size of pointers,
10014 and such code should not in any case be using this attribute.
10016 Another erroneous situation arises if the attribute is
10017 applied to a constant. The resulting pointer can be used to access the
10018 constant, but the effect of trying to modify a constant in this manner
10019 is not well-defined. Consider this example:
10021 @smallexample @c ada
10022 P : constant Integer := 4;
10023 type R is access all Integer;
10024 RV : R := P'Unrestricted_Access;
10026 RV.all := 3;
10027 @end smallexample
10029 @noindent
10030 Here we attempt to modify the constant P from 4 to 3, but the compiler may
10031 or may not notice this attempt, and subsequent references to P may yield
10032 either the value 3 or the value 4 or the assignment may blow up if the
10033 compiler decides to put P in read-only memory. One particular case where
10034 @code{Unrestricted_Access} can be used in this way is to modify the
10035 value of an @code{IN} parameter:
10037 @smallexample @c ada
10038 procedure K (S : in String) is
10039    type R is access all Character;
10040    RV : R := S (3)'Unrestricted_Access;
10041 begin
10042    RV.all := 'a';
10043 end;
10044 @end smallexample
10046 @noindent
10047 In general this is a risky approach. It may appear to "work" but such uses of
10048 @code{Unrestricted_Access} are potentially non-portable, even from one version
10049 of @code{GNAT} to another, so are best avoided if possible.
10051 @node Attribute Update
10052 @unnumberedsec Attribute Update
10053 @findex Update
10054 @noindent
10055 The @code{Update} attribute creates a copy of an array or record value
10056 with one or more modified components. The syntax is:
10058 @smallexample @c ada
10059 PREFIX'Update ( RECORD_COMPONENT_ASSOCIATION_LIST )
10060 PREFIX'Update ( ARRAY_COMPONENT_ASSOCIATION @{, ARRAY_COMPONENT_ASSOCIATION @} )
10061 PREFIX'Update ( MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION
10062                 @{, MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION @} )
10064 MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION ::= INDEX_EXPRESSION_LIST_LIST => EXPRESSION
10065 INDEX_EXPRESSION_LIST_LIST                   ::= INDEX_EXPRESSION_LIST @{| INDEX_EXPRESSION_LIST @}
10066 INDEX_EXPRESSION_LIST                        ::= ( EXPRESSION @{, EXPRESSION @} )
10067 @end smallexample
10069 @noindent
10070 where @code{PREFIX} is the name of an array or record object, and
10071 the association list in parentheses does not contain an @code{others}
10072 choice. The effect is to yield a copy of the array or record value which
10073 is unchanged apart from the components mentioned in the association list, which
10074 are changed to the indicated value. The original value of the array or
10075 record value is not affected. For example:
10077 @smallexample @c ada
10078 type Arr is Array (1 .. 5) of Integer;
10080 Avar1 : Arr := (1,2,3,4,5);
10081 Avar2 : Arr := Avar1'Update (2 => 10, 3 .. 4 => 20);
10082 @end smallexample
10084 @noindent
10085 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
10086 begin unmodified. Similarly:
10088 @smallexample @c ada
10089 type Rec is A, B, C : Integer;
10091 Rvar1 : Rec := (A => 1, B => 2, C => 3);
10092 Rvar2 : Rec := Rvar1'Update (B => 20);
10093 @end smallexample
10095 @noindent
10096 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
10097 with @code{Rvar1} being unmodifed.
10098 Note that the value of the attribute reference is computed
10099 completely before it is used. This means that if you write:
10101 @smallexample @c ada
10102 Avar1 := Avar1'Update (1 => 10, 2 => Function_Call);
10103 @end smallexample
10105 @noindent
10106 then the value of @code{Avar1} is not modified if @code{Function_Call}
10107 raises an exception, unlike the effect of a series of direct assignments
10108 to elements of @code{Avar1}. In general this requires that
10109 two extra complete copies of the object are required, which should be
10110 kept in mind when considering efficiency.
10112 The @code{Update} attribute cannot be applied to prefixes of a limited
10113 type, and cannot reference discriminants in the case of a record type.
10114 The accessibility level of an Update attribute result object is defined
10115 as for an aggregate.
10117 In the record case, no component can be mentioned more than once. In
10118 the array case, two overlapping ranges can appear in the association list,
10119 in which case the modifications are processed left to right.
10121 Multi-dimensional arrays can be modified, as shown by this example:
10123 @smallexample @c ada
10124 A : array (1 .. 10, 1 .. 10) of Integer;
10126 A := A'Update ((1, 2) => 20, (3, 4) => 30);
10127 @end smallexample
10129 @noindent
10130 which changes element (1,2) to 20 and (3,4) to 30.
10132 @node Attribute Valid_Scalars
10133 @unnumberedsec Attribute Valid_Scalars
10134 @findex Valid_Scalars
10135 @noindent
10136 The @code{'Valid_Scalars} attribute is intended to make it easier to
10137 check the validity of scalar subcomponents of composite objects. It
10138 is defined for any prefix @code{X} that denotes an object.
10139 The value of this attribute is of the predefined type Boolean.
10140 @code{X'Valid_Scalars} yields True if and only if evaluation of
10141 @code{P'Valid} yields True for every scalar part P of X or if X has
10142 no scalar parts. It is not specified in what order the scalar parts
10143 are checked, nor whether any more are checked after any one of them
10144 is determined to be invalid. If the prefix @code{X} is of a class-wide
10145 type @code{T'Class} (where @code{T} is the associated specific type),
10146 or if the prefix @code{X} is of a specific tagged type @code{T}, then
10147 only the scalar parts of components of @code{T} are traversed; in other
10148 words, components of extensions of @code{T} are not traversed even if
10149 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
10150 be determined at compile time that the prefix of the attribute has no
10151 scalar parts (e.g., if the prefix is of an access type, an interface type,
10152 an undiscriminated task type, or an undiscriminated protected type).
10154 For scalar types, @code{Valid_Scalars} is equivalent to @code{Valid}. The use
10155 of this attribute is not permitted for @code{Unchecked_Union} types for which
10156 in general it is not possible to determine the values of the discriminants.
10158 Note: @code{Valid_Scalars} can generate a lot of code, especially in the case
10159 of a large variant record. If the attribute is called in many places in the
10160 same program applied to objects of the same type, it can reduce program size
10161 to write a function with a single use of the attribute, and then call that
10162 function from multiple places.
10164 @node Attribute VADS_Size
10165 @unnumberedsec Attribute VADS_Size
10166 @cindex @code{Size}, VADS compatibility
10167 @findex VADS_Size
10168 @noindent
10169 The @code{'VADS_Size} attribute is intended to make it easier to port
10170 legacy code which relies on the semantics of @code{'Size} as implemented
10171 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
10172 same semantic interpretation.  In particular, @code{'VADS_Size} applied
10173 to a predefined or other primitive type with no Size clause yields the
10174 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
10175 typical machines).  In addition @code{'VADS_Size} applied to an object
10176 gives the result that would be obtained by applying the attribute to
10177 the corresponding type.
10179 @node Attribute Value_Size
10180 @unnumberedsec Attribute Value_Size
10181 @cindex @code{Size}, setting for not-first subtype
10182 @findex Value_Size
10183 @code{@var{type}'Value_Size} is the number of bits required to represent
10184 a value of the given subtype.  It is the same as @code{@var{type}'Size},
10185 but, unlike @code{Size}, may be set for non-first subtypes.
10187 @node Attribute Wchar_T_Size
10188 @unnumberedsec Attribute Wchar_T_Size
10189 @findex Wchar_T_Size
10190 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
10191 prefix) provides the size in bits of the C @code{wchar_t} type
10192 primarily for constructing the definition of this type in
10193 package @code{Interfaces.C}. The result is a static constant.
10195 @node Attribute Word_Size
10196 @unnumberedsec Attribute Word_Size
10197 @findex Word_Size
10198 @code{Standard'Word_Size} (@code{Standard} is the only permissible
10199 prefix) provides the value @code{System.Word_Size}. The result is
10200 a static constant.
10202 @node Standard and Implementation Defined Restrictions
10203 @chapter Standard and Implementation Defined Restrictions
10205 @noindent
10206 All RM defined Restriction identifiers are implemented:
10208 @itemize @bullet
10209 @item language-defined restrictions (see 13.12.1)
10210 @item tasking restrictions (see D.7)
10211 @item high integrity restrictions (see H.4)
10212 @end itemize
10214 @noindent
10215 GNAT implements additional restriction identifiers. All restrictions, whether
10216 language defined or GNAT-specific, are listed in the following.
10218 @menu
10219 * Partition-Wide Restrictions::
10220 * Program Unit Level Restrictions::
10221 @end menu
10223 @node Partition-Wide Restrictions
10224 @section Partition-Wide Restrictions
10226 There are two separate lists of restriction identifiers. The first
10227 set requires consistency throughout a partition (in other words, if the
10228 restriction identifier is used for any compilation unit in the partition,
10229 then all compilation units in the partition must obey the restriction).
10231 @menu
10232 * Immediate_Reclamation::
10233 * Max_Asynchronous_Select_Nesting::
10234 * Max_Entry_Queue_Length::
10235 * Max_Protected_Entries::
10236 * Max_Select_Alternatives::
10237 * Max_Storage_At_Blocking::
10238 * Max_Task_Entries::
10239 * Max_Tasks::
10240 * No_Abort_Statements::
10241 * No_Access_Parameter_Allocators::
10242 * No_Access_Subprograms::
10243 * No_Allocators::
10244 * No_Anonymous_Allocators::
10245 * No_Calendar::
10246 * No_Coextensions::
10247 * No_Default_Initialization::
10248 * No_Delay::
10249 * No_Dependence::
10250 * No_Direct_Boolean_Operators::
10251 * No_Dispatch::
10252 * No_Dispatching_Calls::
10253 * No_Dynamic_Attachment::
10254 * No_Dynamic_Priorities::
10255 * No_Entry_Calls_In_Elaboration_Code::
10256 * No_Enumeration_Maps::
10257 * No_Exception_Handlers::
10258 * No_Exception_Propagation::
10259 * No_Exception_Registration::
10260 * No_Exceptions::
10261 * No_Finalization::
10262 * No_Fixed_Point::
10263 * No_Floating_Point::
10264 * No_Implicit_Conditionals::
10265 * No_Implicit_Dynamic_Code::
10266 * No_Implicit_Heap_Allocations::
10267 * No_Implicit_Loops::
10268 * No_Initialize_Scalars::
10269 * No_IO::
10270 * No_Local_Allocators::
10271 * No_Local_Protected_Objects::
10272 * No_Local_Timing_Events::
10273 * No_Long_Long_Integers::
10274 * No_Multiple_Elaboration::
10275 * No_Nested_Finalization::
10276 * No_Protected_Type_Allocators::
10277 * No_Protected_Types::
10278 * No_Recursion::
10279 * No_Reentrancy::
10280 * No_Relative_Delay::
10281 * No_Requeue_Statements::
10282 * No_Secondary_Stack::
10283 * No_Select_Statements::
10284 * No_Specific_Termination_Handlers::
10285 * No_Specification_of_Aspect::
10286 * No_Standard_Allocators_After_Elaboration::
10287 * No_Standard_Storage_Pools::
10288 * No_Stream_Optimizations::
10289 * No_Streams::
10290 * No_Task_Allocators::
10291 * No_Task_Attributes_Package::
10292 * No_Task_Hierarchy::
10293 * No_Task_Termination::
10294 * No_Tasking::
10295 * No_Terminate_Alternatives::
10296 * No_Unchecked_Access::
10297 * Simple_Barriers::
10298 * Static_Priorities::
10299 * Static_Storage_Size::
10300 @end menu
10302 @node Immediate_Reclamation
10303 @unnumberedsubsec Immediate_Reclamation
10304 @findex Immediate_Reclamation
10305 [RM H.4] This restriction ensures that, except for storage occupied by
10306 objects created by allocators and not deallocated via unchecked
10307 deallocation, any storage reserved at run time for an object is
10308 immediately reclaimed when the object no longer exists.
10310 @node Max_Asynchronous_Select_Nesting
10311 @unnumberedsubsec Max_Asynchronous_Select_Nesting
10312 @findex Max_Asynchronous_Select_Nesting
10313 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
10314 selects. Violations of this restriction with a value of zero are
10315 detected at compile time. Violations of this restriction with values
10316 other than zero cause Storage_Error to be raised.
10318 @node Max_Entry_Queue_Length
10319 @unnumberedsubsec Max_Entry_Queue_Length
10320 @findex Max_Entry_Queue_Length
10321 [RM D.7] This restriction is a declaration that any protected entry compiled in
10322 the scope of the restriction has at most the specified number of
10323 tasks waiting on the entry at any one time, and so no queue is required.
10324 Note that this restriction is checked at run time. Violation of this
10325 restriction results in the raising of Program_Error exception at the point of
10326 the call.
10328 @findex Max_Entry_Queue_Depth
10329 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
10330 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
10331 compatibility purposes (and a warning will be generated for its use if
10332 warnings on obsolescent features are activated).
10334 @node Max_Protected_Entries
10335 @unnumberedsubsec Max_Protected_Entries
10336 @findex Max_Protected_Entries
10337 [RM D.7] Specifies the maximum number of entries per protected type. The
10338 bounds of every entry family of a protected unit shall be static, or shall be
10339 defined by a discriminant of a subtype whose corresponding bound is static.
10341 @node Max_Select_Alternatives
10342 @unnumberedsubsec Max_Select_Alternatives
10343 @findex Max_Select_Alternatives
10344 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
10346 @node Max_Storage_At_Blocking
10347 @unnumberedsubsec Max_Storage_At_Blocking
10348 @findex Max_Storage_At_Blocking
10349 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
10350 Storage_Size that can be retained by a blocked task. A violation of this
10351 restriction causes Storage_Error to be raised.
10353 @node Max_Task_Entries
10354 @unnumberedsubsec Max_Task_Entries
10355 @findex Max_Task_Entries
10356 [RM D.7] Specifies the maximum number of entries
10357 per task.  The bounds of every entry family
10358 of a task unit shall be static, or shall be
10359 defined by a discriminant of a subtype whose
10360 corresponding bound is static.
10362 @node Max_Tasks
10363 @unnumberedsubsec Max_Tasks
10364 @findex Max_Tasks
10365 [RM D.7] Specifies the maximum number of task that may be created, not
10366 counting the creation of the environment task.  Violations of this
10367 restriction with a value of zero are detected at compile
10368 time. Violations of this restriction with values other than zero cause
10369 Storage_Error to be raised.
10371 @node No_Abort_Statements
10372 @unnumberedsubsec No_Abort_Statements
10373 @findex No_Abort_Statements
10374 [RM D.7] There are no abort_statements, and there are
10375 no calls to Task_Identification.Abort_Task.
10377 @node No_Access_Parameter_Allocators
10378 @unnumberedsubsec No_Access_Parameter_Allocators
10379 @findex No_Access_Parameter_Allocators
10380 [RM H.4] This restriction ensures at compile time that there are no
10381 occurrences of an allocator as the actual parameter to an access
10382 parameter.
10384 @node No_Access_Subprograms
10385 @unnumberedsubsec No_Access_Subprograms
10386 @findex No_Access_Subprograms
10387 [RM H.4] This restriction ensures at compile time that there are no
10388 declarations of access-to-subprogram types.
10390 @node No_Allocators
10391 @unnumberedsubsec No_Allocators
10392 @findex No_Allocators
10393 [RM H.4] This restriction ensures at compile time that there are no
10394 occurrences of an allocator.
10396 @node No_Anonymous_Allocators
10397 @unnumberedsubsec No_Anonymous_Allocators
10398 @findex No_Anonymous_Allocators
10399 [RM H.4] This restriction ensures at compile time that there are no
10400 occurrences of an allocator of anonymous access type.
10402 @node No_Calendar
10403 @unnumberedsubsec No_Calendar
10404 @findex No_Calendar
10405 [GNAT] This restriction ensures at compile time that there is no implicit or
10406 explicit dependence on the package @code{Ada.Calendar}.
10408 @node No_Coextensions
10409 @unnumberedsubsec No_Coextensions
10410 @findex No_Coextensions
10411 [RM H.4] This restriction ensures at compile time that there are no
10412 coextensions. See 3.10.2.
10414 @node No_Default_Initialization
10415 @unnumberedsubsec No_Default_Initialization
10416 @findex No_Default_Initialization
10418 [GNAT] This restriction prohibits any instance of default initialization
10419 of variables.  The binder implements a consistency rule which prevents
10420 any unit compiled without the restriction from with'ing a unit with the
10421 restriction (this allows the generation of initialization procedures to
10422 be skipped, since you can be sure that no call is ever generated to an
10423 initialization procedure in a unit with the restriction active). If used
10424 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
10425 is to prohibit all cases of variables declared without a specific
10426 initializer (including the case of OUT scalar parameters).
10428 @node No_Delay
10429 @unnumberedsubsec No_Delay
10430 @findex No_Delay
10431 [RM H.4] This restriction ensures at compile time that there are no
10432 delay statements and no dependences on package Calendar.
10434 @node No_Dependence
10435 @unnumberedsubsec No_Dependence
10436 @findex No_Dependence
10437 [RM 13.12.1] This restriction checks at compile time that there are no
10438 dependence on a library unit.
10440 @node No_Direct_Boolean_Operators
10441 @unnumberedsubsec No_Direct_Boolean_Operators
10442 @findex No_Direct_Boolean_Operators
10443 [GNAT] This restriction ensures that no logical operators (and/or/xor)
10444 are used on operands of type Boolean (or any type derived from Boolean).
10445 This is intended for use in safety critical programs where the certification
10446 protocol requires the use of short-circuit (and then, or else) forms for all
10447 composite boolean operations.
10449 @node No_Dispatch
10450 @unnumberedsubsec No_Dispatch
10451 @findex No_Dispatch
10452 [RM H.4] This restriction ensures at compile time that there are no
10453 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
10455 @node No_Dispatching_Calls
10456 @unnumberedsubsec No_Dispatching_Calls
10457 @findex No_Dispatching_Calls
10458 [GNAT] This restriction ensures at compile time that the code generated by the
10459 compiler involves no dispatching calls. The use of this restriction allows the
10460 safe use of record extensions, classwide membership tests and other classwide
10461 features not involving implicit dispatching. This restriction ensures that
10462 the code contains no indirect calls through a dispatching mechanism. Note that
10463 this includes internally-generated calls created by the compiler, for example
10464 in the implementation of class-wide objects assignments. The
10465 membership test is allowed in the presence of this restriction, because its
10466 implementation requires no dispatching.
10467 This restriction is comparable to the official Ada restriction
10468 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
10469 all classwide constructs that do not imply dispatching.
10470 The following example indicates constructs that violate this restriction.
10472 @smallexample
10473 package Pkg is
10474   type T is tagged record
10475     Data : Natural;
10476   end record;
10477   procedure P (X : T);
10479   type DT is new T with record
10480     More_Data : Natural;
10481   end record;
10482   procedure Q (X : DT);
10483 end Pkg;
10485 with Pkg; use Pkg;
10486 procedure Example is
10487   procedure Test (O : T'Class) is
10488     N : Natural  := O'Size;--  Error: Dispatching call
10489     C : T'Class := O;      --  Error: implicit Dispatching Call
10490   begin
10491     if O in DT'Class then  --  OK   : Membership test
10492        Q (DT (O));         --  OK   : Type conversion plus direct call
10493     else
10494        P (O);              --  Error: Dispatching call
10495     end if;
10496   end Test;
10498   Obj : DT;
10499 begin
10500   P (Obj);                 --  OK   : Direct call
10501   P (T (Obj));             --  OK   : Type conversion plus direct call
10502   P (T'Class (Obj));       --  Error: Dispatching call
10504   Test (Obj);              --  OK   : Type conversion
10506   if Obj in T'Class then   --  OK   : Membership test
10507      null;
10508   end if;
10509 end Example;
10510 @end smallexample
10512 @node No_Dynamic_Attachment
10513 @unnumberedsubsec No_Dynamic_Attachment
10514 @findex No_Dynamic_Attachment
10515 [RM D.7] This restriction ensures that there is no call to any of the
10516 operations defined in package Ada.Interrupts
10517 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
10518 Detach_Handler, and Reference).
10520 @findex No_Dynamic_Interrupts
10521 The restriction @code{No_Dynamic_Interrupts} is recognized as a
10522 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
10523 compatibility purposes (and a warning will be generated for its use if
10524 warnings on obsolescent features are activated).
10526 @node No_Dynamic_Priorities
10527 @unnumberedsubsec No_Dynamic_Priorities
10528 @findex No_Dynamic_Priorities
10529 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
10531 @node No_Entry_Calls_In_Elaboration_Code
10532 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
10533 @findex No_Entry_Calls_In_Elaboration_Code
10534 [GNAT] This restriction ensures at compile time that no task or protected entry
10535 calls are made during elaboration code.  As a result of the use of this
10536 restriction, the compiler can assume that no code past an accept statement
10537 in a task can be executed at elaboration time.
10539 @node No_Enumeration_Maps
10540 @unnumberedsubsec No_Enumeration_Maps
10541 @findex No_Enumeration_Maps
10542 [GNAT] This restriction ensures at compile time that no operations requiring
10543 enumeration maps are used (that is Image and Value attributes applied
10544 to enumeration types).
10546 @node No_Exception_Handlers
10547 @unnumberedsubsec No_Exception_Handlers
10548 @findex No_Exception_Handlers
10549 [GNAT] This restriction ensures at compile time that there are no explicit
10550 exception handlers. It also indicates that no exception propagation will
10551 be provided. In this mode, exceptions may be raised but will result in
10552 an immediate call to the last chance handler, a routine that the user
10553 must define with the following profile:
10555 @smallexample @c ada
10556 procedure Last_Chance_Handler
10557   (Source_Location : System.Address; Line : Integer);
10558 pragma Export (C, Last_Chance_Handler,
10559                "__gnat_last_chance_handler");
10560 @end smallexample
10562 The parameter is a C null-terminated string representing a message to be
10563 associated with the exception (typically the source location of the raise
10564 statement generated by the compiler). The Line parameter when nonzero
10565 represents the line number in the source program where the raise occurs.
10567 @node No_Exception_Propagation
10568 @unnumberedsubsec No_Exception_Propagation
10569 @findex No_Exception_Propagation
10570 [GNAT] This restriction guarantees that exceptions are never propagated
10571 to an outer subprogram scope. The only case in which an exception may
10572 be raised is when the handler is statically in the same subprogram, so
10573 that the effect of a raise is essentially like a goto statement. Any
10574 other raise statement (implicit or explicit) will be considered
10575 unhandled. Exception handlers are allowed, but may not contain an
10576 exception occurrence identifier (exception choice). In addition, use of
10577 the package GNAT.Current_Exception is not permitted, and reraise
10578 statements (raise with no operand) are not permitted.
10580 @node No_Exception_Registration
10581 @unnumberedsubsec No_Exception_Registration
10582 @findex No_Exception_Registration
10583 [GNAT] This restriction ensures at compile time that no stream operations for
10584 types Exception_Id or Exception_Occurrence are used. This also makes it
10585 impossible to pass exceptions to or from a partition with this restriction
10586 in a distributed environment. If this restriction is active, the generated
10587 code is simplified by omitting the otherwise-required global registration
10588 of exceptions when they are declared.
10590 @node No_Exceptions
10591 @unnumberedsubsec No_Exceptions
10592 @findex No_Exceptions
10593 [RM H.4] This restriction ensures at compile time that there are no
10594 raise statements and no exception handlers.
10596 @node No_Finalization
10597 @unnumberedsubsec No_Finalization
10598 @findex No_Finalization
10599 [GNAT] This restriction disables the language features described in
10600 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
10601 performed by the compiler to support these features. The following types
10602 are no longer considered controlled when this restriction is in effect:
10603 @itemize @bullet
10604 @item
10605 @code{Ada.Finalization.Controlled}
10606 @item
10607 @code{Ada.Finalization.Limited_Controlled}
10608 @item
10609 Derivations from @code{Controlled} or @code{Limited_Controlled}
10610 @item
10611 Class-wide types
10612 @item
10613 Protected types
10614 @item
10615 Task types
10616 @item
10617 Array and record types with controlled components
10618 @end itemize
10619 The compiler no longer generates code to initialize, finalize or adjust an
10620 object or a nested component, either declared on the stack or on the heap. The
10621 deallocation of a controlled object no longer finalizes its contents.
10623 @node No_Fixed_Point
10624 @unnumberedsubsec No_Fixed_Point
10625 @findex No_Fixed_Point
10626 [RM H.4] This restriction ensures at compile time that there are no
10627 occurrences of fixed point types and operations.
10629 @node No_Floating_Point
10630 @unnumberedsubsec No_Floating_Point
10631 @findex No_Floating_Point
10632 [RM H.4] This restriction ensures at compile time that there are no
10633 occurrences of floating point types and operations.
10635 @node No_Implicit_Conditionals
10636 @unnumberedsubsec No_Implicit_Conditionals
10637 @findex No_Implicit_Conditionals
10638 [GNAT] This restriction ensures that the generated code does not contain any
10639 implicit conditionals, either by modifying the generated code where possible,
10640 or by rejecting any construct that would otherwise generate an implicit
10641 conditional. Note that this check does not include run time constraint
10642 checks, which on some targets may generate implicit conditionals as
10643 well. To control the latter, constraint checks can be suppressed in the
10644 normal manner. Constructs generating implicit conditionals include comparisons
10645 of composite objects and the Max/Min attributes.
10647 @node No_Implicit_Dynamic_Code
10648 @unnumberedsubsec No_Implicit_Dynamic_Code
10649 @findex No_Implicit_Dynamic_Code
10650 @cindex trampoline
10651 [GNAT] This restriction prevents the compiler from building ``trampolines''.
10652 This is a structure that is built on the stack and contains dynamic
10653 code to be executed at run time. On some targets, a trampoline is
10654 built for the following features: @code{Access},
10655 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
10656 nested task bodies; primitive operations of nested tagged types.
10657 Trampolines do not work on machines that prevent execution of stack
10658 data. For example, on windows systems, enabling DEP (data execution
10659 protection) will cause trampolines to raise an exception.
10660 Trampolines are also quite slow at run time.
10662 On many targets, trampolines have been largely eliminated. Look at the
10663 version of system.ads for your target --- if it has
10664 Always_Compatible_Rep equal to False, then trampolines are largely
10665 eliminated. In particular, a trampoline is built for the following
10666 features: @code{Address} of a nested subprogram;
10667 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
10668 but only if pragma Favor_Top_Level applies, or the access type has a
10669 foreign-language convention; primitive operations of nested tagged
10670 types.
10672 @node No_Implicit_Heap_Allocations
10673 @unnumberedsubsec No_Implicit_Heap_Allocations
10674 @findex No_Implicit_Heap_Allocations
10675 [RM D.7] No constructs are allowed to cause implicit heap allocation.
10677 @node No_Implicit_Loops
10678 @unnumberedsubsec No_Implicit_Loops
10679 @findex No_Implicit_Loops
10680 [GNAT] This restriction ensures that the generated code does not contain any
10681 implicit @code{for} loops, either by modifying
10682 the generated code where possible,
10683 or by rejecting any construct that would otherwise generate an implicit
10684 @code{for} loop. If this restriction is active, it is possible to build
10685 large array aggregates with all static components without generating an
10686 intermediate temporary, and without generating a loop to initialize individual
10687 components. Otherwise, a loop is created for arrays larger than about 5000
10688 scalar components.
10690 @node No_Initialize_Scalars
10691 @unnumberedsubsec No_Initialize_Scalars
10692 @findex No_Initialize_Scalars
10693 [GNAT] This restriction ensures that no unit in the partition is compiled with
10694 pragma Initialize_Scalars. This allows the generation of more efficient
10695 code, and in particular eliminates dummy null initialization routines that
10696 are otherwise generated for some record and array types.
10698 @node No_IO
10699 @unnumberedsubsec No_IO
10700 @findex No_IO
10701 [RM H.4] This restriction ensures at compile time that there are no
10702 dependences on any of the library units Sequential_IO, Direct_IO,
10703 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
10705 @node No_Local_Allocators
10706 @unnumberedsubsec No_Local_Allocators
10707 @findex No_Local_Allocators
10708 [RM H.4] This restriction ensures at compile time that there are no
10709 occurrences of an allocator in subprograms, generic subprograms, tasks,
10710 and entry bodies.
10712 @node No_Local_Protected_Objects
10713 @unnumberedsubsec No_Local_Protected_Objects
10714 @findex No_Local_Protected_Objects
10715 [RM D.7] This restriction ensures at compile time that protected objects are
10716 only declared at the library level.
10718 @node No_Local_Timing_Events
10719 @unnumberedsubsec No_Local_Timing_Events
10720 @findex No_Local_Timing_Events
10721 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
10722 declared at the library level.
10724 @node No_Long_Long_Integers
10725 @unnumberedsubsec No_Long_Long_Integers
10726 @findex No_Long_Long_Integers
10727 [GNAT] This partition-wide restriction forbids any explicit reference to
10728 type Standard.Long_Long_Integer, and also forbids declaring range types whose
10729 implicit base type is Long_Long_Integer, and modular types whose size exceeds
10730 Long_Integer'Size.
10732 @node No_Multiple_Elaboration
10733 @unnumberedsubsec No_Multiple_Elaboration
10734 @findex No_Multiple_Elaboration
10735 [GNAT] Normally each package contains a 16-bit counter used to check for access
10736 before elaboration, and to control multiple elaboration attempts.
10737 This counter is eliminated for units compiled with the static model
10738 of elaboration if restriction @code{No_Elaboration_Code}
10739 is active but because of
10740 the need to check for multiple elaboration in the general case, these
10741 counters cannot be eliminated if elaboration code may be present. The
10742 restriction @code{No_Multiple_Elaboration}
10743 allows suppression of these counters
10744 in static elaboration units even if they do have elaboration code. If this
10745 restriction is used, then the situations in which multiple elaboration is
10746 possible, including non-Ada main programs, and Stand Alone libraries, are not
10747 permitted, and will be diagnosed by the binder.
10749 @node No_Nested_Finalization
10750 @unnumberedsubsec No_Nested_Finalization
10751 @findex No_Nested_Finalization
10752 [RM D.7] All objects requiring finalization are declared at the library level.
10754 @node No_Protected_Type_Allocators
10755 @unnumberedsubsec No_Protected_Type_Allocators
10756 @findex No_Protected_Type_Allocators
10757 [RM D.7] This restriction ensures at compile time that there are no allocator
10758 expressions that attempt to allocate protected objects.
10760 @node No_Protected_Types
10761 @unnumberedsubsec No_Protected_Types
10762 @findex No_Protected_Types
10763 [RM H.4] This restriction ensures at compile time that there are no
10764 declarations of protected types or protected objects.
10766 @node No_Recursion
10767 @unnumberedsubsec No_Recursion
10768 @findex No_Recursion
10769 [RM H.4] A program execution is erroneous if a subprogram is invoked as
10770 part of its execution.
10772 @node No_Reentrancy
10773 @unnumberedsubsec No_Reentrancy
10774 @findex No_Reentrancy
10775 [RM H.4] A program execution is erroneous if a subprogram is executed by
10776 two tasks at the same time.
10778 @node No_Relative_Delay
10779 @unnumberedsubsec No_Relative_Delay
10780 @findex No_Relative_Delay
10781 [RM D.7] This restriction ensures at compile time that there are no delay
10782 relative statements and prevents expressions such as @code{delay 1.23;} from
10783 appearing in source code.
10785 @node No_Requeue_Statements
10786 @unnumberedsubsec No_Requeue_Statements
10787 @findex No_Requeue_Statements
10788 [RM D.7] This restriction ensures at compile time that no requeue statements
10789 are permitted and prevents keyword @code{requeue} from being used in source
10790 code.
10792 @findex No_Requeue
10793 The restriction @code{No_Requeue} is recognized as a
10794 synonym for @code{No_Requeue_Statements}. This is retained for historical
10795 compatibility purposes (and a warning will be generated for its use if
10796 warnings on oNobsolescent features are activated).
10798 @node No_Secondary_Stack
10799 @unnumberedsubsec No_Secondary_Stack
10800 @findex No_Secondary_Stack
10801 [GNAT] This restriction ensures at compile time that the generated code
10802 does not contain any reference to the secondary stack.  The secondary
10803 stack is used to implement functions returning unconstrained objects
10804 (arrays or records) on some targets.
10806 @node No_Select_Statements
10807 @unnumberedsubsec No_Select_Statements
10808 @findex No_Select_Statements
10809 [RM D.7] This restriction ensures at compile time no select statements of any
10810 kind are permitted, that is the keyword @code{select} may not appear.
10812 @node No_Specific_Termination_Handlers
10813 @unnumberedsubsec No_Specific_Termination_Handlers
10814 @findex No_Specific_Termination_Handlers
10815 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
10816 or to Ada.Task_Termination.Specific_Handler.
10818 @node No_Specification_of_Aspect
10819 @unnumberedsubsec No_Specification_of_Aspect
10820 @findex No_Specification_of_Aspect
10821 [RM 13.12.1] This restriction checks at compile time that no aspect
10822 specification, attribute definition clause, or pragma is given for a
10823 given aspect.
10825 @node No_Standard_Allocators_After_Elaboration
10826 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
10827 @findex No_Standard_Allocators_After_Elaboration
10828 [RM D.7] Specifies that an allocator using a standard storage pool
10829 should never be evaluated at run time after the elaboration of the
10830 library items of the partition has completed. Otherwise, Storage_Error
10831 is raised.
10833 @node No_Standard_Storage_Pools
10834 @unnumberedsubsec No_Standard_Storage_Pools
10835 @findex No_Standard_Storage_Pools
10836 [GNAT] This restriction ensures at compile time that no access types
10837 use the standard default storage pool.  Any access type declared must
10838 have an explicit Storage_Pool attribute defined specifying a
10839 user-defined storage pool.
10841 @node No_Stream_Optimizations
10842 @unnumberedsubsec No_Stream_Optimizations
10843 @findex No_Stream_Optimizations
10844 [GNAT] This restriction affects the performance of stream operations on types
10845 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
10846 compiler uses block reads and writes when manipulating @code{String} objects
10847 due to their supperior performance. When this restriction is in effect, the
10848 compiler performs all IO operations on a per-character basis.
10850 @node No_Streams
10851 @unnumberedsubsec No_Streams
10852 @findex No_Streams
10853 [GNAT] This restriction ensures at compile/bind time that there are no
10854 stream objects created and no use of stream attributes.
10855 This restriction does not forbid dependences on the package
10856 @code{Ada.Streams}. So it is permissible to with
10857 @code{Ada.Streams} (or another package that does so itself)
10858 as long as no actual stream objects are created and no
10859 stream attributes are used.
10861 Note that the use of restriction allows optimization of tagged types,
10862 since they do not need to worry about dispatching stream operations.
10863 To take maximum advantage of this space-saving optimization, any
10864 unit declaring a tagged type should be compiled with the restriction,
10865 though this is not required.
10867 @node No_Task_Allocators
10868 @unnumberedsubsec No_Task_Allocators
10869 @findex No_Task_Allocators
10870 [RM D.7] There are no allocators for task types
10871 or types containing task subcomponents.
10873 @node No_Task_Attributes_Package
10874 @unnumberedsubsec No_Task_Attributes_Package
10875 @findex No_Task_Attributes_Package
10876 [GNAT] This restriction ensures at compile time that there are no implicit or
10877 explicit dependencies on the package @code{Ada.Task_Attributes}.
10879 @findex No_Task_Attributes
10880 The restriction @code{No_Task_Attributes} is recognized as a synonym
10881 for @code{No_Task_Attributes_Package}. This is retained for historical
10882 compatibility purposes (and a warning will be generated for its use if
10883 warnings on obsolescent features are activated).
10885 @node No_Task_Hierarchy
10886 @unnumberedsubsec No_Task_Hierarchy
10887 @findex No_Task_Hierarchy
10888 [RM D.7] All (non-environment) tasks depend
10889 directly on the environment task of the partition.
10891 @node No_Task_Termination
10892 @unnumberedsubsec No_Task_Termination
10893 @findex No_Task_Termination
10894 [RM D.7] Tasks which terminate are erroneous.
10896 @node No_Tasking
10897 @unnumberedsubsec No_Tasking
10898 @findex No_Tasking
10899 [GNAT] This restriction prevents the declaration of tasks or task types
10900 throughout the partition.  It is similar in effect to the use of
10901 @code{Max_Tasks => 0} except that violations are caught at compile time
10902 and cause an error message to be output either by the compiler or
10903 binder.
10905 @node No_Terminate_Alternatives
10906 @unnumberedsubsec No_Terminate_Alternatives
10907 @findex No_Terminate_Alternatives
10908 [RM D.7] There are no selective accepts with terminate alternatives.
10910 @node No_Unchecked_Access
10911 @unnumberedsubsec No_Unchecked_Access
10912 @findex No_Unchecked_Access
10913 [RM H.4] This restriction ensures at compile time that there are no
10914 occurrences of the Unchecked_Access attribute.
10916 @node Simple_Barriers
10917 @unnumberedsubsec Simple_Barriers
10918 @findex Simple_Barriers
10919 [RM D.7] This restriction ensures at compile time that barriers in entry
10920 declarations for protected types are restricted to either static boolean
10921 expressions or references to simple boolean variables defined in the private
10922 part of the protected type.  No other form of entry barriers is permitted.
10924 @findex Boolean_Entry_Barriers
10925 The restriction @code{Boolean_Entry_Barriers} is recognized as a
10926 synonym for @code{Simple_Barriers}. This is retained for historical
10927 compatibility purposes (and a warning will be generated for its use if
10928 warnings on obsolescent features are activated).
10930 @node Static_Priorities
10931 @unnumberedsubsec Static_Priorities
10932 @findex Static_Priorities
10933 [GNAT] This restriction ensures at compile time that all priority expressions
10934 are static, and that there are no dependences on the package
10935 @code{Ada.Dynamic_Priorities}.
10937 @node Static_Storage_Size
10938 @unnumberedsubsec Static_Storage_Size
10939 @findex Static_Storage_Size
10940 [GNAT] This restriction ensures at compile time that any expression appearing
10941 in a Storage_Size pragma or attribute definition clause is static.
10943 @node Program Unit Level Restrictions
10944 @section Program Unit Level Restrictions
10946 @noindent
10947 The second set of restriction identifiers
10948 does not require partition-wide consistency.
10949 The restriction may be enforced for a single
10950 compilation unit without any effect on any of the
10951 other compilation units in the partition.
10953 @menu
10954 * No_Elaboration_Code::
10955 * No_Entry_Queue::
10956 * No_Implementation_Aspect_Specifications::
10957 * No_Implementation_Attributes::
10958 * No_Implementation_Identifiers::
10959 * No_Implementation_Pragmas::
10960 * No_Implementation_Restrictions::
10961 * No_Implementation_Units::
10962 * No_Implicit_Aliasing::
10963 * No_Obsolescent_Features::
10964 * No_Wide_Characters::
10965 * SPARK_05::
10966 @end menu
10968 @node No_Elaboration_Code
10969 @unnumberedsubsec No_Elaboration_Code
10970 @findex No_Elaboration_Code
10971 [GNAT] This restriction ensures at compile time that no elaboration code is
10972 generated.  Note that this is not the same condition as is enforced
10973 by pragma @code{Preelaborate}.  There are cases in which pragma
10974 @code{Preelaborate} still permits code to be generated (e.g.@: code
10975 to initialize a large array to all zeroes), and there are cases of units
10976 which do not meet the requirements for pragma @code{Preelaborate},
10977 but for which no elaboration code is generated.  Generally, it is
10978 the case that preelaborable units will meet the restrictions, with
10979 the exception of large aggregates initialized with an others_clause,
10980 and exception declarations (which generate calls to a run-time
10981 registry procedure).  This restriction is enforced on
10982 a unit by unit basis, it need not be obeyed consistently
10983 throughout a partition.
10985 In the case of aggregates with others, if the aggregate has a dynamic
10986 size, there is no way to eliminate the elaboration code (such dynamic
10987 bounds would be incompatible with @code{Preelaborate} in any case). If
10988 the bounds are static, then use of this restriction actually modifies
10989 the code choice of the compiler to avoid generating a loop, and instead
10990 generate the aggregate statically if possible, no matter how many times
10991 the data for the others clause must be repeatedly generated.
10993 It is not possible to precisely document
10994 the constructs which are compatible with this restriction, since,
10995 unlike most other restrictions, this is not a restriction on the
10996 source code, but a restriction on the generated object code. For
10997 example, if the source contains a declaration:
10999 @smallexample
11000    Val : constant Integer := X;
11001 @end smallexample
11003 @noindent
11004 where X is not a static constant, it may be possible, depending
11005 on complex optimization circuitry, for the compiler to figure
11006 out the value of X at compile time, in which case this initialization
11007 can be done by the loader, and requires no initialization code. It
11008 is not possible to document the precise conditions under which the
11009 optimizer can figure this out.
11011 Note that this the implementation of this restriction requires full
11012 code generation. If it is used in conjunction with "semantics only"
11013 checking, then some cases of violations may be missed.
11015 @node No_Entry_Queue
11016 @unnumberedsubsec No_Entry_Queue
11017 @findex No_Entry_Queue
11018 [GNAT] This restriction is a declaration that any protected entry compiled in
11019 the scope of the restriction has at most one task waiting on the entry
11020 at any one time, and so no queue is required.  This restriction is not
11021 checked at compile time.  A program execution is erroneous if an attempt
11022 is made to queue a second task on such an entry.
11024 @node No_Implementation_Aspect_Specifications
11025 @unnumberedsubsec No_Implementation_Aspect_Specifications
11026 @findex No_Implementation_Aspect_Specifications
11027 [RM 13.12.1] This restriction checks at compile time that no
11028 GNAT-defined aspects are present.  With this restriction, the only
11029 aspects that can be used are those defined in the Ada Reference Manual.
11031 @node No_Implementation_Attributes
11032 @unnumberedsubsec No_Implementation_Attributes
11033 @findex No_Implementation_Attributes
11034 [RM 13.12.1] This restriction checks at compile time that no
11035 GNAT-defined attributes are present.  With this restriction, the only
11036 attributes that can be used are those defined in the Ada Reference
11037 Manual.
11039 @node No_Implementation_Identifiers
11040 @unnumberedsubsec No_Implementation_Identifiers
11041 @findex No_Implementation_Identifiers
11042 [RM 13.12.1] This restriction checks at compile time that no
11043 implementation-defined identifiers (marked with pragma Implementation_Defined)
11044 occur within language-defined packages.
11046 @node No_Implementation_Pragmas
11047 @unnumberedsubsec No_Implementation_Pragmas
11048 @findex No_Implementation_Pragmas
11049 [RM 13.12.1] This restriction checks at compile time that no
11050 GNAT-defined pragmas are present.  With this restriction, the only
11051 pragmas that can be used are those defined in the Ada Reference Manual.
11053 @node No_Implementation_Restrictions
11054 @unnumberedsubsec No_Implementation_Restrictions
11055 @findex No_Implementation_Restrictions
11056 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
11057 identifiers (other than @code{No_Implementation_Restrictions} itself)
11058 are present.  With this restriction, the only other restriction identifiers
11059 that can be used are those defined in the Ada Reference Manual.
11061 @node No_Implementation_Units
11062 @unnumberedsubsec No_Implementation_Units
11063 @findex No_Implementation_Units
11064 [RM 13.12.1] This restriction checks at compile time that there is no
11065 mention in the context clause of any implementation-defined descendants
11066 of packages Ada, Interfaces, or System.
11068 @node No_Implicit_Aliasing
11069 @unnumberedsubsec No_Implicit_Aliasing
11070 @findex No_Implicit_Aliasing
11071 [GNAT] This restriction, which is not required to be partition-wide consistent,
11072 requires an explicit aliased keyword for an object to which 'Access,
11073 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
11074 the 'Unrestricted_Access attribute for objects. Note: the reason that
11075 Unrestricted_Access is forbidden is that it would require the prefix
11076 to be aliased, and in such cases, it can always be replaced by
11077 the standard attribute Unchecked_Access which is preferable.
11079 @node No_Obsolescent_Features
11080 @unnumberedsubsec No_Obsolescent_Features
11081 @findex No_Obsolescent_Features
11082 [RM 13.12.1] This restriction checks at compile time that no obsolescent
11083 features are used, as defined in Annex J of the Ada Reference Manual.
11085 @node No_Wide_Characters
11086 @unnumberedsubsec No_Wide_Characters
11087 @findex No_Wide_Characters
11088 [GNAT] This restriction ensures at compile time that no uses of the types
11089 @code{Wide_Character} or @code{Wide_String} or corresponding wide
11090 wide types
11091 appear, and that no wide or wide wide string or character literals
11092 appear in the program (that is literals representing characters not in
11093 type @code{Character}).
11095 @node SPARK_05
11096 @unnumberedsubsec SPARK_05
11097 @findex SPARK_05
11098 [GNAT] This restriction checks at compile time that some constructs
11099 forbidden in SPARK 2005 are not present. Error messages related to
11100 SPARK restriction have the form:
11102 @smallexample
11103 violation of restriction "SPARK_05" at <source-location>
11104  <error message>
11105 @end smallexample
11107 @findex SPARK
11108 The restriction @code{SPARK} is recognized as a
11109 synonym for @code{SPARK_05}. This is retained for historical
11110 compatibility purposes (and an unconditional warning will be generated
11111 for its use, advising replacement by @code{SPARK}).
11113 This is not a replacement for the semantic checks performed by the
11114 SPARK Examiner tool, as the compiler currently only deals with code,
11115 not SPARK 2005 annotations, and does not guarantee catching all
11116 cases of constructs forbidden by SPARK 2005.
11118 Thus it may well be the case that code which passes the compiler with
11119 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
11120 the different visibility rules of the Examiner based on SPARK 2005
11121 @code{inherit} annotations.
11123 This restriction can be useful in providing an initial filter for code
11124 developed using SPARK 2005, or in examining legacy code to see how far
11125 it is from meeting SPARK restrictions.
11127 The list below summarizes the checks that are performed when this
11128 restriction is in force:
11129 @itemize @bullet
11130 @item No block statements
11131 @item No case statements with only an others clause
11132 @item Exit statements in loops must respect the SPARK 2005 language restrictions
11133 @item No goto statements
11134 @item Return can only appear as last statement in function
11135 @item Function must have return statement
11136 @item Loop parameter specification must include subtype mark
11137 @item Prefix of expanded name cannot be a loop statement
11138 @item Abstract subprogram not allowed
11139 @item User-defined operators not allowed
11140 @item Access type parameters not allowed
11141 @item Default expressions for parameters not allowed
11142 @item Default expressions for record fields not allowed
11143 @item No tasking constructs allowed
11144 @item Label needed at end of subprograms and packages
11145 @item No mixing of positional and named parameter association
11146 @item No access types as result type
11147 @item No unconstrained arrays as result types
11148 @item No null procedures
11149 @item Initial and later declarations must be in correct order (declaration can't come after body)
11150 @item No attributes on private types if full declaration not visible
11151 @item No package declaration within package specification
11152 @item No controlled types
11153 @item No discriminant types
11154 @item No overloading
11155 @item Selector name cannot be operator symbol (i.e. operator symbol cannot be prefixed)
11156 @item Access attribute not allowed
11157 @item Allocator not allowed
11158 @item Result of catenation must be String
11159 @item Operands of catenation must be string literal, static char or another catenation
11160 @item No conditional expressions
11161 @item No explicit dereference
11162 @item Quantified expression not allowed
11163 @item Slicing not allowed
11164 @item No exception renaming
11165 @item No generic renaming
11166 @item No object renaming
11167 @item No use clause
11168 @item Aggregates must be qualified
11169 @item Non-static choice in array aggregates not allowed
11170 @item The only view conversions which are allowed as in-out parameters are conversions of a tagged type to an ancestor type
11171 @item No mixing of positional and named association in aggregate, no multi choice
11172 @item AND, OR and XOR for arrays only allowed when operands have same static bounds
11173 @item Fixed point operands to * or / must be qualified or converted
11174 @item Comparison operators not allowed for Booleans or arrays (except strings)
11175 @item Equality not allowed for arrays with non-matching static bounds (except strings)
11176 @item Conversion / qualification not allowed for arrays with non-matching static bounds
11177 @item Subprogram declaration only allowed in package spec (unless followed by import)
11178 @item Access types not allowed
11179 @item Incomplete type declaration not allowed
11180 @item Object and subtype declarations must respect SPARK restrictions
11181 @item Digits or delta constraint not allowed
11182 @item Decimal fixed point type not allowed
11183 @item Aliasing of objects not allowed
11184 @item Modular type modulus must be power of 2
11185 @item Base not allowed on subtype mark
11186 @item Unary operators not allowed on modular types (except not)
11187 @item Untagged record cannot be null
11188 @item No class-wide operations
11189 @item Initialization expressions must respect SPARK restrictions
11190 @item Non-static ranges not allowed except in iteration schemes
11191 @item String subtypes must have lower bound of 1
11192 @item Subtype of Boolean cannot have constraint
11193 @item At most one tagged type or extension per package
11194 @item Interface is not allowed
11195 @item Character literal cannot be prefixed (selector name cannot be character literal)
11196 @item Record aggregate cannot contain 'others'
11197 @item Component association in record aggregate must contain a single choice
11198 @item Ancestor part cannot be a type mark
11199 @item Attributes 'Image, 'Width and 'Value not allowed
11200 @item Functions may not update globals
11201 @item Subprograms may not contain direct calls to themselves (prevents recursion within unit)
11202 @item Call to subprogram not allowed in same unit before body has been seen (prevents recursion within unit)
11203 @end itemize
11205 The following restrictions are enforced, but note that they are actually more
11206 strict that the latest SPARK 2005 language definition:
11208 @itemize @bullet
11209 @item No derived types other than tagged type extensions
11210 @item Subtype of unconstrained array must have constraint
11211 @end itemize
11213 This list summarises the main SPARK 2005 language rules that are not
11214 currently checked by the SPARK_05 restriction:
11216 @itemize @bullet
11217 @item SPARK annotations are treated as comments so are not checked at all
11218 @item Based real literals not allowed
11219 @item Objects cannot be initialized at declaration by calls to user-defined functions
11220 @item Objects cannot be initialized at declaration by assignments from variables
11221 @item Objects cannot be initialized at declaration by assignments from indexed/selected components
11222 @item Ranges shall not be null
11223 @item A fixed point delta expression must be a simple expression
11224 @item Restrictions on where renaming declarations may be placed
11225 @item Externals of mode 'out' cannot be referenced
11226 @item Externals of mode 'in' cannot be updated
11227 @item Loop with no iteration scheme or exits only allowed as last statement in main program or task
11228 @item Subprogram cannot have parent unit name
11229 @item SPARK 2005 inherited subprogram must be prefixed with overriding
11230 @item External variables (or functions that reference them) may not be passed as actual parameters
11231 @item Globals must be explicitly mentioned in contract
11232 @item Deferred constants cannot be completed by pragma Import
11233 @item Package initialization cannot read/write variables from other packages
11234 @item Prefix not allowed for entities that are directly visible
11235 @item Identifier declaration can't override inherited package name
11236 @item Cannot use Standard or other predefined packages as identifiers
11237 @item After renaming, cannot use the original name
11238 @item Subprograms can only be renamed to remove package prefix
11239 @item Pragma import must be immediately after entity it names
11240 @item No mutual recursion between multiple units (this can be checked with gnatcheck)
11241 @end itemize
11243 Note that if a unit is compiled in Ada 95 mode with the SPARK restriction,
11244 violations will be reported for constructs forbidden in SPARK 95,
11245 instead of SPARK 2005.
11247 @c ------------------------
11248 @node Implementation Advice
11249 @chapter Implementation Advice
11250 @noindent
11251 The main text of the Ada Reference Manual describes the required
11252 behavior of all Ada compilers, and the GNAT compiler conforms to
11253 these requirements.
11255 In addition, there are sections throughout the Ada Reference Manual headed
11256 by the phrase ``Implementation advice''.  These sections are not normative,
11257 i.e., they do not specify requirements that all compilers must
11258 follow.  Rather they provide advice on generally desirable behavior.  You
11259 may wonder why they are not requirements.  The most typical answer is
11260 that they describe behavior that seems generally desirable, but cannot
11261 be provided on all systems, or which may be undesirable on some systems.
11263 As far as practical, GNAT follows the implementation advice sections in
11264 the Ada Reference Manual.  This chapter contains a table giving the
11265 reference manual section number, paragraph number and several keywords
11266 for each advice.  Each entry consists of the text of the advice followed
11267 by the GNAT interpretation of this advice.  Most often, this simply says
11268 ``followed'', which means that GNAT follows the advice.  However, in a
11269 number of cases, GNAT deliberately deviates from this advice, in which
11270 case the text describes what GNAT does and why.
11272 @cindex Error detection
11273 @unnumberedsec 1.1.3(20): Error Detection
11274 @sp 1
11275 @cartouche
11276 If an implementation detects the use of an unsupported Specialized Needs
11277 Annex feature at run time, it should raise @code{Program_Error} if
11278 feasible.
11279 @end cartouche
11280 Not relevant.  All specialized needs annex features are either supported,
11281 or diagnosed at compile time.
11283 @cindex Child Units
11284 @unnumberedsec 1.1.3(31): Child Units
11285 @sp 1
11286 @cartouche
11287 If an implementation wishes to provide implementation-defined
11288 extensions to the functionality of a language-defined library unit, it
11289 should normally do so by adding children to the library unit.
11290 @end cartouche
11291 Followed.
11293 @cindex Bounded errors
11294 @unnumberedsec 1.1.5(12): Bounded Errors
11295 @sp 1
11296 @cartouche
11297 If an implementation detects a bounded error or erroneous
11298 execution, it should raise @code{Program_Error}.
11299 @end cartouche
11300 Followed in all cases in which the implementation detects a bounded
11301 error or erroneous execution.  Not all such situations are detected at
11302 runtime.
11304 @cindex Pragmas
11305 @unnumberedsec 2.8(16): Pragmas
11306 @sp 1
11307 @cartouche
11308 Normally, implementation-defined pragmas should have no semantic effect
11309 for error-free programs; that is, if the implementation-defined pragmas
11310 are removed from a working program, the program should still be legal,
11311 and should still have the same semantics.
11312 @end cartouche
11313 The following implementation defined pragmas are exceptions to this
11314 rule:
11316 @table @code
11317 @item Abort_Defer
11318 Affects semantics
11319 @item Ada_83
11320 Affects legality
11321 @item Assert
11322 Affects semantics
11323 @item CPP_Class
11324 Affects semantics
11325 @item CPP_Constructor
11326 Affects semantics
11327 @item Debug
11328 Affects semantics
11329 @item Interface_Name
11330 Affects semantics
11331 @item Machine_Attribute
11332 Affects semantics
11333 @item Unimplemented_Unit
11334 Affects legality
11335 @item Unchecked_Union
11336 Affects semantics
11337 @end table
11339 @noindent
11340 In each of the above cases, it is essential to the purpose of the pragma
11341 that this advice not be followed.  For details see the separate section
11342 on implementation defined pragmas.
11344 @unnumberedsec 2.8(17-19): Pragmas
11345 @sp 1
11346 @cartouche
11347 Normally, an implementation should not define pragmas that can
11348 make an illegal program legal, except as follows:
11349 @end cartouche
11350 @sp 1
11351 @cartouche
11352 A pragma used to complete a declaration, such as a pragma @code{Import};
11353 @end cartouche
11354 @sp 1
11355 @cartouche
11356 A pragma used to configure the environment by adding, removing, or
11357 replacing @code{library_items}.
11358 @end cartouche
11359 See response to paragraph 16 of this same section.
11361 @cindex Character Sets
11362 @cindex Alternative Character Sets
11363 @unnumberedsec 3.5.2(5): Alternative Character Sets
11364 @sp 1
11365 @cartouche
11366 If an implementation supports a mode with alternative interpretations
11367 for @code{Character} and @code{Wide_Character}, the set of graphic
11368 characters of @code{Character} should nevertheless remain a proper
11369 subset of the set of graphic characters of @code{Wide_Character}.  Any
11370 character set ``localizations'' should be reflected in the results of
11371 the subprograms defined in the language-defined package
11372 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
11373 an alternative interpretation of @code{Character}, the implementation should
11374 also support a corresponding change in what is a legal
11375 @code{identifier_letter}.
11376 @end cartouche
11377 Not all wide character modes follow this advice, in particular the JIS
11378 and IEC modes reflect standard usage in Japan, and in these encoding,
11379 the upper half of the Latin-1 set is not part of the wide-character
11380 subset, since the most significant bit is used for wide character
11381 encoding.  However, this only applies to the external forms.  Internally
11382 there is no such restriction.
11384 @cindex Integer types
11385 @unnumberedsec 3.5.4(28): Integer Types
11387 @sp 1
11388 @cartouche
11389 An implementation should support @code{Long_Integer} in addition to
11390 @code{Integer} if the target machine supports 32-bit (or longer)
11391 arithmetic.  No other named integer subtypes are recommended for package
11392 @code{Standard}.  Instead, appropriate named integer subtypes should be
11393 provided in the library package @code{Interfaces} (see B.2).
11394 @end cartouche
11395 @code{Long_Integer} is supported.  Other standard integer types are supported
11396 so this advice is not fully followed.  These types
11397 are supported for convenient interface to C, and so that all hardware
11398 types of the machine are easily available.
11399 @unnumberedsec 3.5.4(29): Integer Types
11401 @sp 1
11402 @cartouche
11403 An implementation for a two's complement machine should support
11404 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
11405 implementation should support a non-binary modules up to @code{Integer'Last}.
11406 @end cartouche
11407 Followed.
11409 @cindex Enumeration values
11410 @unnumberedsec 3.5.5(8): Enumeration Values
11411 @sp 1
11412 @cartouche
11413 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
11414 subtype, if the value of the operand does not correspond to the internal
11415 code for any enumeration literal of its type (perhaps due to an
11416 un-initialized variable), then the implementation should raise
11417 @code{Program_Error}.  This is particularly important for enumeration
11418 types with noncontiguous internal codes specified by an
11419 enumeration_representation_clause.
11420 @end cartouche
11421 Followed.
11423 @cindex Float types
11424 @unnumberedsec 3.5.7(17): Float Types
11425 @sp 1
11426 @cartouche
11427 An implementation should support @code{Long_Float} in addition to
11428 @code{Float} if the target machine supports 11 or more digits of
11429 precision.  No other named floating point subtypes are recommended for
11430 package @code{Standard}.  Instead, appropriate named floating point subtypes
11431 should be provided in the library package @code{Interfaces} (see B.2).
11432 @end cartouche
11433 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
11434 former provides improved compatibility with other implementations
11435 supporting this type.  The latter corresponds to the highest precision
11436 floating-point type supported by the hardware.  On most machines, this
11437 will be the same as @code{Long_Float}, but on some machines, it will
11438 correspond to the IEEE extended form.  The notable case is all ia32
11439 (x86) implementations, where @code{Long_Long_Float} corresponds to
11440 the 80-bit extended precision format supported in hardware on this
11441 processor.  Note that the 128-bit format on SPARC is not supported,
11442 since this is a software rather than a hardware format.
11444 @cindex Multidimensional arrays
11445 @cindex Arrays, multidimensional
11446 @unnumberedsec 3.6.2(11): Multidimensional Arrays
11447 @sp 1
11448 @cartouche
11449 An implementation should normally represent multidimensional arrays in
11450 row-major order, consistent with the notation used for multidimensional
11451 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
11452 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
11453 column-major order should be used instead (see B.5, ``Interfacing with
11454 Fortran'').
11455 @end cartouche
11456 Followed.
11458 @findex Duration'Small
11459 @unnumberedsec 9.6(30-31): Duration'Small
11460 @sp 1
11461 @cartouche
11462 Whenever possible in an implementation, the value of @code{Duration'Small}
11463 should be no greater than 100 microseconds.
11464 @end cartouche
11465 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
11467 @sp 1
11468 @cartouche
11469 The time base for @code{delay_relative_statements} should be monotonic;
11470 it need not be the same time base as used for @code{Calendar.Clock}.
11471 @end cartouche
11472 Followed.
11474 @unnumberedsec 10.2.1(12): Consistent Representation
11475 @sp 1
11476 @cartouche
11477 In an implementation, a type declared in a pre-elaborated package should
11478 have the same representation in every elaboration of a given version of
11479 the package, whether the elaborations occur in distinct executions of
11480 the same program, or in executions of distinct programs or partitions
11481 that include the given version.
11482 @end cartouche
11483 Followed, except in the case of tagged types.  Tagged types involve
11484 implicit pointers to a local copy of a dispatch table, and these pointers
11485 have representations which thus depend on a particular elaboration of the
11486 package.  It is not easy to see how it would be possible to follow this
11487 advice without severely impacting efficiency of execution.
11489 @cindex Exception information
11490 @unnumberedsec 11.4.1(19): Exception Information
11491 @sp 1
11492 @cartouche
11493 @code{Exception_Message} by default and @code{Exception_Information}
11494 should produce information useful for
11495 debugging.  @code{Exception_Message} should be short, about one
11496 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
11497 should not include the
11498 @code{Exception_Name}.  @code{Exception_Information} should include both
11499 the @code{Exception_Name} and the @code{Exception_Message}.
11500 @end cartouche
11501 Followed.  For each exception that doesn't have a specified
11502 @code{Exception_Message}, the compiler generates one containing the location
11503 of the raise statement.  This location has the form ``file:line'', where
11504 file is the short file name (without path information) and line is the line
11505 number in the file.  Note that in the case of the Zero Cost Exception
11506 mechanism, these messages become redundant with the Exception_Information that
11507 contains a full backtrace of the calling sequence, so they are disabled.
11508 To disable explicitly the generation of the source location message, use the
11509 Pragma @code{Discard_Names}.
11511 @cindex Suppression of checks
11512 @cindex Checks, suppression of
11513 @unnumberedsec 11.5(28): Suppression of Checks
11514 @sp 1
11515 @cartouche
11516 The implementation should minimize the code executed for checks that
11517 have been suppressed.
11518 @end cartouche
11519 Followed.
11521 @cindex Representation clauses
11522 @unnumberedsec 13.1 (21-24): Representation Clauses
11523 @sp 1
11524 @cartouche
11525 The recommended level of support for all representation items is
11526 qualified as follows:
11527 @end cartouche
11528 @sp 1
11529 @cartouche
11530 An implementation need not support representation items containing
11531 non-static expressions, except that an implementation should support a
11532 representation item for a given entity if each non-static expression in
11533 the representation item is a name that statically denotes a constant
11534 declared before the entity.
11535 @end cartouche
11536 Followed.  In fact, GNAT goes beyond the recommended level of support
11537 by allowing nonstatic expressions in some representation clauses even
11538 without the need to declare constants initialized with the values of
11539 such expressions.
11540 For example:
11542 @smallexample @c ada
11543   X : Integer;
11544   Y : Float;
11545   for Y'Address use X'Address;>>
11546 @end smallexample
11548 @sp 1
11549 @cartouche
11550 An implementation need not support a specification for the @code{Size}
11551 for a given composite subtype, nor the size or storage place for an
11552 object (including a component) of a given composite subtype, unless the
11553 constraints on the subtype and its composite subcomponents (if any) are
11554 all static constraints.
11555 @end cartouche
11556 Followed.  Size Clauses are not permitted on non-static components, as
11557 described above.
11559 @sp 1
11560 @cartouche
11561 An aliased component, or a component whose type is by-reference, should
11562 always be allocated at an addressable location.
11563 @end cartouche
11564 Followed.
11566 @cindex Packed types
11567 @unnumberedsec 13.2(6-8): Packed Types
11568 @sp 1
11569 @cartouche
11570 If a type is packed, then the implementation should try to minimize
11571 storage allocated to objects of the type, possibly at the expense of
11572 speed of accessing components, subject to reasonable complexity in
11573 addressing calculations.
11574 @end cartouche
11575 @sp 1
11576 @cartouche
11577 The recommended level of support pragma @code{Pack} is:
11579 For a packed record type, the components should be packed as tightly as
11580 possible subject to the Sizes of the component subtypes, and subject to
11581 any @code{record_representation_clause} that applies to the type; the
11582 implementation may, but need not, reorder components or cross aligned
11583 word boundaries to improve the packing.  A component whose @code{Size} is
11584 greater than the word size may be allocated an integral number of words.
11585 @end cartouche
11586 Followed.  Tight packing of arrays is supported for all component sizes
11587 up to 64-bits. If the array component size is 1 (that is to say, if
11588 the component is a boolean type or an enumeration type with two values)
11589 then values of the type are implicitly initialized to zero. This
11590 happens both for objects of the packed type, and for objects that have a
11591 subcomponent of the packed type.
11593 @sp 1
11594 @cartouche
11595 An implementation should support Address clauses for imported
11596 subprograms.
11597 @end cartouche
11598 Followed.
11599 @cindex @code{Address} clauses
11600 @unnumberedsec 13.3(14-19): Address Clauses
11602 @sp 1
11603 @cartouche
11604 For an array @var{X}, @code{@var{X}'Address} should point at the first
11605 component of the array, and not at the array bounds.
11606 @end cartouche
11607 Followed.
11609 @sp 1
11610 @cartouche
11611 The recommended level of support for the @code{Address} attribute is:
11613 @code{@var{X}'Address} should produce a useful result if @var{X} is an
11614 object that is aliased or of a by-reference type, or is an entity whose
11615 @code{Address} has been specified.
11616 @end cartouche
11617 Followed.  A valid address will be produced even if none of those
11618 conditions have been met.  If necessary, the object is forced into
11619 memory to ensure the address is valid.
11621 @sp 1
11622 @cartouche
11623 An implementation should support @code{Address} clauses for imported
11624 subprograms.
11625 @end cartouche
11626 Followed.
11628 @sp 1
11629 @cartouche
11630 Objects (including subcomponents) that are aliased or of a by-reference
11631 type should be allocated on storage element boundaries.
11632 @end cartouche
11633 Followed.
11635 @sp 1
11636 @cartouche
11637 If the @code{Address} of an object is specified, or it is imported or exported,
11638 then the implementation should not perform optimizations based on
11639 assumptions of no aliases.
11640 @end cartouche
11641 Followed.
11643 @cindex @code{Alignment} clauses
11644 @unnumberedsec 13.3(29-35): Alignment Clauses
11645 @sp 1
11646 @cartouche
11647 The recommended level of support for the @code{Alignment} attribute for
11648 subtypes is:
11650 An implementation should support specified Alignments that are factors
11651 and multiples of the number of storage elements per word, subject to the
11652 following:
11653 @end cartouche
11654 Followed.
11656 @sp 1
11657 @cartouche
11658 An implementation need not support specified @code{Alignment}s for
11659 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
11660 loaded and stored by available machine instructions.
11661 @end cartouche
11662 Followed.
11664 @sp 1
11665 @cartouche
11666 An implementation need not support specified @code{Alignment}s that are
11667 greater than the maximum @code{Alignment} the implementation ever returns by
11668 default.
11669 @end cartouche
11670 Followed.
11672 @sp 1
11673 @cartouche
11674 The recommended level of support for the @code{Alignment} attribute for
11675 objects is:
11677 Same as above, for subtypes, but in addition:
11678 @end cartouche
11679 Followed.
11681 @sp 1
11682 @cartouche
11683 For stand-alone library-level objects of statically constrained
11684 subtypes, the implementation should support all @code{Alignment}s
11685 supported by the target linker.  For example, page alignment is likely to
11686 be supported for such objects, but not for subtypes.
11687 @end cartouche
11688 Followed.
11690 @cindex @code{Size} clauses
11691 @unnumberedsec 13.3(42-43): Size Clauses
11692 @sp 1
11693 @cartouche
11694 The recommended level of support for the @code{Size} attribute of
11695 objects is:
11697 A @code{Size} clause should be supported for an object if the specified
11698 @code{Size} is at least as large as its subtype's @code{Size}, and
11699 corresponds to a size in storage elements that is a multiple of the
11700 object's @code{Alignment} (if the @code{Alignment} is nonzero).
11701 @end cartouche
11702 Followed.
11704 @unnumberedsec 13.3(50-56): Size Clauses
11705 @sp 1
11706 @cartouche
11707 If the @code{Size} of a subtype is specified, and allows for efficient
11708 independent addressability (see 9.10) on the target architecture, then
11709 the @code{Size} of the following objects of the subtype should equal the
11710 @code{Size} of the subtype:
11712 Aliased objects (including components).
11713 @end cartouche
11714 Followed.
11716 @sp 1
11717 @cartouche
11718 @code{Size} clause on a composite subtype should not affect the
11719 internal layout of components.
11720 @end cartouche
11721 Followed. But note that this can be overridden by use of the implementation
11722 pragma Implicit_Packing in the case of packed arrays.
11724 @sp 1
11725 @cartouche
11726 The recommended level of support for the @code{Size} attribute of subtypes is:
11727 @end cartouche
11728 @sp 1
11729 @cartouche
11730 The @code{Size} (if not specified) of a static discrete or fixed point
11731 subtype should be the number of bits needed to represent each value
11732 belonging to the subtype using an unbiased representation, leaving space
11733 for a sign bit only if the subtype contains negative values.  If such a
11734 subtype is a first subtype, then an implementation should support a
11735 specified @code{Size} for it that reflects this representation.
11736 @end cartouche
11737 Followed.
11739 @sp 1
11740 @cartouche
11741 For a subtype implemented with levels of indirection, the @code{Size}
11742 should include the size of the pointers, but not the size of what they
11743 point at.
11744 @end cartouche
11745 Followed.
11747 @cindex @code{Component_Size} clauses
11748 @unnumberedsec 13.3(71-73): Component Size Clauses
11749 @sp 1
11750 @cartouche
11751 The recommended level of support for the @code{Component_Size}
11752 attribute is:
11753 @end cartouche
11754 @sp 1
11755 @cartouche
11756 An implementation need not support specified @code{Component_Sizes} that are
11757 less than the @code{Size} of the component subtype.
11758 @end cartouche
11759 Followed.
11761 @sp 1
11762 @cartouche
11763 An implementation should support specified @code{Component_Size}s that
11764 are factors and multiples of the word size.  For such
11765 @code{Component_Size}s, the array should contain no gaps between
11766 components.  For other @code{Component_Size}s (if supported), the array
11767 should contain no gaps between components when packing is also
11768 specified; the implementation should forbid this combination in cases
11769 where it cannot support a no-gaps representation.
11770 @end cartouche
11771 Followed.
11773 @cindex Enumeration representation clauses
11774 @cindex Representation clauses, enumeration
11775 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
11776 @sp 1
11777 @cartouche
11778 The recommended level of support for enumeration representation clauses
11781 An implementation need not support enumeration representation clauses
11782 for boolean types, but should at minimum support the internal codes in
11783 the range @code{System.Min_Int.System.Max_Int}.
11784 @end cartouche
11785 Followed.
11787 @cindex Record representation clauses
11788 @cindex Representation clauses, records
11789 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
11790 @sp 1
11791 @cartouche
11792 The recommended level of support for
11793 @*@code{record_representation_clauses} is:
11795 An implementation should support storage places that can be extracted
11796 with a load, mask, shift sequence of machine code, and set with a load,
11797 shift, mask, store sequence, given the available machine instructions
11798 and run-time model.
11799 @end cartouche
11800 Followed.
11802 @sp 1
11803 @cartouche
11804 A storage place should be supported if its size is equal to the
11805 @code{Size} of the component subtype, and it starts and ends on a
11806 boundary that obeys the @code{Alignment} of the component subtype.
11807 @end cartouche
11808 Followed.
11810 @sp 1
11811 @cartouche
11812 If the default bit ordering applies to the declaration of a given type,
11813 then for a component whose subtype's @code{Size} is less than the word
11814 size, any storage place that does not cross an aligned word boundary
11815 should be supported.
11816 @end cartouche
11817 Followed.
11819 @sp 1
11820 @cartouche
11821 An implementation may reserve a storage place for the tag field of a
11822 tagged type, and disallow other components from overlapping that place.
11823 @end cartouche
11824 Followed.  The storage place for the tag field is the beginning of the tagged
11825 record, and its size is Address'Size.  GNAT will reject an explicit component
11826 clause for the tag field.
11828 @sp 1
11829 @cartouche
11830 An implementation need not support a @code{component_clause} for a
11831 component of an extension part if the storage place is not after the
11832 storage places of all components of the parent type, whether or not
11833 those storage places had been specified.
11834 @end cartouche
11835 Followed.  The above advice on record representation clauses is followed,
11836 and all mentioned features are implemented.
11838 @cindex Storage place attributes
11839 @unnumberedsec 13.5.2(5): Storage Place Attributes
11840 @sp 1
11841 @cartouche
11842 If a component is represented using some form of pointer (such as an
11843 offset) to the actual data of the component, and this data is contiguous
11844 with the rest of the object, then the storage place attributes should
11845 reflect the place of the actual data, not the pointer.  If a component is
11846 allocated discontinuously from the rest of the object, then a warning
11847 should be generated upon reference to one of its storage place
11848 attributes.
11849 @end cartouche
11850 Followed.  There are no such components in GNAT@.
11852 @cindex Bit ordering
11853 @unnumberedsec 13.5.3(7-8): Bit Ordering
11854 @sp 1
11855 @cartouche
11856 The recommended level of support for the non-default bit ordering is:
11857 @end cartouche
11858 @sp 1
11859 @cartouche
11860 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
11861 should support the non-default bit ordering in addition to the default
11862 bit ordering.
11863 @end cartouche
11864 Followed.  Word size does not equal storage size in this implementation.
11865 Thus non-default bit ordering is not supported.
11867 @cindex @code{Address}, as private type
11868 @unnumberedsec 13.7(37): Address as Private
11869 @sp 1
11870 @cartouche
11871 @code{Address} should be of a private type.
11872 @end cartouche
11873 Followed.
11875 @cindex Operations, on @code{Address}
11876 @cindex @code{Address}, operations of
11877 @unnumberedsec 13.7.1(16): Address Operations
11878 @sp 1
11879 @cartouche
11880 Operations in @code{System} and its children should reflect the target
11881 environment semantics as closely as is reasonable.  For example, on most
11882 machines, it makes sense for address arithmetic to ``wrap around''.
11883 Operations that do not make sense should raise @code{Program_Error}.
11884 @end cartouche
11885 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
11886 operation raises @code{Program_Error}, since all operations make sense.
11888 @cindex Unchecked conversion
11889 @unnumberedsec 13.9(14-17): Unchecked Conversion
11890 @sp 1
11891 @cartouche
11892 The @code{Size} of an array object should not include its bounds; hence,
11893 the bounds should not be part of the converted data.
11894 @end cartouche
11895 Followed.
11897 @sp 1
11898 @cartouche
11899 The implementation should not generate unnecessary run-time checks to
11900 ensure that the representation of @var{S} is a representation of the
11901 target type.  It should take advantage of the permission to return by
11902 reference when possible.  Restrictions on unchecked conversions should be
11903 avoided unless required by the target environment.
11904 @end cartouche
11905 Followed.  There are no restrictions on unchecked conversion.  A warning is
11906 generated if the source and target types do not have the same size since
11907 the semantics in this case may be target dependent.
11909 @sp 1
11910 @cartouche
11911 The recommended level of support for unchecked conversions is:
11912 @end cartouche
11913 @sp 1
11914 @cartouche
11915 Unchecked conversions should be supported and should be reversible in
11916 the cases where this clause defines the result.  To enable meaningful use
11917 of unchecked conversion, a contiguous representation should be used for
11918 elementary subtypes, for statically constrained array subtypes whose
11919 component subtype is one of the subtypes described in this paragraph,
11920 and for record subtypes without discriminants whose component subtypes
11921 are described in this paragraph.
11922 @end cartouche
11923 Followed.
11925 @cindex Heap usage, implicit
11926 @unnumberedsec 13.11(23-25): Implicit Heap Usage
11927 @sp 1
11928 @cartouche
11929 An implementation should document any cases in which it dynamically
11930 allocates heap storage for a purpose other than the evaluation of an
11931 allocator.
11932 @end cartouche
11933 Followed, the only other points at which heap storage is dynamically
11934 allocated are as follows:
11936 @itemize @bullet
11937 @item
11938 At initial elaboration time, to allocate dynamically sized global
11939 objects.
11941 @item
11942 To allocate space for a task when a task is created.
11944 @item
11945 To extend the secondary stack dynamically when needed.  The secondary
11946 stack is used for returning variable length results.
11947 @end itemize
11949 @sp 1
11950 @cartouche
11951 A default (implementation-provided) storage pool for an
11952 access-to-constant type should not have overhead to support deallocation of
11953 individual objects.
11954 @end cartouche
11955 Followed.
11957 @sp 1
11958 @cartouche
11959 A storage pool for an anonymous access type should be created at the
11960 point of an allocator for the type, and be reclaimed when the designated
11961 object becomes inaccessible.
11962 @end cartouche
11963 Followed.
11965 @cindex Unchecked deallocation
11966 @unnumberedsec 13.11.2(17): Unchecked De-allocation
11967 @sp 1
11968 @cartouche
11969 For a standard storage pool, @code{Free} should actually reclaim the
11970 storage.
11971 @end cartouche
11972 Followed.
11974 @cindex Stream oriented attributes
11975 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
11976 @sp 1
11977 @cartouche
11978 If a stream element is the same size as a storage element, then the
11979 normal in-memory representation should be used by @code{Read} and
11980 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
11981 should use the smallest number of stream elements needed to represent
11982 all values in the base range of the scalar type.
11983 @end cartouche
11985 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
11986 which specifies using the size of the first subtype.
11987 However, such an implementation is based on direct binary
11988 representations and is therefore target- and endianness-dependent.
11989 To address this issue, GNAT also supplies an alternate implementation
11990 of the stream attributes @code{Read} and @code{Write},
11991 which uses the target-independent XDR standard representation
11992 for scalar types.
11993 @cindex XDR representation
11994 @cindex @code{Read} attribute
11995 @cindex @code{Write} attribute
11996 @cindex Stream oriented attributes
11997 The XDR implementation is provided as an alternative body of the
11998 @code{System.Stream_Attributes} package, in the file
11999 @file{s-stratt-xdr.adb} in the GNAT library.
12000 There is no @file{s-stratt-xdr.ads} file.
12001 In order to install the XDR implementation, do the following:
12002 @enumerate
12003 @item Replace the default implementation of the
12004 @code{System.Stream_Attributes} package with the XDR implementation.
12005 For example on a Unix platform issue the commands:
12006 @smallexample
12007 $ mv s-stratt.adb s-stratt-default.adb
12008 $ mv s-stratt-xdr.adb s-stratt.adb
12009 @end smallexample
12011 @item
12012 Rebuild the GNAT run-time library as documented in
12013 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
12014 @end enumerate
12016 @unnumberedsec A.1(52): Names of Predefined Numeric Types
12017 @sp 1
12018 @cartouche
12019 If an implementation provides additional named predefined integer types,
12020 then the names should end with @samp{Integer} as in
12021 @samp{Long_Integer}.  If an implementation provides additional named
12022 predefined floating point types, then the names should end with
12023 @samp{Float} as in @samp{Long_Float}.
12024 @end cartouche
12025 Followed.
12027 @findex Ada.Characters.Handling
12028 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
12029 @sp 1
12030 @cartouche
12031 If an implementation provides a localized definition of @code{Character}
12032 or @code{Wide_Character}, then the effects of the subprograms in
12033 @code{Characters.Handling} should reflect the localizations.  See also
12034 3.5.2.
12035 @end cartouche
12036 Followed.  GNAT provides no such localized definitions.
12038 @cindex Bounded-length strings
12039 @unnumberedsec A.4.4(106): Bounded-Length String Handling
12040 @sp 1
12041 @cartouche
12042 Bounded string objects should not be implemented by implicit pointers
12043 and dynamic allocation.
12044 @end cartouche
12045 Followed.  No implicit pointers or dynamic allocation are used.
12047 @cindex Random number generation
12048 @unnumberedsec A.5.2(46-47): Random Number Generation
12049 @sp 1
12050 @cartouche
12051 Any storage associated with an object of type @code{Generator} should be
12052 reclaimed on exit from the scope of the object.
12053 @end cartouche
12054 Followed.
12056 @sp 1
12057 @cartouche
12058 If the generator period is sufficiently long in relation to the number
12059 of distinct initiator values, then each possible value of
12060 @code{Initiator} passed to @code{Reset} should initiate a sequence of
12061 random numbers that does not, in a practical sense, overlap the sequence
12062 initiated by any other value.  If this is not possible, then the mapping
12063 between initiator values and generator states should be a rapidly
12064 varying function of the initiator value.
12065 @end cartouche
12066 Followed.  The generator period is sufficiently long for the first
12067 condition here to hold true.
12069 @findex Get_Immediate
12070 @unnumberedsec A.10.7(23): @code{Get_Immediate}
12071 @sp 1
12072 @cartouche
12073 The @code{Get_Immediate} procedures should be implemented with
12074 unbuffered input.  For a device such as a keyboard, input should be
12075 @dfn{available} if a key has already been typed, whereas for a disk
12076 file, input should always be available except at end of file.  For a file
12077 associated with a keyboard-like device, any line-editing features of the
12078 underlying operating system should be disabled during the execution of
12079 @code{Get_Immediate}.
12080 @end cartouche
12081 Followed on all targets except VxWorks. For VxWorks, there is no way to
12082 provide this functionality that does not result in the input buffer being
12083 flushed before the @code{Get_Immediate} call. A special unit
12084 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
12085 this functionality.
12087 @findex Export
12088 @unnumberedsec B.1(39-41): Pragma @code{Export}
12089 @sp 1
12090 @cartouche
12091 If an implementation supports pragma @code{Export} to a given language,
12092 then it should also allow the main subprogram to be written in that
12093 language.  It should support some mechanism for invoking the elaboration
12094 of the Ada library units included in the system, and for invoking the
12095 finalization of the environment task.  On typical systems, the
12096 recommended mechanism is to provide two subprograms whose link names are
12097 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
12098 elaboration code for library units.  @code{adafinal} should contain the
12099 finalization code.  These subprograms should have no effect the second
12100 and subsequent time they are called.
12101 @end cartouche
12102 Followed.
12104 @sp 1
12105 @cartouche
12106 Automatic elaboration of pre-elaborated packages should be
12107 provided when pragma @code{Export} is supported.
12108 @end cartouche
12109 Followed when the main program is in Ada.  If the main program is in a
12110 foreign language, then
12111 @code{adainit} must be called to elaborate pre-elaborated
12112 packages.
12114 @sp 1
12115 @cartouche
12116 For each supported convention @var{L} other than @code{Intrinsic}, an
12117 implementation should support @code{Import} and @code{Export} pragmas
12118 for objects of @var{L}-compatible types and for subprograms, and pragma
12119 @code{Convention} for @var{L}-eligible types and for subprograms,
12120 presuming the other language has corresponding features.  Pragma
12121 @code{Convention} need not be supported for scalar types.
12122 @end cartouche
12123 Followed.
12125 @cindex Package @code{Interfaces}
12126 @findex Interfaces
12127 @unnumberedsec B.2(12-13): Package @code{Interfaces}
12128 @sp 1
12129 @cartouche
12130 For each implementation-defined convention identifier, there should be a
12131 child package of package Interfaces with the corresponding name.  This
12132 package should contain any declarations that would be useful for
12133 interfacing to the language (implementation) represented by the
12134 convention.  Any declarations useful for interfacing to any language on
12135 the given hardware architecture should be provided directly in
12136 @code{Interfaces}.
12137 @end cartouche
12138 Followed.
12140 @sp 1
12141 @cartouche
12142 An implementation supporting an interface to C, COBOL, or Fortran should
12143 provide the corresponding package or packages described in the following
12144 clauses.
12145 @end cartouche
12146 Followed.  GNAT provides all the packages described in this section.
12148 @cindex C, interfacing with
12149 @unnumberedsec B.3(63-71): Interfacing with C
12150 @sp 1
12151 @cartouche
12152 An implementation should support the following interface correspondences
12153 between Ada and C@.
12154 @end cartouche
12155 Followed.
12157 @sp 1
12158 @cartouche
12159 An Ada procedure corresponds to a void-returning C function.
12160 @end cartouche
12161 Followed.
12163 @sp 1
12164 @cartouche
12165 An Ada function corresponds to a non-void C function.
12166 @end cartouche
12167 Followed.
12169 @sp 1
12170 @cartouche
12171 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
12172 function.
12173 @end cartouche
12174 Followed.
12176 @sp 1
12177 @cartouche
12178 An Ada @code{in} parameter of an access-to-object type with designated
12179 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
12180 where @var{t} is the C type corresponding to the Ada type @var{T}.
12181 @end cartouche
12182 Followed.
12184 @sp 1
12185 @cartouche
12186 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
12187 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
12188 argument to a C function, where @var{t} is the C type corresponding to
12189 the Ada type @var{T}.  In the case of an elementary @code{out} or
12190 @code{in out} parameter, a pointer to a temporary copy is used to
12191 preserve by-copy semantics.
12192 @end cartouche
12193 Followed.
12195 @sp 1
12196 @cartouche
12197 An Ada parameter of a record type @var{T}, of any mode, is passed as a
12198 @code{@var{t}*} argument to a C function, where @var{t} is the C
12199 structure corresponding to the Ada type @var{T}.
12200 @end cartouche
12201 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
12202 pragma, or Convention, or by explicitly specifying the mechanism for a given
12203 call using an extended import or export pragma.
12205 @sp 1
12206 @cartouche
12207 An Ada parameter of an array type with component type @var{T}, of any
12208 mode, is passed as a @code{@var{t}*} argument to a C function, where
12209 @var{t} is the C type corresponding to the Ada type @var{T}.
12210 @end cartouche
12211 Followed.
12213 @sp 1
12214 @cartouche
12215 An Ada parameter of an access-to-subprogram type is passed as a pointer
12216 to a C function whose prototype corresponds to the designated
12217 subprogram's specification.
12218 @end cartouche
12219 Followed.
12221 @cindex COBOL, interfacing with
12222 @unnumberedsec B.4(95-98): Interfacing with COBOL
12223 @sp 1
12224 @cartouche
12225 An Ada implementation should support the following interface
12226 correspondences between Ada and COBOL@.
12227 @end cartouche
12228 Followed.
12230 @sp 1
12231 @cartouche
12232 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
12233 the COBOL type corresponding to @var{T}.
12234 @end cartouche
12235 Followed.
12237 @sp 1
12238 @cartouche
12239 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
12240 the corresponding COBOL type.
12241 @end cartouche
12242 Followed.
12244 @sp 1
12245 @cartouche
12246 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
12247 COBOL type corresponding to the Ada parameter type; for scalars, a local
12248 copy is used if necessary to ensure by-copy semantics.
12249 @end cartouche
12250 Followed.
12252 @cindex Fortran, interfacing with
12253 @unnumberedsec B.5(22-26): Interfacing with Fortran
12254 @sp 1
12255 @cartouche
12256 An Ada implementation should support the following interface
12257 correspondences between Ada and Fortran:
12258 @end cartouche
12259 Followed.
12261 @sp 1
12262 @cartouche
12263 An Ada procedure corresponds to a Fortran subroutine.
12264 @end cartouche
12265 Followed.
12267 @sp 1
12268 @cartouche
12269 An Ada function corresponds to a Fortran function.
12270 @end cartouche
12271 Followed.
12273 @sp 1
12274 @cartouche
12275 An Ada parameter of an elementary, array, or record type @var{T} is
12276 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
12277 the Fortran type corresponding to the Ada type @var{T}, and where the
12278 INTENT attribute of the corresponding dummy argument matches the Ada
12279 formal parameter mode; the Fortran implementation's parameter passing
12280 conventions are used.  For elementary types, a local copy is used if
12281 necessary to ensure by-copy semantics.
12282 @end cartouche
12283 Followed.
12285 @sp 1
12286 @cartouche
12287 An Ada parameter of an access-to-subprogram type is passed as a
12288 reference to a Fortran procedure whose interface corresponds to the
12289 designated subprogram's specification.
12290 @end cartouche
12291 Followed.
12293 @cindex Machine operations
12294 @unnumberedsec C.1(3-5): Access to Machine Operations
12295 @sp 1
12296 @cartouche
12297 The machine code or intrinsic support should allow access to all
12298 operations normally available to assembly language programmers for the
12299 target environment, including privileged instructions, if any.
12300 @end cartouche
12301 Followed.
12303 @sp 1
12304 @cartouche
12305 The interfacing pragmas (see Annex B) should support interface to
12306 assembler; the default assembler should be associated with the
12307 convention identifier @code{Assembler}.
12308 @end cartouche
12309 Followed.
12311 @sp 1
12312 @cartouche
12313 If an entity is exported to assembly language, then the implementation
12314 should allocate it at an addressable location, and should ensure that it
12315 is retained by the linking process, even if not otherwise referenced
12316 from the Ada code.  The implementation should assume that any call to a
12317 machine code or assembler subprogram is allowed to read or update every
12318 object that is specified as exported.
12319 @end cartouche
12320 Followed.
12322 @unnumberedsec C.1(10-16): Access to Machine Operations
12323 @sp 1
12324 @cartouche
12325 The implementation should ensure that little or no overhead is
12326 associated with calling intrinsic and machine-code subprograms.
12327 @end cartouche
12328 Followed for both intrinsics and machine-code subprograms.
12330 @sp 1
12331 @cartouche
12332 It is recommended that intrinsic subprograms be provided for convenient
12333 access to any machine operations that provide special capabilities or
12334 efficiency and that are not otherwise available through the language
12335 constructs.
12336 @end cartouche
12337 Followed.  A full set of machine operation intrinsic subprograms is provided.
12339 @sp 1
12340 @cartouche
12341 Atomic read-modify-write operations---e.g.@:, test and set, compare and
12342 swap, decrement and test, enqueue/dequeue.
12343 @end cartouche
12344 Followed on any target supporting such operations.
12346 @sp 1
12347 @cartouche
12348 Standard numeric functions---e.g.@:, sin, log.
12349 @end cartouche
12350 Followed on any target supporting such operations.
12352 @sp 1
12353 @cartouche
12354 String manipulation operations---e.g.@:, translate and test.
12355 @end cartouche
12356 Followed on any target supporting such operations.
12358 @sp 1
12359 @cartouche
12360 Vector operations---e.g.@:, compare vector against thresholds.
12361 @end cartouche
12362 Followed on any target supporting such operations.
12364 @sp 1
12365 @cartouche
12366 Direct operations on I/O ports.
12367 @end cartouche
12368 Followed on any target supporting such operations.
12370 @cindex Interrupt support
12371 @unnumberedsec C.3(28): Interrupt Support
12372 @sp 1
12373 @cartouche
12374 If the @code{Ceiling_Locking} policy is not in effect, the
12375 implementation should provide means for the application to specify which
12376 interrupts are to be blocked during protected actions, if the underlying
12377 system allows for a finer-grain control of interrupt blocking.
12378 @end cartouche
12379 Followed.  The underlying system does not allow for finer-grain control
12380 of interrupt blocking.
12382 @cindex Protected procedure handlers
12383 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
12384 @sp 1
12385 @cartouche
12386 Whenever possible, the implementation should allow interrupt handlers to
12387 be called directly by the hardware.
12388 @end cartouche
12389 Followed on any target where the underlying operating system permits
12390 such direct calls.
12392 @sp 1
12393 @cartouche
12394 Whenever practical, violations of any
12395 implementation-defined restrictions should be detected before run time.
12396 @end cartouche
12397 Followed.  Compile time warnings are given when possible.
12399 @cindex Package @code{Interrupts}
12400 @findex Interrupts
12401 @unnumberedsec C.3.2(25): Package @code{Interrupts}
12403 @sp 1
12404 @cartouche
12405 If implementation-defined forms of interrupt handler procedures are
12406 supported, such as protected procedures with parameters, then for each
12407 such form of a handler, a type analogous to @code{Parameterless_Handler}
12408 should be specified in a child package of @code{Interrupts}, with the
12409 same operations as in the predefined package Interrupts.
12410 @end cartouche
12411 Followed.
12413 @cindex Pre-elaboration requirements
12414 @unnumberedsec C.4(14): Pre-elaboration Requirements
12415 @sp 1
12416 @cartouche
12417 It is recommended that pre-elaborated packages be implemented in such a
12418 way that there should be little or no code executed at run time for the
12419 elaboration of entities not already covered by the Implementation
12420 Requirements.
12421 @end cartouche
12422 Followed.  Executable code is generated in some cases, e.g.@: loops
12423 to initialize large arrays.
12425 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
12426 @sp 1
12427 @cartouche
12428 If the pragma applies to an entity, then the implementation should
12429 reduce the amount of storage used for storing names associated with that
12430 entity.
12431 @end cartouche
12432 Followed.
12434 @cindex Package @code{Task_Attributes}
12435 @findex Task_Attributes
12436 @unnumberedsec C.7.2(30): The Package Task_Attributes
12437 @sp 1
12438 @cartouche
12439 Some implementations are targeted to domains in which memory use at run
12440 time must be completely deterministic.  For such implementations, it is
12441 recommended that the storage for task attributes will be pre-allocated
12442 statically and not from the heap.  This can be accomplished by either
12443 placing restrictions on the number and the size of the task's
12444 attributes, or by using the pre-allocated storage for the first @var{N}
12445 attribute objects, and the heap for the others.  In the latter case,
12446 @var{N} should be documented.
12447 @end cartouche
12448 Not followed.  This implementation is not targeted to such a domain.
12450 @cindex Locking Policies
12451 @unnumberedsec D.3(17): Locking Policies
12453 @sp 1
12454 @cartouche
12455 The implementation should use names that end with @samp{_Locking} for
12456 locking policies defined by the implementation.
12457 @end cartouche
12458 Followed.  Two implementation-defined locking policies are defined,
12459 whose names (@code{Inheritance_Locking} and
12460 @code{Concurrent_Readers_Locking}) follow this suggestion.
12462 @cindex Entry queuing policies
12463 @unnumberedsec D.4(16): Entry Queuing Policies
12464 @sp 1
12465 @cartouche
12466 Names that end with @samp{_Queuing} should be used
12467 for all implementation-defined queuing policies.
12468 @end cartouche
12469 Followed.  No such implementation-defined queuing policies exist.
12471 @cindex Preemptive abort
12472 @unnumberedsec D.6(9-10): Preemptive Abort
12473 @sp 1
12474 @cartouche
12475 Even though the @code{abort_statement} is included in the list of
12476 potentially blocking operations (see 9.5.1), it is recommended that this
12477 statement be implemented in a way that never requires the task executing
12478 the @code{abort_statement} to block.
12479 @end cartouche
12480 Followed.
12482 @sp 1
12483 @cartouche
12484 On a multi-processor, the delay associated with aborting a task on
12485 another processor should be bounded; the implementation should use
12486 periodic polling, if necessary, to achieve this.
12487 @end cartouche
12488 Followed.
12490 @cindex Tasking restrictions
12491 @unnumberedsec D.7(21): Tasking Restrictions
12492 @sp 1
12493 @cartouche
12494 When feasible, the implementation should take advantage of the specified
12495 restrictions to produce a more efficient implementation.
12496 @end cartouche
12497 GNAT currently takes advantage of these restrictions by providing an optimized
12498 run time when the Ravenscar profile and the GNAT restricted run time set
12499 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
12500 pragma @code{Profile (Restricted)} for more details.
12502 @cindex Time, monotonic
12503 @unnumberedsec D.8(47-49): Monotonic Time
12504 @sp 1
12505 @cartouche
12506 When appropriate, implementations should provide configuration
12507 mechanisms to change the value of @code{Tick}.
12508 @end cartouche
12509 Such configuration mechanisms are not appropriate to this implementation
12510 and are thus not supported.
12512 @sp 1
12513 @cartouche
12514 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
12515 be implemented as transformations of the same time base.
12516 @end cartouche
12517 Followed.
12519 @sp 1
12520 @cartouche
12521 It is recommended that the @dfn{best} time base which exists in
12522 the underlying system be available to the application through
12523 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
12524 @end cartouche
12525 Followed.
12527 @cindex Partition communication subsystem
12528 @cindex PCS
12529 @unnumberedsec E.5(28-29): Partition Communication Subsystem
12530 @sp 1
12531 @cartouche
12532 Whenever possible, the PCS on the called partition should allow for
12533 multiple tasks to call the RPC-receiver with different messages and
12534 should allow them to block until the corresponding subprogram body
12535 returns.
12536 @end cartouche
12537 Followed by GLADE, a separately supplied PCS that can be used with
12538 GNAT.
12540 @sp 1
12541 @cartouche
12542 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
12543 should raise @code{Storage_Error} if it runs out of space trying to
12544 write the @code{Item} into the stream.
12545 @end cartouche
12546 Followed by GLADE, a separately supplied PCS that can be used with
12547 GNAT@.
12549 @cindex COBOL support
12550 @unnumberedsec F(7): COBOL Support
12551 @sp 1
12552 @cartouche
12553 If COBOL (respectively, C) is widely supported in the target
12554 environment, implementations supporting the Information Systems Annex
12555 should provide the child package @code{Interfaces.COBOL} (respectively,
12556 @code{Interfaces.C}) specified in Annex B and should support a
12557 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
12558 pragmas (see Annex B), thus allowing Ada programs to interface with
12559 programs written in that language.
12560 @end cartouche
12561 Followed.
12563 @cindex Decimal radix support
12564 @unnumberedsec F.1(2): Decimal Radix Support
12565 @sp 1
12566 @cartouche
12567 Packed decimal should be used as the internal representation for objects
12568 of subtype @var{S} when @var{S}'Machine_Radix = 10.
12569 @end cartouche
12570 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
12571 representations.
12573 @cindex Numerics
12574 @unnumberedsec G: Numerics
12575 @sp 2
12576 @cartouche
12577 If Fortran (respectively, C) is widely supported in the target
12578 environment, implementations supporting the Numerics Annex
12579 should provide the child package @code{Interfaces.Fortran} (respectively,
12580 @code{Interfaces.C}) specified in Annex B and should support a
12581 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
12582 pragmas (see Annex B), thus allowing Ada programs to interface with
12583 programs written in that language.
12584 @end cartouche
12585 Followed.
12587 @cindex Complex types
12588 @unnumberedsec G.1.1(56-58): Complex Types
12589 @sp 2
12590 @cartouche
12591 Because the usual mathematical meaning of multiplication of a complex
12592 operand and a real operand is that of the scaling of both components of
12593 the former by the latter, an implementation should not perform this
12594 operation by first promoting the real operand to complex type and then
12595 performing a full complex multiplication.  In systems that, in the
12596 future, support an Ada binding to IEC 559:1989, the latter technique
12597 will not generate the required result when one of the components of the
12598 complex operand is infinite.  (Explicit multiplication of the infinite
12599 component by the zero component obtained during promotion yields a NaN
12600 that propagates into the final result.) Analogous advice applies in the
12601 case of multiplication of a complex operand and a pure-imaginary
12602 operand, and in the case of division of a complex operand by a real or
12603 pure-imaginary operand.
12604 @end cartouche
12605 Not followed.
12607 @sp 1
12608 @cartouche
12609 Similarly, because the usual mathematical meaning of addition of a
12610 complex operand and a real operand is that the imaginary operand remains
12611 unchanged, an implementation should not perform this operation by first
12612 promoting the real operand to complex type and then performing a full
12613 complex addition.  In implementations in which the @code{Signed_Zeros}
12614 attribute of the component type is @code{True} (and which therefore
12615 conform to IEC 559:1989 in regard to the handling of the sign of zero in
12616 predefined arithmetic operations), the latter technique will not
12617 generate the required result when the imaginary component of the complex
12618 operand is a negatively signed zero.  (Explicit addition of the negative
12619 zero to the zero obtained during promotion yields a positive zero.)
12620 Analogous advice applies in the case of addition of a complex operand
12621 and a pure-imaginary operand, and in the case of subtraction of a
12622 complex operand and a real or pure-imaginary operand.
12623 @end cartouche
12624 Not followed.
12626 @sp 1
12627 @cartouche
12628 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
12629 attempt to provide a rational treatment of the signs of zero results and
12630 result components.  As one example, the result of the @code{Argument}
12631 function should have the sign of the imaginary component of the
12632 parameter @code{X} when the point represented by that parameter lies on
12633 the positive real axis; as another, the sign of the imaginary component
12634 of the @code{Compose_From_Polar} function should be the same as
12635 (respectively, the opposite of) that of the @code{Argument} parameter when that
12636 parameter has a value of zero and the @code{Modulus} parameter has a
12637 nonnegative (respectively, negative) value.
12638 @end cartouche
12639 Followed.
12641 @cindex Complex elementary functions
12642 @unnumberedsec G.1.2(49): Complex Elementary Functions
12643 @sp 1
12644 @cartouche
12645 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
12646 @code{True} should attempt to provide a rational treatment of the signs
12647 of zero results and result components.  For example, many of the complex
12648 elementary functions have components that are odd functions of one of
12649 the parameter components; in these cases, the result component should
12650 have the sign of the parameter component at the origin.  Other complex
12651 elementary functions have zero components whose sign is opposite that of
12652 a parameter component at the origin, or is always positive or always
12653 negative.
12654 @end cartouche
12655 Followed.
12657 @cindex Accuracy requirements
12658 @unnumberedsec G.2.4(19): Accuracy Requirements
12659 @sp 1
12660 @cartouche
12661 The versions of the forward trigonometric functions without a
12662 @code{Cycle} parameter should not be implemented by calling the
12663 corresponding version with a @code{Cycle} parameter of
12664 @code{2.0*Numerics.Pi}, since this will not provide the required
12665 accuracy in some portions of the domain.  For the same reason, the
12666 version of @code{Log} without a @code{Base} parameter should not be
12667 implemented by calling the corresponding version with a @code{Base}
12668 parameter of @code{Numerics.e}.
12669 @end cartouche
12670 Followed.
12672 @cindex Complex arithmetic accuracy
12673 @cindex Accuracy, complex arithmetic
12674 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
12676 @sp 1
12677 @cartouche
12678 The version of the @code{Compose_From_Polar} function without a
12679 @code{Cycle} parameter should not be implemented by calling the
12680 corresponding version with a @code{Cycle} parameter of
12681 @code{2.0*Numerics.Pi}, since this will not provide the required
12682 accuracy in some portions of the domain.
12683 @end cartouche
12684 Followed.
12686 @cindex Sequential elaboration policy
12687 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
12689 @sp 1
12690 @cartouche
12691 If the partition elaboration policy is @code{Sequential} and the
12692 Environment task becomes permanently blocked during elaboration then the
12693 partition is deadlocked and it is recommended that the partition be
12694 immediately terminated.
12695 @end cartouche
12696 Not followed.
12698 @c -----------------------------------------
12699 @node Implementation Defined Characteristics
12700 @chapter Implementation Defined Characteristics
12702 @noindent
12703 In addition to the implementation dependent pragmas and attributes, and the
12704 implementation advice, there are a number of other Ada features that are
12705 potentially implementation dependent and are designated as
12706 implementation-defined. These are mentioned throughout the Ada Reference
12707 Manual, and are summarized in Annex M@.
12709 A requirement for conforming Ada compilers is that they provide
12710 documentation describing how the implementation deals with each of these
12711 issues.  In this chapter you will find each point in Annex M listed,
12712 followed by a description of how GNAT
12713 handles the implementation dependence.
12715 You can use this chapter as a guide to minimizing implementation
12716 dependent features in your programs if portability to other compilers
12717 and other operating systems is an important consideration.  The numbers
12718 in each entry below correspond to the paragraph numbers in the Ada
12719 Reference Manual.
12722 @itemize @bullet
12723 @sp 1
12724 @item
12725 @cartouche
12726 @noindent
12727 Whether or not each recommendation given in Implementation
12728 Advice is followed.  See 1.1.2(37).
12729 @end cartouche
12730 @noindent
12731 @xref{Implementation Advice}.
12734 @sp 1
12735 @item
12736 @cartouche
12737 @noindent
12738 Capacity limitations of the implementation.  See 1.1.3(3).
12739 @end cartouche
12740 @noindent
12741 The complexity of programs that can be processed is limited only by the
12742 total amount of available virtual memory, and disk space for the
12743 generated object files.
12746 @sp 1
12747 @item
12748 @cartouche
12749 @noindent
12750 Variations from the standard that are impractical to avoid
12751 given the implementation's execution environment.  See 1.1.3(6).
12752 @end cartouche
12753 @noindent
12754 There are no variations from the standard.
12757 @sp 1
12758 @item
12759 @cartouche
12760 @noindent
12761 Which @code{code_statement}s cause external
12762 interactions.  See 1.1.3(10).
12763 @end cartouche
12764 @noindent
12765 Any @code{code_statement} can potentially cause external interactions.
12767 @sp 1
12768 @item
12769 @cartouche
12770 @noindent
12771 The coded representation for the text of an Ada
12772 program.  See 2.1(4).
12773 @end cartouche
12774 @noindent
12775 See separate section on source representation.
12778 @sp 1
12779 @item
12780 @cartouche
12781 @noindent
12782 The control functions allowed in comments.  See 2.1(14).
12783 @end cartouche
12784 @noindent
12785 See separate section on source representation.
12787 @sp 1
12788 @item
12789 @cartouche
12790 @noindent
12791 The representation for an end of line.  See 2.2(2).
12792 @end cartouche
12793 @noindent
12794 See separate section on source representation.
12796 @sp 1
12797 @item
12798 @cartouche
12799 @noindent
12800 Maximum supported line length and lexical element
12801 length.  See 2.2(15).
12802 @end cartouche
12803 @noindent
12804 The maximum line length is 255 characters and the maximum length of
12805 a lexical element is also 255 characters. This is the default setting
12806 if not overridden by the use of compiler switch @option{-gnaty} (which
12807 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
12808 line length to be specified to be any value up to 32767. The maximum
12809 length of a lexical element is the same as the maximum line length.
12811 @sp 1
12812 @item
12813 @cartouche
12814 @noindent
12815 Implementation defined pragmas.  See 2.8(14).
12816 @end cartouche
12817 @noindent
12819 @xref{Implementation Defined Pragmas}.
12821 @sp 1
12822 @item
12823 @cartouche
12824 @noindent
12825 Effect of pragma @code{Optimize}.  See 2.8(27).
12826 @end cartouche
12827 @noindent
12828 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
12829 parameter, checks that the optimization flag is set, and aborts if it is
12830 not.
12832 @sp 1
12833 @item
12834 @cartouche
12835 @noindent
12836 The sequence of characters of the value returned by
12837 @code{@var{S}'Image} when some of the graphic characters of
12838 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
12839 3.5(37).
12840 @end cartouche
12841 @noindent
12842 The sequence of characters is as defined by the wide character encoding
12843 method used for the source.  See section on source representation for
12844 further details.
12846 @sp 1
12847 @item
12848 @cartouche
12849 @noindent
12850 The predefined integer types declared in
12851 @code{Standard}.  See 3.5.4(25).
12852 @end cartouche
12853 @noindent
12854 @table @code
12855 @item Short_Short_Integer
12856 8 bit signed
12857 @item Short_Integer
12858 (Short) 16 bit signed
12859 @item Integer
12860 32 bit signed
12861 @item Long_Integer
12862 64 bit signed (on most 64 bit targets, depending on the C definition of long).
12863 32 bit signed (all other targets)
12864 @item Long_Long_Integer
12865 64 bit signed
12866 @end table
12868 @sp 1
12869 @item
12870 @cartouche
12871 @noindent
12872 Any nonstandard integer types and the operators defined
12873 for them.  See 3.5.4(26).
12874 @end cartouche
12875 @noindent
12876 There are no nonstandard integer types.
12878 @sp 1
12879 @item
12880 @cartouche
12881 @noindent
12882 Any nonstandard real types and the operators defined for
12883 them.  See 3.5.6(8).
12884 @end cartouche
12885 @noindent
12886 There are no nonstandard real types.
12888 @sp 1
12889 @item
12890 @cartouche
12891 @noindent
12892 What combinations of requested decimal precision and range
12893 are supported for floating point types.  See 3.5.7(7).
12894 @end cartouche
12895 @noindent
12896 The precision and range is as defined by the IEEE standard.
12898 @sp 1
12899 @item
12900 @cartouche
12901 @noindent
12902 The predefined floating point types declared in
12903 @code{Standard}.  See 3.5.7(16).
12904 @end cartouche
12905 @noindent
12906 @table @code
12907 @item Short_Float
12908 32 bit IEEE short
12909 @item Float
12910 (Short) 32 bit IEEE short
12911 @item Long_Float
12912 64 bit IEEE long
12913 @item Long_Long_Float
12914 64 bit IEEE long (80 bit IEEE long on x86 processors)
12915 @end table
12917 @sp 1
12918 @item
12919 @cartouche
12920 @noindent
12921 The small of an ordinary fixed point type.  See 3.5.9(8).
12922 @end cartouche
12923 @noindent
12924 @code{Fine_Delta} is 2**(@minus{}63)
12926 @sp 1
12927 @item
12928 @cartouche
12929 @noindent
12930 What combinations of small, range, and digits are
12931 supported for fixed point types.  See 3.5.9(10).
12932 @end cartouche
12933 @noindent
12934 Any combinations are permitted that do not result in a small less than
12935 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
12936 If the mantissa is larger than 53 bits on machines where Long_Long_Float
12937 is 64 bits (true of all architectures except ia32), then the output from
12938 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
12939 is because floating-point conversions are used to convert fixed point.
12941 @sp 1
12942 @item
12943 @cartouche
12944 @noindent
12945 The result of @code{Tags.Expanded_Name} for types declared
12946 within an unnamed @code{block_statement}.  See 3.9(10).
12947 @end cartouche
12948 @noindent
12949 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
12950 decimal integer are allocated.
12952 @sp 1
12953 @item
12954 @cartouche
12955 @noindent
12956 Implementation-defined attributes.  See 4.1.4(12).
12957 @end cartouche
12958 @noindent
12959 @xref{Implementation Defined Attributes}.
12961 @sp 1
12962 @item
12963 @cartouche
12964 @noindent
12965 Any implementation-defined time types.  See 9.6(6).
12966 @end cartouche
12967 @noindent
12968 There are no implementation-defined time types.
12970 @sp 1
12971 @item
12972 @cartouche
12973 @noindent
12974 The time base associated with relative delays.
12975 @end cartouche
12976 @noindent
12977 See 9.6(20).  The time base used is that provided by the C library
12978 function @code{gettimeofday}.
12980 @sp 1
12981 @item
12982 @cartouche
12983 @noindent
12984 The time base of the type @code{Calendar.Time}.  See
12985 9.6(23).
12986 @end cartouche
12987 @noindent
12988 The time base used is that provided by the C library function
12989 @code{gettimeofday}.
12991 @sp 1
12992 @item
12993 @cartouche
12994 @noindent
12995 The time zone used for package @code{Calendar}
12996 operations.  See 9.6(24).
12997 @end cartouche
12998 @noindent
12999 The time zone used by package @code{Calendar} is the current system time zone
13000 setting for local time, as accessed by the C library function
13001 @code{localtime}.
13003 @sp 1
13004 @item
13005 @cartouche
13006 @noindent
13007 Any limit on @code{delay_until_statements} of
13008 @code{select_statements}.  See 9.6(29).
13009 @end cartouche
13010 @noindent
13011 There are no such limits.
13013 @sp 1
13014 @item
13015 @cartouche
13016 @noindent
13017 Whether or not two non-overlapping parts of a composite
13018 object are independently addressable, in the case where packing, record
13019 layout, or @code{Component_Size} is specified for the object.  See
13020 9.10(1).
13021 @end cartouche
13022 @noindent
13023 Separate components are independently addressable if they do not share
13024 overlapping storage units.
13026 @sp 1
13027 @item
13028 @cartouche
13029 @noindent
13030 The representation for a compilation.  See 10.1(2).
13031 @end cartouche
13032 @noindent
13033 A compilation is represented by a sequence of files presented to the
13034 compiler in a single invocation of the @command{gcc} command.
13036 @sp 1
13037 @item
13038 @cartouche
13039 @noindent
13040 Any restrictions on compilations that contain multiple
13041 compilation_units.  See 10.1(4).
13042 @end cartouche
13043 @noindent
13044 No single file can contain more than one compilation unit, but any
13045 sequence of files can be presented to the compiler as a single
13046 compilation.
13048 @sp 1
13049 @item
13050 @cartouche
13051 @noindent
13052 The mechanisms for creating an environment and for adding
13053 and replacing compilation units.  See 10.1.4(3).
13054 @end cartouche
13055 @noindent
13056 See separate section on compilation model.
13058 @sp 1
13059 @item
13060 @cartouche
13061 @noindent
13062 The manner of explicitly assigning library units to a
13063 partition.  See 10.2(2).
13064 @end cartouche
13065 @noindent
13066 If a unit contains an Ada main program, then the Ada units for the partition
13067 are determined by recursive application of the rules in the Ada Reference
13068 Manual section 10.2(2-6).  In other words, the Ada units will be those that
13069 are needed by the main program, and then this definition of need is applied
13070 recursively to those units, and the partition contains the transitive
13071 closure determined by this relationship.  In short, all the necessary units
13072 are included, with no need to explicitly specify the list.  If additional
13073 units are required, e.g.@: by foreign language units, then all units must be
13074 mentioned in the context clause of one of the needed Ada units.
13076 If the partition contains no main program, or if the main program is in
13077 a language other than Ada, then GNAT
13078 provides the binder options @option{-z} and @option{-n} respectively, and in
13079 this case a list of units can be explicitly supplied to the binder for
13080 inclusion in the partition (all units needed by these units will also
13081 be included automatically).  For full details on the use of these
13082 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
13083 @value{EDITION} User's Guide}.
13085 @sp 1
13086 @item
13087 @cartouche
13088 @noindent
13089 The implementation-defined means, if any, of specifying
13090 which compilation units are needed by a given compilation unit.  See
13091 10.2(2).
13092 @end cartouche
13093 @noindent
13094 The units needed by a given compilation unit are as defined in
13095 the Ada Reference Manual section 10.2(2-6).  There are no
13096 implementation-defined pragmas or other implementation-defined
13097 means for specifying needed units.
13099 @sp 1
13100 @item
13101 @cartouche
13102 @noindent
13103 The manner of designating the main subprogram of a
13104 partition.  See 10.2(7).
13105 @end cartouche
13106 @noindent
13107 The main program is designated by providing the name of the
13108 corresponding @file{ALI} file as the input parameter to the binder.
13110 @sp 1
13111 @item
13112 @cartouche
13113 @noindent
13114 The order of elaboration of @code{library_items}.  See
13115 10.2(18).
13116 @end cartouche
13117 @noindent
13118 The first constraint on ordering is that it meets the requirements of
13119 Chapter 10 of the Ada Reference Manual.  This still leaves some
13120 implementation dependent choices, which are resolved by first
13121 elaborating bodies as early as possible (i.e., in preference to specs
13122 where there is a choice), and second by evaluating the immediate with
13123 clauses of a unit to determine the probably best choice, and
13124 third by elaborating in alphabetical order of unit names
13125 where a choice still remains.
13127 @sp 1
13128 @item
13129 @cartouche
13130 @noindent
13131 Parameter passing and function return for the main
13132 subprogram.  See 10.2(21).
13133 @end cartouche
13134 @noindent
13135 The main program has no parameters.  It may be a procedure, or a function
13136 returning an integer type.  In the latter case, the returned integer
13137 value is the return code of the program (overriding any value that
13138 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
13140 @sp 1
13141 @item
13142 @cartouche
13143 @noindent
13144 The mechanisms for building and running partitions.  See
13145 10.2(24).
13146 @end cartouche
13147 @noindent
13148 GNAT itself supports programs with only a single partition.  The GNATDIST
13149 tool provided with the GLADE package (which also includes an implementation
13150 of the PCS) provides a completely flexible method for building and running
13151 programs consisting of multiple partitions.  See the separate GLADE manual
13152 for details.
13154 @sp 1
13155 @item
13156 @cartouche
13157 @noindent
13158 The details of program execution, including program
13159 termination.  See 10.2(25).
13160 @end cartouche
13161 @noindent
13162 See separate section on compilation model.
13164 @sp 1
13165 @item
13166 @cartouche
13167 @noindent
13168 The semantics of any non-active partitions supported by the
13169 implementation.  See 10.2(28).
13170 @end cartouche
13171 @noindent
13172 Passive partitions are supported on targets where shared memory is
13173 provided by the operating system.  See the GLADE reference manual for
13174 further details.
13176 @sp 1
13177 @item
13178 @cartouche
13179 @noindent
13180 The information returned by @code{Exception_Message}.  See
13181 11.4.1(10).
13182 @end cartouche
13183 @noindent
13184 Exception message returns the null string unless a specific message has
13185 been passed by the program.
13187 @sp 1
13188 @item
13189 @cartouche
13190 @noindent
13191 The result of @code{Exceptions.Exception_Name} for types
13192 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
13193 @end cartouche
13194 @noindent
13195 Blocks have implementation defined names of the form @code{B@var{nnn}}
13196 where @var{nnn} is an integer.
13198 @sp 1
13199 @item
13200 @cartouche
13201 @noindent
13202 The information returned by
13203 @code{Exception_Information}.  See 11.4.1(13).
13204 @end cartouche
13205 @noindent
13206 @code{Exception_Information} returns a string in the following format:
13208 @smallexample
13209 @emph{Exception_Name:} nnnnn
13210 @emph{Message:} mmmmm
13211 @emph{PID:} ppp
13212 @emph{Load address:} 0xhhhh
13213 @emph{Call stack traceback locations:}
13214 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
13215 @end smallexample
13217 @noindent
13218 where
13220 @itemize @bullet
13221 @item
13222 @code{nnnn} is the fully qualified name of the exception in all upper
13223 case letters. This line is always present.
13225 @item
13226 @code{mmmm} is the message (this line present only if message is non-null)
13228 @item
13229 @code{ppp} is the Process Id value as a decimal integer (this line is
13230 present only if the Process Id is nonzero). Currently we are
13231 not making use of this field.
13233 @item
13234 The Load address line, the Call stack traceback locations line and the
13235 following values are present only if at least one traceback location was
13236 recorded. The Load address indicates the address at which the main executable
13237 was loaded; this line may not be present if operating system hasn't relocated
13238 the main executable. The values are given in C style format, with lower case
13239 letters for a-f, and only as many digits present as are necessary.
13240 @end itemize
13242 @noindent
13243 The line terminator sequence at the end of each line, including
13244 the last line is a single @code{LF} character (@code{16#0A#}).
13246 @sp 1
13247 @item
13248 @cartouche
13249 @noindent
13250 Implementation-defined check names.  See 11.5(27).
13251 @end cartouche
13252 @noindent
13253 The implementation defined check name Alignment_Check controls checking of
13254 address clause values for proper alignment (that is, the address supplied
13255 must be consistent with the alignment of the type).
13257 The implementation defined check name Predicate_Check controls whether
13258 predicate checks are generated.
13260 The implementation defined check name Validity_Check controls whether
13261 validity checks are generated.
13263 In addition, a user program can add implementation-defined check names
13264 by means of the pragma Check_Name.
13266 @sp 1
13267 @item
13268 @cartouche
13269 @noindent
13270 The interpretation of each aspect of representation.  See
13271 13.1(20).
13272 @end cartouche
13273 @noindent
13274 See separate section on data representations.
13276 @sp 1
13277 @item
13278 @cartouche
13279 @noindent
13280 Any restrictions placed upon representation items.  See
13281 13.1(20).
13282 @end cartouche
13283 @noindent
13284 See separate section on data representations.
13286 @sp 1
13287 @item
13288 @cartouche
13289 @noindent
13290 The meaning of @code{Size} for indefinite subtypes.  See
13291 13.3(48).
13292 @end cartouche
13293 @noindent
13294 Size for an indefinite subtype is the maximum possible size, except that
13295 for the case of a subprogram parameter, the size of the parameter object
13296 is the actual size.
13298 @sp 1
13299 @item
13300 @cartouche
13301 @noindent
13302 The default external representation for a type tag.  See
13303 13.3(75).
13304 @end cartouche
13305 @noindent
13306 The default external representation for a type tag is the fully expanded
13307 name of the type in upper case letters.
13309 @sp 1
13310 @item
13311 @cartouche
13312 @noindent
13313 What determines whether a compilation unit is the same in
13314 two different partitions.  See 13.3(76).
13315 @end cartouche
13316 @noindent
13317 A compilation unit is the same in two different partitions if and only
13318 if it derives from the same source file.
13320 @sp 1
13321 @item
13322 @cartouche
13323 @noindent
13324 Implementation-defined components.  See 13.5.1(15).
13325 @end cartouche
13326 @noindent
13327 The only implementation defined component is the tag for a tagged type,
13328 which contains a pointer to the dispatching table.
13330 @sp 1
13331 @item
13332 @cartouche
13333 @noindent
13334 If @code{Word_Size} = @code{Storage_Unit}, the default bit
13335 ordering.  See 13.5.3(5).
13336 @end cartouche
13337 @noindent
13338 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
13339 implementation, so no non-default bit ordering is supported.  The default
13340 bit ordering corresponds to the natural endianness of the target architecture.
13342 @sp 1
13343 @item
13344 @cartouche
13345 @noindent
13346 The contents of the visible part of package @code{System}
13347 and its language-defined children.  See 13.7(2).
13348 @end cartouche
13349 @noindent
13350 See the definition of these packages in files @file{system.ads} and
13351 @file{s-stoele.ads}. Note that two declarations are added to package
13352 System.
13354 @smallexample @c ada
13355    Max_Priority           : constant Positive :=
13356      Priority'Last;
13357    Max_Interrupt_Priority : constant Positive :=
13358      Interrupt_Priority'Last;
13359 @end smallexample
13361 @sp 1
13362 @item
13363 @cartouche
13364 @noindent
13365 The contents of the visible part of package
13366 @code{System.Machine_Code}, and the meaning of
13367 @code{code_statements}.  See 13.8(7).
13368 @end cartouche
13369 @noindent
13370 See the definition and documentation in file @file{s-maccod.ads}.
13372 @sp 1
13373 @item
13374 @cartouche
13375 @noindent
13376 The effect of unchecked conversion.  See 13.9(11).
13377 @end cartouche
13378 @noindent
13379 Unchecked conversion between types of the same size
13380 results in an uninterpreted transmission of the bits from one type
13381 to the other.  If the types are of unequal sizes, then in the case of
13382 discrete types, a shorter source is first zero or sign extended as
13383 necessary, and a shorter target is simply truncated on the left.
13384 For all non-discrete types, the source is first copied if necessary
13385 to ensure that the alignment requirements of the target are met, then
13386 a pointer is constructed to the source value, and the result is obtained
13387 by dereferencing this pointer after converting it to be a pointer to the
13388 target type. Unchecked conversions where the target subtype is an
13389 unconstrained array are not permitted. If the target alignment is
13390 greater than the source alignment, then a copy of the result is
13391 made with appropriate alignment
13393 @sp 1
13394 @item
13395 @cartouche
13396 @noindent
13397 The semantics of operations on invalid representations.
13398 See 13.9.2(10-11).
13399 @end cartouche
13400 @noindent
13401 For assignments and other operations where the use of invalid values cannot
13402 result in erroneous behavior, the compiler ignores the possibility of invalid
13403 values. An exception is raised at the point where an invalid value would
13404 result in erroneous behavior. For example executing:
13406 @smallexample @c ada
13407 procedure invalidvals is
13408    X : Integer := -1;
13409    Y : Natural range 1 .. 10;
13410    for Y'Address use X'Address;
13411    Z : Natural range 1 .. 10;
13412    A : array (Natural range 1 .. 10) of Integer;
13413 begin
13414    Z := Y;     -- no exception
13415    A (Z) := 3; -- exception raised;
13416 end;
13417 @end smallexample
13419 @noindent
13420 As indicated, an exception is raised on the array assignment, but not
13421 on the simple assignment of the invalid negative value from Y to Z.
13423 @sp 1
13424 @item
13425 @cartouche
13426 @noindent
13427 The manner of choosing a storage pool for an access type
13428 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
13429 @end cartouche
13430 @noindent
13431 There are 3 different standard pools used by the compiler when
13432 @code{Storage_Pool} is not specified depending whether the type is local
13433 to a subprogram or defined at the library level and whether
13434 @code{Storage_Size}is specified or not.  See documentation in the runtime
13435 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
13436 @code{System.Pool_Local} in files @file{s-poosiz.ads},
13437 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
13438 default pools used.
13440 @sp 1
13441 @item
13442 @cartouche
13443 @noindent
13444 Whether or not the implementation provides user-accessible
13445 names for the standard pool type(s).  See 13.11(17).
13446 @end cartouche
13447 @noindent
13449 See documentation in the sources of the run time mentioned in the previous
13450 paragraph.  All these pools are accessible by means of @code{with}'ing
13451 these units.
13453 @sp 1
13454 @item
13455 @cartouche
13456 @noindent
13457 The meaning of @code{Storage_Size}.  See 13.11(18).
13458 @end cartouche
13459 @noindent
13460 @code{Storage_Size} is measured in storage units, and refers to the
13461 total space available for an access type collection, or to the primary
13462 stack space for a task.
13464 @sp 1
13465 @item
13466 @cartouche
13467 @noindent
13468 Implementation-defined aspects of storage pools.  See
13469 13.11(22).
13470 @end cartouche
13471 @noindent
13472 See documentation in the sources of the run time mentioned in the
13473 paragraph about standard storage pools above
13474 for details on GNAT-defined aspects of storage pools.
13476 @sp 1
13477 @item
13478 @cartouche
13479 @noindent
13480 The set of restrictions allowed in a pragma
13481 @code{Restrictions}.  See 13.12(7).
13482 @end cartouche
13483 @noindent
13484 @xref{Standard and Implementation Defined Restrictions}.
13486 @sp 1
13487 @item
13488 @cartouche
13489 @noindent
13490 The consequences of violating limitations on
13491 @code{Restrictions} pragmas.  See 13.12(9).
13492 @end cartouche
13493 @noindent
13494 Restrictions that can be checked at compile time result in illegalities
13495 if violated.  Currently there are no other consequences of violating
13496 restrictions.
13498 @sp 1
13499 @item
13500 @cartouche
13501 @noindent
13502 The representation used by the @code{Read} and
13503 @code{Write} attributes of elementary types in terms of stream
13504 elements.  See 13.13.2(9).
13505 @end cartouche
13506 @noindent
13507 The representation is the in-memory representation of the base type of
13508 the type, using the number of bits corresponding to the
13509 @code{@var{type}'Size} value, and the natural ordering of the machine.
13511 @sp 1
13512 @item
13513 @cartouche
13514 @noindent
13515 The names and characteristics of the numeric subtypes
13516 declared in the visible part of package @code{Standard}.  See A.1(3).
13517 @end cartouche
13518 @noindent
13519 See items describing the integer and floating-point types supported.
13521 @sp 1
13522 @item
13523 @cartouche
13524 @noindent
13525 The string returned by @code{Character_Set_Version}.
13526 See A.3.5(3).
13527 @end cartouche
13528 @noindent
13529 @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns
13530 the string "Unicode 4.0", referring to version 4.0 of the
13531 Unicode specification.
13533 @sp 1
13534 @item
13535 @cartouche
13536 @noindent
13537 The accuracy actually achieved by the elementary
13538 functions.  See A.5.1(1).
13539 @end cartouche
13540 @noindent
13541 The elementary functions correspond to the functions available in the C
13542 library.  Only fast math mode is implemented.
13544 @sp 1
13545 @item
13546 @cartouche
13547 @noindent
13548 The sign of a zero result from some of the operators or
13549 functions in @code{Numerics.Generic_Elementary_Functions}, when
13550 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
13551 @end cartouche
13552 @noindent
13553 The sign of zeroes follows the requirements of the IEEE 754 standard on
13554 floating-point.
13556 @sp 1
13557 @item
13558 @cartouche
13559 @noindent
13560 The value of
13561 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
13562 @end cartouche
13563 @noindent
13564 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13566 @sp 1
13567 @item
13568 @cartouche
13569 @noindent
13570 The value of
13571 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
13572 @end cartouche
13573 @noindent
13574 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13576 @sp 1
13577 @item
13578 @cartouche
13579 @noindent
13580 The algorithms for random number generation.  See
13581 A.5.2(32).
13582 @end cartouche
13583 @noindent
13584 The algorithm is the Mersenne Twister, as documented in the source file
13585 @file{s-rannum.adb}. This version of the algorithm has a period of
13586 2**19937-1.
13588 @sp 1
13589 @item
13590 @cartouche
13591 @noindent
13592 The string representation of a random number generator's
13593 state.  See A.5.2(38).
13594 @end cartouche
13595 @noindent
13596 The value returned by the Image function is the concatenation of
13597 the fixed-width decimal representations of the 624 32-bit integers
13598 of the state vector.
13600 @sp 1
13601 @item
13602 @cartouche
13603 @noindent
13604 The minimum time interval between calls to the
13605 time-dependent Reset procedure that are guaranteed to initiate different
13606 random number sequences.  See A.5.2(45).
13607 @end cartouche
13608 @noindent
13609 The minimum period between reset calls to guarantee distinct series of
13610 random numbers is one microsecond.
13612 @sp 1
13613 @item
13614 @cartouche
13615 @noindent
13616 The values of the @code{Model_Mantissa},
13617 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
13618 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
13619 Annex is not supported.  See A.5.3(72).
13620 @end cartouche
13621 @noindent
13622 Run the compiler with @option{-gnatS} to produce a listing of package
13623 @code{Standard}, has the values of all numeric attributes.
13625 @sp 1
13626 @item
13627 @cartouche
13628 @noindent
13629 Any implementation-defined characteristics of the
13630 input-output packages.  See A.7(14).
13631 @end cartouche
13632 @noindent
13633 There are no special implementation defined characteristics for these
13634 packages.
13636 @sp 1
13637 @item
13638 @cartouche
13639 @noindent
13640 The value of @code{Buffer_Size} in @code{Storage_IO}.  See
13641 A.9(10).
13642 @end cartouche
13643 @noindent
13644 All type representations are contiguous, and the @code{Buffer_Size} is
13645 the value of @code{@var{type}'Size} rounded up to the next storage unit
13646 boundary.
13648 @sp 1
13649 @item
13650 @cartouche
13651 @noindent
13652 External files for standard input, standard output, and
13653 standard error See A.10(5).
13654 @end cartouche
13655 @noindent
13656 These files are mapped onto the files provided by the C streams
13657 libraries.  See source file @file{i-cstrea.ads} for further details.
13659 @sp 1
13660 @item
13661 @cartouche
13662 @noindent
13663 The accuracy of the value produced by @code{Put}.  See
13664 A.10.9(36).
13665 @end cartouche
13666 @noindent
13667 If more digits are requested in the output than are represented by the
13668 precision of the value, zeroes are output in the corresponding least
13669 significant digit positions.
13671 @sp 1
13672 @item
13673 @cartouche
13674 @noindent
13675 The meaning of @code{Argument_Count}, @code{Argument}, and
13676 @code{Command_Name}.  See A.15(1).
13677 @end cartouche
13678 @noindent
13679 These are mapped onto the @code{argv} and @code{argc} parameters of the
13680 main program in the natural manner.
13682 @sp 1
13683 @item
13684 @cartouche
13685 @noindent
13686 The interpretation of the @code{Form} parameter in procedure
13687 @code{Create_Directory}.  See A.16(56).
13688 @end cartouche
13689 @noindent
13690 The @code{Form} parameter is not used.
13692 @sp 1
13693 @item
13694 @cartouche
13695 @noindent
13696 The interpretation of the @code{Form} parameter in procedure
13697 @code{Create_Path}.  See A.16(60).
13698 @end cartouche
13699 @noindent
13700 The @code{Form} parameter is not used.
13702 @sp 1
13703 @item
13704 @cartouche
13705 @noindent
13706 The interpretation of the @code{Form} parameter in procedure
13707 @code{Copy_File}.  See A.16(68).
13708 @end cartouche
13709 @noindent
13710 The @code{Form} parameter is case-insensitive.
13712 Two fields are recognized in the @code{Form} parameter:
13714 @table @code
13716 @item preserve=<value>
13718 @item mode=<value>
13720 @end table
13722 @noindent
13723 <value> starts immediately after the character '=' and ends with the
13724 character immediately preceding the next comma (',') or with the last
13725 character of the parameter.
13727 The only possible values for preserve= are:
13729 @table @code
13731 @item no_attributes
13732 Do not try to preserve any file attributes. This is the default if no
13733 preserve= is found in Form.
13735 @item all_attributes
13736 Try to preserve all file attributes (timestamps, access rights).
13738 @item timestamps
13739 Preserve the timestamp of the copied file, but not the other file attributes.
13741 @end table
13743 @noindent
13744 The only possible values for mode= are:
13746 @table @code
13748 @item copy
13749 Only do the copy if the destination file does not already exist. If it already
13750 exists, Copy_File fails.
13752 @item overwrite
13753 Copy the file in all cases. Overwrite an already existing destination file.
13755 @item append
13756 Append the original file to the destination file. If the destination file does
13757 not exist, the destination file is a copy of the source file. When mode=append,
13758 the field preserve=, if it exists, is not taken into account.
13760 @end table
13762 @noindent
13763 If the Form parameter includes one or both of the fields and the value or
13764 values are incorrect, Copy_file fails with Use_Error.
13766 Examples of correct Forms:
13768 @smallexample
13769 Form => "preserve=no_attributes,mode=overwrite" (the default)
13770 Form => "mode=append"
13771 Form => "mode=copy, preserve=all_attributes"
13772 @end smallexample
13774 @noindent
13775 Examples of incorrect Forms
13777 @smallexample
13778 Form => "preserve=junk"
13779 Form => "mode=internal, preserve=timestamps"
13780 @end smallexample
13782 @sp 1
13783 @item
13784 @cartouche
13785 @noindent
13786 The interpretation of the @code{Pattern} parameter, when not the null string,
13787 in the @code{Start_Search} and @code{Search} procedures.
13788 See A.16(104) and A.16(112).
13789 @end cartouche
13790 @noindent
13791 When the @code{Pattern} parameter is not the null string, it is interpreted
13792 according to the syntax of regular expressions as defined in the
13793 @code{GNAT.Regexp} package.
13794 @xref{GNAT.Regexp (g-regexp.ads)}.
13796 @sp 1
13797 @item
13798 @cartouche
13799 @noindent
13800 Implementation-defined convention names.  See B.1(11).
13801 @end cartouche
13802 @noindent
13803 The following convention names are supported
13805 @table @code
13806 @item  Ada
13808 @item Ada_Pass_By_Copy
13809 Allowed for any types except by-reference types such as limited
13810 records. Compatible with convention Ada, but causes any parameters
13811 with this convention to be passed by copy.
13812 @item Ada_Pass_By_Reference
13813 Allowed for any types except by-copy types such as scalars.
13814 Compatible with convention Ada, but causes any parameters
13815 with this convention to be passed by reference.
13816 @item Assembler
13817 Assembly language
13818 @item Asm
13819 Synonym for Assembler
13820 @item Assembly
13821 Synonym for Assembler
13822 @item C
13824 @item C_Pass_By_Copy
13825 Allowed only for record types, like C, but also notes that record
13826 is to be passed by copy rather than reference.
13827 @item COBOL
13828 COBOL
13829 @item C_Plus_Plus (or CPP)
13831 @item Default
13832 Treated the same as C
13833 @item External
13834 Treated the same as C
13835 @item Fortran
13836 Fortran
13837 @item Intrinsic
13838 For support of pragma @code{Import} with convention Intrinsic, see
13839 separate section on Intrinsic Subprograms.
13840 @item Stdcall
13841 Stdcall (used for Windows implementations only).  This convention correspond
13842 to the WINAPI (previously called Pascal convention) C/C++ convention under
13843 Windows.  A routine with this convention cleans the stack before
13844 exit. This pragma cannot be applied to a dispatching call.
13845 @item DLL
13846 Synonym for Stdcall
13847 @item Win32
13848 Synonym for Stdcall
13849 @item Stubbed
13850 Stubbed is a special convention used to indicate that the body of the
13851 subprogram will be entirely ignored.  Any call to the subprogram
13852 is converted into a raise of the @code{Program_Error} exception.  If a
13853 pragma @code{Import} specifies convention @code{stubbed} then no body need
13854 be present at all.  This convention is useful during development for the
13855 inclusion of subprograms whose body has not yet been written.
13857 @end table
13858 @noindent
13859 In addition, all otherwise unrecognized convention names are also
13860 treated as being synonymous with convention C@.  In all implementations
13861 except for VMS, use of such other names results in a warning.  In VMS
13862 implementations, these names are accepted silently.
13864 @sp 1
13865 @item
13866 @cartouche
13867 @noindent
13868 The meaning of link names.  See B.1(36).
13869 @end cartouche
13870 @noindent
13871 Link names are the actual names used by the linker.
13873 @sp 1
13874 @item
13875 @cartouche
13876 @noindent
13877 The manner of choosing link names when neither the link
13878 name nor the address of an imported or exported entity is specified.  See
13879 B.1(36).
13880 @end cartouche
13881 @noindent
13882 The default linker name is that which would be assigned by the relevant
13883 external language, interpreting the Ada name as being in all lower case
13884 letters.
13886 @sp 1
13887 @item
13888 @cartouche
13889 @noindent
13890 The effect of pragma @code{Linker_Options}.  See B.1(37).
13891 @end cartouche
13892 @noindent
13893 The string passed to @code{Linker_Options} is presented uninterpreted as
13894 an argument to the link command, unless it contains ASCII.NUL characters.
13895 NUL characters if they appear act as argument separators, so for example
13897 @smallexample @c ada
13898 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
13899 @end smallexample
13901 @noindent
13902 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
13903 linker. The order of linker options is preserved for a given unit. The final
13904 list of options passed to the linker is in reverse order of the elaboration
13905 order. For example, linker options for a body always appear before the options
13906 from the corresponding package spec.
13908 @sp 1
13909 @item
13910 @cartouche
13911 @noindent
13912 The contents of the visible part of package
13913 @code{Interfaces} and its language-defined descendants.  See B.2(1).
13914 @end cartouche
13915 @noindent
13916 See files with prefix @file{i-} in the distributed library.
13918 @sp 1
13919 @item
13920 @cartouche
13921 @noindent
13922 Implementation-defined children of package
13923 @code{Interfaces}.  The contents of the visible part of package
13924 @code{Interfaces}.  See B.2(11).
13925 @end cartouche
13926 @noindent
13927 See files with prefix @file{i-} in the distributed library.
13929 @sp 1
13930 @item
13931 @cartouche
13932 @noindent
13933 The types @code{Floating}, @code{Long_Floating},
13934 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
13935 @code{COBOL_Character}; and the initialization of the variables
13936 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
13937 @code{Interfaces.COBOL}.  See B.4(50).
13938 @end cartouche
13939 @noindent
13940 @table @code
13941 @item Floating
13942 Float
13943 @item Long_Floating
13944 (Floating) Long_Float
13945 @item Binary
13946 Integer
13947 @item Long_Binary
13948 Long_Long_Integer
13949 @item Decimal_Element
13950 Character
13951 @item COBOL_Character
13952 Character
13953 @end table
13955 @noindent
13956 For initialization, see the file @file{i-cobol.ads} in the distributed library.
13958 @sp 1
13959 @item
13960 @cartouche
13961 @noindent
13962 Support for access to machine instructions.  See C.1(1).
13963 @end cartouche
13964 @noindent
13965 See documentation in file @file{s-maccod.ads} in the distributed library.
13967 @sp 1
13968 @item
13969 @cartouche
13970 @noindent
13971 Implementation-defined aspects of access to machine
13972 operations.  See C.1(9).
13973 @end cartouche
13974 @noindent
13975 See documentation in file @file{s-maccod.ads} in the distributed library.
13977 @sp 1
13978 @item
13979 @cartouche
13980 @noindent
13981 Implementation-defined aspects of interrupts.  See C.3(2).
13982 @end cartouche
13983 @noindent
13984 Interrupts are mapped to signals or conditions as appropriate.  See
13985 definition of unit
13986 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
13987 on the interrupts supported on a particular target.
13989 @sp 1
13990 @item
13991 @cartouche
13992 @noindent
13993 Implementation-defined aspects of pre-elaboration.  See
13994 C.4(13).
13995 @end cartouche
13996 @noindent
13997 GNAT does not permit a partition to be restarted without reloading,
13998 except under control of the debugger.
14000 @sp 1
14001 @item
14002 @cartouche
14003 @noindent
14004 The semantics of pragma @code{Discard_Names}.  See C.5(7).
14005 @end cartouche
14006 @noindent
14007 Pragma @code{Discard_Names} causes names of enumeration literals to
14008 be suppressed.  In the presence of this pragma, the Image attribute
14009 provides the image of the Pos of the literal, and Value accepts
14010 Pos values.
14012 @sp 1
14013 @item
14014 @cartouche
14015 @noindent
14016 The result of the @code{Task_Identification.Image}
14017 attribute.  See C.7.1(7).
14018 @end cartouche
14019 @noindent
14020 The result of this attribute is a string that identifies
14021 the object or component that denotes a given task. If a variable @code{Var}
14022 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
14023 where the suffix
14024 is the hexadecimal representation of the virtual address of the corresponding
14025 task control block. If the variable is an array of tasks, the image of each
14026 task will have the form of an indexed component indicating the position of a
14027 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
14028 component of a record, the image of the task will have the form of a selected
14029 component. These rules are fully recursive, so that the image of a task that
14030 is a subcomponent of a composite object corresponds to the expression that
14031 designates this task.
14032 @noindent
14033 If a task is created by an allocator, its image depends on the context. If the
14034 allocator is part of an object declaration, the rules described above are used
14035 to construct its image, and this image is not affected by subsequent
14036 assignments. If the allocator appears within an expression, the image
14037 includes only the name of the task type.
14038 @noindent
14039 If the configuration pragma Discard_Names is present, or if the restriction
14040 No_Implicit_Heap_Allocation is in effect,  the image reduces to
14041 the numeric suffix, that is to say the hexadecimal representation of the
14042 virtual address of the control block of the task.
14043 @sp 1
14044 @item
14045 @cartouche
14046 @noindent
14047 The value of @code{Current_Task} when in a protected entry
14048 or interrupt handler.  See C.7.1(17).
14049 @end cartouche
14050 @noindent
14051 Protected entries or interrupt handlers can be executed by any
14052 convenient thread, so the value of @code{Current_Task} is undefined.
14054 @sp 1
14055 @item
14056 @cartouche
14057 @noindent
14058 The effect of calling @code{Current_Task} from an entry
14059 body or interrupt handler.  See C.7.1(19).
14060 @end cartouche
14061 @noindent
14062 The effect of calling @code{Current_Task} from an entry body or
14063 interrupt handler is to return the identification of the task currently
14064 executing the code.
14066 @sp 1
14067 @item
14068 @cartouche
14069 @noindent
14070 Implementation-defined aspects of
14071 @code{Task_Attributes}.  See C.7.2(19).
14072 @end cartouche
14073 @noindent
14074 There are no implementation-defined aspects of @code{Task_Attributes}.
14076 @sp 1
14077 @item
14078 @cartouche
14079 @noindent
14080 Values of all @code{Metrics}.  See D(2).
14081 @end cartouche
14082 @noindent
14083 The metrics information for GNAT depends on the performance of the
14084 underlying operating system.  The sources of the run-time for tasking
14085 implementation, together with the output from @option{-gnatG} can be
14086 used to determine the exact sequence of operating systems calls made
14087 to implement various tasking constructs.  Together with appropriate
14088 information on the performance of the underlying operating system,
14089 on the exact target in use, this information can be used to determine
14090 the required metrics.
14092 @sp 1
14093 @item
14094 @cartouche
14095 @noindent
14096 The declarations of @code{Any_Priority} and
14097 @code{Priority}.  See D.1(11).
14098 @end cartouche
14099 @noindent
14100 See declarations in file @file{system.ads}.
14102 @sp 1
14103 @item
14104 @cartouche
14105 @noindent
14106 Implementation-defined execution resources.  See D.1(15).
14107 @end cartouche
14108 @noindent
14109 There are no implementation-defined execution resources.
14111 @sp 1
14112 @item
14113 @cartouche
14114 @noindent
14115 Whether, on a multiprocessor, a task that is waiting for
14116 access to a protected object keeps its processor busy.  See D.2.1(3).
14117 @end cartouche
14118 @noindent
14119 On a multi-processor, a task that is waiting for access to a protected
14120 object does not keep its processor busy.
14122 @sp 1
14123 @item
14124 @cartouche
14125 @noindent
14126 The affect of implementation defined execution resources
14127 on task dispatching.  See D.2.1(9).
14128 @end cartouche
14129 @noindent
14130 Tasks map to threads in the threads package used by GNAT@.  Where possible
14131 and appropriate, these threads correspond to native threads of the
14132 underlying operating system.
14134 @sp 1
14135 @item
14136 @cartouche
14137 @noindent
14138 Implementation-defined @code{policy_identifiers} allowed
14139 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
14140 @end cartouche
14141 @noindent
14142 There are no implementation-defined policy-identifiers allowed in this
14143 pragma.
14145 @sp 1
14146 @item
14147 @cartouche
14148 @noindent
14149 Implementation-defined aspects of priority inversion.  See
14150 D.2.2(16).
14151 @end cartouche
14152 @noindent
14153 Execution of a task cannot be preempted by the implementation processing
14154 of delay expirations for lower priority tasks.
14156 @sp 1
14157 @item
14158 @cartouche
14159 @noindent
14160 Implementation-defined task dispatching.  See D.2.2(18).
14161 @end cartouche
14162 @noindent
14163 The policy is the same as that of the underlying threads implementation.
14165 @sp 1
14166 @item
14167 @cartouche
14168 @noindent
14169 Implementation-defined @code{policy_identifiers} allowed
14170 in a pragma @code{Locking_Policy}.  See D.3(4).
14171 @end cartouche
14172 @noindent
14173 The two implementation defined policies permitted in GNAT are
14174 @code{Inheritance_Locking} and  @code{Conccurent_Readers_Locking}.  On
14175 targets that support the @code{Inheritance_Locking} policy, locking is
14176 implemented by inheritance, i.e.@: the task owning the lock operates
14177 at a priority equal to the highest priority of any task currently
14178 requesting the lock.  On targets that support the
14179 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
14180 read/write lock allowing multiple propected object functions to enter
14181 concurrently.
14183 @sp 1
14184 @item
14185 @cartouche
14186 @noindent
14187 Default ceiling priorities.  See D.3(10).
14188 @end cartouche
14189 @noindent
14190 The ceiling priority of protected objects of the type
14191 @code{System.Interrupt_Priority'Last} as described in the Ada
14192 Reference Manual D.3(10),
14194 @sp 1
14195 @item
14196 @cartouche
14197 @noindent
14198 The ceiling of any protected object used internally by
14199 the implementation.  See D.3(16).
14200 @end cartouche
14201 @noindent
14202 The ceiling priority of internal protected objects is
14203 @code{System.Priority'Last}.
14205 @sp 1
14206 @item
14207 @cartouche
14208 @noindent
14209 Implementation-defined queuing policies.  See D.4(1).
14210 @end cartouche
14211 @noindent
14212 There are no implementation-defined queuing policies.
14214 @sp 1
14215 @item
14216 @cartouche
14217 @noindent
14218 On a multiprocessor, any conditions that cause the
14219 completion of an aborted construct to be delayed later than what is
14220 specified for a single processor.  See D.6(3).
14221 @end cartouche
14222 @noindent
14223 The semantics for abort on a multi-processor is the same as on a single
14224 processor, there are no further delays.
14226 @sp 1
14227 @item
14228 @cartouche
14229 @noindent
14230 Any operations that implicitly require heap storage
14231 allocation.  See D.7(8).
14232 @end cartouche
14233 @noindent
14234 The only operation that implicitly requires heap storage allocation is
14235 task creation.
14237 @sp 1
14238 @item
14239 @cartouche
14240 @noindent
14241 Implementation-defined aspects of pragma
14242 @code{Restrictions}.  See D.7(20).
14243 @end cartouche
14244 @noindent
14245 There are no such implementation-defined aspects.
14247 @sp 1
14248 @item
14249 @cartouche
14250 @noindent
14251 Implementation-defined aspects of package
14252 @code{Real_Time}.  See D.8(17).
14253 @end cartouche
14254 @noindent
14255 There are no implementation defined aspects of package @code{Real_Time}.
14257 @sp 1
14258 @item
14259 @cartouche
14260 @noindent
14261 Implementation-defined aspects of
14262 @code{delay_statements}.  See D.9(8).
14263 @end cartouche
14264 @noindent
14265 Any difference greater than one microsecond will cause the task to be
14266 delayed (see D.9(7)).
14268 @sp 1
14269 @item
14270 @cartouche
14271 @noindent
14272 The upper bound on the duration of interrupt blocking
14273 caused by the implementation.  See D.12(5).
14274 @end cartouche
14275 @noindent
14276 The upper bound is determined by the underlying operating system.  In
14277 no cases is it more than 10 milliseconds.
14279 @sp 1
14280 @item
14281 @cartouche
14282 @noindent
14283 The means for creating and executing distributed
14284 programs.  See E(5).
14285 @end cartouche
14286 @noindent
14287 The GLADE package provides a utility GNATDIST for creating and executing
14288 distributed programs.  See the GLADE reference manual for further details.
14290 @sp 1
14291 @item
14292 @cartouche
14293 @noindent
14294 Any events that can result in a partition becoming
14295 inaccessible.  See E.1(7).
14296 @end cartouche
14297 @noindent
14298 See the GLADE reference manual for full details on such events.
14300 @sp 1
14301 @item
14302 @cartouche
14303 @noindent
14304 The scheduling policies, treatment of priorities, and
14305 management of shared resources between partitions in certain cases.  See
14306 E.1(11).
14307 @end cartouche
14308 @noindent
14309 See the GLADE reference manual for full details on these aspects of
14310 multi-partition execution.
14312 @sp 1
14313 @item
14314 @cartouche
14315 @noindent
14316 Events that cause the version of a compilation unit to
14317 change.  See E.3(5).
14318 @end cartouche
14319 @noindent
14320 Editing the source file of a compilation unit, or the source files of
14321 any units on which it is dependent in a significant way cause the version
14322 to change.  No other actions cause the version number to change.  All changes
14323 are significant except those which affect only layout, capitalization or
14324 comments.
14326 @sp 1
14327 @item
14328 @cartouche
14329 @noindent
14330 Whether the execution of the remote subprogram is
14331 immediately aborted as a result of cancellation.  See E.4(13).
14332 @end cartouche
14333 @noindent
14334 See the GLADE reference manual for details on the effect of abort in
14335 a distributed application.
14337 @sp 1
14338 @item
14339 @cartouche
14340 @noindent
14341 Implementation-defined aspects of the PCS@.  See E.5(25).
14342 @end cartouche
14343 @noindent
14344 See the GLADE reference manual for a full description of all implementation
14345 defined aspects of the PCS@.
14347 @sp 1
14348 @item
14349 @cartouche
14350 @noindent
14351 Implementation-defined interfaces in the PCS@.  See
14352 E.5(26).
14353 @end cartouche
14354 @noindent
14355 See the GLADE reference manual for a full description of all
14356 implementation defined interfaces.
14358 @sp 1
14359 @item
14360 @cartouche
14361 @noindent
14362 The values of named numbers in the package
14363 @code{Decimal}.  See F.2(7).
14364 @end cartouche
14365 @noindent
14366 @table @code
14367 @item Max_Scale
14369 @item Min_Scale
14371 @item Min_Delta
14372 1.0E-18
14373 @item Max_Delta
14374 1.0E+18
14375 @item Max_Decimal_Digits
14377 @end table
14379 @sp 1
14380 @item
14381 @cartouche
14382 @noindent
14383 The value of @code{Max_Picture_Length} in the package
14384 @code{Text_IO.Editing}.  See F.3.3(16).
14385 @end cartouche
14386 @noindent
14389 @sp 1
14390 @item
14391 @cartouche
14392 @noindent
14393 The value of @code{Max_Picture_Length} in the package
14394 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
14395 @end cartouche
14396 @noindent
14399 @sp 1
14400 @item
14401 @cartouche
14402 @noindent
14403 The accuracy actually achieved by the complex elementary
14404 functions and by other complex arithmetic operations.  See G.1(1).
14405 @end cartouche
14406 @noindent
14407 Standard library functions are used for the complex arithmetic
14408 operations.  Only fast math mode is currently supported.
14410 @sp 1
14411 @item
14412 @cartouche
14413 @noindent
14414 The sign of a zero result (or a component thereof) from
14415 any operator or function in @code{Numerics.Generic_Complex_Types}, when
14416 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
14417 @end cartouche
14418 @noindent
14419 The signs of zero values are as recommended by the relevant
14420 implementation advice.
14422 @sp 1
14423 @item
14424 @cartouche
14425 @noindent
14426 The sign of a zero result (or a component thereof) from
14427 any operator or function in
14428 @code{Numerics.Generic_Complex_Elementary_Functions}, when
14429 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
14430 @end cartouche
14431 @noindent
14432 The signs of zero values are as recommended by the relevant
14433 implementation advice.
14435 @sp 1
14436 @item
14437 @cartouche
14438 @noindent
14439 Whether the strict mode or the relaxed mode is the
14440 default.  See G.2(2).
14441 @end cartouche
14442 @noindent
14443 The strict mode is the default.  There is no separate relaxed mode.  GNAT
14444 provides a highly efficient implementation of strict mode.
14446 @sp 1
14447 @item
14448 @cartouche
14449 @noindent
14450 The result interval in certain cases of fixed-to-float
14451 conversion.  See G.2.1(10).
14452 @end cartouche
14453 @noindent
14454 For cases where the result interval is implementation dependent, the
14455 accuracy is that provided by performing all operations in 64-bit IEEE
14456 floating-point format.
14458 @sp 1
14459 @item
14460 @cartouche
14461 @noindent
14462 The result of a floating point arithmetic operation in
14463 overflow situations, when the @code{Machine_Overflows} attribute of the
14464 result type is @code{False}.  See G.2.1(13).
14465 @end cartouche
14466 @noindent
14467 Infinite and NaN values are produced as dictated by the IEEE
14468 floating-point standard.
14470 Note that on machines that are not fully compliant with the IEEE
14471 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
14472 must be used for achieving IEEE conforming behavior (although at the cost
14473 of a significant performance penalty), so infinite and NaN values are
14474 properly generated.
14476 @sp 1
14477 @item
14478 @cartouche
14479 @noindent
14480 The result interval for division (or exponentiation by a
14481 negative exponent), when the floating point hardware implements division
14482 as multiplication by a reciprocal.  See G.2.1(16).
14483 @end cartouche
14484 @noindent
14485 Not relevant, division is IEEE exact.
14487 @sp 1
14488 @item
14489 @cartouche
14490 @noindent
14491 The definition of close result set, which determines the
14492 accuracy of certain fixed point multiplications and divisions.  See
14493 G.2.3(5).
14494 @end cartouche
14495 @noindent
14496 Operations in the close result set are performed using IEEE long format
14497 floating-point arithmetic.  The input operands are converted to
14498 floating-point, the operation is done in floating-point, and the result
14499 is converted to the target type.
14501 @sp 1
14502 @item
14503 @cartouche
14504 @noindent
14505 Conditions on a @code{universal_real} operand of a fixed
14506 point multiplication or division for which the result shall be in the
14507 perfect result set.  See G.2.3(22).
14508 @end cartouche
14509 @noindent
14510 The result is only defined to be in the perfect result set if the result
14511 can be computed by a single scaling operation involving a scale factor
14512 representable in 64-bits.
14514 @sp 1
14515 @item
14516 @cartouche
14517 @noindent
14518 The result of a fixed point arithmetic operation in
14519 overflow situations, when the @code{Machine_Overflows} attribute of the
14520 result type is @code{False}.  See G.2.3(27).
14521 @end cartouche
14522 @noindent
14523 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
14524 types.
14526 @sp 1
14527 @item
14528 @cartouche
14529 @noindent
14530 The result of an elementary function reference in
14531 overflow situations, when the @code{Machine_Overflows} attribute of the
14532 result type is @code{False}.  See G.2.4(4).
14533 @end cartouche
14534 @noindent
14535 IEEE infinite and Nan values are produced as appropriate.
14537 @sp 1
14538 @item
14539 @cartouche
14540 @noindent
14541 The value of the angle threshold, within which certain
14542 elementary functions, complex arithmetic operations, and complex
14543 elementary functions yield results conforming to a maximum relative
14544 error bound.  See G.2.4(10).
14545 @end cartouche
14546 @noindent
14547 Information on this subject is not yet available.
14549 @sp 1
14550 @item
14551 @cartouche
14552 @noindent
14553 The accuracy of certain elementary functions for
14554 parameters beyond the angle threshold.  See G.2.4(10).
14555 @end cartouche
14556 @noindent
14557 Information on this subject is not yet available.
14559 @sp 1
14560 @item
14561 @cartouche
14562 @noindent
14563 The result of a complex arithmetic operation or complex
14564 elementary function reference in overflow situations, when the
14565 @code{Machine_Overflows} attribute of the corresponding real type is
14566 @code{False}.  See G.2.6(5).
14567 @end cartouche
14568 @noindent
14569 IEEE infinite and Nan values are produced as appropriate.
14571 @sp 1
14572 @item
14573 @cartouche
14574 @noindent
14575 The accuracy of certain complex arithmetic operations and
14576 certain complex elementary functions for parameters (or components
14577 thereof) beyond the angle threshold.  See G.2.6(8).
14578 @end cartouche
14579 @noindent
14580 Information on those subjects is not yet available.
14582 @sp 1
14583 @item
14584 @cartouche
14585 @noindent
14586 Information regarding bounded errors and erroneous
14587 execution.  See H.2(1).
14588 @end cartouche
14589 @noindent
14590 Information on this subject is not yet available.
14592 @sp 1
14593 @item
14594 @cartouche
14595 @noindent
14596 Implementation-defined aspects of pragma
14597 @code{Inspection_Point}.  See H.3.2(8).
14598 @end cartouche
14599 @noindent
14600 Pragma @code{Inspection_Point} ensures that the variable is live and can
14601 be examined by the debugger at the inspection point.
14603 @sp 1
14604 @item
14605 @cartouche
14606 @noindent
14607 Implementation-defined aspects of pragma
14608 @code{Restrictions}.  See H.4(25).
14609 @end cartouche
14610 @noindent
14611 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
14612 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
14613 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
14615 @sp 1
14616 @item
14617 @cartouche
14618 @noindent
14619 Any restrictions on pragma @code{Restrictions}.  See
14620 H.4(27).
14621 @end cartouche
14622 @noindent
14623 There are no restrictions on pragma @code{Restrictions}.
14625 @end itemize
14628 @c =======================
14629 @node Intrinsic Subprograms
14630 @chapter Intrinsic Subprograms
14631 @cindex Intrinsic Subprograms
14633 @menu
14634 * Intrinsic Operators::
14635 * Compilation_Date::
14636 * Compilation_Time::
14637 * Enclosing_Entity::
14638 * Exception_Information::
14639 * Exception_Message::
14640 * Exception_Name::
14641 * File::
14642 * Line::
14643 * Shifts and Rotates::
14644 * Source_Location::
14645 @end menu
14647 @noindent
14648 GNAT allows a user application program to write the declaration:
14650 @smallexample @c ada
14651    pragma Import (Intrinsic, name);
14652 @end smallexample
14654 @noindent
14655 providing that the name corresponds to one of the implemented intrinsic
14656 subprograms in GNAT, and that the parameter profile of the referenced
14657 subprogram meets the requirements.  This chapter describes the set of
14658 implemented intrinsic subprograms, and the requirements on parameter profiles.
14659 Note that no body is supplied; as with other uses of pragma Import, the
14660 body is supplied elsewhere (in this case by the compiler itself).  Note
14661 that any use of this feature is potentially non-portable, since the
14662 Ada standard does not require Ada compilers to implement this feature.
14664 @node Intrinsic Operators
14665 @section Intrinsic Operators
14666 @cindex Intrinsic operator
14668 @noindent
14669 All the predefined numeric operators in package Standard
14670 in @code{pragma Import (Intrinsic,..)}
14671 declarations.  In the binary operator case, the operands must have the same
14672 size.  The operand or operands must also be appropriate for
14673 the operator.  For example, for addition, the operands must
14674 both be floating-point or both be fixed-point, and the
14675 right operand for @code{"**"} must have a root type of
14676 @code{Standard.Integer'Base}.
14677 You can use an intrinsic operator declaration as in the following example:
14679 @smallexample @c ada
14680    type Int1 is new Integer;
14681    type Int2 is new Integer;
14683    function "+" (X1 : Int1; X2 : Int2) return Int1;
14684    function "+" (X1 : Int1; X2 : Int2) return Int2;
14685    pragma Import (Intrinsic, "+");
14686 @end smallexample
14688 @noindent
14689 This declaration would permit ``mixed mode'' arithmetic on items
14690 of the differing types @code{Int1} and @code{Int2}.
14691 It is also possible to specify such operators for private types, if the
14692 full views are appropriate arithmetic types.
14694 @node Compilation_Date
14695 @section Compilation_Date
14696 @cindex Compilation_Date
14697 @noindent
14698 This intrinsic subprogram is used in the implementation of the
14699 library package @code{GNAT.Source_Info}.  The only useful use of the
14700 intrinsic import in this case is the one in this unit, so an
14701 application program should simply call the function
14702 @code{GNAT.Source_Info.Compilation_Date} to obtain the date of
14703 the current compilation (in local time format MMM DD YYYY).
14705 @node Compilation_Time
14706 @section Compilation_Time
14707 @cindex Compilation_Time
14708 @noindent
14709 This intrinsic subprogram is used in the implementation of the
14710 library package @code{GNAT.Source_Info}.  The only useful use of the
14711 intrinsic import in this case is the one in this unit, so an
14712 application program should simply call the function
14713 @code{GNAT.Source_Info.Compilation_Time} to obtain the time of
14714 the current compilation (in local time format HH:MM:SS).
14716 @node Enclosing_Entity
14717 @section Enclosing_Entity
14718 @cindex Enclosing_Entity
14719 @noindent
14720 This intrinsic subprogram is used in the implementation of the
14721 library package @code{GNAT.Source_Info}.  The only useful use of the
14722 intrinsic import in this case is the one in this unit, so an
14723 application program should simply call the function
14724 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
14725 the current subprogram, package, task, entry, or protected subprogram.
14727 @node Exception_Information
14728 @section Exception_Information
14729 @cindex Exception_Information'
14730 @noindent
14731 This intrinsic subprogram is used in the implementation of the
14732 library package @code{GNAT.Current_Exception}.  The only useful
14733 use of the intrinsic import in this case is the one in this unit,
14734 so an application program should simply call the function
14735 @code{GNAT.Current_Exception.Exception_Information} to obtain
14736 the exception information associated with the current exception.
14738 @node Exception_Message
14739 @section Exception_Message
14740 @cindex Exception_Message
14741 @noindent
14742 This intrinsic subprogram is used in the implementation of the
14743 library package @code{GNAT.Current_Exception}.  The only useful
14744 use of the intrinsic import in this case is the one in this unit,
14745 so an application program should simply call the function
14746 @code{GNAT.Current_Exception.Exception_Message} to obtain
14747 the message associated with the current exception.
14749 @node Exception_Name
14750 @section Exception_Name
14751 @cindex Exception_Name
14752 @noindent
14753 This intrinsic subprogram is used in the implementation of the
14754 library package @code{GNAT.Current_Exception}.  The only useful
14755 use of the intrinsic import in this case is the one in this unit,
14756 so an application program should simply call the function
14757 @code{GNAT.Current_Exception.Exception_Name} to obtain
14758 the name of the current exception.
14760 @node File
14761 @section File
14762 @cindex File
14763 @noindent
14764 This intrinsic subprogram is used in the implementation of the
14765 library package @code{GNAT.Source_Info}.  The only useful use of the
14766 intrinsic import in this case is the one in this unit, so an
14767 application program should simply call the function
14768 @code{GNAT.Source_Info.File} to obtain the name of the current
14769 file.
14771 @node Line
14772 @section Line
14773 @cindex Line
14774 @noindent
14775 This intrinsic subprogram is used in the implementation of the
14776 library package @code{GNAT.Source_Info}.  The only useful use of the
14777 intrinsic import in this case is the one in this unit, so an
14778 application program should simply call the function
14779 @code{GNAT.Source_Info.Line} to obtain the number of the current
14780 source line.
14782 @node Shifts and Rotates
14783 @section Shifts and Rotates
14784 @cindex Shift_Left
14785 @cindex Shift_Right
14786 @cindex Shift_Right_Arithmetic
14787 @cindex Rotate_Left
14788 @cindex Rotate_Right
14789 @noindent
14790 In standard Ada, the shift and rotate functions are available only
14791 for the predefined modular types in package @code{Interfaces}.  However, in
14792 GNAT it is possible to define these functions for any integer
14793 type (signed or modular), as in this example:
14795 @smallexample @c ada
14796    function Shift_Left
14797      (Value  : T;
14798       Amount : Natural) return T;
14799 @end smallexample
14801 @noindent
14802 The function name must be one of
14803 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
14804 Rotate_Right. T must be an integer type. T'Size must be
14805 8, 16, 32 or 64 bits; if T is modular, the modulus
14806 must be 2**8, 2**16, 2**32 or 2**64.
14807 The result type must be the same as the type of @code{Value}.
14808 The shift amount must be Natural.
14809 The formal parameter names can be anything.
14811 A more convenient way of providing these shift operators is to use
14812 the Provide_Shift_Operators pragma, which provides the function declarations
14813 and corresponding pragma Import's for all five shift functions.
14815 @node Source_Location
14816 @section Source_Location
14817 @cindex Source_Location
14818 @noindent
14819 This intrinsic subprogram is used in the implementation of the
14820 library routine @code{GNAT.Source_Info}.  The only useful use of the
14821 intrinsic import in this case is the one in this unit, so an
14822 application program should simply call the function
14823 @code{GNAT.Source_Info.Source_Location} to obtain the current
14824 source file location.
14826 @node Representation Clauses and Pragmas
14827 @chapter Representation Clauses and Pragmas
14828 @cindex Representation Clauses
14830 @menu
14831 * Alignment Clauses::
14832 * Size Clauses::
14833 * Storage_Size Clauses::
14834 * Size of Variant Record Objects::
14835 * Biased Representation ::
14836 * Value_Size and Object_Size Clauses::
14837 * Component_Size Clauses::
14838 * Bit_Order Clauses::
14839 * Effect of Bit_Order on Byte Ordering::
14840 * Pragma Pack for Arrays::
14841 * Pragma Pack for Records::
14842 * Record Representation Clauses::
14843 * Handling of Records with Holes::
14844 * Enumeration Clauses::
14845 * Address Clauses::
14846 * Use of Address Clauses for Memory-Mapped I/O::
14847 * Effect of Convention on Representation::
14848 * Conventions and Anonymous Access Types::
14849 * Determining the Representations chosen by GNAT::
14850 @end menu
14852 @noindent
14853 @cindex Representation Clause
14854 @cindex Representation Pragma
14855 @cindex Pragma, representation
14856 This section describes the representation clauses accepted by GNAT, and
14857 their effect on the representation of corresponding data objects.
14859 GNAT fully implements Annex C (Systems Programming).  This means that all
14860 the implementation advice sections in chapter 13 are fully implemented.
14861 However, these sections only require a minimal level of support for
14862 representation clauses.  GNAT provides much more extensive capabilities,
14863 and this section describes the additional capabilities provided.
14865 @node Alignment Clauses
14866 @section Alignment Clauses
14867 @cindex Alignment Clause
14869 @noindent
14870 GNAT requires that all alignment clauses specify a power of 2, and all
14871 default alignments are always a power of 2.  The default alignment
14872 values are as follows:
14874 @itemize @bullet
14875 @item @emph{Primitive Types}.
14876 For primitive types, the alignment is the minimum of the actual size of
14877 objects of the type divided by @code{Storage_Unit},
14878 and the maximum alignment supported by the target.
14879 (This maximum alignment is given by the GNAT-specific attribute
14880 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
14881 @cindex @code{Maximum_Alignment} attribute
14882 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
14883 default alignment will be 8 on any target that supports alignments
14884 this large, but on some targets, the maximum alignment may be smaller
14885 than 8, in which case objects of type @code{Long_Float} will be maximally
14886 aligned.
14888 @item @emph{Arrays}.
14889 For arrays, the alignment is equal to the alignment of the component type
14890 for the normal case where no packing or component size is given.  If the
14891 array is packed, and the packing is effective (see separate section on
14892 packed arrays), then the alignment will be one for long packed arrays,
14893 or arrays whose length is not known at compile time.  For short packed
14894 arrays, which are handled internally as modular types, the alignment
14895 will be as described for primitive types, e.g.@: a packed array of length
14896 31 bits will have an object size of four bytes, and an alignment of 4.
14898 @item @emph{Records}.
14899 For the normal non-packed case, the alignment of a record is equal to
14900 the maximum alignment of any of its components.  For tagged records, this
14901 includes the implicit access type used for the tag.  If a pragma @code{Pack}
14902 is used and all components are packable (see separate section on pragma
14903 @code{Pack}), then the resulting alignment is 1, unless the layout of the
14904 record makes it profitable to increase it.
14906 A special case is when:
14907 @itemize @bullet
14908 @item
14909 the size of the record is given explicitly, or a
14910 full record representation clause is given, and
14911 @item
14912 the size of the record is 2, 4, or 8 bytes.
14913 @end itemize
14914 @noindent
14915 In this case, an alignment is chosen to match the
14916 size of the record. For example, if we have:
14918 @smallexample @c ada
14919    type Small is record
14920       A, B : Character;
14921    end record;
14922    for Small'Size use 16;
14923 @end smallexample
14925 @noindent
14926 then the default alignment of the record type @code{Small} is 2, not 1. This
14927 leads to more efficient code when the record is treated as a unit, and also
14928 allows the type to specified as @code{Atomic} on architectures requiring
14929 strict alignment.
14931 @end itemize
14933 @noindent
14934 An alignment clause may specify a larger alignment than the default value
14935 up to some maximum value dependent on the target (obtainable by using the
14936 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
14937 a smaller alignment than the default value for enumeration, integer and
14938 fixed point types, as well as for record types, for example
14940 @smallexample @c ada
14941   type V is record
14942      A : Integer;
14943   end record;
14945   for V'alignment use 1;
14946 @end smallexample
14948 @noindent
14949 @cindex Alignment, default
14950 The default alignment for the type @code{V} is 4, as a result of the
14951 Integer field in the record, but it is permissible, as shown, to
14952 override the default alignment of the record with a smaller value.
14954 @cindex Alignment, subtypes
14955 Note that according to the Ada standard, an alignment clause applies only
14956 to the first named subtype. If additional subtypes are declared, then the
14957 compiler is allowed to choose any alignment it likes, and there is no way
14958 to control this choice. Consider:
14960 @smallexample @c ada
14961    type R is range 1 .. 10_000;
14962    for R'Alignment use 1;
14963    subtype RS is R range 1 .. 1000;
14964 @end smallexample
14966 @noindent
14967 The alignment clause specifies an alignment of 1 for the first named subtype
14968 @code{R} but this does not necessarily apply to @code{RS}. When writing
14969 portable Ada code, you should avoid writing code that explicitly or
14970 implicitly relies on the alignment of such subtypes.
14972 For the GNAT compiler, if an explicit alignment clause is given, this
14973 value is also used for any subsequent subtypes. So for GNAT, in the
14974 above example, you can count on the alignment of @code{RS} being 1. But this
14975 assumption is non-portable, and other compilers may choose different
14976 alignments for the subtype @code{RS}.
14978 @node Size Clauses
14979 @section Size Clauses
14980 @cindex Size Clause
14982 @noindent
14983 The default size for a type @code{T} is obtainable through the
14984 language-defined attribute @code{T'Size} and also through the
14985 equivalent GNAT-defined attribute @code{T'Value_Size}.
14986 For objects of type @code{T}, GNAT will generally increase the type size
14987 so that the object size (obtainable through the GNAT-defined attribute
14988 @code{T'Object_Size})
14989 is a multiple of @code{T'Alignment * Storage_Unit}.
14990 For example
14992 @smallexample @c ada
14993    type Smallint is range 1 .. 6;
14995    type Rec is record
14996       Y1 : integer;
14997       Y2 : boolean;
14998    end record;
14999 @end smallexample
15001 @noindent
15002 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
15003 as specified by the RM rules,
15004 but objects of this type will have a size of 8
15005 (@code{Smallint'Object_Size} = 8),
15006 since objects by default occupy an integral number
15007 of storage units.  On some targets, notably older
15008 versions of the Digital Alpha, the size of stand
15009 alone objects of this type may be 32, reflecting
15010 the inability of the hardware to do byte load/stores.
15012 Similarly, the size of type @code{Rec} is 40 bits
15013 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
15014 the alignment is 4, so objects of this type will have
15015 their size increased to 64 bits so that it is a multiple
15016 of the alignment (in bits).  This decision is
15017 in accordance with the specific Implementation Advice in RM 13.3(43):
15019 @quotation
15020 A @code{Size} clause should be supported for an object if the specified
15021 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
15022 to a size in storage elements that is a multiple of the object's
15023 @code{Alignment} (if the @code{Alignment} is nonzero).
15024 @end quotation
15026 @noindent
15027 An explicit size clause may be used to override the default size by
15028 increasing it.  For example, if we have:
15030 @smallexample @c ada
15031    type My_Boolean is new Boolean;
15032    for My_Boolean'Size use 32;
15033 @end smallexample
15035 @noindent
15036 then values of this type will always be 32 bits long.  In the case of
15037 discrete types, the size can be increased up to 64 bits, with the effect
15038 that the entire specified field is used to hold the value, sign- or
15039 zero-extended as appropriate.  If more than 64 bits is specified, then
15040 padding space is allocated after the value, and a warning is issued that
15041 there are unused bits.
15043 Similarly the size of records and arrays may be increased, and the effect
15044 is to add padding bits after the value.  This also causes a warning message
15045 to be generated.
15047 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
15048 Size in bits, this corresponds to an object of size 256 megabytes (minus
15049 one).  This limitation is true on all targets.  The reason for this
15050 limitation is that it improves the quality of the code in many cases
15051 if it is known that a Size value can be accommodated in an object of
15052 type Integer.
15054 @node Storage_Size Clauses
15055 @section Storage_Size Clauses
15056 @cindex Storage_Size Clause
15058 @noindent
15059 For tasks, the @code{Storage_Size} clause specifies the amount of space
15060 to be allocated for the task stack.  This cannot be extended, and if the
15061 stack is exhausted, then @code{Storage_Error} will be raised (if stack
15062 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
15063 or a @code{Storage_Size} pragma in the task definition to set the
15064 appropriate required size.  A useful technique is to include in every
15065 task definition a pragma of the form:
15067 @smallexample @c ada
15068    pragma Storage_Size (Default_Stack_Size);
15069 @end smallexample
15071 @noindent
15072 Then @code{Default_Stack_Size} can be defined in a global package, and
15073 modified as required. Any tasks requiring stack sizes different from the
15074 default can have an appropriate alternative reference in the pragma.
15076 You can also use the @option{-d} binder switch to modify the default stack
15077 size.
15079 For access types, the @code{Storage_Size} clause specifies the maximum
15080 space available for allocation of objects of the type.  If this space is
15081 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
15082 In the case where the access type is declared local to a subprogram, the
15083 use of a @code{Storage_Size} clause triggers automatic use of a special
15084 predefined storage pool (@code{System.Pool_Size}) that ensures that all
15085 space for the pool is automatically reclaimed on exit from the scope in
15086 which the type is declared.
15088 A special case recognized by the compiler is the specification of a
15089 @code{Storage_Size} of zero for an access type.  This means that no
15090 items can be allocated from the pool, and this is recognized at compile
15091 time, and all the overhead normally associated with maintaining a fixed
15092 size storage pool is eliminated.  Consider the following example:
15094 @smallexample @c ada
15095    procedure p is
15096       type R is array (Natural) of Character;
15097       type P is access all R;
15098       for P'Storage_Size use 0;
15099       --  Above access type intended only for interfacing purposes
15101       y : P;
15103       procedure g (m : P);
15104       pragma Import (C, g);
15106       --  @dots{}
15108    begin
15109       --  @dots{}
15110       y := new R;
15111    end;
15112 @end smallexample
15114 @noindent
15115 As indicated in this example, these dummy storage pools are often useful in
15116 connection with interfacing where no object will ever be allocated.  If you
15117 compile the above example, you get the warning:
15119 @smallexample
15120    p.adb:16:09: warning: allocation from empty storage pool
15121    p.adb:16:09: warning: Storage_Error will be raised at run time
15122 @end smallexample
15124 @noindent
15125 Of course in practice, there will not be any explicit allocators in the
15126 case of such an access declaration.
15128 @node Size of Variant Record Objects
15129 @section Size of Variant Record Objects
15130 @cindex Size, variant record objects
15131 @cindex Variant record objects, size
15133 @noindent
15134 In the case of variant record objects, there is a question whether Size gives
15135 information about a particular variant, or the maximum size required
15136 for any variant.  Consider the following program
15138 @smallexample @c ada
15139 with Text_IO; use Text_IO;
15140 procedure q is
15141    type R1 (A : Boolean := False) is record
15142      case A is
15143        when True  => X : Character;
15144        when False => null;
15145      end case;
15146    end record;
15148    V1 : R1 (False);
15149    V2 : R1;
15151 begin
15152    Put_Line (Integer'Image (V1'Size));
15153    Put_Line (Integer'Image (V2'Size));
15154 end q;
15155 @end smallexample
15157 @noindent
15158 Here we are dealing with a variant record, where the True variant
15159 requires 16 bits, and the False variant requires 8 bits.
15160 In the above example, both V1 and V2 contain the False variant,
15161 which is only 8 bits long.  However, the result of running the
15162 program is:
15164 @smallexample
15167 @end smallexample
15169 @noindent
15170 The reason for the difference here is that the discriminant value of
15171 V1 is fixed, and will always be False.  It is not possible to assign
15172 a True variant value to V1, therefore 8 bits is sufficient.  On the
15173 other hand, in the case of V2, the initial discriminant value is
15174 False (from the default), but it is possible to assign a True
15175 variant value to V2, therefore 16 bits must be allocated for V2
15176 in the general case, even fewer bits may be needed at any particular
15177 point during the program execution.
15179 As can be seen from the output of this program, the @code{'Size}
15180 attribute applied to such an object in GNAT gives the actual allocated
15181 size of the variable, which is the largest size of any of the variants.
15182 The Ada Reference Manual is not completely clear on what choice should
15183 be made here, but the GNAT behavior seems most consistent with the
15184 language in the RM@.
15186 In some cases, it may be desirable to obtain the size of the current
15187 variant, rather than the size of the largest variant.  This can be
15188 achieved in GNAT by making use of the fact that in the case of a
15189 subprogram parameter, GNAT does indeed return the size of the current
15190 variant (because a subprogram has no way of knowing how much space
15191 is actually allocated for the actual).
15193 Consider the following modified version of the above program:
15195 @smallexample @c ada
15196 with Text_IO; use Text_IO;
15197 procedure q is
15198    type R1 (A : Boolean := False) is record
15199      case A is
15200        when True  => X : Character;
15201        when False => null;
15202      end case;
15203    end record;
15205    V2 : R1;
15207    function Size (V : R1) return Integer is
15208    begin
15209       return V'Size;
15210    end Size;
15212 begin
15213    Put_Line (Integer'Image (V2'Size));
15214    Put_Line (Integer'IMage (Size (V2)));
15215    V2 := (True, 'x');
15216    Put_Line (Integer'Image (V2'Size));
15217    Put_Line (Integer'IMage (Size (V2)));
15218 end q;
15219 @end smallexample
15221 @noindent
15222 The output from this program is
15224 @smallexample
15229 @end smallexample
15231 @noindent
15232 Here we see that while the @code{'Size} attribute always returns
15233 the maximum size, regardless of the current variant value, the
15234 @code{Size} function does indeed return the size of the current
15235 variant value.
15237 @node Biased Representation
15238 @section Biased Representation
15239 @cindex Size for biased representation
15240 @cindex Biased representation
15242 @noindent
15243 In the case of scalars with a range starting at other than zero, it is
15244 possible in some cases to specify a size smaller than the default minimum
15245 value, and in such cases, GNAT uses an unsigned biased representation,
15246 in which zero is used to represent the lower bound, and successive values
15247 represent successive values of the type.
15249 For example, suppose we have the declaration:
15251 @smallexample @c ada
15252    type Small is range -7 .. -4;
15253    for Small'Size use 2;
15254 @end smallexample
15256 @noindent
15257 Although the default size of type @code{Small} is 4, the @code{Size}
15258 clause is accepted by GNAT and results in the following representation
15259 scheme:
15261 @smallexample
15262   -7 is represented as 2#00#
15263   -6 is represented as 2#01#
15264   -5 is represented as 2#10#
15265   -4 is represented as 2#11#
15266 @end smallexample
15268 @noindent
15269 Biased representation is only used if the specified @code{Size} clause
15270 cannot be accepted in any other manner.  These reduced sizes that force
15271 biased representation can be used for all discrete types except for
15272 enumeration types for which a representation clause is given.
15274 @node Value_Size and Object_Size Clauses
15275 @section Value_Size and Object_Size Clauses
15276 @findex Value_Size
15277 @findex Object_Size
15278 @cindex Size, of objects
15280 @noindent
15281 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
15282 number of bits required to hold values of type @code{T}.
15283 Although this interpretation was allowed in Ada 83, it was not required,
15284 and this requirement in practice can cause some significant difficulties.
15285 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
15286 However, in Ada 95 and Ada 2005,
15287 @code{Natural'Size} is
15288 typically 31.  This means that code may change in behavior when moving
15289 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
15291 @smallexample @c ada
15292    type Rec is record;
15293       A : Natural;
15294       B : Natural;
15295    end record;
15297    for Rec use record
15298       at 0  range 0 .. Natural'Size - 1;
15299       at 0  range Natural'Size .. 2 * Natural'Size - 1;
15300    end record;
15301 @end smallexample
15303 @noindent
15304 In the above code, since the typical size of @code{Natural} objects
15305 is 32 bits and @code{Natural'Size} is 31, the above code can cause
15306 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
15307 there are cases where the fact that the object size can exceed the
15308 size of the type causes surprises.
15310 To help get around this problem GNAT provides two implementation
15311 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
15312 applied to a type, these attributes yield the size of the type
15313 (corresponding to the RM defined size attribute), and the size of
15314 objects of the type respectively.
15316 The @code{Object_Size} is used for determining the default size of
15317 objects and components.  This size value can be referred to using the
15318 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
15319 the basis of the determination of the size.  The backend is free to
15320 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
15321 character might be stored in 32 bits on a machine with no efficient
15322 byte access instructions such as the Alpha.
15324 The default rules for the value of @code{Object_Size} for
15325 discrete types are as follows:
15327 @itemize @bullet
15328 @item
15329 The @code{Object_Size} for base subtypes reflect the natural hardware
15330 size in bits (run the compiler with @option{-gnatS} to find those values
15331 for numeric types). Enumeration types and fixed-point base subtypes have
15332 8, 16, 32 or 64 bits for this size, depending on the range of values
15333 to be stored.
15335 @item
15336 The @code{Object_Size} of a subtype is the same as the
15337 @code{Object_Size} of
15338 the type from which it is obtained.
15340 @item
15341 The @code{Object_Size} of a derived base type is copied from the parent
15342 base type, and the @code{Object_Size} of a derived first subtype is copied
15343 from the parent first subtype.
15344 @end itemize
15346 @noindent
15347 The @code{Value_Size} attribute
15348 is the (minimum) number of bits required to store a value
15349 of the type.
15350 This value is used to determine how tightly to pack
15351 records or arrays with components of this type, and also affects
15352 the semantics of unchecked conversion (unchecked conversions where
15353 the @code{Value_Size} values differ generate a warning, and are potentially
15354 target dependent).
15356 The default rules for the value of @code{Value_Size} are as follows:
15358 @itemize @bullet
15359 @item
15360 The @code{Value_Size} for a base subtype is the minimum number of bits
15361 required to store all values of the type (including the sign bit
15362 only if negative values are possible).
15364 @item
15365 If a subtype statically matches the first subtype of a given type, then it has
15366 by default the same @code{Value_Size} as the first subtype.  This is a
15367 consequence of RM 13.1(14) (``if two subtypes statically match,
15368 then their subtype-specific aspects are the same''.)
15370 @item
15371 All other subtypes have a @code{Value_Size} corresponding to the minimum
15372 number of bits required to store all values of the subtype.  For
15373 dynamic bounds, it is assumed that the value can range down or up
15374 to the corresponding bound of the ancestor
15375 @end itemize
15377 @noindent
15378 The RM defined attribute @code{Size} corresponds to the
15379 @code{Value_Size} attribute.
15381 The @code{Size} attribute may be defined for a first-named subtype.  This sets
15382 the @code{Value_Size} of
15383 the first-named subtype to the given value, and the
15384 @code{Object_Size} of this first-named subtype to the given value padded up
15385 to an appropriate boundary.  It is a consequence of the default rules
15386 above that this @code{Object_Size} will apply to all further subtypes.  On the
15387 other hand, @code{Value_Size} is affected only for the first subtype, any
15388 dynamic subtypes obtained from it directly, and any statically matching
15389 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
15391 @code{Value_Size} and
15392 @code{Object_Size} may be explicitly set for any subtype using
15393 an attribute definition clause.  Note that the use of these attributes
15394 can cause the RM 13.1(14) rule to be violated.  If two access types
15395 reference aliased objects whose subtypes have differing @code{Object_Size}
15396 values as a result of explicit attribute definition clauses, then it
15397 is illegal to convert from one access subtype to the other. For a more
15398 complete description of this additional legality rule, see the
15399 description of the @code{Object_Size} attribute.
15401 At the implementation level, Esize stores the Object_Size and the
15402 RM_Size field stores the @code{Value_Size} (and hence the value of the
15403 @code{Size} attribute,
15404 which, as noted above, is equivalent to @code{Value_Size}).
15406 To get a feel for the difference, consider the following examples (note
15407 that in each case the base is @code{Short_Short_Integer} with a size of 8):
15409 @smallexample
15410                                        Object_Size     Value_Size
15412 type x1 is range 0 .. 5;                    8               3
15414 type x2 is range 0 .. 5;
15415 for x2'size use 12;                        16              12
15417 subtype x3 is x2 range 0 .. 3;             16               2
15419 subtype x4 is x2'base range 0 .. 10;        8               4
15421 subtype x5 is x2 range 0 .. dynamic;       16               3*
15423 subtype x6 is x2'base range 0 .. dynamic;   8               3*
15425 @end smallexample
15427 @noindent
15428 Note: the entries marked ``3*'' are not actually specified by the Ada
15429 Reference Manual, but it seems in the spirit of the RM rules to allocate
15430 the minimum number of bits (here 3, given the range for @code{x2})
15431 known to be large enough to hold the given range of values.
15433 So far, so good, but GNAT has to obey the RM rules, so the question is
15434 under what conditions must the RM @code{Size} be used.
15435 The following is a list
15436 of the occasions on which the RM @code{Size} must be used:
15438 @itemize @bullet
15439 @item
15440 Component size for packed arrays or records
15442 @item
15443 Value of the attribute @code{Size} for a type
15445 @item
15446 Warning about sizes not matching for unchecked conversion
15447 @end itemize
15449 @noindent
15450 For record types, the @code{Object_Size} is always a multiple of the
15451 alignment of the type (this is true for all types). In some cases the
15452 @code{Value_Size} can be smaller. Consider:
15454 @smallexample
15455    type R is record
15456      X : Integer;
15457      Y : Character;
15458    end record;
15459 @end smallexample
15461 @noindent
15462 On a typical 32-bit architecture, the X component will be four bytes, and
15463 require four-byte alignment, and the Y component will be one byte. In this
15464 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
15465 required to store a value of this type, and for example, it is permissible
15466 to have a component of type R in an outer array whose component size is
15467 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
15468 since it must be rounded up so that this value is a multiple of the
15469 alignment (4 bytes = 32 bits).
15471 @noindent
15472 For all other types, the @code{Object_Size}
15473 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
15474 Only @code{Size} may be specified for such types.
15476 Note that @code{Value_Size} can be used to force biased representation
15477 for a particular subtype. Consider this example:
15479 @smallexample
15480    type R is (A, B, C, D, E, F);
15481    subtype RAB is R range A .. B;
15482    subtype REF is R range E .. F;
15483 @end smallexample
15485 @noindent
15486 By default, @code{RAB}
15487 has a size of 1 (sufficient to accommodate the representation
15488 of @code{A} and @code{B}, 0 and 1), and @code{REF}
15489 has a size of 3 (sufficient to accommodate the representation
15490 of @code{E} and @code{F}, 4 and 5). But if we add the
15491 following @code{Value_Size} attribute definition clause:
15493 @smallexample
15494    for REF'Value_Size use 1;
15495 @end smallexample
15497 @noindent
15498 then biased representation is forced for @code{REF},
15499 and 0 will represent @code{E} and 1 will represent @code{F}.
15500 A warning is issued when a @code{Value_Size} attribute
15501 definition clause forces biased representation. This
15502 warning can be turned off using @code{-gnatw.B}.
15504 @node Component_Size Clauses
15505 @section Component_Size Clauses
15506 @cindex Component_Size Clause
15508 @noindent
15509 Normally, the value specified in a component size clause must be consistent
15510 with the subtype of the array component with regard to size and alignment.
15511 In other words, the value specified must be at least equal to the size
15512 of this subtype, and must be a multiple of the alignment value.
15514 In addition, component size clauses are allowed which cause the array
15515 to be packed, by specifying a smaller value.  A first case is for
15516 component size values in the range 1 through 63.  The value specified
15517 must not be smaller than the Size of the subtype.  GNAT will accurately
15518 honor all packing requests in this range.  For example, if we have:
15520 @smallexample @c ada
15521 type r is array (1 .. 8) of Natural;
15522 for r'Component_Size use 31;
15523 @end smallexample
15525 @noindent
15526 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
15527 Of course access to the components of such an array is considerably
15528 less efficient than if the natural component size of 32 is used.
15529 A second case is when the subtype of the component is a record type
15530 padded because of its default alignment.  For example, if we have:
15532 @smallexample @c ada
15533 type r is record
15534   i : Integer;
15535   j : Integer;
15536   b : Boolean;
15537 end record;
15539 type a is array (1 .. 8) of r;
15540 for a'Component_Size use 72;
15541 @end smallexample
15543 @noindent
15544 then the resulting array has a length of 72 bytes, instead of 96 bytes
15545 if the alignment of the record (4) was obeyed.
15547 Note that there is no point in giving both a component size clause
15548 and a pragma Pack for the same array type. if such duplicate
15549 clauses are given, the pragma Pack will be ignored.
15551 @node Bit_Order Clauses
15552 @section Bit_Order Clauses
15553 @cindex Bit_Order Clause
15554 @cindex bit ordering
15555 @cindex ordering, of bits
15557 @noindent
15558 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
15559 attribute.  The specification may either correspond to the default bit
15560 order for the target, in which case the specification has no effect and
15561 places no additional restrictions, or it may be for the non-standard
15562 setting (that is the opposite of the default).
15564 In the case where the non-standard value is specified, the effect is
15565 to renumber bits within each byte, but the ordering of bytes is not
15566 affected.  There are certain
15567 restrictions placed on component clauses as follows:
15569 @itemize @bullet
15571 @item Components fitting within a single storage unit.
15572 @noindent
15573 These are unrestricted, and the effect is merely to renumber bits.  For
15574 example if we are on a little-endian machine with @code{Low_Order_First}
15575 being the default, then the following two declarations have exactly
15576 the same effect:
15578 @smallexample @c ada
15579    type R1 is record
15580       A : Boolean;
15581       B : Integer range 1 .. 120;
15582    end record;
15584    for R1 use record
15585       A at 0 range 0 .. 0;
15586       B at 0 range 1 .. 7;
15587    end record;
15589    type R2 is record
15590       A : Boolean;
15591       B : Integer range 1 .. 120;
15592    end record;
15594    for R2'Bit_Order use High_Order_First;
15596    for R2 use record
15597       A at 0 range 7 .. 7;
15598       B at 0 range 0 .. 6;
15599    end record;
15600 @end smallexample
15602 @noindent
15603 The useful application here is to write the second declaration with the
15604 @code{Bit_Order} attribute definition clause, and know that it will be treated
15605 the same, regardless of whether the target is little-endian or big-endian.
15607 @item Components occupying an integral number of bytes.
15608 @noindent
15609 These are components that exactly fit in two or more bytes.  Such component
15610 declarations are allowed, but have no effect, since it is important to realize
15611 that the @code{Bit_Order} specification does not affect the ordering of bytes.
15612 In particular, the following attempt at getting an endian-independent integer
15613 does not work:
15615 @smallexample @c ada
15616    type R2 is record
15617       A : Integer;
15618    end record;
15620    for R2'Bit_Order use High_Order_First;
15622    for R2 use record
15623       A at 0 range 0 .. 31;
15624    end record;
15625 @end smallexample
15627 @noindent
15628 This declaration will result in a little-endian integer on a
15629 little-endian machine, and a big-endian integer on a big-endian machine.
15630 If byte flipping is required for interoperability between big- and
15631 little-endian machines, this must be explicitly programmed.  This capability
15632 is not provided by @code{Bit_Order}.
15634 @item Components that are positioned across byte boundaries
15635 @noindent
15636 but do not occupy an integral number of bytes.  Given that bytes are not
15637 reordered, such fields would occupy a non-contiguous sequence of bits
15638 in memory, requiring non-trivial code to reassemble.  They are for this
15639 reason not permitted, and any component clause specifying such a layout
15640 will be flagged as illegal by GNAT@.
15642 @end itemize
15644 @noindent
15645 Since the misconception that Bit_Order automatically deals with all
15646 endian-related incompatibilities is a common one, the specification of
15647 a component field that is an integral number of bytes will always
15648 generate a warning.  This warning may be suppressed using @code{pragma
15649 Warnings (Off)} if desired.  The following section contains additional
15650 details regarding the issue of byte ordering.
15652 @node Effect of Bit_Order on Byte Ordering
15653 @section Effect of Bit_Order on Byte Ordering
15654 @cindex byte ordering
15655 @cindex ordering, of bytes
15657 @noindent
15658 In this section we will review the effect of the @code{Bit_Order} attribute
15659 definition clause on byte ordering.  Briefly, it has no effect at all, but
15660 a detailed example will be helpful.  Before giving this
15661 example, let us review the precise
15662 definition of the effect of defining @code{Bit_Order}.  The effect of a
15663 non-standard bit order is described in section 15.5.3 of the Ada
15664 Reference Manual:
15666 @quotation
15667 2   A bit ordering is a method of interpreting the meaning of
15668 the storage place attributes.
15669 @end quotation
15671 @noindent
15672 To understand the precise definition of storage place attributes in
15673 this context, we visit section 13.5.1 of the manual:
15675 @quotation
15676 13   A record_representation_clause (without the mod_clause)
15677 specifies the layout.  The storage place attributes (see 13.5.2)
15678 are taken from the values of the position, first_bit, and last_bit
15679 expressions after normalizing those values so that first_bit is
15680 less than Storage_Unit.
15681 @end quotation
15683 @noindent
15684 The critical point here is that storage places are taken from
15685 the values after normalization, not before.  So the @code{Bit_Order}
15686 interpretation applies to normalized values.  The interpretation
15687 is described in the later part of the 15.5.3 paragraph:
15689 @quotation
15690 2   A bit ordering is a method of interpreting the meaning of
15691 the storage place attributes.  High_Order_First (known in the
15692 vernacular as ``big endian'') means that the first bit of a
15693 storage element (bit 0) is the most significant bit (interpreting
15694 the sequence of bits that represent a component as an unsigned
15695 integer value).  Low_Order_First (known in the vernacular as
15696 ``little endian'') means the opposite: the first bit is the
15697 least significant.
15698 @end quotation
15700 @noindent
15701 Note that the numbering is with respect to the bits of a storage
15702 unit.  In other words, the specification affects only the numbering
15703 of bits within a single storage unit.
15705 We can make the effect clearer by giving an example.
15707 Suppose that we have an external device which presents two bytes, the first
15708 byte presented, which is the first (low addressed byte) of the two byte
15709 record is called Master, and the second byte is called Slave.
15711 The left most (most significant bit is called Control for each byte, and
15712 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
15713 (least significant) bit.
15715 On a big-endian machine, we can write the following representation clause
15717 @smallexample @c ada
15718    type Data is record
15719       Master_Control : Bit;
15720       Master_V1      : Bit;
15721       Master_V2      : Bit;
15722       Master_V3      : Bit;
15723       Master_V4      : Bit;
15724       Master_V5      : Bit;
15725       Master_V6      : Bit;
15726       Master_V7      : Bit;
15727       Slave_Control  : Bit;
15728       Slave_V1       : Bit;
15729       Slave_V2       : Bit;
15730       Slave_V3       : Bit;
15731       Slave_V4       : Bit;
15732       Slave_V5       : Bit;
15733       Slave_V6       : Bit;
15734       Slave_V7       : Bit;
15735    end record;
15737    for Data use record
15738       Master_Control at 0 range 0 .. 0;
15739       Master_V1      at 0 range 1 .. 1;
15740       Master_V2      at 0 range 2 .. 2;
15741       Master_V3      at 0 range 3 .. 3;
15742       Master_V4      at 0 range 4 .. 4;
15743       Master_V5      at 0 range 5 .. 5;
15744       Master_V6      at 0 range 6 .. 6;
15745       Master_V7      at 0 range 7 .. 7;
15746       Slave_Control  at 1 range 0 .. 0;
15747       Slave_V1       at 1 range 1 .. 1;
15748       Slave_V2       at 1 range 2 .. 2;
15749       Slave_V3       at 1 range 3 .. 3;
15750       Slave_V4       at 1 range 4 .. 4;
15751       Slave_V5       at 1 range 5 .. 5;
15752       Slave_V6       at 1 range 6 .. 6;
15753       Slave_V7       at 1 range 7 .. 7;
15754    end record;
15755 @end smallexample
15757 @noindent
15758 Now if we move this to a little endian machine, then the bit ordering within
15759 the byte is backwards, so we have to rewrite the record rep clause as:
15761 @smallexample @c ada
15762    for Data use record
15763       Master_Control at 0 range 7 .. 7;
15764       Master_V1      at 0 range 6 .. 6;
15765       Master_V2      at 0 range 5 .. 5;
15766       Master_V3      at 0 range 4 .. 4;
15767       Master_V4      at 0 range 3 .. 3;
15768       Master_V5      at 0 range 2 .. 2;
15769       Master_V6      at 0 range 1 .. 1;
15770       Master_V7      at 0 range 0 .. 0;
15771       Slave_Control  at 1 range 7 .. 7;
15772       Slave_V1       at 1 range 6 .. 6;
15773       Slave_V2       at 1 range 5 .. 5;
15774       Slave_V3       at 1 range 4 .. 4;
15775       Slave_V4       at 1 range 3 .. 3;
15776       Slave_V5       at 1 range 2 .. 2;
15777       Slave_V6       at 1 range 1 .. 1;
15778       Slave_V7       at 1 range 0 .. 0;
15779    end record;
15780 @end smallexample
15782 @noindent
15783 It is a nuisance to have to rewrite the clause, especially if
15784 the code has to be maintained on both machines.  However,
15785 this is a case that we can handle with the
15786 @code{Bit_Order} attribute if it is implemented.
15787 Note that the implementation is not required on byte addressed
15788 machines, but it is indeed implemented in GNAT.
15789 This means that we can simply use the
15790 first record clause, together with the declaration
15792 @smallexample @c ada
15793    for Data'Bit_Order use High_Order_First;
15794 @end smallexample
15796 @noindent
15797 and the effect is what is desired, namely the layout is exactly the same,
15798 independent of whether the code is compiled on a big-endian or little-endian
15799 machine.
15801 The important point to understand is that byte ordering is not affected.
15802 A @code{Bit_Order} attribute definition never affects which byte a field
15803 ends up in, only where it ends up in that byte.
15804 To make this clear, let us rewrite the record rep clause of the previous
15805 example as:
15807 @smallexample @c ada
15808    for Data'Bit_Order use High_Order_First;
15809    for Data use record
15810       Master_Control at 0 range  0 .. 0;
15811       Master_V1      at 0 range  1 .. 1;
15812       Master_V2      at 0 range  2 .. 2;
15813       Master_V3      at 0 range  3 .. 3;
15814       Master_V4      at 0 range  4 .. 4;
15815       Master_V5      at 0 range  5 .. 5;
15816       Master_V6      at 0 range  6 .. 6;
15817       Master_V7      at 0 range  7 .. 7;
15818       Slave_Control  at 0 range  8 .. 8;
15819       Slave_V1       at 0 range  9 .. 9;
15820       Slave_V2       at 0 range 10 .. 10;
15821       Slave_V3       at 0 range 11 .. 11;
15822       Slave_V4       at 0 range 12 .. 12;
15823       Slave_V5       at 0 range 13 .. 13;
15824       Slave_V6       at 0 range 14 .. 14;
15825       Slave_V7       at 0 range 15 .. 15;
15826    end record;
15827 @end smallexample
15829 @noindent
15830 This is exactly equivalent to saying (a repeat of the first example):
15832 @smallexample @c ada
15833    for Data'Bit_Order use High_Order_First;
15834    for Data use record
15835       Master_Control at 0 range 0 .. 0;
15836       Master_V1      at 0 range 1 .. 1;
15837       Master_V2      at 0 range 2 .. 2;
15838       Master_V3      at 0 range 3 .. 3;
15839       Master_V4      at 0 range 4 .. 4;
15840       Master_V5      at 0 range 5 .. 5;
15841       Master_V6      at 0 range 6 .. 6;
15842       Master_V7      at 0 range 7 .. 7;
15843       Slave_Control  at 1 range 0 .. 0;
15844       Slave_V1       at 1 range 1 .. 1;
15845       Slave_V2       at 1 range 2 .. 2;
15846       Slave_V3       at 1 range 3 .. 3;
15847       Slave_V4       at 1 range 4 .. 4;
15848       Slave_V5       at 1 range 5 .. 5;
15849       Slave_V6       at 1 range 6 .. 6;
15850       Slave_V7       at 1 range 7 .. 7;
15851    end record;
15852 @end smallexample
15854 @noindent
15855 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
15856 field.  The storage place attributes are obtained by normalizing the
15857 values given so that the @code{First_Bit} value is less than 8.  After
15858 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
15859 we specified in the other case.
15861 Now one might expect that the @code{Bit_Order} attribute might affect
15862 bit numbering within the entire record component (two bytes in this
15863 case, thus affecting which byte fields end up in), but that is not
15864 the way this feature is defined, it only affects numbering of bits,
15865 not which byte they end up in.
15867 Consequently it never makes sense to specify a starting bit number
15868 greater than 7 (for a byte addressable field) if an attribute
15869 definition for @code{Bit_Order} has been given, and indeed it
15870 may be actively confusing to specify such a value, so the compiler
15871 generates a warning for such usage.
15873 If you do need to control byte ordering then appropriate conditional
15874 values must be used.  If in our example, the slave byte came first on
15875 some machines we might write:
15877 @smallexample @c ada
15878    Master_Byte_First constant Boolean := @dots{};
15880    Master_Byte : constant Natural :=
15881                    1 - Boolean'Pos (Master_Byte_First);
15882    Slave_Byte  : constant Natural :=
15883                    Boolean'Pos (Master_Byte_First);
15885    for Data'Bit_Order use High_Order_First;
15886    for Data use record
15887       Master_Control at Master_Byte range 0 .. 0;
15888       Master_V1      at Master_Byte range 1 .. 1;
15889       Master_V2      at Master_Byte range 2 .. 2;
15890       Master_V3      at Master_Byte range 3 .. 3;
15891       Master_V4      at Master_Byte range 4 .. 4;
15892       Master_V5      at Master_Byte range 5 .. 5;
15893       Master_V6      at Master_Byte range 6 .. 6;
15894       Master_V7      at Master_Byte range 7 .. 7;
15895       Slave_Control  at Slave_Byte  range 0 .. 0;
15896       Slave_V1       at Slave_Byte  range 1 .. 1;
15897       Slave_V2       at Slave_Byte  range 2 .. 2;
15898       Slave_V3       at Slave_Byte  range 3 .. 3;
15899       Slave_V4       at Slave_Byte  range 4 .. 4;
15900       Slave_V5       at Slave_Byte  range 5 .. 5;
15901       Slave_V6       at Slave_Byte  range 6 .. 6;
15902       Slave_V7       at Slave_Byte  range 7 .. 7;
15903    end record;
15904 @end smallexample
15906 @noindent
15907 Now to switch between machines, all that is necessary is
15908 to set the boolean constant @code{Master_Byte_First} in
15909 an appropriate manner.
15911 @node Pragma Pack for Arrays
15912 @section Pragma Pack for Arrays
15913 @cindex Pragma Pack (for arrays)
15915 @noindent
15916 Pragma @code{Pack} applied to an array has no effect unless the component type
15917 is packable.  For a component type to be packable, it must be one of the
15918 following cases:
15920 @itemize @bullet
15921 @item
15922 Any scalar type
15923 @item
15924 Any type whose size is specified with a size clause
15925 @item
15926 Any packed array type with a static size
15927 @item
15928 Any record type padded because of its default alignment
15929 @end itemize
15931 @noindent
15932 For all these cases, if the component subtype size is in the range
15933 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
15934 component size were specified giving the component subtype size.
15935 For example if we have:
15937 @smallexample @c ada
15938    type r is range 0 .. 17;
15940    type ar is array (1 .. 8) of r;
15941    pragma Pack (ar);
15942 @end smallexample
15944 @noindent
15945 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
15946 and the size of the array @code{ar} will be exactly 40 bits.
15948 Note that in some cases this rather fierce approach to packing can produce
15949 unexpected effects.  For example, in Ada 95 and Ada 2005,
15950 subtype @code{Natural} typically has a size of 31, meaning that if you
15951 pack an array of @code{Natural}, you get 31-bit
15952 close packing, which saves a few bits, but results in far less efficient
15953 access.  Since many other Ada compilers will ignore such a packing request,
15954 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
15955 might not be what is intended.  You can easily remove this warning by
15956 using an explicit @code{Component_Size} setting instead, which never generates
15957 a warning, since the intention of the programmer is clear in this case.
15959 GNAT treats packed arrays in one of two ways.  If the size of the array is
15960 known at compile time and is less than 64 bits, then internally the array
15961 is represented as a single modular type, of exactly the appropriate number
15962 of bits.  If the length is greater than 63 bits, or is not known at compile
15963 time, then the packed array is represented as an array of bytes, and the
15964 length is always a multiple of 8 bits.
15966 Note that to represent a packed array as a modular type, the alignment must
15967 be suitable for the modular type involved. For example, on typical machines
15968 a 32-bit packed array will be represented by a 32-bit modular integer with
15969 an alignment of four bytes. If you explicitly override the default alignment
15970 with an alignment clause that is too small, the modular representation
15971 cannot be used. For example, consider the following set of declarations:
15973 @smallexample @c ada
15974    type R is range 1 .. 3;
15975    type S is array (1 .. 31) of R;
15976    for S'Component_Size use 2;
15977    for S'Size use 62;
15978    for S'Alignment use 1;
15979 @end smallexample
15981 @noindent
15982 If the alignment clause were not present, then a 62-bit modular
15983 representation would be chosen (typically with an alignment of 4 or 8
15984 bytes depending on the target). But the default alignment is overridden
15985 with the explicit alignment clause. This means that the modular
15986 representation cannot be used, and instead the array of bytes
15987 representation must be used, meaning that the length must be a multiple
15988 of 8. Thus the above set of declarations will result in a diagnostic
15989 rejecting the size clause and noting that the minimum size allowed is 64.
15991 @cindex Pragma Pack (for type Natural)
15992 @cindex Pragma Pack warning
15994 One special case that is worth noting occurs when the base type of the
15995 component size is 8/16/32 and the subtype is one bit less. Notably this
15996 occurs with subtype @code{Natural}. Consider:
15998 @smallexample @c ada
15999    type Arr is array (1 .. 32) of Natural;
16000    pragma Pack (Arr);
16001 @end smallexample
16003 @noindent
16004 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
16005 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
16006 Ada 83 compilers did not attempt 31 bit packing.
16008 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
16009 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
16010 substantial unintended performance penalty when porting legacy Ada 83 code.
16011 To help prevent this, GNAT generates a warning in such cases. If you really
16012 want 31 bit packing in a case like this, you can set the component size
16013 explicitly:
16015 @smallexample @c ada
16016    type Arr is array (1 .. 32) of Natural;
16017    for Arr'Component_Size use 31;
16018 @end smallexample
16020 @noindent
16021 Here 31-bit packing is achieved as required, and no warning is generated,
16022 since in this case the programmer intention is clear.
16024 @node Pragma Pack for Records
16025 @section Pragma Pack for Records
16026 @cindex Pragma Pack (for records)
16028 @noindent
16029 Pragma @code{Pack} applied to a record will pack the components to reduce
16030 wasted space from alignment gaps and by reducing the amount of space
16031 taken by components.  We distinguish between @emph{packable} components and
16032 @emph{non-packable} components.
16033 Components of the following types are considered packable:
16034 @itemize @bullet
16035 @item
16036 Components of a primitive type are packable unless they are aliased
16037 or of an atomic type.
16039 @item
16040 Small packed arrays, whose size does not exceed 64 bits, and where the
16041 size is statically known at compile time, are represented internally
16042 as modular integers, and so they are also packable.
16044 @end itemize
16046 @noindent
16047 All packable components occupy the exact number of bits corresponding to
16048 their @code{Size} value, and are packed with no padding bits, i.e.@: they
16049 can start on an arbitrary bit boundary.
16051 All other types are non-packable, they occupy an integral number of
16052 storage units, and
16053 are placed at a boundary corresponding to their alignment requirements.
16055 For example, consider the record
16057 @smallexample @c ada
16058    type Rb1 is array (1 .. 13) of Boolean;
16059    pragma Pack (Rb1);
16061    type Rb2 is array (1 .. 65) of Boolean;
16062    pragma Pack (Rb2);
16064    type AF is new Float with Atomic;
16066    type X2 is record
16067       L1 : Boolean;
16068       L2 : Duration;
16069       L3 : AF;
16070       L4 : Boolean;
16071       L5 : Rb1;
16072       L6 : Rb2;
16073    end record;
16074    pragma Pack (X2);
16075 @end smallexample
16077 @noindent
16078 The representation for the record X2 is as follows:
16080 @smallexample @c ada
16081 for X2'Size use 224;
16082 for X2 use record
16083    L1 at  0 range  0 .. 0;
16084    L2 at  0 range  1 .. 64;
16085    L3 at 12 range  0 .. 31;
16086    L4 at 16 range  0 .. 0;
16087    L5 at 16 range  1 .. 13;
16088    L6 at 18 range  0 .. 71;
16089 end record;
16090 @end smallexample
16092 @noindent
16093 Studying this example, we see that the packable fields @code{L1}
16094 and @code{L2} are
16095 of length equal to their sizes, and placed at specific bit boundaries (and
16096 not byte boundaries) to
16097 eliminate padding.  But @code{L3} is of a non-packable float type (because
16098 it is aliased), so it is on the next appropriate alignment boundary.
16100 The next two fields are fully packable, so @code{L4} and @code{L5} are
16101 minimally packed with no gaps.  However, type @code{Rb2} is a packed
16102 array that is longer than 64 bits, so it is itself non-packable.  Thus
16103 the @code{L6} field is aligned to the next byte boundary, and takes an
16104 integral number of bytes, i.e.@: 72 bits.
16106 @node Record Representation Clauses
16107 @section Record Representation Clauses
16108 @cindex Record Representation Clause
16110 @noindent
16111 Record representation clauses may be given for all record types, including
16112 types obtained by record extension.  Component clauses are allowed for any
16113 static component.  The restrictions on component clauses depend on the type
16114 of the component.
16116 @cindex Component Clause
16117 For all components of an elementary type, the only restriction on component
16118 clauses is that the size must be at least the 'Size value of the type
16119 (actually the Value_Size).  There are no restrictions due to alignment,
16120 and such components may freely cross storage boundaries.
16122 Packed arrays with a size up to and including 64 bits are represented
16123 internally using a modular type with the appropriate number of bits, and
16124 thus the same lack of restriction applies.  For example, if you declare:
16126 @smallexample @c ada
16127    type R is array (1 .. 49) of Boolean;
16128    pragma Pack (R);
16129    for R'Size use 49;
16130 @end smallexample
16132 @noindent
16133 then a component clause for a component of type R may start on any
16134 specified bit boundary, and may specify a value of 49 bits or greater.
16136 For packed bit arrays that are longer than 64 bits, there are two
16137 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
16138 including the important case of single bits or boolean values, then
16139 there are no limitations on placement of such components, and they
16140 may start and end at arbitrary bit boundaries.
16142 If the component size is not a power of 2 (e.g.@: 3 or 5), then
16143 an array of this type longer than 64 bits must always be placed on
16144 on a storage unit (byte) boundary and occupy an integral number
16145 of storage units (bytes). Any component clause that does not
16146 meet this requirement will be rejected.
16148 Any aliased component, or component of an aliased type, must
16149 have its normal alignment and size. A component clause that
16150 does not meet this requirement will be rejected.
16152 The tag field of a tagged type always occupies an address sized field at
16153 the start of the record.  No component clause may attempt to overlay this
16154 tag. When a tagged type appears as a component, the tag field must have
16155 proper alignment
16157 In the case of a record extension T1, of a type T, no component clause applied
16158 to the type T1 can specify a storage location that would overlap the first
16159 T'Size bytes of the record.
16161 For all other component types, including non-bit-packed arrays,
16162 the component can be placed at an arbitrary bit boundary,
16163 so for example, the following is permitted:
16165 @smallexample @c ada
16166    type R is array (1 .. 10) of Boolean;
16167    for R'Size use 80;
16169    type Q is record
16170       G, H : Boolean;
16171       L, M : R;
16172    end record;
16174    for Q use record
16175       G at 0 range  0 ..   0;
16176       H at 0 range  1 ..   1;
16177       L at 0 range  2 ..  81;
16178       R at 0 range 82 .. 161;
16179    end record;
16180 @end smallexample
16182 @noindent
16183 Note: the above rules apply to recent releases of GNAT 5.
16184 In GNAT 3, there are more severe restrictions on larger components.
16185 For non-primitive types, including packed arrays with a size greater than
16186 64 bits, component clauses must respect the alignment requirement of the
16187 type, in particular, always starting on a byte boundary, and the length
16188 must be a multiple of the storage unit.
16190 @node Handling of Records with Holes
16191 @section Handling of Records with Holes
16192 @cindex Handling of Records with Holes
16194 As a result of alignment considerations, records may contain "holes"
16195 or gaps
16196 which do not correspond to the data bits of any of the components.
16197 Record representation clauses can also result in holes in records.
16199 GNAT does not attempt to clear these holes, so in record objects,
16200 they should be considered to hold undefined rubbish. The generated
16201 equality routine just tests components so does not access these
16202 undefined bits, and assignment and copy operations may or may not
16203 preserve the contents of these holes (for assignments, the holes
16204 in the target will in practice contain either the bits that are
16205 present in the holes in the source, or the bits that were present
16206 in the target before the assignment).
16208 If it is necessary to ensure that holes in records have all zero
16209 bits, then record objects for which this initialization is desired
16210 should be explicitly set to all zero values using Unchecked_Conversion
16211 or address overlays. For example
16213 @smallexample @c ada
16214 type HRec is record
16215    C : Character;
16216    I : Integer;
16217 end record;
16218 @end smallexample
16220 @noindent
16221 On typical machines, integers need to be aligned on a four-byte
16222 boundary, resulting in three bytes of undefined rubbish following
16223 the 8-bit field for C. To ensure that the hole in a variable of
16224 type HRec is set to all zero bits,
16225 you could for example do:
16227 @smallexample @c ada
16228 type Base is record
16229    Dummy1, Dummy2 : Integer := 0;
16230 end record;
16232 BaseVar : Base;
16233 RealVar : Hrec;
16234 for RealVar'Address use BaseVar'Address;
16235 @end smallexample
16237 @noindent
16238 Now the 8-bytes of the value of RealVar start out containing all zero
16239 bits. A safer approach is to just define dummy fields, avoiding the
16240 holes, as in:
16242 @smallexample @c ada
16243 type HRec is record
16244    C      : Character;
16245    Dummy1 : Short_Short_Integer := 0;
16246    Dummy2 : Short_Short_Integer := 0;
16247    Dummy3 : Short_Short_Integer := 0;
16248    I      : Integer;
16249 end record;
16250 @end smallexample
16252 @noindent
16253 And to make absolutely sure that the intent of this is followed, you
16254 can use representation clauses:
16256 @smallexample @c ada
16257 for Hrec use record
16258    C      at 0 range 0 .. 7;
16259    Dummy1 at 1 range 0 .. 7;
16260    Dummy2 at 2 range 0 .. 7;
16261    Dummy3 at 3 range 0 .. 7;
16262    I      at 4 range 0 .. 31;
16263 end record;
16264 for Hrec'Size use 64;
16265 @end smallexample
16267 @node Enumeration Clauses
16268 @section Enumeration Clauses
16270 The only restriction on enumeration clauses is that the range of values
16271 must be representable.  For the signed case, if one or more of the
16272 representation values are negative, all values must be in the range:
16274 @smallexample @c ada
16275    System.Min_Int .. System.Max_Int
16276 @end smallexample
16278 @noindent
16279 For the unsigned case, where all values are nonnegative, the values must
16280 be in the range:
16282 @smallexample @c ada
16283    0 .. System.Max_Binary_Modulus;
16284 @end smallexample
16286 @noindent
16287 A @emph{confirming} representation clause is one in which the values range
16288 from 0 in sequence, i.e.@: a clause that confirms the default representation
16289 for an enumeration type.
16290 Such a confirming representation
16291 is permitted by these rules, and is specially recognized by the compiler so
16292 that no extra overhead results from the use of such a clause.
16294 If an array has an index type which is an enumeration type to which an
16295 enumeration clause has been applied, then the array is stored in a compact
16296 manner.  Consider the declarations:
16298 @smallexample @c ada
16299    type r is (A, B, C);
16300    for r use (A => 1, B => 5, C => 10);
16301    type t is array (r) of Character;
16302 @end smallexample
16304 @noindent
16305 The array type t corresponds to a vector with exactly three elements and
16306 has a default size equal to @code{3*Character'Size}.  This ensures efficient
16307 use of space, but means that accesses to elements of the array will incur
16308 the overhead of converting representation values to the corresponding
16309 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
16311 @node Address Clauses
16312 @section Address Clauses
16313 @cindex Address Clause
16315 The reference manual allows a general restriction on representation clauses,
16316 as found in RM 13.1(22):
16318 @quotation
16319 An implementation need not support representation
16320 items containing nonstatic expressions, except that
16321 an implementation should support a representation item
16322 for a given entity if each nonstatic expression in the
16323 representation item is a name that statically denotes
16324 a constant declared before the entity.
16325 @end quotation
16327 @noindent
16328 In practice this is applicable only to address clauses, since this is the
16329 only case in which a non-static expression is permitted by the syntax.  As
16330 the AARM notes in sections 13.1 (22.a-22.h):
16332 @display
16333   22.a   Reason: This is to avoid the following sort of thing:
16335   22.b        X : Integer := F(@dots{});
16336               Y : Address := G(@dots{});
16337               for X'Address use Y;
16339   22.c   In the above, we have to evaluate the
16340          initialization expression for X before we
16341          know where to put the result.  This seems
16342          like an unreasonable implementation burden.
16344   22.d   The above code should instead be written
16345          like this:
16347   22.e        Y : constant Address := G(@dots{});
16348               X : Integer := F(@dots{});
16349               for X'Address use Y;
16351   22.f   This allows the expression ``Y'' to be safely
16352          evaluated before X is created.
16354   22.g   The constant could be a formal parameter of mode in.
16356   22.h   An implementation can support other nonstatic
16357          expressions if it wants to.  Expressions of type
16358          Address are hardly ever static, but their value
16359          might be known at compile time anyway in many
16360          cases.
16361 @end display
16363 @noindent
16364 GNAT does indeed permit many additional cases of non-static expressions.  In
16365 particular, if the type involved is elementary there are no restrictions
16366 (since in this case, holding a temporary copy of the initialization value,
16367 if one is present, is inexpensive).  In addition, if there is no implicit or
16368 explicit initialization, then there are no restrictions.  GNAT will reject
16369 only the case where all three of these conditions hold:
16371 @itemize @bullet
16373 @item
16374 The type of the item is non-elementary (e.g.@: a record or array).
16376 @item
16377 There is explicit or implicit initialization required for the object.
16378 Note that access values are always implicitly initialized.
16380 @item
16381 The address value is non-static.  Here GNAT is more permissive than the
16382 RM, and allows the address value to be the address of a previously declared
16383 stand-alone variable, as long as it does not itself have an address clause.
16385 @smallexample @c ada
16386            Anchor  : Some_Initialized_Type;
16387            Overlay : Some_Initialized_Type;
16388            for Overlay'Address use Anchor'Address;
16389 @end smallexample
16391 @noindent
16392 However, the prefix of the address clause cannot be an array component, or
16393 a component of a discriminated record.
16395 @end itemize
16397 @noindent
16398 As noted above in section 22.h, address values are typically non-static.  In
16399 particular the To_Address function, even if applied to a literal value, is
16400 a non-static function call.  To avoid this minor annoyance, GNAT provides
16401 the implementation defined attribute 'To_Address.  The following two
16402 expressions have identical values:
16404 @findex Attribute
16405 @findex To_Address
16406 @smallexample @c ada
16407    To_Address (16#1234_0000#)
16408    System'To_Address (16#1234_0000#);
16409 @end smallexample
16411 @noindent
16412 except that the second form is considered to be a static expression, and
16413 thus when used as an address clause value is always permitted.
16415 @noindent
16416 Additionally, GNAT treats as static an address clause that is an
16417 unchecked_conversion of a static integer value.  This simplifies the porting
16418 of legacy code, and provides a portable equivalent to the GNAT attribute
16419 @code{To_Address}.
16421 Another issue with address clauses is the interaction with alignment
16422 requirements.  When an address clause is given for an object, the address
16423 value must be consistent with the alignment of the object (which is usually
16424 the same as the alignment of the type of the object).  If an address clause
16425 is given that specifies an inappropriately aligned address value, then the
16426 program execution is erroneous.
16428 Since this source of erroneous behavior can have unfortunate effects, GNAT
16429 checks (at compile time if possible, generating a warning, or at execution
16430 time with a run-time check) that the alignment is appropriate.  If the
16431 run-time check fails, then @code{Program_Error} is raised.  This run-time
16432 check is suppressed if range checks are suppressed, or if the special GNAT
16433 check Alignment_Check is suppressed, or if
16434 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
16436 Finally, GNAT does not permit overlaying of objects of controlled types or
16437 composite types containing a controlled component. In most cases, the compiler
16438 can detect an attempt at such overlays and will generate a warning at compile
16439 time and a Program_Error exception at run time.
16441 @findex Export
16442 An address clause cannot be given for an exported object.  More
16443 understandably the real restriction is that objects with an address
16444 clause cannot be exported.  This is because such variables are not
16445 defined by the Ada program, so there is no external object to export.
16447 @findex Import
16448 It is permissible to give an address clause and a pragma Import for the
16449 same object.  In this case, the variable is not really defined by the
16450 Ada program, so there is no external symbol to be linked.  The link name
16451 and the external name are ignored in this case.  The reason that we allow this
16452 combination is that it provides a useful idiom to avoid unwanted
16453 initializations on objects with address clauses.
16455 When an address clause is given for an object that has implicit or
16456 explicit initialization, then by default initialization takes place.  This
16457 means that the effect of the object declaration is to overwrite the
16458 memory at the specified address.  This is almost always not what the
16459 programmer wants, so GNAT will output a warning:
16461 @smallexample
16462   with System;
16463   package G is
16464      type R is record
16465         M : Integer := 0;
16466      end record;
16468      Ext : R;
16469      for Ext'Address use System'To_Address (16#1234_1234#);
16470          |
16471   >>> warning: implicit initialization of "Ext" may
16472       modify overlaid storage
16473   >>> warning: use pragma Import for "Ext" to suppress
16474       initialization (RM B(24))
16476   end G;
16477 @end smallexample
16479 @noindent
16480 As indicated by the warning message, the solution is to use a (dummy) pragma
16481 Import to suppress this initialization.  The pragma tell the compiler that the
16482 object is declared and initialized elsewhere.  The following package compiles
16483 without warnings (and the initialization is suppressed):
16485 @smallexample @c ada
16486    with System;
16487    package G is
16488       type R is record
16489          M : Integer := 0;
16490       end record;
16492       Ext : R;
16493       for Ext'Address use System'To_Address (16#1234_1234#);
16494       pragma Import (Ada, Ext);
16495    end G;
16496 @end smallexample
16498 @noindent
16499 A final issue with address clauses involves their use for overlaying
16500 variables, as in the following example:
16501 @cindex Overlaying of objects
16503 @smallexample @c ada
16504   A : Integer;
16505   B : Integer;
16506   for B'Address use A'Address;
16507 @end smallexample
16509 @noindent
16510 or alternatively, using the form recommended by the RM:
16512 @smallexample @c ada
16513   A    : Integer;
16514   Addr : constant Address := A'Address;
16515   B    : Integer;
16516   for B'Address use Addr;
16517 @end smallexample
16519 @noindent
16520 In both of these cases, @code{A}
16521 and @code{B} become aliased to one another via the
16522 address clause. This use of address clauses to overlay
16523 variables, achieving an effect similar to unchecked
16524 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
16525 the effect is implementation defined. Furthermore, the
16526 Ada RM specifically recommends that in a situation
16527 like this, @code{B} should be subject to the following
16528 implementation advice (RM 13.3(19)):
16530 @quotation
16531 19  If the Address of an object is specified, or it is imported
16532     or exported, then the implementation should not perform
16533     optimizations based on assumptions of no aliases.
16534 @end quotation
16536 @noindent
16537 GNAT follows this recommendation, and goes further by also applying
16538 this recommendation to the overlaid variable (@code{A}
16539 in the above example) in this case. This means that the overlay
16540 works "as expected", in that a modification to one of the variables
16541 will affect the value of the other.
16543 Note that when address clause overlays are used in this way, there is an
16544 issue of unintentional initialization, as shown by this example:
16546 @smallexample @c ada
16547 package Overwrite_Record is
16548    type R is record
16549       A : Character := 'C';
16550       B : Character := 'A';
16551    end record;
16552    X : Short_Integer := 3;
16553    Y : R;
16554    for Y'Address use X'Address;
16555        |
16556 >>> warning: default initialization of "Y" may
16557     modify "X", use pragma Import for "Y" to
16558     suppress initialization (RM B.1(24))
16560 end Overwrite_Record;
16561 @end smallexample
16563 @noindent
16564 Here the default initialization of @code{Y} will clobber the value
16565 of @code{X}, which justifies the warning. The warning notes that
16566 this effect can be eliminated by adding a @code{pragma Import}
16567 which suppresses the initialization:
16569 @smallexample @c ada
16570 package Overwrite_Record is
16571    type R is record
16572       A : Character := 'C';
16573       B : Character := 'A';
16574    end record;
16575    X : Short_Integer := 3;
16576    Y : R;
16577    for Y'Address use X'Address;
16578    pragma Import (Ada, Y);
16579 end Overwrite_Record;
16580 @end smallexample
16582 @noindent
16583 Note that the use of @code{pragma Initialize_Scalars} may cause variables to
16584 be initialized when they would not otherwise have been in the absence
16585 of the use of this pragma. This may cause an overlay to have this
16586 unintended clobbering effect. The compiler avoids this for scalar
16587 types, but not for composite objects (where in general the effect
16588 of @code{Initialize_Scalars} is part of the initialization routine
16589 for the composite object:
16591 @smallexample @c ada
16592 pragma Initialize_Scalars;
16593 with Ada.Text_IO;  use Ada.Text_IO;
16594 procedure Overwrite_Array is
16595    type Arr is array (1 .. 5) of Integer;
16596    X : Arr := (others => 1);
16597    A : Arr;
16598    for A'Address use X'Address;
16599        |
16600 >>> warning: default initialization of "A" may
16601     modify "X", use pragma Import for "A" to
16602     suppress initialization (RM B.1(24))
16604 begin
16605    if X /= Arr'(others => 1) then
16606       Put_Line ("X was clobbered");
16607    else
16608       Put_Line ("X was not clobbered");
16609    end if;
16610 end Overwrite_Array;
16611 @end smallexample
16613 @noindent
16614 The above program generates the warning as shown, and at execution
16615 time, prints @code{X was clobbered}. If the @code{pragma Import} is
16616 added as suggested:
16618 @smallexample @c ada
16619 pragma Initialize_Scalars;
16620 with Ada.Text_IO;  use Ada.Text_IO;
16621 procedure Overwrite_Array is
16622    type Arr is array (1 .. 5) of Integer;
16623    X : Arr := (others => 1);
16624    A : Arr;
16625    for A'Address use X'Address;
16626    pragma Import (Ada, A);
16627 begin
16628    if X /= Arr'(others => 1) then
16629       Put_Line ("X was clobbered");
16630    else
16631       Put_Line ("X was not clobbered");
16632    end if;
16633 end Overwrite_Array;
16634 @end smallexample
16636 @noindent
16637 then the program compiles without the warning and when run will generate
16638 the output @code{X was not clobbered}.
16640 @node Use of Address Clauses for Memory-Mapped I/O
16641 @section Use of Address Clauses for Memory-Mapped I/O
16642 @cindex Memory-mapped I/O
16644 A common pattern is to use an address clause to map an atomic variable to
16645 a location in memory that corresponds to a memory-mapped I/O operation or
16646 operations, for example:
16648 @smallexample @c ada
16649     type Mem_Word is record
16650        A,B,C,D : Byte;
16651     end record;
16652     pragma Atomic (Mem_Word);
16653     for Mem_Word_Size use 32;
16655     Mem : Mem_Word;
16656     for Mem'Address use some-address;
16657     ...
16658     Temp := Mem;
16659     Temp.A := 32;
16660     Mem := Temp;
16661 @end smallexample
16663 @noindent
16664 For a full access (reference or modification) of the variable (Mem) in
16665 this case, as in the above examples, GNAT guarantees that the entire atomic
16666 word will be accessed. It is not clear whether the RM requires this. For
16667 example in the above, can the compiler reference only the Mem.A field as
16668 an optimization? Whatever the answer to this question is, GNAT makes the
16669 guarantee that for such a reference, the entire word is read or written.
16671 A problem arises with a component access such as:
16673 @smallexample @c ada
16674     Mem.A := 32;
16675 @end smallexample
16677 @noindent
16678 Note that the component A is not declared as atomic. This means that it is
16679 not clear what this assignment means. It could correspond to full word read
16680 and write as given in the first example, or on architectures that supported
16681 such an operation it might be a single byte store instruction. The RM does
16682 not have anything to say in this situation, and GNAT does not make any
16683 guarantee. The code generated may vary from target to target. GNAT will issue
16684 a warning in such a case:
16686 @smallexample @c ada
16687     Mem.A := 32;
16688     |
16689     >>> warning: access to non-atomic component of atomic array,
16690         may cause unexpected accesses to atomic object
16691 @end smallexample
16693 @noindent
16694 It is best to be explicit in this situation, by either declaring the
16695 components to be atomic if you want the byte store, or explicitly writing
16696 the full word access sequence if that is what the hardware requires.
16698 @node Effect of Convention on Representation
16699 @section Effect of Convention on Representation
16700 @cindex Convention, effect on representation
16702 @noindent
16703 Normally the specification of a foreign language convention for a type or
16704 an object has no effect on the chosen representation.  In particular, the
16705 representation chosen for data in GNAT generally meets the standard system
16706 conventions, and for example records are laid out in a manner that is
16707 consistent with C@.  This means that specifying convention C (for example)
16708 has no effect.
16710 There are four exceptions to this general rule:
16712 @itemize @bullet
16714 @item Convention Fortran and array subtypes
16715 If pragma Convention Fortran is specified for an array subtype, then in
16716 accordance with the implementation advice in section 3.6.2(11) of the
16717 Ada Reference Manual, the array will be stored in a Fortran-compatible
16718 column-major manner, instead of the normal default row-major order.
16720 @item Convention C and enumeration types
16721 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
16722 to accommodate all values of the type.  For example, for the enumeration
16723 type declared by:
16725 @smallexample @c ada
16726    type Color is (Red, Green, Blue);
16727 @end smallexample
16729 @noindent
16730 8 bits is sufficient to store all values of the type, so by default, objects
16731 of type @code{Color} will be represented using 8 bits.  However, normal C
16732 convention is to use 32 bits for all enum values in C, since enum values
16733 are essentially of type int.  If pragma @code{Convention C} is specified for an
16734 Ada enumeration type, then the size is modified as necessary (usually to
16735 32 bits) to be consistent with the C convention for enum values.
16737 Note that this treatment applies only to types. If Convention C is given for
16738 an enumeration object, where the enumeration type is not Convention C, then
16739 Object_Size bits are allocated. For example, for a normal enumeration type,
16740 with less than 256 elements, only 8 bits will be allocated for the object.
16741 Since this may be a surprise in terms of what C expects, GNAT will issue a
16742 warning in this situation. The warning can be suppressed by giving an explicit
16743 size clause specifying the desired size.
16745 @item Convention C/Fortran and Boolean types
16746 In C, the usual convention for boolean values, that is values used for
16747 conditions, is that zero represents false, and nonzero values represent
16748 true.  In Ada, the normal convention is that two specific values, typically
16749 0/1, are used to represent false/true respectively.
16751 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
16752 value represents true).
16754 To accommodate the Fortran and C conventions, if a pragma Convention specifies
16755 C or Fortran convention for a derived Boolean, as in the following example:
16757 @smallexample @c ada
16758    type C_Switch is new Boolean;
16759    pragma Convention (C, C_Switch);
16760 @end smallexample
16762 @noindent
16763 then the GNAT generated code will treat any nonzero value as true.  For truth
16764 values generated by GNAT, the conventional value 1 will be used for True, but
16765 when one of these values is read, any nonzero value is treated as True.
16767 @item Access types on OpenVMS
16768 For 64-bit OpenVMS systems, access types (other than those for unconstrained
16769 arrays) are 64-bits long. An exception to this rule is for the case of
16770 C-convention access types where there is no explicit size clause present (or
16771 inherited for derived types). In this case, GNAT chooses to make these
16772 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
16773 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
16775 @end itemize
16777 @node Conventions and Anonymous Access Types
16778 @section Conventions and Anonymous Access Types
16779 @cindex Anonymous access types
16780 @cindex Convention for anonymous access types
16782 The RM is not entirely clear on convention handling in a number of cases,
16783 and in particular, it is not clear on the convention to be given to
16784 anonymous access types in general, and in particular what is to be
16785 done for the case of anonymous access-to-subprogram.
16787 In GNAT, we decide that if an explicit Convention is applied
16788 to an object or component, and its type is such an anonymous type,
16789 then the convention will apply to this anonymous type as well. This
16790 seems to make sense since it is anomolous in any case to have a
16791 different convention for an object and its type, and there is clearly
16792 no way to explicitly specify a convention for an anonymous type, since
16793 it doesn't have a name to specify!
16795 Furthermore, we decide that if a convention is applied to a record type,
16796 then this convention is inherited by any of its components that are of an
16797 anonymous access type which do not have an explicitly specified convention.
16799 The following program shows these conventions in action:
16801 @smallexample @c ada
16802 package ConvComp is
16803    type Foo is range 1 .. 10;
16804    type T1 is record
16805       A : access function (X : Foo) return Integer;
16806       B : Integer;
16807    end record;
16808    pragma Convention (C, T1);
16810    type T2 is record
16811       A : access function (X : Foo) return Integer;
16812       pragma Convention  (C, A);
16813       B : Integer;
16814    end record;
16815    pragma Convention (COBOL, T2);
16817    type T3 is record
16818       A : access function (X : Foo) return Integer;
16819       pragma Convention  (COBOL, A);
16820       B : Integer;
16821    end record;
16822    pragma Convention (C, T3);
16824    type T4 is record
16825       A : access function (X : Foo) return Integer;
16826       B : Integer;
16827    end record;
16828    pragma Convention (COBOL, T4);
16830    function F (X : Foo) return Integer;
16831    pragma Convention (C, F);
16833    function F (X : Foo) return Integer is (13);
16835    TV1 : T1 := (F'Access, 12);  -- OK
16836    TV2 : T2 := (F'Access, 13);  -- OK
16838    TV3 : T3 := (F'Access, 13);  -- ERROR
16839                 |
16840 >>> subprogram "F" has wrong convention
16841 >>> does not match access to subprogram declared at line 17
16842      38.    TV4 : T4 := (F'Access, 13);  -- ERROR
16843                 |
16844 >>> subprogram "F" has wrong convention
16845 >>> does not match access to subprogram declared at line 24
16846      39. end ConvComp;
16847 @end smallexample
16849 @node Determining the Representations chosen by GNAT
16850 @section Determining the Representations chosen by GNAT
16851 @cindex Representation, determination of
16852 @cindex @option{-gnatR} switch
16854 @noindent
16855 Although the descriptions in this section are intended to be complete, it is
16856 often easier to simply experiment to see what GNAT accepts and what the
16857 effect is on the layout of types and objects.
16859 As required by the Ada RM, if a representation clause is not accepted, then
16860 it must be rejected as illegal by the compiler.  However, when a
16861 representation clause or pragma is accepted, there can still be questions
16862 of what the compiler actually does.  For example, if a partial record
16863 representation clause specifies the location of some components and not
16864 others, then where are the non-specified components placed? Or if pragma
16865 @code{Pack} is used on a record, then exactly where are the resulting
16866 fields placed? The section on pragma @code{Pack} in this chapter can be
16867 used to answer the second question, but it is often easier to just see
16868 what the compiler does.
16870 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
16871 with this option, then the compiler will output information on the actual
16872 representations chosen, in a format similar to source representation
16873 clauses.  For example, if we compile the package:
16875 @smallexample @c ada
16876 package q is
16877    type r (x : boolean) is tagged record
16878       case x is
16879          when True => S : String (1 .. 100);
16880          when False => null;
16881       end case;
16882    end record;
16884    type r2 is new r (false) with record
16885       y2 : integer;
16886    end record;
16888    for r2 use record
16889       y2 at 16 range 0 .. 31;
16890    end record;
16892    type x is record
16893       y : character;
16894    end record;
16896    type x1 is array (1 .. 10) of x;
16897    for x1'component_size use 11;
16899    type ia is access integer;
16901    type Rb1 is array (1 .. 13) of Boolean;
16902    pragma Pack (rb1);
16904    type Rb2 is array (1 .. 65) of Boolean;
16905    pragma Pack (rb2);
16907    type x2 is record
16908       l1 : Boolean;
16909       l2 : Duration;
16910       l3 : Float;
16911       l4 : Boolean;
16912       l5 : Rb1;
16913       l6 : Rb2;
16914    end record;
16915    pragma Pack (x2);
16916 end q;
16917 @end smallexample
16919 @noindent
16920 using the switch @option{-gnatR} we obtain the following output:
16922 @smallexample
16923 Representation information for unit q
16924 -------------------------------------
16926 for r'Size use ??;
16927 for r'Alignment use 4;
16928 for r use record
16929    x    at 4 range  0 .. 7;
16930    _tag at 0 range  0 .. 31;
16931    s    at 5 range  0 .. 799;
16932 end record;
16934 for r2'Size use 160;
16935 for r2'Alignment use 4;
16936 for r2 use record
16937    x       at  4 range  0 .. 7;
16938    _tag    at  0 range  0 .. 31;
16939    _parent at  0 range  0 .. 63;
16940    y2      at 16 range  0 .. 31;
16941 end record;
16943 for x'Size use 8;
16944 for x'Alignment use 1;
16945 for x use record
16946    y at 0 range  0 .. 7;
16947 end record;
16949 for x1'Size use 112;
16950 for x1'Alignment use 1;
16951 for x1'Component_Size use 11;
16953 for rb1'Size use 13;
16954 for rb1'Alignment use 2;
16955 for rb1'Component_Size use 1;
16957 for rb2'Size use 72;
16958 for rb2'Alignment use 1;
16959 for rb2'Component_Size use 1;
16961 for x2'Size use 224;
16962 for x2'Alignment use 4;
16963 for x2 use record
16964    l1 at  0 range  0 .. 0;
16965    l2 at  0 range  1 .. 64;
16966    l3 at 12 range  0 .. 31;
16967    l4 at 16 range  0 .. 0;
16968    l5 at 16 range  1 .. 13;
16969    l6 at 18 range  0 .. 71;
16970 end record;
16971 @end smallexample
16973 @noindent
16974 The Size values are actually the Object_Size, i.e.@: the default size that
16975 will be allocated for objects of the type.
16976 The ?? size for type r indicates that we have a variant record, and the
16977 actual size of objects will depend on the discriminant value.
16979 The Alignment values show the actual alignment chosen by the compiler
16980 for each record or array type.
16982 The record representation clause for type r shows where all fields
16983 are placed, including the compiler generated tag field (whose location
16984 cannot be controlled by the programmer).
16986 The record representation clause for the type extension r2 shows all the
16987 fields present, including the parent field, which is a copy of the fields
16988 of the parent type of r2, i.e.@: r1.
16990 The component size and size clauses for types rb1 and rb2 show
16991 the exact effect of pragma @code{Pack} on these arrays, and the record
16992 representation clause for type x2 shows how pragma @code{Pack} affects
16993 this record type.
16995 In some cases, it may be useful to cut and paste the representation clauses
16996 generated by the compiler into the original source to fix and guarantee
16997 the actual representation to be used.
16999 @node Standard Library Routines
17000 @chapter Standard Library Routines
17002 @noindent
17003 The Ada Reference Manual contains in Annex A a full description of an
17004 extensive set of standard library routines that can be used in any Ada
17005 program, and which must be provided by all Ada compilers.  They are
17006 analogous to the standard C library used by C programs.
17008 GNAT implements all of the facilities described in annex A, and for most
17009 purposes the description in the Ada Reference Manual, or appropriate Ada
17010 text book, will be sufficient for making use of these facilities.
17012 In the case of the input-output facilities,
17013 @xref{The Implementation of Standard I/O},
17014 gives details on exactly how GNAT interfaces to the
17015 file system.  For the remaining packages, the Ada Reference Manual
17016 should be sufficient.  The following is a list of the packages included,
17017 together with a brief description of the functionality that is provided.
17019 For completeness, references are included to other predefined library
17020 routines defined in other sections of the Ada Reference Manual (these are
17021 cross-indexed from Annex A). For further details see the relevant
17022 package declarations in the run-time library. In particular, a few units
17023 are not implemented, as marked by the presence of pragma Unimplemented_Unit,
17024 and in this case the package declaration contains comments explaining why
17025 the unit is not implemented.
17027 @table @code
17028 @item Ada (A.2)
17029 This is a parent package for all the standard library packages.  It is
17030 usually included implicitly in your program, and itself contains no
17031 useful data or routines.
17033 @item Ada.Assertions (11.4.2)
17034 @code{Assertions} provides the @code{Assert} subprograms, and also
17035 the declaration of the @code{Assertion_Error} exception.
17037 @item Ada.Asynchronous_Task_Control (D.11)
17038 @code{Asynchronous_Task_Control} provides low level facilities for task
17039 synchronization. It is typically not implemented. See package spec for details.
17041 @item Ada.Calendar (9.6)
17042 @code{Calendar} provides time of day access, and routines for
17043 manipulating times and durations.
17045 @item Ada.Calendar.Arithmetic (9.6.1)
17046 This package provides additional arithmetic
17047 operations for @code{Calendar}.
17049 @item Ada.Calendar.Formatting (9.6.1)
17050 This package provides formatting operations for @code{Calendar}.
17052 @item Ada.Calendar.Time_Zones (9.6.1)
17053 This package provides additional @code{Calendar} facilities
17054 for handling time zones.
17056 @item Ada.Characters (A.3.1)
17057 This is a dummy parent package that contains no useful entities
17059 @item Ada.Characters.Conversions (A.3.2)
17060 This package provides character conversion functions.
17062 @item Ada.Characters.Handling (A.3.2)
17063 This package provides some basic character handling capabilities,
17064 including classification functions for classes of characters (e.g.@: test
17065 for letters, or digits).
17067 @item Ada.Characters.Latin_1 (A.3.3)
17068 This package includes a complete set of definitions of the characters
17069 that appear in type CHARACTER@.  It is useful for writing programs that
17070 will run in international environments.  For example, if you want an
17071 upper case E with an acute accent in a string, it is often better to use
17072 the definition of @code{UC_E_Acute} in this package.  Then your program
17073 will print in an understandable manner even if your environment does not
17074 support these extended characters.
17076 @item Ada.Command_Line (A.15)
17077 This package provides access to the command line parameters and the name
17078 of the current program (analogous to the use of @code{argc} and @code{argv}
17079 in C), and also allows the exit status for the program to be set in a
17080 system-independent manner.
17082 @item Ada.Complex_Text_IO (G.1.3)
17083 This package provides text input and output of complex numbers.
17085 @item Ada.Containers (A.18.1)
17086 A top level package providing a few basic definitions used by all the
17087 following specific child packages that provide specific kinds of
17088 containers.
17090 @item Ada.Containers.Bounded_Priority_Queues (A.18.31)
17092 @item Ada.Containers.Bounded_Synchronized_Queues (A.18.29)
17094 @item Ada.Containers.Doubly_Linked_Lists (A.18.3)
17096 @item Ada.Containers.Generic_Array_Sort (A.18.26)
17098 @item Ada.Containers.Generic_Constrained_Array_Sort (A.18.26)
17100 @item Ada.Containers.Generic_Sort (A.18.26)
17102 @item Ada.Containers.Hashed_Maps (A.18.5)
17104 @item Ada.Containers.Hashed_Sets (A.18.8)
17106 @item Ada.Containers.Indefinite_Doubly_Linked_Lists (A.18.12)
17108 @item Ada.Containers.Indefinite_Hashed_Maps (A.18.13)
17110 @item Ada.Containers.Indefinite_Hashed_Sets (A.18.15)
17112 @item Ada.Containers.Indefinite_Holders (A.18.18)
17114 @item Ada.Containers.Indefinite_Multiway_Trees (A.18.17)
17116 @item Ada.Containers.Indefinite_Ordered_Maps (A.18.14)
17118 @item Ada.Containers.Indefinite_Ordered_Sets (A.18.16)
17120 @item Ada.Containers.Indefinite_Vectors (A.18.11)
17122 @item Ada.Containers.Multiway_Trees (A.18.10)
17124 @item Ada.Containers.Ordered_Maps (A.18.6)
17126 @item Ada.Containers.Ordered_Sets (A.18.9)
17128 @item Ada.Containers.Synchronized_Queue_Interfaces (A.18.27)
17130 @item Ada.Containers.Unbounded_Priority_Queues (A.18.30)
17132 @item Ada.Containers.Unbounded_Synchronized_Queues (A.18.28)
17134 @item Ada.Containers.Vectors (A.18.2)
17136 @item Ada.Directories (A.16)
17137 This package provides operations on directories.
17139 @item Ada.Directories.Hierarchical_File_Names (A.16.1)
17140 This package provides additional directory operations handling
17141 hiearchical file names.
17143 @item Ada.Directories.Information (A.16)
17144 This is an implementation defined package for additional directory
17145 operations, which is not implemented in GNAT.
17147 @item Ada.Decimal (F.2)
17148 This package provides constants describing the range of decimal numbers
17149 implemented, and also a decimal divide routine (analogous to the COBOL
17150 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
17152 @item Ada.Direct_IO (A.8.4)
17153 This package provides input-output using a model of a set of records of
17154 fixed-length, containing an arbitrary definite Ada type, indexed by an
17155 integer record number.
17157 @item Ada.Dispatching (D.2.1)
17158 A parent package containing definitions for task dispatching operations.
17160 @item Ada.Dispatching.EDF (D.2.6)
17161 Not implemented in GNAT.
17163 @item Ada.Dispatching.Non_Preemptive (D.2.4)
17164 Not implemented in GNAT.
17166 @item Ada.Dispatching.Round_Robin (D.2.5)
17167 Not implemented in GNAT.
17169 @item Ada.Dynamic_Priorities (D.5)
17170 This package allows the priorities of a task to be adjusted dynamically
17171 as the task is running.
17173 @item Ada.Environment_Variables (A.17)
17174 This package provides facilities for accessing environment variables.
17176 @item Ada.Exceptions (11.4.1)
17177 This package provides additional information on exceptions, and also
17178 contains facilities for treating exceptions as data objects, and raising
17179 exceptions with associated messages.
17181 @item Ada.Execution_Time (D.14)
17182 Not implemented in GNAT.
17184 @item Ada.Execution_Time.Group_Budgets (D.14.2)
17185 Not implemented in GNAT.
17187 @item Ada.Execution_Time.Timers (D.14.1)'
17188 Not implemented in GNAT.
17190 @item Ada.Finalization (7.6)
17191 This package contains the declarations and subprograms to support the
17192 use of controlled types, providing for automatic initialization and
17193 finalization (analogous to the constructors and destructors of C++).
17195 @item Ada.Float_Text_IO (A.10.9)
17196 A library level instantiation of Text_IO.Float_IO for type Float.
17198 @item Ada.Float_Wide_Text_IO (A.10.9)
17199 A library level instantiation of Wide_Text_IO.Float_IO for type Float.
17201 @item Ada.Float_Wide_Wide_Text_IO (A.10.9)
17202 A library level instantiation of Wide_Wide_Text_IO.Float_IO for type Float.
17204 @item Ada.Integer_Text_IO (A.10.9)
17205 A library level instantiation of Text_IO.Integer_IO for type Integer.
17207 @item Ada.Integer_Wide_Text_IO (A.10.9)
17208 A library level instantiation of Wide_Text_IO.Integer_IO for type Integer.
17210 @item Ada.Integer_Wide_Wide_Text_IO (A.10.9)
17211 A library level instantiation of Wide_Wide_Text_IO.Integer_IO for type Integer.
17213 @item Ada.Interrupts (C.3.2)
17214 This package provides facilities for interfacing to interrupts, which
17215 includes the set of signals or conditions that can be raised and
17216 recognized as interrupts.
17218 @item Ada.Interrupts.Names (C.3.2)
17219 This package provides the set of interrupt names (actually signal
17220 or condition names) that can be handled by GNAT@.
17222 @item Ada.IO_Exceptions (A.13)
17223 This package defines the set of exceptions that can be raised by use of
17224 the standard IO packages.
17226 @item Ada.Iterator_Interfaces (5.5.1)
17227 This package provides a generic interface to generalized iterators.
17229 @item Ada.Locales (A.19)
17230 This package provides declarations providing information (Language
17231 and Country) about the current locale.
17233 @item Ada.Numerics
17234 This package contains some standard constants and exceptions used
17235 throughout the numerics packages.  Note that the constants pi and e are
17236 defined here, and it is better to use these definitions than rolling
17237 your own.
17239 @item Ada.Numerics.Complex_Arrays (G.3.2)
17240 Provides operations on arrays of complex numbers.
17242 @item Ada.Numerics.Complex_Elementary_Functions
17243 Provides the implementation of standard elementary functions (such as
17244 log and trigonometric functions) operating on complex numbers using the
17245 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
17246 created by the package @code{Numerics.Complex_Types}.
17248 @item Ada.Numerics.Complex_Types
17249 This is a predefined instantiation of
17250 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
17251 build the type @code{Complex} and @code{Imaginary}.
17253 @item Ada.Numerics.Discrete_Random
17254 This generic package provides a random number generator suitable for generating
17255 uniformly distributed values of a specified discrete subtype.
17257 @item Ada.Numerics.Float_Random
17258 This package provides a random number generator suitable for generating
17259 uniformly distributed floating point values in the unit interval.
17261 @item Ada.Numerics.Generic_Complex_Elementary_Functions
17262 This is a generic version of the package that provides the
17263 implementation of standard elementary functions (such as log and
17264 trigonometric functions) for an arbitrary complex type.
17266 The following predefined instantiations of this package are provided:
17268 @table @code
17269 @item Short_Float
17270 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
17271 @item Float
17272 @code{Ada.Numerics.Complex_Elementary_Functions}
17273 @item Long_Float
17274 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
17275 @end table
17277 @item Ada.Numerics.Generic_Complex_Types
17278 This is a generic package that allows the creation of complex types,
17279 with associated complex arithmetic operations.
17281 The following predefined instantiations of this package exist
17282 @table @code
17283 @item Short_Float
17284 @code{Ada.Numerics.Short_Complex_Complex_Types}
17285 @item Float
17286 @code{Ada.Numerics.Complex_Complex_Types}
17287 @item Long_Float
17288 @code{Ada.Numerics.Long_Complex_Complex_Types}
17289 @end table
17291 @item Ada.Numerics.Generic_Elementary_Functions
17292 This is a generic package that provides the implementation of standard
17293 elementary functions (such as log an trigonometric functions) for an
17294 arbitrary float type.
17296 The following predefined instantiations of this package exist
17298 @table @code
17299 @item Short_Float
17300 @code{Ada.Numerics.Short_Elementary_Functions}
17301 @item Float
17302 @code{Ada.Numerics.Elementary_Functions}
17303 @item Long_Float
17304 @code{Ada.Numerics.Long_Elementary_Functions}
17305 @end table
17307 @item Ada.Numerics.Generic_Real_Arrays (G.3.1)
17308 Generic operations on arrays of reals
17310 @item Ada.Numerics.Real_Arrays (G.3.1)
17311 Preinstantiation of Ada.Numerics.Generic_Real_Arrays (Float).
17313 @item Ada.Real_Time (D.8)
17314 This package provides facilities similar to those of @code{Calendar}, but
17315 operating with a finer clock suitable for real time control. Note that
17316 annex D requires that there be no backward clock jumps, and GNAT generally
17317 guarantees this behavior, but of course if the external clock on which
17318 the GNAT runtime depends is deliberately reset by some external event,
17319 then such a backward jump may occur.
17321 @item Ada.Real_Time.Timing_Events (D.15)
17322 Not implemented in GNAT.
17324 @item Ada.Sequential_IO (A.8.1)
17325 This package provides input-output facilities for sequential files,
17326 which can contain a sequence of values of a single type, which can be
17327 any Ada type, including indefinite (unconstrained) types.
17329 @item Ada.Storage_IO (A.9)
17330 This package provides a facility for mapping arbitrary Ada types to and
17331 from a storage buffer.  It is primarily intended for the creation of new
17332 IO packages.
17334 @item Ada.Streams (13.13.1)
17335 This is a generic package that provides the basic support for the
17336 concept of streams as used by the stream attributes (@code{Input},
17337 @code{Output}, @code{Read} and @code{Write}).
17339 @item Ada.Streams.Stream_IO (A.12.1)
17340 This package is a specialization of the type @code{Streams} defined in
17341 package @code{Streams} together with a set of operations providing
17342 Stream_IO capability.  The Stream_IO model permits both random and
17343 sequential access to a file which can contain an arbitrary set of values
17344 of one or more Ada types.
17346 @item Ada.Strings (A.4.1)
17347 This package provides some basic constants used by the string handling
17348 packages.
17350 @item Ada.Strings.Bounded (A.4.4)
17351 This package provides facilities for handling variable length
17352 strings.  The bounded model requires a maximum length.  It is thus
17353 somewhat more limited than the unbounded model, but avoids the use of
17354 dynamic allocation or finalization.
17356 @item Ada.Strings.Bounded.Equal_Case_Insensitive (A.4.10)
17357 Provides case-insensitive comparisons of bounded strings
17359 @item Ada.Strings.Bounded.Hash (A.4.9)
17360 This package provides a generic hash function for bounded strings
17362 @item Ada.Strings.Bounded.Hash_Case_Insensitive (A.4.9)
17363 This package provides a generic hash function for bounded strings that
17364 converts the string to be hashed to lower case.
17366 @item Ada.Strings.Bounded.Less_Case_Insensitive (A.4.10)
17367 This package provides a comparison function for bounded strings that works
17368 in a case insensitive manner by converting to lower case before the comparison.
17370 @item Ada.Strings.Fixed (A.4.3)
17371 This package provides facilities for handling fixed length strings.
17373 @item Ada.Strings.Fixed.Equal_Case_Insensitive (A.4.10)
17374 This package provides an equality function for fixed strings that compares
17375 the strings after converting both to lower case.
17377 @item Ada.Strings.Fixed.Hash_Case_Insensitive (A.4.9)
17378 This package provides a case insensitive hash function for fixed strings that
17379 converts the string to lower case before computing the hash.
17381 @item Ada.Strings.Fixed.Less_Case_Insensitive (A.4.10)
17382 This package provides a comparison function for fixed strings that works
17383 in a case insensitive manner by converting to lower case before the comparison.
17385 Ada.Strings.Hash (A.4.9)
17386 This package provides a hash function for strings.
17388 Ada.Strings.Hash_Case_Insensitive (A.4.9)
17389 This package provides a hash function for strings that is case insensitive.
17390 The string is converted to lower case before computing the hash.
17392 @item Ada.Strings.Less_Case_Insensitive (A.4.10)
17393 This package provides a comparison function for\strings that works
17394 in a case insensitive manner by converting to lower case before the comparison.
17396 @item Ada.Strings.Maps (A.4.2)
17397 This package provides facilities for handling character mappings and
17398 arbitrarily defined subsets of characters.  For instance it is useful in
17399 defining specialized translation tables.
17401 @item Ada.Strings.Maps.Constants (A.4.6)
17402 This package provides a standard set of predefined mappings and
17403 predefined character sets.  For example, the standard upper to lower case
17404 conversion table is found in this package.  Note that upper to lower case
17405 conversion is non-trivial if you want to take the entire set of
17406 characters, including extended characters like E with an acute accent,
17407 into account.  You should use the mappings in this package (rather than
17408 adding 32 yourself) to do case mappings.
17410 @item Ada.Strings.Unbounded (A.4.5)
17411 This package provides facilities for handling variable length
17412 strings.  The unbounded model allows arbitrary length strings, but
17413 requires the use of dynamic allocation and finalization.
17415 @item Ada.Strings.Unbounded.Equal_Case_Insensitive (A.4.10)
17416 Provides case-insensitive comparisons of unbounded strings
17418 @item Ada.Strings.Unbounded.Hash (A.4.9)
17419 This package provides a generic hash function for unbounded strings
17421 @item Ada.Strings.Unbounded.Hash_Case_Insensitive (A.4.9)
17422 This package provides a generic hash function for unbounded strings that
17423 converts the string to be hashed to lower case.
17425 @item Ada.Strings.Unbounded.Less_Case_Insensitive (A.4.10)
17426 This package provides a comparison function for unbounded strings that works
17427 in a case insensitive manner by converting to lower case before the comparison.
17429 @item Ada.Strings.UTF_Encoding (A.4.11)
17430 This package provides basic definitions for dealing with UTF-encoded strings.
17432 @item Ada.Strings.UTF_Encoding.Conversions (A.4.11)
17433 This package provides conversion functions for UTF-encoded strings.
17435 @item Ada.Strings.UTF_Encoding.Strings (A.4.11)
17436 @itemx Ada.Strings.UTF_Encoding.Wide_Strings (A.4.11)
17437 @itemx Ada.Strings.UTF_Encoding.Wide_Wide_Strings (A.4.11)
17438 These packages provide facilities for handling UTF encodings for
17439 Strings, Wide_Strings and Wide_Wide_Strings.
17441 @item Ada.Strings.Wide_Bounded (A.4.7)
17442 @itemx Ada.Strings.Wide_Fixed (A.4.7)
17443 @itemx Ada.Strings.Wide_Maps (A.4.7)
17444 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
17445 These packages provide analogous capabilities to the corresponding
17446 packages without @samp{Wide_} in the name, but operate with the types
17447 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
17448 and @code{Character}. Versions of all the child packages are available.
17450 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
17451 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
17452 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
17453 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
17454 These packages provide analogous capabilities to the corresponding
17455 packages without @samp{Wide_} in the name, but operate with the types
17456 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
17457 of @code{String} and @code{Character}.
17459 @item Ada.Synchronous_Barriers (D.10.1)
17460 This package provides facilities for synchronizing tasks at a low level
17461 with barriers.
17463 @item Ada.Synchronous_Task_Control (D.10)
17464 This package provides some standard facilities for controlling task
17465 communication in a synchronous manner.
17467 @item Ada.Synchronous_Task_Control.EDF (D.10)
17468 Not implemented in GNAT.
17470 @item Ada.Tags
17471 This package contains definitions for manipulation of the tags of tagged
17472 values.
17474 @item Ada.Tags.Generic_Dispatching_Constructor (3.9)
17475 This package provides a way of constructing tagged class-wide values given
17476 only the tag value.
17478 @item Ada.Task_Attributes (C.7.2)
17479 This package provides the capability of associating arbitrary
17480 task-specific data with separate tasks.
17482 @item Ada.Task_Identifification (C.7.1)
17483 This package provides capabilities for task identification.
17485 @item Ada.Task_Termination (C.7.3)
17486 This package provides control over task termination.
17488 @item Ada.Text_IO
17489 This package provides basic text input-output capabilities for
17490 character, string and numeric data.  The subpackages of this
17491 package are listed next. Note that although these are defined
17492 as subpackages in the RM, they are actually transparently
17493 implemented as child packages in GNAT, meaning that they
17494 are only loaded if needed.
17496 @item Ada.Text_IO.Decimal_IO
17497 Provides input-output facilities for decimal fixed-point types
17499 @item Ada.Text_IO.Enumeration_IO
17500 Provides input-output facilities for enumeration types.
17502 @item Ada.Text_IO.Fixed_IO
17503 Provides input-output facilities for ordinary fixed-point types.
17505 @item Ada.Text_IO.Float_IO
17506 Provides input-output facilities for float types.  The following
17507 predefined instantiations of this generic package are available:
17509 @table @code
17510 @item Short_Float
17511 @code{Short_Float_Text_IO}
17512 @item Float
17513 @code{Float_Text_IO}
17514 @item Long_Float
17515 @code{Long_Float_Text_IO}
17516 @end table
17518 @item Ada.Text_IO.Integer_IO
17519 Provides input-output facilities for integer types.  The following
17520 predefined instantiations of this generic package are available:
17522 @table @code
17523 @item Short_Short_Integer
17524 @code{Ada.Short_Short_Integer_Text_IO}
17525 @item Short_Integer
17526 @code{Ada.Short_Integer_Text_IO}
17527 @item Integer
17528 @code{Ada.Integer_Text_IO}
17529 @item Long_Integer
17530 @code{Ada.Long_Integer_Text_IO}
17531 @item Long_Long_Integer
17532 @code{Ada.Long_Long_Integer_Text_IO}
17533 @end table
17535 @item Ada.Text_IO.Modular_IO
17536 Provides input-output facilities for modular (unsigned) types.
17538 @item Ada.Text_IO.Bounded_IO (A.10.11)
17539 Provides input-output facilities for bounded strings.
17541 @item Ada.Text_IO.Complex_IO (G.1.3)
17542 This package provides basic text input-output capabilities for complex
17543 data.
17545 @item Ada.Text_IO.Editing (F.3.3)
17546 This package contains routines for edited output, analogous to the use
17547 of pictures in COBOL@.  The picture formats used by this package are a
17548 close copy of the facility in COBOL@.
17550 @item Ada.Text_IO.Text_Streams (A.12.2)
17551 This package provides a facility that allows Text_IO files to be treated
17552 as streams, so that the stream attributes can be used for writing
17553 arbitrary data, including binary data, to Text_IO files.
17555 @item Ada.Text_IO.Unbounded_IO (A.10.12)
17556 This package provides input-output facilities for unbounded strings.
17558 @item Ada.Unchecked_Conversion (13.9)
17559 This generic package allows arbitrary conversion from one type to
17560 another of the same size, providing for breaking the type safety in
17561 special circumstances.
17563 If the types have the same Size (more accurately the same Value_Size),
17564 then the effect is simply to transfer the bits from the source to the
17565 target type without any modification.  This usage is well defined, and
17566 for simple types whose representation is typically the same across
17567 all implementations, gives a portable method of performing such
17568 conversions.
17570 If the types do not have the same size, then the result is implementation
17571 defined, and thus may be non-portable.  The following describes how GNAT
17572 handles such unchecked conversion cases.
17574 If the types are of different sizes, and are both discrete types, then
17575 the effect is of a normal type conversion without any constraint checking.
17576 In particular if the result type has a larger size, the result will be
17577 zero or sign extended.  If the result type has a smaller size, the result
17578 will be truncated by ignoring high order bits.
17580 If the types are of different sizes, and are not both discrete types,
17581 then the conversion works as though pointers were created to the source
17582 and target, and the pointer value is converted.  The effect is that bits
17583 are copied from successive low order storage units and bits of the source
17584 up to the length of the target type.
17586 A warning is issued if the lengths differ, since the effect in this
17587 case is implementation dependent, and the above behavior may not match
17588 that of some other compiler.
17590 A pointer to one type may be converted to a pointer to another type using
17591 unchecked conversion.  The only case in which the effect is undefined is
17592 when one or both pointers are pointers to unconstrained array types.  In
17593 this case, the bounds information may get incorrectly transferred, and in
17594 particular, GNAT uses double size pointers for such types, and it is
17595 meaningless to convert between such pointer types.  GNAT will issue a
17596 warning if the alignment of the target designated type is more strict
17597 than the alignment of the source designated type (since the result may
17598 be unaligned in this case).
17600 A pointer other than a pointer to an unconstrained array type may be
17601 converted to and from System.Address.  Such usage is common in Ada 83
17602 programs, but note that Ada.Address_To_Access_Conversions is the
17603 preferred method of performing such conversions in Ada 95 and Ada 2005.
17604 Neither
17605 unchecked conversion nor Ada.Address_To_Access_Conversions should be
17606 used in conjunction with pointers to unconstrained objects, since
17607 the bounds information cannot be handled correctly in this case.
17609 @item Ada.Unchecked_Deallocation (13.11.2)
17610 This generic package allows explicit freeing of storage previously
17611 allocated by use of an allocator.
17613 @item Ada.Wide_Text_IO (A.11)
17614 This package is similar to @code{Ada.Text_IO}, except that the external
17615 file supports wide character representations, and the internal types are
17616 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17617 and @code{String}. The corresponding set of nested packages and child
17618 packages are defined.
17620 @item Ada.Wide_Wide_Text_IO (A.11)
17621 This package is similar to @code{Ada.Text_IO}, except that the external
17622 file supports wide character representations, and the internal types are
17623 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17624 and @code{String}. The corresponding set of nested packages and child
17625 packages are defined.
17627 @end table
17629 For packages in Interfaces and System, all the RM defined packages are
17630 available in GNAT, see the Ada 2012 RM for full details.
17632 @node The Implementation of Standard I/O
17633 @chapter The Implementation of Standard I/O
17635 @noindent
17636 GNAT implements all the required input-output facilities described in
17637 A.6 through A.14.  These sections of the Ada Reference Manual describe the
17638 required behavior of these packages from the Ada point of view, and if
17639 you are writing a portable Ada program that does not need to know the
17640 exact manner in which Ada maps to the outside world when it comes to
17641 reading or writing external files, then you do not need to read this
17642 chapter.  As long as your files are all regular files (not pipes or
17643 devices), and as long as you write and read the files only from Ada, the
17644 description in the Ada Reference Manual is sufficient.
17646 However, if you want to do input-output to pipes or other devices, such
17647 as the keyboard or screen, or if the files you are dealing with are
17648 either generated by some other language, or to be read by some other
17649 language, then you need to know more about the details of how the GNAT
17650 implementation of these input-output facilities behaves.
17652 In this chapter we give a detailed description of exactly how GNAT
17653 interfaces to the file system.  As always, the sources of the system are
17654 available to you for answering questions at an even more detailed level,
17655 but for most purposes the information in this chapter will suffice.
17657 Another reason that you may need to know more about how input-output is
17658 implemented arises when you have a program written in mixed languages
17659 where, for example, files are shared between the C and Ada sections of
17660 the same program.  GNAT provides some additional facilities, in the form
17661 of additional child library packages, that facilitate this sharing, and
17662 these additional facilities are also described in this chapter.
17664 @menu
17665 * Standard I/O Packages::
17666 * FORM Strings::
17667 * Direct_IO::
17668 * Sequential_IO::
17669 * Text_IO::
17670 * Wide_Text_IO::
17671 * Wide_Wide_Text_IO::
17672 * Stream_IO::
17673 * Text Translation::
17674 * Shared Files::
17675 * Filenames encoding::
17676 * File content encoding::
17677 * Open Modes::
17678 * Operations on C Streams::
17679 * Interfacing to C Streams::
17680 @end menu
17682 @node Standard I/O Packages
17683 @section Standard I/O Packages
17685 @noindent
17686 The Standard I/O packages described in Annex A for
17688 @itemize @bullet
17689 @item
17690 Ada.Text_IO
17691 @item
17692 Ada.Text_IO.Complex_IO
17693 @item
17694 Ada.Text_IO.Text_Streams
17695 @item
17696 Ada.Wide_Text_IO
17697 @item
17698 Ada.Wide_Text_IO.Complex_IO
17699 @item
17700 Ada.Wide_Text_IO.Text_Streams
17701 @item
17702 Ada.Wide_Wide_Text_IO
17703 @item
17704 Ada.Wide_Wide_Text_IO.Complex_IO
17705 @item
17706 Ada.Wide_Wide_Text_IO.Text_Streams
17707 @item
17708 Ada.Stream_IO
17709 @item
17710 Ada.Sequential_IO
17711 @item
17712 Ada.Direct_IO
17713 @end itemize
17715 @noindent
17716 are implemented using the C
17717 library streams facility; where
17719 @itemize @bullet
17720 @item
17721 All files are opened using @code{fopen}.
17722 @item
17723 All input/output operations use @code{fread}/@code{fwrite}.
17724 @end itemize
17726 @noindent
17727 There is no internal buffering of any kind at the Ada library level. The only
17728 buffering is that provided at the system level in the implementation of the
17729 library routines that support streams. This facilitates shared use of these
17730 streams by mixed language programs. Note though that system level buffering is
17731 explicitly enabled at elaboration of the standard I/O packages and that can
17732 have an impact on mixed language programs, in particular those using I/O before
17733 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
17734 the Ada elaboration routine before performing any I/O or when impractical,
17735 flush the common I/O streams and in particular Standard_Output before
17736 elaborating the Ada code.
17738 @node FORM Strings
17739 @section FORM Strings
17741 @noindent
17742 The format of a FORM string in GNAT is:
17744 @smallexample
17745 "keyword=value,keyword=value,@dots{},keyword=value"
17746 @end smallexample
17748 @noindent
17749 where letters may be in upper or lower case, and there are no spaces
17750 between values.  The order of the entries is not important.  Currently
17751 the following keywords defined.
17753 @smallexample
17754 TEXT_TRANSLATION=[YES|NO|TEXT|BINARY|U8TEXT|WTEXT|U16TEXT]
17755 SHARED=[YES|NO]
17756 WCEM=[n|h|u|s|e|8|b]
17757 ENCODING=[UTF8|8BITS]
17758 @end smallexample
17760 @noindent
17761 The use of these parameters is described later in this section. If an
17762 unrecognized keyword appears in a form string, it is silently ignored
17763 and not considered invalid.
17765 @noindent
17766 For OpenVMS additional FORM string keywords are available for use with
17767 RMS services.  The syntax is:
17769 @smallexample
17770 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
17771 @end smallexample
17773 @noindent
17774 The following RMS keywords and values are currently defined:
17776 @smallexample
17777 Context=Force_Stream_Mode|Force_Record_Mode
17778 @end smallexample
17780 @noindent
17781 VMS RMS keys are silently ignored on non-VMS systems.  On OpenVMS
17782 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
17784 @node Direct_IO
17785 @section Direct_IO
17787 @noindent
17788 Direct_IO can only be instantiated for definite types.  This is a
17789 restriction of the Ada language, which means that the records are fixed
17790 length (the length being determined by @code{@var{type}'Size}, rounded
17791 up to the next storage unit boundary if necessary).
17793 The records of a Direct_IO file are simply written to the file in index
17794 sequence, with the first record starting at offset zero, and subsequent
17795 records following.  There is no control information of any kind.  For
17796 example, if 32-bit integers are being written, each record takes
17797 4-bytes, so the record at index @var{K} starts at offset
17798 (@var{K}@minus{}1)*4.
17800 There is no limit on the size of Direct_IO files, they are expanded as
17801 necessary to accommodate whatever records are written to the file.
17803 @node Sequential_IO
17804 @section Sequential_IO
17806 @noindent
17807 Sequential_IO may be instantiated with either a definite (constrained)
17808 or indefinite (unconstrained) type.
17810 For the definite type case, the elements written to the file are simply
17811 the memory images of the data values with no control information of any
17812 kind.  The resulting file should be read using the same type, no validity
17813 checking is performed on input.
17815 For the indefinite type case, the elements written consist of two
17816 parts.  First is the size of the data item, written as the memory image
17817 of a @code{Interfaces.C.size_t} value, followed by the memory image of
17818 the data value.  The resulting file can only be read using the same
17819 (unconstrained) type.  Normal assignment checks are performed on these
17820 read operations, and if these checks fail, @code{Data_Error} is
17821 raised.  In particular, in the array case, the lengths must match, and in
17822 the variant record case, if the variable for a particular read operation
17823 is constrained, the discriminants must match.
17825 Note that it is not possible to use Sequential_IO to write variable
17826 length array items, and then read the data back into different length
17827 arrays.  For example, the following will raise @code{Data_Error}:
17829 @smallexample @c ada
17830  package IO is new Sequential_IO (String);
17831  F : IO.File_Type;
17832  S : String (1..4);
17833  @dots{}
17834  IO.Create (F)
17835  IO.Write (F, "hello!")
17836  IO.Reset (F, Mode=>In_File);
17837  IO.Read (F, S);
17838  Put_Line (S);
17840 @end smallexample
17842 @noindent
17843 On some Ada implementations, this will print @code{hell}, but the program is
17844 clearly incorrect, since there is only one element in the file, and that
17845 element is the string @code{hello!}.
17847 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
17848 using Stream_IO, and this is the preferred mechanism.  In particular, the
17849 above program fragment rewritten to use Stream_IO will work correctly.
17851 @node Text_IO
17852 @section Text_IO
17854 @noindent
17855 Text_IO files consist of a stream of characters containing the following
17856 special control characters:
17858 @smallexample
17859 LF (line feed, 16#0A#) Line Mark
17860 FF (form feed, 16#0C#) Page Mark
17861 @end smallexample
17863 @noindent
17864 A canonical Text_IO file is defined as one in which the following
17865 conditions are met:
17867 @itemize @bullet
17868 @item
17869 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
17870 of the line.
17872 @item
17873 The character @code{FF} is used only as a page mark, i.e.@: to mark the
17874 end of a page and consequently can appear only immediately following a
17875 @code{LF} (line mark) character.
17877 @item
17878 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
17879 (line mark, page mark).  In the former case, the page mark is implicitly
17880 assumed to be present.
17881 @end itemize
17883 @noindent
17884 A file written using Text_IO will be in canonical form provided that no
17885 explicit @code{LF} or @code{FF} characters are written using @code{Put}
17886 or @code{Put_Line}.  There will be no @code{FF} character at the end of
17887 the file unless an explicit @code{New_Page} operation was performed
17888 before closing the file.
17890 A canonical Text_IO file that is a regular file (i.e., not a device or a
17891 pipe) can be read using any of the routines in Text_IO@.  The
17892 semantics in this case will be exactly as defined in the Ada Reference
17893 Manual, and all the routines in Text_IO are fully implemented.
17895 A text file that does not meet the requirements for a canonical Text_IO
17896 file has one of the following:
17898 @itemize @bullet
17899 @item
17900 The file contains @code{FF} characters not immediately following a
17901 @code{LF} character.
17903 @item
17904 The file contains @code{LF} or @code{FF} characters written by
17905 @code{Put} or @code{Put_Line}, which are not logically considered to be
17906 line marks or page marks.
17908 @item
17909 The file ends in a character other than @code{LF} or @code{FF},
17910 i.e.@: there is no explicit line mark or page mark at the end of the file.
17911 @end itemize
17913 @noindent
17914 Text_IO can be used to read such non-standard text files but subprograms
17915 to do with line or page numbers do not have defined meanings.  In
17916 particular, a @code{FF} character that does not follow a @code{LF}
17917 character may or may not be treated as a page mark from the point of
17918 view of page and line numbering.  Every @code{LF} character is considered
17919 to end a line, and there is an implied @code{LF} character at the end of
17920 the file.
17922 @menu
17923 * Text_IO Stream Pointer Positioning::
17924 * Text_IO Reading and Writing Non-Regular Files::
17925 * Get_Immediate::
17926 * Treating Text_IO Files as Streams::
17927 * Text_IO Extensions::
17928 * Text_IO Facilities for Unbounded Strings::
17929 @end menu
17931 @node Text_IO Stream Pointer Positioning
17932 @subsection Stream Pointer Positioning
17934 @noindent
17935 @code{Ada.Text_IO} has a definition of current position for a file that
17936 is being read.  No internal buffering occurs in Text_IO, and usually the
17937 physical position in the stream used to implement the file corresponds
17938 to this logical position defined by Text_IO@.  There are two exceptions:
17940 @itemize @bullet
17941 @item
17942 After a call to @code{End_Of_Page} that returns @code{True}, the stream
17943 is positioned past the @code{LF} (line mark) that precedes the page
17944 mark.  Text_IO maintains an internal flag so that subsequent read
17945 operations properly handle the logical position which is unchanged by
17946 the @code{End_Of_Page} call.
17948 @item
17949 After a call to @code{End_Of_File} that returns @code{True}, if the
17950 Text_IO file was positioned before the line mark at the end of file
17951 before the call, then the logical position is unchanged, but the stream
17952 is physically positioned right at the end of file (past the line mark,
17953 and past a possible page mark following the line mark.  Again Text_IO
17954 maintains internal flags so that subsequent read operations properly
17955 handle the logical position.
17956 @end itemize
17958 @noindent
17959 These discrepancies have no effect on the observable behavior of
17960 Text_IO, but if a single Ada stream is shared between a C program and
17961 Ada program, or shared (using @samp{shared=yes} in the form string)
17962 between two Ada files, then the difference may be observable in some
17963 situations.
17965 @node Text_IO Reading and Writing Non-Regular Files
17966 @subsection Reading and Writing Non-Regular Files
17968 @noindent
17969 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
17970 can be used for reading and writing.  Writing is not affected and the
17971 sequence of characters output is identical to the normal file case, but
17972 for reading, the behavior of Text_IO is modified to avoid undesirable
17973 look-ahead as follows:
17975 An input file that is not a regular file is considered to have no page
17976 marks.  Any @code{Ascii.FF} characters (the character normally used for a
17977 page mark) appearing in the file are considered to be data
17978 characters.  In particular:
17980 @itemize @bullet
17981 @item
17982 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
17983 following a line mark.  If a page mark appears, it will be treated as a
17984 data character.
17986 @item
17987 This avoids the need to wait for an extra character to be typed or
17988 entered from the pipe to complete one of these operations.
17990 @item
17991 @code{End_Of_Page} always returns @code{False}
17993 @item
17994 @code{End_Of_File} will return @code{False} if there is a page mark at
17995 the end of the file.
17996 @end itemize
17998 @noindent
17999 Output to non-regular files is the same as for regular files.  Page marks
18000 may be written to non-regular files using @code{New_Page}, but as noted
18001 above they will not be treated as page marks on input if the output is
18002 piped to another Ada program.
18004 Another important discrepancy when reading non-regular files is that the end
18005 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
18006 pressing the @key{EOT} key,
18007 then end of file
18008 is signaled once (i.e.@: the test @code{End_Of_File}
18009 will yield @code{True}, or a read will
18010 raise @code{End_Error}), but then reading can resume
18011 to read data past that end of
18012 file indication, until another end of file indication is entered.
18014 @node Get_Immediate
18015 @subsection Get_Immediate
18016 @cindex Get_Immediate
18018 @noindent
18019 Get_Immediate returns the next character (including control characters)
18020 from the input file.  In particular, Get_Immediate will return LF or FF
18021 characters used as line marks or page marks.  Such operations leave the
18022 file positioned past the control character, and it is thus not treated
18023 as having its normal function.  This means that page, line and column
18024 counts after this kind of Get_Immediate call are set as though the mark
18025 did not occur.  In the case where a Get_Immediate leaves the file
18026 positioned between the line mark and page mark (which is not normally
18027 possible), it is undefined whether the FF character will be treated as a
18028 page mark.
18030 @node Treating Text_IO Files as Streams
18031 @subsection Treating Text_IO Files as Streams
18032 @cindex Stream files
18034 @noindent
18035 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
18036 as a stream.  Data written to a Text_IO file in this stream mode is
18037 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
18038 16#0C# (@code{FF}), the resulting file may have non-standard
18039 format.  Similarly if read operations are used to read from a Text_IO
18040 file treated as a stream, then @code{LF} and @code{FF} characters may be
18041 skipped and the effect is similar to that described above for
18042 @code{Get_Immediate}.
18044 @node Text_IO Extensions
18045 @subsection Text_IO Extensions
18046 @cindex Text_IO extensions
18048 @noindent
18049 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
18050 to the standard @code{Text_IO} package:
18052 @itemize @bullet
18053 @item function File_Exists (Name : String) return Boolean;
18054 Determines if a file of the given name exists.
18056 @item function Get_Line return String;
18057 Reads a string from the standard input file.  The value returned is exactly
18058 the length of the line that was read.
18060 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
18061 Similar, except that the parameter File specifies the file from which
18062 the string is to be read.
18064 @end itemize
18066 @node Text_IO Facilities for Unbounded Strings
18067 @subsection Text_IO Facilities for Unbounded Strings
18068 @cindex Text_IO for unbounded strings
18069 @cindex Unbounded_String, Text_IO operations
18071 @noindent
18072 The package @code{Ada.Strings.Unbounded.Text_IO}
18073 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
18074 subprograms useful for Text_IO operations on unbounded strings:
18076 @itemize @bullet
18078 @item function Get_Line (File : File_Type) return Unbounded_String;
18079 Reads a line from the specified file
18080 and returns the result as an unbounded string.
18082 @item procedure Put (File : File_Type; U : Unbounded_String);
18083 Writes the value of the given unbounded string to the specified file
18084 Similar to the effect of
18085 @code{Put (To_String (U))} except that an extra copy is avoided.
18087 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
18088 Writes the value of the given unbounded string to the specified file,
18089 followed by a @code{New_Line}.
18090 Similar to the effect of @code{Put_Line (To_String (U))} except
18091 that an extra copy is avoided.
18092 @end itemize
18094 @noindent
18095 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
18096 and is optional.  If the parameter is omitted, then the standard input or
18097 output file is referenced as appropriate.
18099 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
18100 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
18101 @code{Wide_Text_IO} functionality for unbounded wide strings.
18103 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
18104 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
18105 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
18107 @node Wide_Text_IO
18108 @section Wide_Text_IO
18110 @noindent
18111 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
18112 both input and output files may contain special sequences that represent
18113 wide character values.  The encoding scheme for a given file may be
18114 specified using a FORM parameter:
18116 @smallexample
18117 WCEM=@var{x}
18118 @end smallexample
18120 @noindent
18121 as part of the FORM string (WCEM = wide character encoding method),
18122 where @var{x} is one of the following characters
18124 @table @samp
18125 @item h
18126 Hex ESC encoding
18127 @item u
18128 Upper half encoding
18129 @item s
18130 Shift-JIS encoding
18131 @item e
18132 EUC Encoding
18133 @item 8
18134 UTF-8 encoding
18135 @item b
18136 Brackets encoding
18137 @end table
18139 @noindent
18140 The encoding methods match those that
18141 can be used in a source
18142 program, but there is no requirement that the encoding method used for
18143 the source program be the same as the encoding method used for files,
18144 and different files may use different encoding methods.
18146 The default encoding method for the standard files, and for opened files
18147 for which no WCEM parameter is given in the FORM string matches the
18148 wide character encoding specified for the main program (the default
18149 being brackets encoding if no coding method was specified with -gnatW).
18151 @table @asis
18152 @item Hex Coding
18153 In this encoding, a wide character is represented by a five character
18154 sequence:
18156 @smallexample
18157 ESC a b c d
18158 @end smallexample
18160 @noindent
18161 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
18162 characters (using upper case letters) of the wide character code.  For
18163 example, ESC A345 is used to represent the wide character with code
18164 16#A345#.  This scheme is compatible with use of the full
18165 @code{Wide_Character} set.
18167 @item Upper Half Coding
18168 The wide character with encoding 16#abcd#, where the upper bit is on
18169 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
18170 16#cd#.  The second byte may never be a format control character, but is
18171 not required to be in the upper half.  This method can be also used for
18172 shift-JIS or EUC where the internal coding matches the external coding.
18174 @item Shift JIS Coding
18175 A wide character is represented by a two character sequence 16#ab# and
18176 16#cd#, with the restrictions described for upper half encoding as
18177 described above.  The internal character code is the corresponding JIS
18178 character according to the standard algorithm for Shift-JIS
18179 conversion.  Only characters defined in the JIS code set table can be
18180 used with this encoding method.
18182 @item EUC Coding
18183 A wide character is represented by a two character sequence 16#ab# and
18184 16#cd#, with both characters being in the upper half.  The internal
18185 character code is the corresponding JIS character according to the EUC
18186 encoding algorithm.  Only characters defined in the JIS code set table
18187 can be used with this encoding method.
18189 @item UTF-8 Coding
18190 A wide character is represented using
18191 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
18192 10646-1/Am.2.  Depending on the character value, the representation
18193 is a one, two, or three byte sequence:
18195 @smallexample
18196 16#0000#-16#007f#: 2#0xxxxxxx#
18197 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
18198 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
18199 @end smallexample
18201 @noindent
18202 where the @var{xxx} bits correspond to the left-padded bits of the
18203 16-bit character value.  Note that all lower half ASCII characters
18204 are represented as ASCII bytes and all upper half characters and
18205 other wide characters are represented as sequences of upper-half
18206 (The full UTF-8 scheme allows for encoding 31-bit characters as
18207 6-byte sequences, but in this implementation, all UTF-8 sequences
18208 of four or more bytes length will raise a Constraint_Error, as
18209 will all invalid UTF-8 sequences.)
18211 @item Brackets Coding
18212 In this encoding, a wide character is represented by the following eight
18213 character sequence:
18215 @smallexample
18216 [ " a b c d " ]
18217 @end smallexample
18219 @noindent
18220 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
18221 characters (using uppercase letters) of the wide character code.  For
18222 example, @code{["A345"]} is used to represent the wide character with code
18223 @code{16#A345#}.
18224 This scheme is compatible with use of the full Wide_Character set.
18225 On input, brackets coding can also be used for upper half characters,
18226 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
18227 is only used for wide characters with a code greater than @code{16#FF#}.
18229 Note that brackets coding is not normally used in the context of
18230 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
18231 a portable way of encoding source files. In the context of Wide_Text_IO
18232 or Wide_Wide_Text_IO, it can only be used if the file does not contain
18233 any instance of the left bracket character other than to encode wide
18234 character values using the brackets encoding method. In practice it is
18235 expected that some standard wide character encoding method such
18236 as UTF-8 will be used for text input output.
18238 If brackets notation is used, then any occurrence of a left bracket
18239 in the input file which is not the start of a valid wide character
18240 sequence will cause Constraint_Error to be raised. It is possible to
18241 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
18242 input will interpret this as a left bracket.
18244 However, when a left bracket is output, it will be output as a left bracket
18245 and not as ["5B"]. We make this decision because for normal use of
18246 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
18247 brackets. For example, if we write:
18249 @smallexample
18250    Put_Line ("Start of output [first run]");
18251 @end smallexample
18253 @noindent
18254 we really do not want to have the left bracket in this message clobbered so
18255 that the output reads:
18257 @smallexample
18258    Start of output ["5B"]first run]
18259 @end smallexample
18261 @noindent
18262 In practice brackets encoding is reasonably useful for normal Put_Line use
18263 since we won't get confused between left brackets and wide character
18264 sequences in the output. But for input, or when files are written out
18265 and read back in, it really makes better sense to use one of the standard
18266 encoding methods such as UTF-8.
18268 @end table
18270 @noindent
18271 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
18272 not all wide character
18273 values can be represented.  An attempt to output a character that cannot
18274 be represented using the encoding scheme for the file causes
18275 Constraint_Error to be raised.  An invalid wide character sequence on
18276 input also causes Constraint_Error to be raised.
18278 @menu
18279 * Wide_Text_IO Stream Pointer Positioning::
18280 * Wide_Text_IO Reading and Writing Non-Regular Files::
18281 @end menu
18283 @node Wide_Text_IO Stream Pointer Positioning
18284 @subsection Stream Pointer Positioning
18286 @noindent
18287 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
18288 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
18289 case:
18291 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
18292 normal lower ASCII set (i.e.@: a character in the range:
18294 @smallexample @c ada
18295 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
18296 @end smallexample
18298 @noindent
18299 then although the logical position of the file pointer is unchanged by
18300 the @code{Look_Ahead} call, the stream is physically positioned past the
18301 wide character sequence.  Again this is to avoid the need for buffering
18302 or backup, and all @code{Wide_Text_IO} routines check the internal
18303 indication that this situation has occurred so that this is not visible
18304 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
18305 can be observed if the wide text file shares a stream with another file.
18307 @node Wide_Text_IO Reading and Writing Non-Regular Files
18308 @subsection Reading and Writing Non-Regular Files
18310 @noindent
18311 As in the case of Text_IO, when a non-regular file is read, it is
18312 assumed that the file contains no page marks (any form characters are
18313 treated as data characters), and @code{End_Of_Page} always returns
18314 @code{False}.  Similarly, the end of file indication is not sticky, so
18315 it is possible to read beyond an end of file.
18317 @node Wide_Wide_Text_IO
18318 @section Wide_Wide_Text_IO
18320 @noindent
18321 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
18322 both input and output files may contain special sequences that represent
18323 wide wide character values.  The encoding scheme for a given file may be
18324 specified using a FORM parameter:
18326 @smallexample
18327 WCEM=@var{x}
18328 @end smallexample
18330 @noindent
18331 as part of the FORM string (WCEM = wide character encoding method),
18332 where @var{x} is one of the following characters
18334 @table @samp
18335 @item h
18336 Hex ESC encoding
18337 @item u
18338 Upper half encoding
18339 @item s
18340 Shift-JIS encoding
18341 @item e
18342 EUC Encoding
18343 @item 8
18344 UTF-8 encoding
18345 @item b
18346 Brackets encoding
18347 @end table
18349 @noindent
18350 The encoding methods match those that
18351 can be used in a source
18352 program, but there is no requirement that the encoding method used for
18353 the source program be the same as the encoding method used for files,
18354 and different files may use different encoding methods.
18356 The default encoding method for the standard files, and for opened files
18357 for which no WCEM parameter is given in the FORM string matches the
18358 wide character encoding specified for the main program (the default
18359 being brackets encoding if no coding method was specified with -gnatW).
18361 @table @asis
18363 @item UTF-8 Coding
18364 A wide character is represented using
18365 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
18366 10646-1/Am.2.  Depending on the character value, the representation
18367 is a one, two, three, or four byte sequence:
18369 @smallexample
18370 16#000000#-16#00007f#: 2#0xxxxxxx#
18371 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
18372 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
18373 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
18374 @end smallexample
18376 @noindent
18377 where the @var{xxx} bits correspond to the left-padded bits of the
18378 21-bit character value.  Note that all lower half ASCII characters
18379 are represented as ASCII bytes and all upper half characters and
18380 other wide characters are represented as sequences of upper-half
18381 characters.
18383 @item Brackets Coding
18384 In this encoding, a wide wide character is represented by the following eight
18385 character sequence if is in wide character range
18387 @smallexample
18388 [ " a b c d " ]
18389 @end smallexample
18391 and by the following ten character sequence if not
18393 @smallexample
18394 [ " a b c d e f " ]
18395 @end smallexample
18397 @noindent
18398 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
18399 are the four or six hexadecimal
18400 characters (using uppercase letters) of the wide wide character code.  For
18401 example, @code{["01A345"]} is used to represent the wide wide character
18402 with code @code{16#01A345#}.
18404 This scheme is compatible with use of the full Wide_Wide_Character set.
18405 On input, brackets coding can also be used for upper half characters,
18406 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
18407 is only used for wide characters with a code greater than @code{16#FF#}.
18409 @end table
18411 @noindent
18412 If is also possible to use the other Wide_Character encoding methods,
18413 such as Shift-JIS, but the other schemes cannot support the full range
18414 of wide wide characters.
18415 An attempt to output a character that cannot
18416 be represented using the encoding scheme for the file causes
18417 Constraint_Error to be raised.  An invalid wide character sequence on
18418 input also causes Constraint_Error to be raised.
18420 @menu
18421 * Wide_Wide_Text_IO Stream Pointer Positioning::
18422 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
18423 @end menu
18425 @node Wide_Wide_Text_IO Stream Pointer Positioning
18426 @subsection Stream Pointer Positioning
18428 @noindent
18429 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
18430 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
18431 case:
18433 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
18434 normal lower ASCII set (i.e.@: a character in the range:
18436 @smallexample @c ada
18437 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
18438 @end smallexample
18440 @noindent
18441 then although the logical position of the file pointer is unchanged by
18442 the @code{Look_Ahead} call, the stream is physically positioned past the
18443 wide character sequence.  Again this is to avoid the need for buffering
18444 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
18445 indication that this situation has occurred so that this is not visible
18446 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
18447 can be observed if the wide text file shares a stream with another file.
18449 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
18450 @subsection Reading and Writing Non-Regular Files
18452 @noindent
18453 As in the case of Text_IO, when a non-regular file is read, it is
18454 assumed that the file contains no page marks (any form characters are
18455 treated as data characters), and @code{End_Of_Page} always returns
18456 @code{False}.  Similarly, the end of file indication is not sticky, so
18457 it is possible to read beyond an end of file.
18459 @node Stream_IO
18460 @section Stream_IO
18462 @noindent
18463 A stream file is a sequence of bytes, where individual elements are
18464 written to the file as described in the Ada Reference Manual.  The type
18465 @code{Stream_Element} is simply a byte.  There are two ways to read or
18466 write a stream file.
18468 @itemize @bullet
18469 @item
18470 The operations @code{Read} and @code{Write} directly read or write a
18471 sequence of stream elements with no control information.
18473 @item
18474 The stream attributes applied to a stream file transfer data in the
18475 manner described for stream attributes.
18476 @end itemize
18478 @node Text Translation
18479 @section Text Translation
18481 @noindent
18482 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
18483 passed to Text_IO.Create and Text_IO.Open. @samp{Text_Translation=@var{xxx}}
18484 has no effect on Unix systems. Possible values are:
18486 @itemize @bullet
18488 @item
18489 @samp{@var{Yes} or @var{Text}} is the default, which means to
18490 translate LF to/from CR/LF on Windows systems.
18492 @samp{@var{No}} disables this translation; i.e. it
18493 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
18494 may be used to create Unix-style files on
18495 Windows.
18497 @item
18498 @samp{@var{wtext}} translation enabled in Unicode mode.
18499 (corresponds to _O_WTEXT).
18501 @item
18502 @samp{@var{u8text}} translation enabled in Unicode UTF-8 mode.
18503 (corresponds to O_U8TEXT).
18505 @item
18506 @samp{@var{u16text}} translation enabled in Unicode UTF-16
18507 mode. (corresponds to_O_U16TEXT).
18509 @end itemize
18513 @node Shared Files
18514 @section Shared Files
18516 @noindent
18517 Section A.14 of the Ada Reference Manual allows implementations to
18518 provide a wide variety of behavior if an attempt is made to access the
18519 same external file with two or more internal files.
18521 To provide a full range of functionality, while at the same time
18522 minimizing the problems of portability caused by this implementation
18523 dependence, GNAT handles file sharing as follows:
18525 @itemize @bullet
18526 @item
18527 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
18528 to open two or more files with the same full name is considered an error
18529 and is not supported.  The exception @code{Use_Error} will be
18530 raised.  Note that a file that is not explicitly closed by the program
18531 remains open until the program terminates.
18533 @item
18534 If the form parameter @samp{shared=no} appears in the form string, the
18535 file can be opened or created with its own separate stream identifier,
18536 regardless of whether other files sharing the same external file are
18537 opened.  The exact effect depends on how the C stream routines handle
18538 multiple accesses to the same external files using separate streams.
18540 @item
18541 If the form parameter @samp{shared=yes} appears in the form string for
18542 each of two or more files opened using the same full name, the same
18543 stream is shared between these files, and the semantics are as described
18544 in Ada Reference Manual, Section A.14.
18545 @end itemize
18547 @noindent
18548 When a program that opens multiple files with the same name is ported
18549 from another Ada compiler to GNAT, the effect will be that
18550 @code{Use_Error} is raised.
18552 The documentation of the original compiler and the documentation of the
18553 program should then be examined to determine if file sharing was
18554 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
18555 and @code{Create} calls as required.
18557 When a program is ported from GNAT to some other Ada compiler, no
18558 special attention is required unless the @samp{shared=@var{xxx}} form
18559 parameter is used in the program.  In this case, you must examine the
18560 documentation of the new compiler to see if it supports the required
18561 file sharing semantics, and form strings modified appropriately.  Of
18562 course it may be the case that the program cannot be ported if the
18563 target compiler does not support the required functionality.  The best
18564 approach in writing portable code is to avoid file sharing (and hence
18565 the use of the @samp{shared=@var{xxx}} parameter in the form string)
18566 completely.
18568 One common use of file sharing in Ada 83 is the use of instantiations of
18569 Sequential_IO on the same file with different types, to achieve
18570 heterogeneous input-output.  Although this approach will work in GNAT if
18571 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
18572 for this purpose (using the stream attributes)
18574 @node Filenames encoding
18575 @section Filenames encoding
18577 @noindent
18578 An encoding form parameter can be used to specify the filename
18579 encoding @samp{encoding=@var{xxx}}.
18581 @itemize @bullet
18582 @item
18583 If the form parameter @samp{encoding=utf8} appears in the form string, the
18584 filename must be encoded in UTF-8.
18586 @item
18587 If the form parameter @samp{encoding=8bits} appears in the form
18588 string, the filename must be a standard 8bits string.
18589 @end itemize
18591 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
18592 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
18593 variable. And if not set @samp{utf8} is assumed.
18595 @table @samp
18596 @item CP_ACP
18597 The current system Windows ANSI code page.
18598 @item CP_UTF8
18599 UTF-8 encoding
18600 @end table
18602 This encoding form parameter is only supported on the Windows
18603 platform. On the other Operating Systems the run-time is supporting
18604 UTF-8 natively.
18606 @node File content encoding
18607 @section File content encoding
18609 @noindent
18610 For text files it is possible to specify the encoding to use. This is
18611 controlled by the by the @samp{GNAT_CCS_ENCODING} environment
18612 variable. And if not set @samp{TEXT} is assumed.
18614 The possible values are those supported on Windows:
18616 @table @samp
18617 @item TEXT
18618 Translated text mode
18619 @item WTEXT
18620 Translated unicode encoding
18621 @item U16TEXT
18622 Unicode 16-bit encoding
18623 @item U8TEXT
18624 Unicode 8-bit encoding
18625 @end table
18627 This encoding is only supported on the Windows platform.
18629 @node Open Modes
18630 @section Open Modes
18632 @noindent
18633 @code{Open} and @code{Create} calls result in a call to @code{fopen}
18634 using the mode shown in the following table:
18636 @sp 2
18637 @center @code{Open} and @code{Create} Call Modes
18638 @smallexample
18639                                @b{OPEN }           @b{CREATE}
18640 Append_File                    "r+"             "w+"
18641 In_File                        "r"              "w+"
18642 Out_File (Direct_IO)           "r+"             "w"
18643 Out_File (all other cases)     "w"              "w"
18644 Inout_File                     "r+"             "w+"
18645 @end smallexample
18647 @noindent
18648 If text file translation is required, then either @samp{b} or @samp{t}
18649 is added to the mode, depending on the setting of Text.  Text file
18650 translation refers to the mapping of CR/LF sequences in an external file
18651 to LF characters internally.  This mapping only occurs in DOS and
18652 DOS-like systems, and is not relevant to other systems.
18654 A special case occurs with Stream_IO@.  As shown in the above table, the
18655 file is initially opened in @samp{r} or @samp{w} mode for the
18656 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
18657 subsequently requires switching from reading to writing or vice-versa,
18658 then the file is reopened in @samp{r+} mode to permit the required operation.
18660 @node Operations on C Streams
18661 @section Operations on C Streams
18662 The package @code{Interfaces.C_Streams} provides an Ada program with direct
18663 access to the C library functions for operations on C streams:
18665 @smallexample @c adanocomment
18666 package Interfaces.C_Streams is
18667   -- Note: the reason we do not use the types that are in
18668   -- Interfaces.C is that we want to avoid dragging in the
18669   -- code in this unit if possible.
18670   subtype chars is System.Address;
18671   -- Pointer to null-terminated array of characters
18672   subtype FILEs is System.Address;
18673   -- Corresponds to the C type FILE*
18674   subtype voids is System.Address;
18675   -- Corresponds to the C type void*
18676   subtype int is Integer;
18677   subtype long is Long_Integer;
18678   -- Note: the above types are subtypes deliberately, and it
18679   -- is part of this spec that the above correspondences are
18680   -- guaranteed.  This means that it is legitimate to, for
18681   -- example, use Integer instead of int.  We provide these
18682   -- synonyms for clarity, but in some cases it may be
18683   -- convenient to use the underlying types (for example to
18684   -- avoid an unnecessary dependency of a spec on the spec
18685   -- of this unit).
18686   type size_t is mod 2 ** Standard'Address_Size;
18687   NULL_Stream : constant FILEs;
18688   -- Value returned (NULL in C) to indicate an
18689   -- fdopen/fopen/tmpfile error
18690   ----------------------------------
18691   -- Constants Defined in stdio.h --
18692   ----------------------------------
18693   EOF : constant int;
18694   -- Used by a number of routines to indicate error or
18695   -- end of file
18696   IOFBF : constant int;
18697   IOLBF : constant int;
18698   IONBF : constant int;
18699   -- Used to indicate buffering mode for setvbuf call
18700   SEEK_CUR : constant int;
18701   SEEK_END : constant int;
18702   SEEK_SET : constant int;
18703   -- Used to indicate origin for fseek call
18704   function stdin return FILEs;
18705   function stdout return FILEs;
18706   function stderr return FILEs;
18707   -- Streams associated with standard files
18708   --------------------------
18709   -- Standard C functions --
18710   --------------------------
18711   -- The functions selected below are ones that are
18712   -- available in UNIX (but not necessarily in ANSI C).
18713   -- These are very thin interfaces
18714   -- which copy exactly the C headers.  For more
18715   -- documentation on these functions, see the Microsoft C
18716   -- "Run-Time Library Reference" (Microsoft Press, 1990,
18717   -- ISBN 1-55615-225-6), which includes useful information
18718   -- on system compatibility.
18719   procedure clearerr (stream : FILEs);
18720   function fclose (stream : FILEs) return int;
18721   function fdopen (handle : int; mode : chars) return FILEs;
18722   function feof (stream : FILEs) return int;
18723   function ferror (stream : FILEs) return int;
18724   function fflush (stream : FILEs) return int;
18725   function fgetc (stream : FILEs) return int;
18726   function fgets (strng : chars; n : int; stream : FILEs)
18727       return chars;
18728   function fileno (stream : FILEs) return int;
18729   function fopen (filename : chars; Mode : chars)
18730       return FILEs;
18731   -- Note: to maintain target independence, use
18732   -- text_translation_required, a boolean variable defined in
18733   -- a-sysdep.c to deal with the target dependent text
18734   -- translation requirement.  If this variable is set,
18735   -- then  b/t should be appended to the standard mode
18736   -- argument to set the text translation mode off or on
18737   -- as required.
18738   function fputc (C : int; stream : FILEs) return int;
18739   function fputs (Strng : chars; Stream : FILEs) return int;
18740   function fread
18741      (buffer : voids;
18742       size : size_t;
18743       count : size_t;
18744       stream : FILEs)
18745       return size_t;
18746   function freopen
18747      (filename : chars;
18748       mode : chars;
18749       stream : FILEs)
18750       return FILEs;
18751   function fseek
18752      (stream : FILEs;
18753       offset : long;
18754       origin : int)
18755       return int;
18756   function ftell (stream : FILEs) return long;
18757   function fwrite
18758      (buffer : voids;
18759       size : size_t;
18760       count : size_t;
18761       stream : FILEs)
18762       return size_t;
18763   function isatty (handle : int) return int;
18764   procedure mktemp (template : chars);
18765   -- The return value (which is just a pointer to template)
18766   -- is discarded
18767   procedure rewind (stream : FILEs);
18768   function rmtmp return int;
18769   function setvbuf
18770      (stream : FILEs;
18771       buffer : chars;
18772       mode : int;
18773       size : size_t)
18774       return int;
18776   function tmpfile return FILEs;
18777   function ungetc (c : int; stream : FILEs) return int;
18778   function unlink (filename : chars) return int;
18779   ---------------------
18780   -- Extra functions --
18781   ---------------------
18782   -- These functions supply slightly thicker bindings than
18783   -- those above.  They are derived from functions in the
18784   -- C Run-Time Library, but may do a bit more work than
18785   -- just directly calling one of the Library functions.
18786   function is_regular_file (handle : int) return int;
18787   -- Tests if given handle is for a regular file (result 1)
18788   -- or for a non-regular file (pipe or device, result 0).
18789   ---------------------------------
18790   -- Control of Text/Binary Mode --
18791   ---------------------------------
18792   -- If text_translation_required is true, then the following
18793   -- functions may be used to dynamically switch a file from
18794   -- binary to text mode or vice versa.  These functions have
18795   -- no effect if text_translation_required is false (i.e.@: in
18796   -- normal UNIX mode).  Use fileno to get a stream handle.
18797   procedure set_binary_mode (handle : int);
18798   procedure set_text_mode (handle : int);
18799   ----------------------------
18800   -- Full Path Name support --
18801   ----------------------------
18802   procedure full_name (nam : chars; buffer : chars);
18803   -- Given a NUL terminated string representing a file
18804   -- name, returns in buffer a NUL terminated string
18805   -- representing the full path name for the file name.
18806   -- On systems where it is relevant the   drive is also
18807   -- part of the full path name.  It is the responsibility
18808   -- of the caller to pass an actual parameter for buffer
18809   -- that is big enough for any full path name.  Use
18810   -- max_path_len given below as the size of buffer.
18811   max_path_len : integer;
18812   -- Maximum length of an allowable full path name on the
18813   -- system, including a terminating NUL character.
18814 end Interfaces.C_Streams;
18815 @end smallexample
18817 @node Interfacing to C Streams
18818 @section Interfacing to C Streams
18820 @noindent
18821 The packages in this section permit interfacing Ada files to C Stream
18822 operations.
18824 @smallexample @c ada
18825  with Interfaces.C_Streams;
18826  package Ada.Sequential_IO.C_Streams is
18827     function C_Stream (F : File_Type)
18828        return Interfaces.C_Streams.FILEs;
18829     procedure Open
18830       (File : in out File_Type;
18831        Mode : in File_Mode;
18832        C_Stream : in Interfaces.C_Streams.FILEs;
18833        Form : in String := "");
18834  end Ada.Sequential_IO.C_Streams;
18836   with Interfaces.C_Streams;
18837   package Ada.Direct_IO.C_Streams is
18838      function C_Stream (F : File_Type)
18839         return Interfaces.C_Streams.FILEs;
18840      procedure Open
18841        (File : in out File_Type;
18842         Mode : in File_Mode;
18843         C_Stream : in Interfaces.C_Streams.FILEs;
18844         Form : in String := "");
18845   end Ada.Direct_IO.C_Streams;
18847   with Interfaces.C_Streams;
18848   package Ada.Text_IO.C_Streams is
18849      function C_Stream (F : File_Type)
18850         return Interfaces.C_Streams.FILEs;
18851      procedure Open
18852        (File : in out File_Type;
18853         Mode : in File_Mode;
18854         C_Stream : in Interfaces.C_Streams.FILEs;
18855         Form : in String := "");
18856   end Ada.Text_IO.C_Streams;
18858   with Interfaces.C_Streams;
18859   package Ada.Wide_Text_IO.C_Streams is
18860      function C_Stream (F : File_Type)
18861         return Interfaces.C_Streams.FILEs;
18862      procedure Open
18863        (File : in out File_Type;
18864         Mode : in File_Mode;
18865         C_Stream : in Interfaces.C_Streams.FILEs;
18866         Form : in String := "");
18867  end Ada.Wide_Text_IO.C_Streams;
18869   with Interfaces.C_Streams;
18870   package Ada.Wide_Wide_Text_IO.C_Streams is
18871      function C_Stream (F : File_Type)
18872         return Interfaces.C_Streams.FILEs;
18873      procedure Open
18874        (File : in out File_Type;
18875         Mode : in File_Mode;
18876         C_Stream : in Interfaces.C_Streams.FILEs;
18877         Form : in String := "");
18878  end Ada.Wide_Wide_Text_IO.C_Streams;
18880  with Interfaces.C_Streams;
18881  package Ada.Stream_IO.C_Streams is
18882     function C_Stream (F : File_Type)
18883        return Interfaces.C_Streams.FILEs;
18884     procedure Open
18885       (File : in out File_Type;
18886        Mode : in File_Mode;
18887        C_Stream : in Interfaces.C_Streams.FILEs;
18888        Form : in String := "");
18889  end Ada.Stream_IO.C_Streams;
18890 @end smallexample
18892 @noindent
18893 In each of these six packages, the @code{C_Stream} function obtains the
18894 @code{FILE} pointer from a currently opened Ada file.  It is then
18895 possible to use the @code{Interfaces.C_Streams} package to operate on
18896 this stream, or the stream can be passed to a C program which can
18897 operate on it directly.  Of course the program is responsible for
18898 ensuring that only appropriate sequences of operations are executed.
18900 One particular use of relevance to an Ada program is that the
18901 @code{setvbuf} function can be used to control the buffering of the
18902 stream used by an Ada file.  In the absence of such a call the standard
18903 default buffering is used.
18905 The @code{Open} procedures in these packages open a file giving an
18906 existing C Stream instead of a file name.  Typically this stream is
18907 imported from a C program, allowing an Ada file to operate on an
18908 existing C file.
18910 @node The GNAT Library
18911 @chapter The GNAT Library
18913 @noindent
18914 The GNAT library contains a number of general and special purpose packages.
18915 It represents functionality that the GNAT developers have found useful, and
18916 which is made available to GNAT users.  The packages described here are fully
18917 supported, and upwards compatibility will be maintained in future releases,
18918 so you can use these facilities with the confidence that the same functionality
18919 will be available in future releases.
18921 The chapter here simply gives a brief summary of the facilities available.
18922 The full documentation is found in the spec file for the package.  The full
18923 sources of these library packages, including both spec and body, are provided
18924 with all GNAT releases.  For example, to find out the full specifications of
18925 the SPITBOL pattern matching capability, including a full tutorial and
18926 extensive examples, look in the @file{g-spipat.ads} file in the library.
18928 For each entry here, the package name (as it would appear in a @code{with}
18929 clause) is given, followed by the name of the corresponding spec file in
18930 parentheses.  The packages are children in four hierarchies, @code{Ada},
18931 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
18932 GNAT-specific hierarchy.
18934 Note that an application program should only use packages in one of these
18935 four hierarchies if the package is defined in the Ada Reference Manual,
18936 or is listed in this section of the GNAT Programmers Reference Manual.
18937 All other units should be considered internal implementation units and
18938 should not be directly @code{with}'ed by application code.  The use of
18939 a @code{with} statement that references one of these internal implementation
18940 units makes an application potentially dependent on changes in versions
18941 of GNAT, and will generate a warning message.
18943 @menu
18944 * Ada.Characters.Latin_9 (a-chlat9.ads)::
18945 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
18946 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
18947 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
18948 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
18949 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
18950 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
18951 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
18952 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
18953 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
18954 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
18955 * Ada.Command_Line.Environment (a-colien.ads)::
18956 * Ada.Command_Line.Remove (a-colire.ads)::
18957 * Ada.Command_Line.Response_File (a-clrefi.ads)::
18958 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
18959 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
18960 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
18961 * Ada.Exceptions.Traceback (a-exctra.ads)::
18962 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
18963 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
18964 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
18965 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
18966 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
18967 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
18968 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
18969 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
18970 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
18971 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
18972 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
18973 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
18974 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
18975 * GNAT.Altivec (g-altive.ads)::
18976 * GNAT.Altivec.Conversions (g-altcon.ads)::
18977 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
18978 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
18979 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
18980 * GNAT.Array_Split (g-arrspl.ads)::
18981 * GNAT.AWK (g-awk.ads)::
18982 * GNAT.Bounded_Buffers (g-boubuf.ads)::
18983 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
18984 * GNAT.Bubble_Sort (g-bubsor.ads)::
18985 * GNAT.Bubble_Sort_A (g-busora.ads)::
18986 * GNAT.Bubble_Sort_G (g-busorg.ads)::
18987 * GNAT.Byte_Order_Mark (g-byorma.ads)::
18988 * GNAT.Byte_Swapping (g-bytswa.ads)::
18989 * GNAT.Calendar (g-calend.ads)::
18990 * GNAT.Calendar.Time_IO (g-catiio.ads)::
18991 * GNAT.Case_Util (g-casuti.ads)::
18992 * GNAT.CGI (g-cgi.ads)::
18993 * GNAT.CGI.Cookie (g-cgicoo.ads)::
18994 * GNAT.CGI.Debug (g-cgideb.ads)::
18995 * GNAT.Command_Line (g-comlin.ads)::
18996 * GNAT.Compiler_Version (g-comver.ads)::
18997 * GNAT.Ctrl_C (g-ctrl_c.ads)::
18998 * GNAT.CRC32 (g-crc32.ads)::
18999 * GNAT.Current_Exception (g-curexc.ads)::
19000 * GNAT.Debug_Pools (g-debpoo.ads)::
19001 * GNAT.Debug_Utilities (g-debuti.ads)::
19002 * GNAT.Decode_String (g-decstr.ads)::
19003 * GNAT.Decode_UTF8_String (g-deutst.ads)::
19004 * GNAT.Directory_Operations (g-dirope.ads)::
19005 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
19006 * GNAT.Dynamic_HTables (g-dynhta.ads)::
19007 * GNAT.Dynamic_Tables (g-dyntab.ads)::
19008 * GNAT.Encode_String (g-encstr.ads)::
19009 * GNAT.Encode_UTF8_String (g-enutst.ads)::
19010 * GNAT.Exception_Actions (g-excact.ads)::
19011 * GNAT.Exception_Traces (g-exctra.ads)::
19012 * GNAT.Exceptions (g-except.ads)::
19013 * GNAT.Expect (g-expect.ads)::
19014 * GNAT.Expect.TTY (g-exptty.ads)::
19015 * GNAT.Float_Control (g-flocon.ads)::
19016 * GNAT.Formatted_String (g-forstr.ads)::
19017 * GNAT.Heap_Sort (g-heasor.ads)::
19018 * GNAT.Heap_Sort_A (g-hesora.ads)::
19019 * GNAT.Heap_Sort_G (g-hesorg.ads)::
19020 * GNAT.HTable (g-htable.ads)::
19021 * GNAT.IO (g-io.ads)::
19022 * GNAT.IO_Aux (g-io_aux.ads)::
19023 * GNAT.Lock_Files (g-locfil.ads)::
19024 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
19025 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
19026 * GNAT.MD5 (g-md5.ads)::
19027 * GNAT.Memory_Dump (g-memdum.ads)::
19028 * GNAT.Most_Recent_Exception (g-moreex.ads)::
19029 * GNAT.OS_Lib (g-os_lib.ads)::
19030 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
19031 * GNAT.Random_Numbers (g-rannum.ads)::
19032 * GNAT.Regexp (g-regexp.ads)::
19033 * GNAT.Registry (g-regist.ads)::
19034 * GNAT.Regpat (g-regpat.ads)::
19035 * GNAT.Rewrite_Data (g-rewdat.ads)::
19036 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
19037 * GNAT.Semaphores (g-semaph.ads)::
19038 * GNAT.Serial_Communications (g-sercom.ads)::
19039 * GNAT.SHA1 (g-sha1.ads)::
19040 * GNAT.SHA224 (g-sha224.ads)::
19041 * GNAT.SHA256 (g-sha256.ads)::
19042 * GNAT.SHA384 (g-sha384.ads)::
19043 * GNAT.SHA512 (g-sha512.ads)::
19044 * GNAT.Signals (g-signal.ads)::
19045 * GNAT.Sockets (g-socket.ads)::
19046 * GNAT.Source_Info (g-souinf.ads)::
19047 * GNAT.Spelling_Checker (g-speche.ads)::
19048 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
19049 * GNAT.Spitbol.Patterns (g-spipat.ads)::
19050 * GNAT.Spitbol (g-spitbo.ads)::
19051 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
19052 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
19053 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
19054 * GNAT.SSE (g-sse.ads)::
19055 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
19056 * GNAT.Strings (g-string.ads)::
19057 * GNAT.String_Split (g-strspl.ads)::
19058 * GNAT.Table (g-table.ads)::
19059 * GNAT.Task_Lock (g-tasloc.ads)::
19060 * GNAT.Threads (g-thread.ads)::
19061 * GNAT.Time_Stamp (g-timsta.ads)::
19062 * GNAT.Traceback (g-traceb.ads)::
19063 * GNAT.Traceback.Symbolic (g-trasym.ads)::
19064 * GNAT.UTF_32 (g-utf_32.ads)::
19065 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
19066 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
19067 * GNAT.Wide_String_Split (g-wistsp.ads)::
19068 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
19069 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
19070 * Interfaces.C.Extensions (i-cexten.ads)::
19071 * Interfaces.C.Streams (i-cstrea.ads)::
19072 * Interfaces.Packed_Decimal (i-pacdec.ads)::
19073 * Interfaces.VxWorks (i-vxwork.ads)::
19074 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
19075 * System.Address_Image (s-addima.ads)::
19076 * System.Assertions (s-assert.ads)::
19077 * System.Memory (s-memory.ads)::
19078 * System.Multiprocessors (s-multip.ads)::
19079 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
19080 * System.Partition_Interface (s-parint.ads)::
19081 * System.Pool_Global (s-pooglo.ads)::
19082 * System.Pool_Local (s-pooloc.ads)::
19083 * System.Restrictions (s-restri.ads)::
19084 * System.Rident (s-rident.ads)::
19085 * System.Strings.Stream_Ops (s-ststop.ads)::
19086 * System.Unsigned_Types (s-unstyp.ads)::
19087 * System.Wch_Cnv (s-wchcnv.ads)::
19088 * System.Wch_Con (s-wchcon.ads)::
19089 @end menu
19091 @node Ada.Characters.Latin_9 (a-chlat9.ads)
19092 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
19093 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
19094 @cindex Latin_9 constants for Character
19096 @noindent
19097 This child of @code{Ada.Characters}
19098 provides a set of definitions corresponding to those in the
19099 RM-defined package @code{Ada.Characters.Latin_1} but with the
19100 few modifications required for @code{Latin-9}
19101 The provision of such a package
19102 is specifically authorized by the Ada Reference Manual
19103 (RM A.3.3(27)).
19105 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
19106 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
19107 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
19108 @cindex Latin_1 constants for Wide_Character
19110 @noindent
19111 This child of @code{Ada.Characters}
19112 provides a set of definitions corresponding to those in the
19113 RM-defined package @code{Ada.Characters.Latin_1} but with the
19114 types of the constants being @code{Wide_Character}
19115 instead of @code{Character}.  The provision of such a package
19116 is specifically authorized by the Ada Reference Manual
19117 (RM A.3.3(27)).
19119 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
19120 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
19121 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
19122 @cindex Latin_9 constants for Wide_Character
19124 @noindent
19125 This child of @code{Ada.Characters}
19126 provides a set of definitions corresponding to those in the
19127 GNAT defined package @code{Ada.Characters.Latin_9} but with the
19128 types of the constants being @code{Wide_Character}
19129 instead of @code{Character}.  The provision of such a package
19130 is specifically authorized by the Ada Reference Manual
19131 (RM A.3.3(27)).
19133 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
19134 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
19135 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
19136 @cindex Latin_1 constants for Wide_Wide_Character
19138 @noindent
19139 This child of @code{Ada.Characters}
19140 provides a set of definitions corresponding to those in the
19141 RM-defined package @code{Ada.Characters.Latin_1} but with the
19142 types of the constants being @code{Wide_Wide_Character}
19143 instead of @code{Character}.  The provision of such a package
19144 is specifically authorized by the Ada Reference Manual
19145 (RM A.3.3(27)).
19147 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
19148 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
19149 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
19150 @cindex Latin_9 constants for Wide_Wide_Character
19152 @noindent
19153 This child of @code{Ada.Characters}
19154 provides a set of definitions corresponding to those in the
19155 GNAT defined package @code{Ada.Characters.Latin_9} but with the
19156 types of the constants being @code{Wide_Wide_Character}
19157 instead of @code{Character}.  The provision of such a package
19158 is specifically authorized by the Ada Reference Manual
19159 (RM A.3.3(27)).
19161 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
19162 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
19163 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
19164 @cindex Formal container for doubly linked lists
19166 @noindent
19167 This child of @code{Ada.Containers} defines a modified version of the
19168 Ada 2005 container for doubly linked lists, meant to facilitate formal
19169 verification of code using such containers. The specification of this
19170 unit is compatible with SPARK 2014.
19172 Note that although this container was designed with formal verification
19173 in mind, it may well be generally useful in that it is a simplified more
19174 efficient version than the one defined in the standard. In particular it
19175 does not have the complex overhead required to detect cursor tampering.
19177 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
19178 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
19179 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
19180 @cindex Formal container for hashed maps
19182 @noindent
19183 This child of @code{Ada.Containers} defines a modified version of the
19184 Ada 2005 container for hashed maps, meant to facilitate formal
19185 verification of code using such containers. The specification of this
19186 unit is compatible with SPARK 2014.
19188 Note that although this container was designed with formal verification
19189 in mind, it may well be generally useful in that it is a simplified more
19190 efficient version than the one defined in the standard. In particular it
19191 does not have the complex overhead required to detect cursor tampering.
19193 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
19194 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
19195 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
19196 @cindex Formal container for hashed sets
19198 @noindent
19199 This child of @code{Ada.Containers} defines a modified version of the
19200 Ada 2005 container for hashed sets, meant to facilitate formal
19201 verification of code using such containers. The specification of this
19202 unit is compatible with SPARK 2014.
19204 Note that although this container was designed with formal verification
19205 in mind, it may well be generally useful in that it is a simplified more
19206 efficient version than the one defined in the standard. In particular it
19207 does not have the complex overhead required to detect cursor tampering.
19209 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
19210 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
19211 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
19212 @cindex Formal container for ordered maps
19214 @noindent
19215 This child of @code{Ada.Containers} defines a modified version of the
19216 Ada 2005 container for ordered maps, meant to facilitate formal
19217 verification of code using such containers. The specification of this
19218 unit is compatible with SPARK 2014.
19220 Note that although this container was designed with formal verification
19221 in mind, it may well be generally useful in that it is a simplified more
19222 efficient version than the one defined in the standard. In particular it
19223 does not have the complex overhead required to detect cursor tampering.
19225 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
19226 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
19227 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
19228 @cindex Formal container for ordered sets
19230 @noindent
19231 This child of @code{Ada.Containers} defines a modified version of the
19232 Ada 2005 container for ordered sets, meant to facilitate formal
19233 verification of code using such containers. The specification of this
19234 unit is compatible with SPARK 2014.
19236 Note that although this container was designed with formal verification
19237 in mind, it may well be generally useful in that it is a simplified more
19238 efficient version than the one defined in the standard. In particular it
19239 does not have the complex overhead required to detect cursor tampering.
19241 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
19242 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
19243 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
19244 @cindex Formal container for vectors
19246 @noindent
19247 This child of @code{Ada.Containers} defines a modified version of the
19248 Ada 2005 container for vectors, meant to facilitate formal
19249 verification of code using such containers. The specification of this
19250 unit is compatible with SPARK 2014.
19252 Note that although this container was designed with formal verification
19253 in mind, it may well be generally useful in that it is a simplified more
19254 efficient version than the one defined in the standard. In particular it
19255 does not have the complex overhead required to detect cursor tampering.
19257 @node Ada.Command_Line.Environment (a-colien.ads)
19258 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
19259 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
19260 @cindex Environment entries
19262 @noindent
19263 This child of @code{Ada.Command_Line}
19264 provides a mechanism for obtaining environment values on systems
19265 where this concept makes sense.
19267 @node Ada.Command_Line.Remove (a-colire.ads)
19268 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
19269 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
19270 @cindex Removing command line arguments
19271 @cindex Command line, argument removal
19273 @noindent
19274 This child of @code{Ada.Command_Line}
19275 provides a mechanism for logically removing
19276 arguments from the argument list.  Once removed, an argument is not visible
19277 to further calls on the subprograms in @code{Ada.Command_Line} will not
19278 see the removed argument.
19280 @node Ada.Command_Line.Response_File (a-clrefi.ads)
19281 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
19282 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
19283 @cindex Response file for command line
19284 @cindex Command line, response file
19285 @cindex Command line, handling long command lines
19287 @noindent
19288 This child of @code{Ada.Command_Line} provides a mechanism facilities for
19289 getting command line arguments from a text file, called a "response file".
19290 Using a response file allow passing a set of arguments to an executable longer
19291 than the maximum allowed by the system on the command line.
19293 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
19294 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
19295 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
19296 @cindex C Streams, Interfacing with Direct_IO
19298 @noindent
19299 This package provides subprograms that allow interfacing between
19300 C streams and @code{Direct_IO}.  The stream identifier can be
19301 extracted from a file opened on the Ada side, and an Ada file
19302 can be constructed from a stream opened on the C side.
19304 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
19305 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
19306 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
19307 @cindex Null_Occurrence, testing for
19309 @noindent
19310 This child subprogram provides a way of testing for the null
19311 exception occurrence (@code{Null_Occurrence}) without raising
19312 an exception.
19314 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
19315 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
19316 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
19317 @cindex Null_Occurrence, testing for
19319 @noindent
19320 This child subprogram is used for handling otherwise unhandled
19321 exceptions (hence the name last chance), and perform clean ups before
19322 terminating the program. Note that this subprogram never returns.
19324 @node Ada.Exceptions.Traceback (a-exctra.ads)
19325 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
19326 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
19327 @cindex Traceback for Exception Occurrence
19329 @noindent
19330 This child package provides the subprogram (@code{Tracebacks}) to
19331 give a traceback array of addresses based on an exception
19332 occurrence.
19334 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
19335 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
19336 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
19337 @cindex C Streams, Interfacing with Sequential_IO
19339 @noindent
19340 This package provides subprograms that allow interfacing between
19341 C streams and @code{Sequential_IO}.  The stream identifier can be
19342 extracted from a file opened on the Ada side, and an Ada file
19343 can be constructed from a stream opened on the C side.
19345 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
19346 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
19347 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
19348 @cindex C Streams, Interfacing with Stream_IO
19350 @noindent
19351 This package provides subprograms that allow interfacing between
19352 C streams and @code{Stream_IO}.  The stream identifier can be
19353 extracted from a file opened on the Ada side, and an Ada file
19354 can be constructed from a stream opened on the C side.
19356 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
19357 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
19358 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
19359 @cindex @code{Unbounded_String}, IO support
19360 @cindex @code{Text_IO}, extensions for unbounded strings
19362 @noindent
19363 This package provides subprograms for Text_IO for unbounded
19364 strings, avoiding the necessity for an intermediate operation
19365 with ordinary strings.
19367 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
19368 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
19369 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
19370 @cindex @code{Unbounded_Wide_String}, IO support
19371 @cindex @code{Text_IO}, extensions for unbounded wide strings
19373 @noindent
19374 This package provides subprograms for Text_IO for unbounded
19375 wide strings, avoiding the necessity for an intermediate operation
19376 with ordinary wide strings.
19378 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
19379 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
19380 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
19381 @cindex @code{Unbounded_Wide_Wide_String}, IO support
19382 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
19384 @noindent
19385 This package provides subprograms for Text_IO for unbounded
19386 wide wide strings, avoiding the necessity for an intermediate operation
19387 with ordinary wide wide strings.
19389 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
19390 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
19391 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
19392 @cindex C Streams, Interfacing with @code{Text_IO}
19394 @noindent
19395 This package provides subprograms that allow interfacing between
19396 C streams and @code{Text_IO}.  The stream identifier can be
19397 extracted from a file opened on the Ada side, and an Ada file
19398 can be constructed from a stream opened on the C side.
19400 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
19401 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
19402 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
19403 @cindex @code{Text_IO} resetting standard files
19405 @noindent
19406 This procedure is used to reset the status of the standard files used
19407 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
19408 embedded application) where the status of the files may change during
19409 execution (for example a standard input file may be redefined to be
19410 interactive).
19412 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
19413 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
19414 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
19415 @cindex Unicode categorization, Wide_Character
19417 @noindent
19418 This package provides subprograms that allow categorization of
19419 Wide_Character values according to Unicode categories.
19421 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
19422 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
19423 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
19424 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
19426 @noindent
19427 This package provides subprograms that allow interfacing between
19428 C streams and @code{Wide_Text_IO}.  The stream identifier can be
19429 extracted from a file opened on the Ada side, and an Ada file
19430 can be constructed from a stream opened on the C side.
19432 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
19433 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
19434 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
19435 @cindex @code{Wide_Text_IO} resetting standard files
19437 @noindent
19438 This procedure is used to reset the status of the standard files used
19439 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
19440 embedded application) where the status of the files may change during
19441 execution (for example a standard input file may be redefined to be
19442 interactive).
19444 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
19445 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
19446 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
19447 @cindex Unicode categorization, Wide_Wide_Character
19449 @noindent
19450 This package provides subprograms that allow categorization of
19451 Wide_Wide_Character values according to Unicode categories.
19453 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
19454 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
19455 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
19456 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
19458 @noindent
19459 This package provides subprograms that allow interfacing between
19460 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
19461 extracted from a file opened on the Ada side, and an Ada file
19462 can be constructed from a stream opened on the C side.
19464 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
19465 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
19466 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
19467 @cindex @code{Wide_Wide_Text_IO} resetting standard files
19469 @noindent
19470 This procedure is used to reset the status of the standard files used
19471 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
19472 restart in an embedded application) where the status of the files may
19473 change during execution (for example a standard input file may be
19474 redefined to be interactive).
19476 @node GNAT.Altivec (g-altive.ads)
19477 @section @code{GNAT.Altivec} (@file{g-altive.ads})
19478 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
19479 @cindex AltiVec
19481 @noindent
19482 This is the root package of the GNAT AltiVec binding. It provides
19483 definitions of constants and types common to all the versions of the
19484 binding.
19486 @node GNAT.Altivec.Conversions (g-altcon.ads)
19487 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
19488 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
19489 @cindex AltiVec
19491 @noindent
19492 This package provides the Vector/View conversion routines.
19494 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
19495 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
19496 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
19497 @cindex AltiVec
19499 @noindent
19500 This package exposes the Ada interface to the AltiVec operations on
19501 vector objects. A soft emulation is included by default in the GNAT
19502 library. The hard binding is provided as a separate package. This unit
19503 is common to both bindings.
19505 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
19506 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
19507 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
19508 @cindex AltiVec
19510 @noindent
19511 This package exposes the various vector types part of the Ada binding
19512 to AltiVec facilities.
19514 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
19515 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19516 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19517 @cindex AltiVec
19519 @noindent
19520 This package provides public 'View' data types from/to which private
19521 vector representations can be converted via
19522 GNAT.Altivec.Conversions. This allows convenient access to individual
19523 vector elements and provides a simple way to initialize vector
19524 objects.
19526 @node GNAT.Array_Split (g-arrspl.ads)
19527 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19528 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19529 @cindex Array splitter
19531 @noindent
19532 Useful array-manipulation routines: given a set of separators, split
19533 an array wherever the separators appear, and provide direct access
19534 to the resulting slices.
19536 @node GNAT.AWK (g-awk.ads)
19537 @section @code{GNAT.AWK} (@file{g-awk.ads})
19538 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
19539 @cindex Parsing
19540 @cindex AWK
19542 @noindent
19543 Provides AWK-like parsing functions, with an easy interface for parsing one
19544 or more files containing formatted data.  The file is viewed as a database
19545 where each record is a line and a field is a data element in this line.
19547 @node GNAT.Bounded_Buffers (g-boubuf.ads)
19548 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19549 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19550 @cindex Parsing
19551 @cindex Bounded Buffers
19553 @noindent
19554 Provides a concurrent generic bounded buffer abstraction.  Instances are
19555 useful directly or as parts of the implementations of other abstractions,
19556 such as mailboxes.
19558 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
19559 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19560 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19561 @cindex Parsing
19562 @cindex Mailboxes
19564 @noindent
19565 Provides a thread-safe asynchronous intertask mailbox communication facility.
19567 @node GNAT.Bubble_Sort (g-bubsor.ads)
19568 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19569 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19570 @cindex Sorting
19571 @cindex Bubble sort
19573 @noindent
19574 Provides a general implementation of bubble sort usable for sorting arbitrary
19575 data items.  Exchange and comparison procedures are provided by passing
19576 access-to-procedure values.
19578 @node GNAT.Bubble_Sort_A (g-busora.ads)
19579 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19580 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19581 @cindex Sorting
19582 @cindex Bubble sort
19584 @noindent
19585 Provides a general implementation of bubble sort usable for sorting arbitrary
19586 data items.  Move and comparison procedures are provided by passing
19587 access-to-procedure values. This is an older version, retained for
19588 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
19590 @node GNAT.Bubble_Sort_G (g-busorg.ads)
19591 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19592 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19593 @cindex Sorting
19594 @cindex Bubble sort
19596 @noindent
19597 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
19598 are provided as generic parameters, this improves efficiency, especially
19599 if the procedures can be inlined, at the expense of duplicating code for
19600 multiple instantiations.
19602 @node GNAT.Byte_Order_Mark (g-byorma.ads)
19603 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19604 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19605 @cindex UTF-8 representation
19606 @cindex Wide characte representations
19608 @noindent
19609 Provides a routine which given a string, reads the start of the string to
19610 see whether it is one of the standard byte order marks (BOM's) which signal
19611 the encoding of the string. The routine includes detection of special XML
19612 sequences for various UCS input formats.
19614 @node GNAT.Byte_Swapping (g-bytswa.ads)
19615 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19616 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19617 @cindex Byte swapping
19618 @cindex Endianness
19620 @noindent
19621 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
19622 Machine-specific implementations are available in some cases.
19624 @node GNAT.Calendar (g-calend.ads)
19625 @section @code{GNAT.Calendar} (@file{g-calend.ads})
19626 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
19627 @cindex @code{Calendar}
19629 @noindent
19630 Extends the facilities provided by @code{Ada.Calendar} to include handling
19631 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
19632 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
19633 C @code{timeval} format.
19635 @node GNAT.Calendar.Time_IO (g-catiio.ads)
19636 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19637 @cindex @code{Calendar}
19638 @cindex Time
19639 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19641 @node GNAT.Case_Util (g-casuti.ads)
19642 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
19643 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
19644 @cindex Casing utilities
19645 @cindex Character handling (@code{GNAT.Case_Util})
19647 @noindent
19648 A set of simple routines for handling upper and lower casing of strings
19649 without the overhead of the full casing tables
19650 in @code{Ada.Characters.Handling}.
19652 @node GNAT.CGI (g-cgi.ads)
19653 @section @code{GNAT.CGI} (@file{g-cgi.ads})
19654 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
19655 @cindex CGI (Common Gateway Interface)
19657 @noindent
19658 This is a package for interfacing a GNAT program with a Web server via the
19659 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
19660 parameters, which are a set of key/value pairs sent by the Web server.  It
19661 builds a table whose index is the key and provides some services to deal
19662 with this table.
19664 @node GNAT.CGI.Cookie (g-cgicoo.ads)
19665 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19666 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19667 @cindex CGI (Common Gateway Interface) cookie support
19668 @cindex Cookie support in CGI
19670 @noindent
19671 This is a package to interface a GNAT program with a Web server via the
19672 Common Gateway Interface (CGI).  It exports services to deal with Web
19673 cookies (piece of information kept in the Web client software).
19675 @node GNAT.CGI.Debug (g-cgideb.ads)
19676 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19677 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19678 @cindex CGI (Common Gateway Interface) debugging
19680 @noindent
19681 This is a package to help debugging CGI (Common Gateway Interface)
19682 programs written in Ada.
19684 @node GNAT.Command_Line (g-comlin.ads)
19685 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
19686 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
19687 @cindex Command line
19689 @noindent
19690 Provides a high level interface to @code{Ada.Command_Line} facilities,
19691 including the ability to scan for named switches with optional parameters
19692 and expand file names using wild card notations.
19694 @node GNAT.Compiler_Version (g-comver.ads)
19695 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19696 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19697 @cindex Compiler Version
19698 @cindex Version, of compiler
19700 @noindent
19701 Provides a routine for obtaining the version of the compiler used to
19702 compile the program. More accurately this is the version of the binder
19703 used to bind the program (this will normally be the same as the version
19704 of the compiler if a consistent tool set is used to compile all units
19705 of a partition).
19707 @node GNAT.Ctrl_C (g-ctrl_c.ads)
19708 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19709 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19710 @cindex Interrupt
19712 @noindent
19713 Provides a simple interface to handle Ctrl-C keyboard events.
19715 @node GNAT.CRC32 (g-crc32.ads)
19716 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
19717 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
19718 @cindex CRC32
19719 @cindex Cyclic Redundancy Check
19721 @noindent
19722 This package implements the CRC-32 algorithm.  For a full description
19723 of this algorithm see
19724 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
19725 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
19726 Aug.@: 1988.  Sarwate, D.V@.
19728 @node GNAT.Current_Exception (g-curexc.ads)
19729 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19730 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19731 @cindex Current exception
19732 @cindex Exception retrieval
19734 @noindent
19735 Provides access to information on the current exception that has been raised
19736 without the need for using the Ada 95 / Ada 2005 exception choice parameter
19737 specification syntax.
19738 This is particularly useful in simulating typical facilities for
19739 obtaining information about exceptions provided by Ada 83 compilers.
19741 @node GNAT.Debug_Pools (g-debpoo.ads)
19742 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19743 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19744 @cindex Debugging
19745 @cindex Debug pools
19746 @cindex Memory corruption debugging
19748 @noindent
19749 Provide a debugging storage pools that helps tracking memory corruption
19750 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
19751 @value{EDITION} User's Guide}.
19753 @node GNAT.Debug_Utilities (g-debuti.ads)
19754 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19755 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19756 @cindex Debugging
19758 @noindent
19759 Provides a few useful utilities for debugging purposes, including conversion
19760 to and from string images of address values. Supports both C and Ada formats
19761 for hexadecimal literals.
19763 @node GNAT.Decode_String (g-decstr.ads)
19764 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
19765 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
19766 @cindex Decoding strings
19767 @cindex String decoding
19768 @cindex Wide character encoding
19769 @cindex UTF-8
19770 @cindex Unicode
19772 @noindent
19773 A generic package providing routines for decoding wide character and wide wide
19774 character strings encoded as sequences of 8-bit characters using a specified
19775 encoding method. Includes validation routines, and also routines for stepping
19776 to next or previous encoded character in an encoded string.
19777 Useful in conjunction with Unicode character coding. Note there is a
19778 preinstantiation for UTF-8. See next entry.
19780 @node GNAT.Decode_UTF8_String (g-deutst.ads)
19781 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19782 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19783 @cindex Decoding strings
19784 @cindex Decoding UTF-8 strings
19785 @cindex UTF-8 string decoding
19786 @cindex Wide character decoding
19787 @cindex UTF-8
19788 @cindex Unicode
19790 @noindent
19791 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
19793 @node GNAT.Directory_Operations (g-dirope.ads)
19794 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19795 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19796 @cindex Directory operations
19798 @noindent
19799 Provides a set of routines for manipulating directories, including changing
19800 the current directory, making new directories, and scanning the files in a
19801 directory.
19803 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
19804 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19805 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19806 @cindex Directory operations iteration
19808 @noindent
19809 A child unit of GNAT.Directory_Operations providing additional operations
19810 for iterating through directories.
19812 @node GNAT.Dynamic_HTables (g-dynhta.ads)
19813 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19814 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19815 @cindex Hash tables
19817 @noindent
19818 A generic implementation of hash tables that can be used to hash arbitrary
19819 data.  Provided in two forms, a simple form with built in hash functions,
19820 and a more complex form in which the hash function is supplied.
19822 @noindent
19823 This package provides a facility similar to that of @code{GNAT.HTable},
19824 except that this package declares a type that can be used to define
19825 dynamic instances of the hash table, while an instantiation of
19826 @code{GNAT.HTable} creates a single instance of the hash table.
19828 @node GNAT.Dynamic_Tables (g-dyntab.ads)
19829 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19830 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19831 @cindex Table implementation
19832 @cindex Arrays, extendable
19834 @noindent
19835 A generic package providing a single dimension array abstraction where the
19836 length of the array can be dynamically modified.
19838 @noindent
19839 This package provides a facility similar to that of @code{GNAT.Table},
19840 except that this package declares a type that can be used to define
19841 dynamic instances of the table, while an instantiation of
19842 @code{GNAT.Table} creates a single instance of the table type.
19844 @node GNAT.Encode_String (g-encstr.ads)
19845 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
19846 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
19847 @cindex Encoding strings
19848 @cindex String encoding
19849 @cindex Wide character encoding
19850 @cindex UTF-8
19851 @cindex Unicode
19853 @noindent
19854 A generic package providing routines for encoding wide character and wide
19855 wide character strings as sequences of 8-bit characters using a specified
19856 encoding method. Useful in conjunction with Unicode character coding.
19857 Note there is a preinstantiation for UTF-8. See next entry.
19859 @node GNAT.Encode_UTF8_String (g-enutst.ads)
19860 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19861 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19862 @cindex Encoding strings
19863 @cindex Encoding UTF-8 strings
19864 @cindex UTF-8 string encoding
19865 @cindex Wide character encoding
19866 @cindex UTF-8
19867 @cindex Unicode
19869 @noindent
19870 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
19872 @node GNAT.Exception_Actions (g-excact.ads)
19873 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19874 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19875 @cindex Exception actions
19877 @noindent
19878 Provides callbacks when an exception is raised. Callbacks can be registered
19879 for specific exceptions, or when any exception is raised. This
19880 can be used for instance to force a core dump to ease debugging.
19882 @node GNAT.Exception_Traces (g-exctra.ads)
19883 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19884 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19885 @cindex Exception traces
19886 @cindex Debugging
19888 @noindent
19889 Provides an interface allowing to control automatic output upon exception
19890 occurrences.
19892 @node GNAT.Exceptions (g-except.ads)
19893 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
19894 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
19895 @cindex Exceptions, Pure
19896 @cindex Pure packages, exceptions
19898 @noindent
19899 Normally it is not possible to raise an exception with
19900 a message from a subprogram in a pure package, since the
19901 necessary types and subprograms are in @code{Ada.Exceptions}
19902 which is not a pure unit. @code{GNAT.Exceptions} provides a
19903 facility for getting around this limitation for a few
19904 predefined exceptions, and for example allow raising
19905 @code{Constraint_Error} with a message from a pure subprogram.
19907 @node GNAT.Expect (g-expect.ads)
19908 @section @code{GNAT.Expect} (@file{g-expect.ads})
19909 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
19911 @noindent
19912 Provides a set of subprograms similar to what is available
19913 with the standard Tcl Expect tool.
19914 It allows you to easily spawn and communicate with an external process.
19915 You can send commands or inputs to the process, and compare the output
19916 with some expected regular expression. Currently @code{GNAT.Expect}
19917 is implemented on all native GNAT ports except for OpenVMS@.
19918 It is not implemented for cross ports, and in particular is not
19919 implemented for VxWorks or LynxOS@.
19921 @node GNAT.Expect.TTY (g-exptty.ads)
19922 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
19923 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
19925 @noindent
19926 As GNAT.Expect but using pseudo-terminal.
19927 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
19928 ports except for OpenVMS@. It is not implemented for cross ports, and
19929 in particular is not implemented for VxWorks or LynxOS@.
19931 @node GNAT.Float_Control (g-flocon.ads)
19932 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
19933 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
19934 @cindex Floating-Point Processor
19936 @noindent
19937 Provides an interface for resetting the floating-point processor into the
19938 mode required for correct semantic operation in Ada.  Some third party
19939 library calls may cause this mode to be modified, and the Reset procedure
19940 in this package can be used to reestablish the required mode.
19942 @node GNAT.Formatted_String (g-forstr.ads)
19943 @section @code{GNAT.Formatted_String} (@file{g-forstr.ads})
19944 @cindex @code{GNAT.Formatted_String} (@file{g-forstr.ads})
19945 @cindex Formatted String
19947 @noindent
19948 Provides support for C/C++ printf() formatted strings. The format is
19949 copied from the printf() routine and should therefore gives identical
19950 output. Some generic routines are provided to be able to use types
19951 derived from Integer, Float or enumerations as values for the
19952 formatted string.
19954 @node GNAT.Heap_Sort (g-heasor.ads)
19955 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
19956 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
19957 @cindex Sorting
19959 @noindent
19960 Provides a general implementation of heap sort usable for sorting arbitrary
19961 data items. Exchange and comparison procedures are provided by passing
19962 access-to-procedure values.  The algorithm used is a modified heap sort
19963 that performs approximately N*log(N) comparisons in the worst case.
19965 @node GNAT.Heap_Sort_A (g-hesora.ads)
19966 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
19967 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
19968 @cindex Sorting
19970 @noindent
19971 Provides a general implementation of heap sort usable for sorting arbitrary
19972 data items. Move and comparison procedures are provided by passing
19973 access-to-procedure values.  The algorithm used is a modified heap sort
19974 that performs approximately N*log(N) comparisons in the worst case.
19975 This differs from @code{GNAT.Heap_Sort} in having a less convenient
19976 interface, but may be slightly more efficient.
19978 @node GNAT.Heap_Sort_G (g-hesorg.ads)
19979 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
19980 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
19981 @cindex Sorting
19983 @noindent
19984 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
19985 are provided as generic parameters, this improves efficiency, especially
19986 if the procedures can be inlined, at the expense of duplicating code for
19987 multiple instantiations.
19989 @node GNAT.HTable (g-htable.ads)
19990 @section @code{GNAT.HTable} (@file{g-htable.ads})
19991 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
19992 @cindex Hash tables
19994 @noindent
19995 A generic implementation of hash tables that can be used to hash arbitrary
19996 data.  Provides two approaches, one a simple static approach, and the other
19997 allowing arbitrary dynamic hash tables.
19999 @node GNAT.IO (g-io.ads)
20000 @section @code{GNAT.IO} (@file{g-io.ads})
20001 @cindex @code{GNAT.IO} (@file{g-io.ads})
20002 @cindex Simple I/O
20003 @cindex Input/Output facilities
20005 @noindent
20006 A simple preelaborable input-output package that provides a subset of
20007 simple Text_IO functions for reading characters and strings from
20008 Standard_Input, and writing characters, strings and integers to either
20009 Standard_Output or Standard_Error.
20011 @node GNAT.IO_Aux (g-io_aux.ads)
20012 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
20013 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
20014 @cindex Text_IO
20015 @cindex Input/Output facilities
20017 Provides some auxiliary functions for use with Text_IO, including a test
20018 for whether a file exists, and functions for reading a line of text.
20020 @node GNAT.Lock_Files (g-locfil.ads)
20021 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
20022 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
20023 @cindex File locking
20024 @cindex Locking using files
20026 @noindent
20027 Provides a general interface for using files as locks.  Can be used for
20028 providing program level synchronization.
20030 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
20031 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
20032 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
20033 @cindex Random number generation
20035 @noindent
20036 The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
20037 a modified version of the Blum-Blum-Shub generator.
20039 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
20040 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
20041 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
20042 @cindex Random number generation
20044 @noindent
20045 The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
20046 a modified version of the Blum-Blum-Shub generator.
20048 @node GNAT.MD5 (g-md5.ads)
20049 @section @code{GNAT.MD5} (@file{g-md5.ads})
20050 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
20051 @cindex Message Digest MD5
20053 @noindent
20054 Implements the MD5 Message-Digest Algorithm as described in RFC 1321, and
20055 the HMAC-MD5 message authentication function as described in RFC 2104 and
20056 FIPS PUB 198.
20058 @node GNAT.Memory_Dump (g-memdum.ads)
20059 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
20060 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
20061 @cindex Dump Memory
20063 @noindent
20064 Provides a convenient routine for dumping raw memory to either the
20065 standard output or standard error files. Uses GNAT.IO for actual
20066 output.
20068 @node GNAT.Most_Recent_Exception (g-moreex.ads)
20069 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
20070 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
20071 @cindex Exception, obtaining most recent
20073 @noindent
20074 Provides access to the most recently raised exception.  Can be used for
20075 various logging purposes, including duplicating functionality of some
20076 Ada 83 implementation dependent extensions.
20078 @node GNAT.OS_Lib (g-os_lib.ads)
20079 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
20080 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
20081 @cindex Operating System interface
20082 @cindex Spawn capability
20084 @noindent
20085 Provides a range of target independent operating system interface functions,
20086 including time/date management, file operations, subprocess management,
20087 including a portable spawn procedure, and access to environment variables
20088 and error return codes.
20090 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
20091 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
20092 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
20093 @cindex Hash functions
20095 @noindent
20096 Provides a generator of static minimal perfect hash functions. No
20097 collisions occur and each item can be retrieved from the table in one
20098 probe (perfect property). The hash table size corresponds to the exact
20099 size of the key set and no larger (minimal property). The key set has to
20100 be know in advance (static property). The hash functions are also order
20101 preserving. If w2 is inserted after w1 in the generator, their
20102 hashcode are in the same order. These hashing functions are very
20103 convenient for use with realtime applications.
20105 @node GNAT.Random_Numbers (g-rannum.ads)
20106 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
20107 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
20108 @cindex Random number generation
20110 @noindent
20111 Provides random number capabilities which extend those available in the
20112 standard Ada library and are more convenient to use.
20114 @node GNAT.Regexp (g-regexp.ads)
20115 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
20116 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
20117 @cindex Regular expressions
20118 @cindex Pattern matching
20120 @noindent
20121 A simple implementation of regular expressions, using a subset of regular
20122 expression syntax copied from familiar Unix style utilities.  This is the
20123 simplest of the three pattern matching packages provided, and is particularly
20124 suitable for ``file globbing'' applications.
20126 @node GNAT.Registry (g-regist.ads)
20127 @section @code{GNAT.Registry} (@file{g-regist.ads})
20128 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
20129 @cindex Windows Registry
20131 @noindent
20132 This is a high level binding to the Windows registry.  It is possible to
20133 do simple things like reading a key value, creating a new key.  For full
20134 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
20135 package provided with the Win32Ada binding
20137 @node GNAT.Regpat (g-regpat.ads)
20138 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
20139 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
20140 @cindex Regular expressions
20141 @cindex Pattern matching
20143 @noindent
20144 A complete implementation of Unix-style regular expression matching, copied
20145 from the original V7 style regular expression library written in C by
20146 Henry Spencer (and binary compatible with this C library).
20148 @node GNAT.Rewrite_Data (g-rewdat.ads)
20149 @section @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
20150 @cindex @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
20151 @cindex Rewrite data
20153 @noindent
20154 A unit to rewrite on-the-fly string occurrences in a stream of
20155 data. The implementation has a very minimal memory footprint as the
20156 full content to be processed is not loaded into memory all at once. This makes
20157 this interface usable for large files or socket streams.
20159 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
20160 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
20161 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
20162 @cindex Secondary Stack Info
20164 @noindent
20165 Provide the capability to query the high water mark of the current task's
20166 secondary stack.
20168 @node GNAT.Semaphores (g-semaph.ads)
20169 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
20170 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
20171 @cindex Semaphores
20173 @noindent
20174 Provides classic counting and binary semaphores using protected types.
20176 @node GNAT.Serial_Communications (g-sercom.ads)
20177 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
20178 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
20179 @cindex Serial_Communications
20181 @noindent
20182 Provides a simple interface to send and receive data over a serial
20183 port. This is only supported on GNU/Linux and Windows.
20185 @node GNAT.SHA1 (g-sha1.ads)
20186 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
20187 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
20188 @cindex Secure Hash Algorithm SHA-1
20190 @noindent
20191 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
20192 and RFC 3174, and the HMAC-SHA1 message authentication function as described
20193 in RFC 2104 and FIPS PUB 198.
20195 @node GNAT.SHA224 (g-sha224.ads)
20196 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
20197 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
20198 @cindex Secure Hash Algorithm SHA-224
20200 @noindent
20201 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3,
20202 and the HMAC-SHA224 message authentication function as described
20203 in RFC 2104 and FIPS PUB 198.
20205 @node GNAT.SHA256 (g-sha256.ads)
20206 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
20207 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
20208 @cindex Secure Hash Algorithm SHA-256
20210 @noindent
20211 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3,
20212 and the HMAC-SHA256 message authentication function as described
20213 in RFC 2104 and FIPS PUB 198.
20215 @node GNAT.SHA384 (g-sha384.ads)
20216 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
20217 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
20218 @cindex Secure Hash Algorithm SHA-384
20220 @noindent
20221 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3,
20222 and the HMAC-SHA384 message authentication function as described
20223 in RFC 2104 and FIPS PUB 198.
20225 @node GNAT.SHA512 (g-sha512.ads)
20226 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
20227 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
20228 @cindex Secure Hash Algorithm SHA-512
20230 @noindent
20231 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3,
20232 and the HMAC-SHA512 message authentication function as described
20233 in RFC 2104 and FIPS PUB 198.
20235 @node GNAT.Signals (g-signal.ads)
20236 @section @code{GNAT.Signals} (@file{g-signal.ads})
20237 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
20238 @cindex Signals
20240 @noindent
20241 Provides the ability to manipulate the blocked status of signals on supported
20242 targets.
20244 @node GNAT.Sockets (g-socket.ads)
20245 @section @code{GNAT.Sockets} (@file{g-socket.ads})
20246 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
20247 @cindex Sockets
20249 @noindent
20250 A high level and portable interface to develop sockets based applications.
20251 This package is based on the sockets thin binding found in
20252 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
20253 on all native GNAT ports except for OpenVMS@.  It is not implemented
20254 for the LynxOS@ cross port.
20256 @node GNAT.Source_Info (g-souinf.ads)
20257 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
20258 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
20259 @cindex Source Information
20261 @noindent
20262 Provides subprograms that give access to source code information known at
20263 compile time, such as the current file name and line number. Also provides
20264 subprograms yielding the date and time of the current compilation (like the
20265 C macros @code{__DATE__} and @code{__TIME__})
20267 @node GNAT.Spelling_Checker (g-speche.ads)
20268 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
20269 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
20270 @cindex Spell checking
20272 @noindent
20273 Provides a function for determining whether one string is a plausible
20274 near misspelling of another string.
20276 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
20277 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
20278 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
20279 @cindex Spell checking
20281 @noindent
20282 Provides a generic function that can be instantiated with a string type for
20283 determining whether one string is a plausible near misspelling of another
20284 string.
20286 @node GNAT.Spitbol.Patterns (g-spipat.ads)
20287 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
20288 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
20289 @cindex SPITBOL pattern matching
20290 @cindex Pattern matching
20292 @noindent
20293 A complete implementation of SNOBOL4 style pattern matching.  This is the
20294 most elaborate of the pattern matching packages provided.  It fully duplicates
20295 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
20296 efficient algorithm developed by Robert Dewar for the SPITBOL system.
20298 @node GNAT.Spitbol (g-spitbo.ads)
20299 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
20300 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
20301 @cindex SPITBOL interface
20303 @noindent
20304 The top level package of the collection of SPITBOL-style functionality, this
20305 package provides basic SNOBOL4 string manipulation functions, such as
20306 Pad, Reverse, Trim, Substr capability, as well as a generic table function
20307 useful for constructing arbitrary mappings from strings in the style of
20308 the SNOBOL4 TABLE function.
20310 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
20311 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
20312 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
20313 @cindex Sets of strings
20314 @cindex SPITBOL Tables
20316 @noindent
20317 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
20318 for type @code{Standard.Boolean}, giving an implementation of sets of
20319 string values.
20321 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
20322 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
20323 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
20324 @cindex Integer maps
20325 @cindex Maps
20326 @cindex SPITBOL Tables
20328 @noindent
20329 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
20330 for type @code{Standard.Integer}, giving an implementation of maps
20331 from string to integer values.
20333 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
20334 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
20335 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
20336 @cindex String maps
20337 @cindex Maps
20338 @cindex SPITBOL Tables
20340 @noindent
20341 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
20342 a variable length string type, giving an implementation of general
20343 maps from strings to strings.
20345 @node GNAT.SSE (g-sse.ads)
20346 @section @code{GNAT.SSE} (@file{g-sse.ads})
20347 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
20349 @noindent
20350 Root of a set of units aimed at offering Ada bindings to a subset of
20351 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
20352 targets.  It exposes vector component types together with a general
20353 introduction to the binding contents and use.
20355 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
20356 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
20357 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
20359 @noindent
20360 SSE vector types for use with SSE related intrinsics.
20362 @node GNAT.Strings (g-string.ads)
20363 @section @code{GNAT.Strings} (@file{g-string.ads})
20364 @cindex @code{GNAT.Strings} (@file{g-string.ads})
20366 @noindent
20367 Common String access types and related subprograms. Basically it
20368 defines a string access and an array of string access types.
20370 @node GNAT.String_Split (g-strspl.ads)
20371 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
20372 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
20373 @cindex String splitter
20375 @noindent
20376 Useful string manipulation routines: given a set of separators, split
20377 a string wherever the separators appear, and provide direct access
20378 to the resulting slices. This package is instantiated from
20379 @code{GNAT.Array_Split}.
20381 @node GNAT.Table (g-table.ads)
20382 @section @code{GNAT.Table} (@file{g-table.ads})
20383 @cindex @code{GNAT.Table} (@file{g-table.ads})
20384 @cindex Table implementation
20385 @cindex Arrays, extendable
20387 @noindent
20388 A generic package providing a single dimension array abstraction where the
20389 length of the array can be dynamically modified.
20391 @noindent
20392 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
20393 except that this package declares a single instance of the table type,
20394 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
20395 used to define dynamic instances of the table.
20397 @node GNAT.Task_Lock (g-tasloc.ads)
20398 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
20399 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
20400 @cindex Task synchronization
20401 @cindex Task locking
20402 @cindex Locking
20404 @noindent
20405 A very simple facility for locking and unlocking sections of code using a
20406 single global task lock.  Appropriate for use in situations where contention
20407 between tasks is very rarely expected.
20409 @node GNAT.Threads (g-thread.ads)
20410 @section @code{GNAT.Threads} (@file{g-thread.ads})
20411 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
20412 @cindex Foreign threads
20413 @cindex Threads, foreign
20415 @noindent
20416 Provides facilities for dealing with foreign threads which need to be known
20417 by the GNAT run-time system. Consult the documentation of this package for
20418 further details if your program has threads that are created by a non-Ada
20419 environment which then accesses Ada code.
20421 @node GNAT.Time_Stamp (g-timsta.ads)
20422 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
20423 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
20424 @cindex Time stamp
20425 @cindex Current time
20427 @noindent
20428 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
20429 represents the current date and time in ISO 8601 format. This is a very simple
20430 routine with minimal code and there are no dependencies on any other unit.
20432 @node GNAT.Traceback (g-traceb.ads)
20433 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
20434 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
20435 @cindex Trace back facilities
20437 @noindent
20438 Provides a facility for obtaining non-symbolic traceback information, useful
20439 in various debugging situations.
20441 @node GNAT.Traceback.Symbolic (g-trasym.ads)
20442 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
20443 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
20444 @cindex Trace back facilities
20446 @node GNAT.UTF_32 (g-utf_32.ads)
20447 @section @code{GNAT.UTF_32} (@file{g-table.ads})
20448 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
20449 @cindex Wide character codes
20451 @noindent
20452 This is a package intended to be used in conjunction with the
20453 @code{Wide_Character} type in Ada 95 and the
20454 @code{Wide_Wide_Character} type in Ada 2005 (available
20455 in @code{GNAT} in Ada 2005 mode). This package contains
20456 Unicode categorization routines, as well as lexical
20457 categorization routines corresponding to the Ada 2005
20458 lexical rules for identifiers and strings, and also a
20459 lower case to upper case fold routine corresponding to
20460 the Ada 2005 rules for identifier equivalence.
20462 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
20463 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
20464 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
20465 @cindex Spell checking
20467 @noindent
20468 Provides a function for determining whether one wide wide string is a plausible
20469 near misspelling of another wide wide string, where the strings are represented
20470 using the UTF_32_String type defined in System.Wch_Cnv.
20472 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
20473 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
20474 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
20475 @cindex Spell checking
20477 @noindent
20478 Provides a function for determining whether one wide string is a plausible
20479 near misspelling of another wide string.
20481 @node GNAT.Wide_String_Split (g-wistsp.ads)
20482 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
20483 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
20484 @cindex Wide_String splitter
20486 @noindent
20487 Useful wide string manipulation routines: given a set of separators, split
20488 a wide string wherever the separators appear, and provide direct access
20489 to the resulting slices. This package is instantiated from
20490 @code{GNAT.Array_Split}.
20492 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
20493 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
20494 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
20495 @cindex Spell checking
20497 @noindent
20498 Provides a function for determining whether one wide wide string is a plausible
20499 near misspelling of another wide wide string.
20501 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
20502 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
20503 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
20504 @cindex Wide_Wide_String splitter
20506 @noindent
20507 Useful wide wide string manipulation routines: given a set of separators, split
20508 a wide wide string wherever the separators appear, and provide direct access
20509 to the resulting slices. This package is instantiated from
20510 @code{GNAT.Array_Split}.
20512 @node Interfaces.C.Extensions (i-cexten.ads)
20513 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
20514 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
20516 @noindent
20517 This package contains additional C-related definitions, intended
20518 for use with either manually or automatically generated bindings
20519 to C libraries.
20521 @node Interfaces.C.Streams (i-cstrea.ads)
20522 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
20523 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
20524 @cindex  C streams, interfacing
20526 @noindent
20527 This package is a binding for the most commonly used operations
20528 on C streams.
20530 @node Interfaces.Packed_Decimal (i-pacdec.ads)
20531 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20532 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20533 @cindex  IBM Packed Format
20534 @cindex  Packed Decimal
20536 @noindent
20537 This package provides a set of routines for conversions to and
20538 from a packed decimal format compatible with that used on IBM
20539 mainframes.
20541 @node Interfaces.VxWorks (i-vxwork.ads)
20542 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20543 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20544 @cindex Interfacing to VxWorks
20545 @cindex VxWorks, interfacing
20547 @noindent
20548 This package provides a limited binding to the VxWorks API.
20549 In particular, it interfaces with the
20550 VxWorks hardware interrupt facilities.
20552 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
20553 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20554 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20555 @cindex Interfacing to VxWorks' I/O
20556 @cindex VxWorks, I/O interfacing
20557 @cindex VxWorks, Get_Immediate
20558 @cindex Get_Immediate, VxWorks
20560 @noindent
20561 This package provides a binding to the ioctl (IO/Control)
20562 function of VxWorks, defining a set of option values and
20563 function codes. A particular use of this package is
20564 to enable the use of Get_Immediate under VxWorks.
20566 @node System.Address_Image (s-addima.ads)
20567 @section @code{System.Address_Image} (@file{s-addima.ads})
20568 @cindex @code{System.Address_Image} (@file{s-addima.ads})
20569 @cindex Address image
20570 @cindex Image, of an address
20572 @noindent
20573 This function provides a useful debugging
20574 function that gives an (implementation dependent)
20575 string which identifies an address.
20577 @node System.Assertions (s-assert.ads)
20578 @section @code{System.Assertions} (@file{s-assert.ads})
20579 @cindex @code{System.Assertions} (@file{s-assert.ads})
20580 @cindex Assertions
20581 @cindex Assert_Failure, exception
20583 @noindent
20584 This package provides the declaration of the exception raised
20585 by an run-time assertion failure, as well as the routine that
20586 is used internally to raise this assertion.
20588 @node System.Memory (s-memory.ads)
20589 @section @code{System.Memory} (@file{s-memory.ads})
20590 @cindex @code{System.Memory} (@file{s-memory.ads})
20591 @cindex Memory allocation
20593 @noindent
20594 This package provides the interface to the low level routines used
20595 by the generated code for allocation and freeing storage for the
20596 default storage pool (analogous to the C routines malloc and free.
20597 It also provides a reallocation interface analogous to the C routine
20598 realloc. The body of this unit may be modified to provide alternative
20599 allocation mechanisms for the default pool, and in addition, direct
20600 calls to this unit may be made for low level allocation uses (for
20601 example see the body of @code{GNAT.Tables}).
20603 @node System.Multiprocessors (s-multip.ads)
20604 @section @code{System.Multiprocessors} (@file{s-multip.ads})
20605 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
20606 @cindex Multiprocessor interface
20607 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20608 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20609 technically an implementation-defined addition).
20611 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
20612 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20613 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20614 @cindex Multiprocessor interface
20615 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20616 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20617 technically an implementation-defined addition).
20619 @node System.Partition_Interface (s-parint.ads)
20620 @section @code{System.Partition_Interface} (@file{s-parint.ads})
20621 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
20622 @cindex Partition interfacing functions
20624 @noindent
20625 This package provides facilities for partition interfacing.  It
20626 is used primarily in a distribution context when using Annex E
20627 with @code{GLADE}.
20629 @node System.Pool_Global (s-pooglo.ads)
20630 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
20631 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
20632 @cindex Storage pool, global
20633 @cindex Global storage pool
20635 @noindent
20636 This package provides a storage pool that is equivalent to the default
20637 storage pool used for access types for which no pool is specifically
20638 declared. It uses malloc/free to allocate/free and does not attempt to
20639 do any automatic reclamation.
20641 @node System.Pool_Local (s-pooloc.ads)
20642 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
20643 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
20644 @cindex Storage pool, local
20645 @cindex Local storage pool
20647 @noindent
20648 This package provides a storage pool that is intended for use with locally
20649 defined access types. It uses malloc/free for allocate/free, and maintains
20650 a list of allocated blocks, so that all storage allocated for the pool can
20651 be freed automatically when the pool is finalized.
20653 @node System.Restrictions (s-restri.ads)
20654 @section @code{System.Restrictions} (@file{s-restri.ads})
20655 @cindex @code{System.Restrictions} (@file{s-restri.ads})
20656 @cindex Run-time restrictions access
20658 @noindent
20659 This package provides facilities for accessing at run time
20660 the status of restrictions specified at compile time for
20661 the partition. Information is available both with regard
20662 to actual restrictions specified, and with regard to
20663 compiler determined information on which restrictions
20664 are violated by one or more packages in the partition.
20666 @node System.Rident (s-rident.ads)
20667 @section @code{System.Rident} (@file{s-rident.ads})
20668 @cindex @code{System.Rident} (@file{s-rident.ads})
20669 @cindex Restrictions definitions
20671 @noindent
20672 This package provides definitions of the restrictions
20673 identifiers supported by GNAT, and also the format of
20674 the restrictions provided in package System.Restrictions.
20675 It is not normally necessary to @code{with} this generic package
20676 since the necessary instantiation is included in
20677 package System.Restrictions.
20679 @node System.Strings.Stream_Ops (s-ststop.ads)
20680 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20681 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20682 @cindex Stream operations
20683 @cindex String stream operations
20685 @noindent
20686 This package provides a set of stream subprograms for standard string types.
20687 It is intended primarily to support implicit use of such subprograms when
20688 stream attributes are applied to string types, but the subprograms in this
20689 package can be used directly by application programs.
20691 @node System.Unsigned_Types (s-unstyp.ads)
20692 @section @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20693 @cindex @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20695 @noindent
20696 This package contains definitions of standard unsigned types that
20697 correspond in size to the standard signed types declared in Standard,
20698 and (unlike the types in Interfaces) have corresponding names. It
20699 also contains some related definitions for other specialized types
20700 used by the compiler in connection with packed array types.
20702 @node System.Wch_Cnv (s-wchcnv.ads)
20703 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20704 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20705 @cindex Wide Character, Representation
20706 @cindex Wide String, Conversion
20707 @cindex Representation of wide characters
20709 @noindent
20710 This package provides routines for converting between
20711 wide and wide wide characters and a representation as a value of type
20712 @code{Standard.String}, using a specified wide character
20713 encoding method.  It uses definitions in
20714 package @code{System.Wch_Con}.
20716 @node System.Wch_Con (s-wchcon.ads)
20717 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
20718 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
20720 @noindent
20721 This package provides definitions and descriptions of
20722 the various methods used for encoding wide characters
20723 in ordinary strings.  These definitions are used by
20724 the package @code{System.Wch_Cnv}.
20726 @node Interfacing to Other Languages
20727 @chapter Interfacing to Other Languages
20728 @noindent
20729 The facilities in annex B of the Ada Reference Manual are fully
20730 implemented in GNAT, and in addition, a full interface to C++ is
20731 provided.
20733 @menu
20734 * Interfacing to C::
20735 * Interfacing to C++::
20736 * Interfacing to COBOL::
20737 * Interfacing to Fortran::
20738 * Interfacing to non-GNAT Ada code::
20739 @end menu
20741 @node Interfacing to C
20742 @section Interfacing to C
20744 @noindent
20745 Interfacing to C with GNAT can use one of two approaches:
20747 @itemize @bullet
20748 @item
20749 The types in the package @code{Interfaces.C} may be used.
20750 @item
20751 Standard Ada types may be used directly.  This may be less portable to
20752 other compilers, but will work on all GNAT compilers, which guarantee
20753 correspondence between the C and Ada types.
20754 @end itemize
20756 @noindent
20757 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
20758 effect, since this is the default.  The following table shows the
20759 correspondence between Ada scalar types and the corresponding C types.
20761 @table @code
20762 @item Integer
20763 @code{int}
20764 @item Short_Integer
20765 @code{short}
20766 @item Short_Short_Integer
20767 @code{signed char}
20768 @item Long_Integer
20769 @code{long}
20770 @item Long_Long_Integer
20771 @code{long long}
20772 @item Short_Float
20773 @code{float}
20774 @item Float
20775 @code{float}
20776 @item Long_Float
20777 @code{double}
20778 @item Long_Long_Float
20779 This is the longest floating-point type supported by the hardware.
20780 @end table
20782 @noindent
20783 Additionally, there are the following general correspondences between Ada
20784 and C types:
20785 @itemize @bullet
20786 @item
20787 Ada enumeration types map to C enumeration types directly if pragma
20788 @code{Convention C} is specified, which causes them to have int
20789 length.  Without pragma @code{Convention C}, Ada enumeration types map to
20790 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
20791 @code{int}, respectively) depending on the number of values passed.
20792 This is the only case in which pragma @code{Convention C} affects the
20793 representation of an Ada type.
20795 @item
20796 Ada access types map to C pointers, except for the case of pointers to
20797 unconstrained types in Ada, which have no direct C equivalent.
20799 @item
20800 Ada arrays map directly to C arrays.
20802 @item
20803 Ada records map directly to C structures.
20805 @item
20806 Packed Ada records map to C structures where all members are bit fields
20807 of the length corresponding to the @code{@var{type}'Size} value in Ada.
20808 @end itemize
20810 @node Interfacing to C++
20811 @section Interfacing to C++
20813 @noindent
20814 The interface to C++ makes use of the following pragmas, which are
20815 primarily intended to be constructed automatically using a binding generator
20816 tool, although it is possible to construct them by hand.
20818 Using these pragmas it is possible to achieve complete
20819 inter-operability between Ada tagged types and C++ class definitions.
20820 See @ref{Implementation Defined Pragmas}, for more details.
20822 @table @code
20823 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
20824 The argument denotes an entity in the current declarative region that is
20825 declared as a tagged or untagged record type. It indicates that the type
20826 corresponds to an externally declared C++ class type, and is to be laid
20827 out the same way that C++ would lay out the type.
20829 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
20830 for backward compatibility but its functionality is available
20831 using pragma @code{Import} with @code{Convention} = @code{CPP}.
20833 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
20834 This pragma identifies an imported function (imported in the usual way
20835 with pragma @code{Import}) as corresponding to a C++ constructor.
20836 @end table
20838 A few restrictions are placed on the use of the @code{Access} attribute
20839 in conjunction with subprograms subject to convention @code{CPP}: the
20840 attribute may be used neither on primitive operations of a tagged
20841 record type with convention @code{CPP}, imported or not, nor on
20842 subprograms imported with pragma @code{CPP_Constructor}.
20844 In addition, C++ exceptions are propagated and can be handled in an
20845 @code{others} choice of an exception handler. The corresponding Ada
20846 occurrence has no message, and the simple name of the exception identity
20847 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
20848 tasks works properly when such foreign exceptions are propagated.
20850 It is also possible to import a C++ exception using the following syntax:
20852 @smallexample @c ada
20853 LOCAL_NAME : exception;
20854 pragma Import (Cpp,
20855   [Entity =>] LOCAL_NAME,
20856   [External_Name =>] static_string_EXPRESSION);
20857 @end smallexample
20859 @noindent
20860 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
20861 cover a specific C++ exception in an exception handler.
20863 @node Interfacing to COBOL
20864 @section Interfacing to COBOL
20866 @noindent
20867 Interfacing to COBOL is achieved as described in section B.4 of
20868 the Ada Reference Manual.
20870 @node Interfacing to Fortran
20871 @section Interfacing to Fortran
20873 @noindent
20874 Interfacing to Fortran is achieved as described in section B.5 of the
20875 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
20876 multi-dimensional array causes the array to be stored in column-major
20877 order as required for convenient interface to Fortran.
20879 @node Interfacing to non-GNAT Ada code
20880 @section Interfacing to non-GNAT Ada code
20882 It is possible to specify the convention @code{Ada} in a pragma
20883 @code{Import} or pragma @code{Export}.  However this refers to
20884 the calling conventions used by GNAT, which may or may not be
20885 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
20886 compiler to allow interoperation.
20888 If arguments types are kept simple, and if the foreign compiler generally
20889 follows system calling conventions, then it may be possible to integrate
20890 files compiled by other Ada compilers, provided that the elaboration
20891 issues are adequately addressed (for example by eliminating the
20892 need for any load time elaboration).
20894 In particular, GNAT running on VMS is designed to
20895 be highly compatible with the DEC Ada 83 compiler, so this is one
20896 case in which it is possible to import foreign units of this type,
20897 provided that the data items passed are restricted to simple scalar
20898 values or simple record types without variants, or simple array
20899 types with fixed bounds.
20901 @node Specialized Needs Annexes
20902 @chapter Specialized Needs Annexes
20904 @noindent
20905 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
20906 required in all implementations.  However, as described in this chapter,
20907 GNAT implements all of these annexes:
20909 @table @asis
20910 @item Systems Programming (Annex C)
20911 The Systems Programming Annex is fully implemented.
20913 @item Real-Time Systems (Annex D)
20914 The Real-Time Systems Annex is fully implemented.
20916 @item Distributed Systems (Annex E)
20917 Stub generation is fully implemented in the GNAT compiler.  In addition,
20918 a complete compatible PCS is available as part of the GLADE system,
20919 a separate product.  When the two
20920 products are used in conjunction, this annex is fully implemented.
20922 @item Information Systems (Annex F)
20923 The Information Systems annex is fully implemented.
20925 @item Numerics (Annex G)
20926 The Numerics Annex is fully implemented.
20928 @item Safety and Security / High-Integrity Systems (Annex H)
20929 The Safety and Security Annex (termed the High-Integrity Systems Annex
20930 in Ada 2005) is fully implemented.
20931 @end table
20933 @node Implementation of Specific Ada Features
20934 @chapter Implementation of Specific Ada Features
20936 @noindent
20937 This chapter describes the GNAT implementation of several Ada language
20938 facilities.
20940 @menu
20941 * Machine Code Insertions::
20942 * GNAT Implementation of Tasking::
20943 * GNAT Implementation of Shared Passive Packages::
20944 * Code Generation for Array Aggregates::
20945 * The Size of Discriminated Records with Default Discriminants::
20946 * Strict Conformance to the Ada Reference Manual::
20947 @end menu
20949 @node Machine Code Insertions
20950 @section Machine Code Insertions
20951 @cindex Machine Code insertions
20953 @noindent
20954 Package @code{Machine_Code} provides machine code support as described
20955 in the Ada Reference Manual in two separate forms:
20956 @itemize @bullet
20957 @item
20958 Machine code statements, consisting of qualified expressions that
20959 fit the requirements of RM section 13.8.
20960 @item
20961 An intrinsic callable procedure, providing an alternative mechanism of
20962 including machine instructions in a subprogram.
20963 @end itemize
20965 @noindent
20966 The two features are similar, and both are closely related to the mechanism
20967 provided by the asm instruction in the GNU C compiler.  Full understanding
20968 and use of the facilities in this package requires understanding the asm
20969 instruction, see @ref{Extended Asm,,, gcc, Using the GNU Compiler
20970 Collection (GCC)}.
20972 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
20973 semantic restrictions and effects as described below.  Both are provided so
20974 that the procedure call can be used as a statement, and the function call
20975 can be used to form a code_statement.
20977 Consider this C @code{asm} instruction:
20978 @smallexample
20979    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
20980 @end smallexample
20982 @noindent
20983 The equivalent can be written for GNAT as:
20985 @smallexample @c ada
20986 Asm ("fsinx %1 %0",
20987      My_Float'Asm_Output ("=f", result),
20988      My_Float'Asm_Input  ("f",  angle));
20989 @end smallexample
20991 @noindent
20992 The first argument to @code{Asm} is the assembler template, and is
20993 identical to what is used in GNU C@.  This string must be a static
20994 expression.  The second argument is the output operand list.  It is
20995 either a single @code{Asm_Output} attribute reference, or a list of such
20996 references enclosed in parentheses (technically an array aggregate of
20997 such references).
20999 The @code{Asm_Output} attribute denotes a function that takes two
21000 parameters.  The first is a string, the second is the name of a variable
21001 of the type designated by the attribute prefix.  The first (string)
21002 argument is required to be a static expression and designates the
21003 constraint (@pxref{Constraints,,, gcc, Using the GNU Compiler
21004 Collection (GCC)})
21005 for the parameter (e.g.@: what kind of register is required).  The second
21006 argument is the variable to be written or updated with the
21007 result.  The possible values for constraint are the same as those used in
21008 the RTL, and are dependent on the configuration file used to build the
21009 GCC back end.  If there are no output operands, then this argument may
21010 either be omitted, or explicitly given as @code{No_Output_Operands}.
21011 No support is provided for GNU C's symbolic names for output parameters.
21013 The second argument of @code{@var{my_float}'Asm_Output} functions as
21014 though it were an @code{out} parameter, which is a little curious, but
21015 all names have the form of expressions, so there is no syntactic
21016 irregularity, even though normally functions would not be permitted
21017 @code{out} parameters.  The third argument is the list of input
21018 operands.  It is either a single @code{Asm_Input} attribute reference, or
21019 a list of such references enclosed in parentheses (technically an array
21020 aggregate of such references).
21022 The @code{Asm_Input} attribute denotes a function that takes two
21023 parameters.  The first is a string, the second is an expression of the
21024 type designated by the prefix.  The first (string) argument is required
21025 to be a static expression, and is the constraint for the parameter,
21026 (e.g.@: what kind of register is required).  The second argument is the
21027 value to be used as the input argument.  The possible values for the
21028 constraint are the same as those used in the RTL, and are dependent on
21029 the configuration file used to built the GCC back end.
21030 No support is provided for GNU C's symbolic names for input parameters.
21032 If there are no input operands, this argument may either be omitted, or
21033 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
21034 present in the above example, is a list of register names, called the
21035 @dfn{clobber} argument.  This argument, if given, must be a static string
21036 expression, and is a space or comma separated list of names of registers
21037 that must be considered destroyed as a result of the @code{Asm} call.  If
21038 this argument is the null string (the default value), then the code
21039 generator assumes that no additional registers are destroyed.
21040 In addition to registers, the special clobbers @code{memory} and
21041 @code{cc} as described in the GNU C docs are both supported.
21043 The fifth argument, not present in the above example, called the
21044 @dfn{volatile} argument, is by default @code{False}.  It can be set to
21045 the literal value @code{True} to indicate to the code generator that all
21046 optimizations with respect to the instruction specified should be
21047 suppressed, and in particular an instruction that has outputs
21048 will still be generated, even if none of the outputs are
21049 used.  @xref{Volatile,,,
21050 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
21051 Generally it is strongly advisable to use Volatile for any ASM statement
21052 that is missing either input or output operands or to avoid unwanted
21053 optimizations. A warning is generated if this advice is not followed.
21055 No support is provided for GNU C's @code{asm goto} feature.
21057 The @code{Asm} subprograms may be used in two ways.  First the procedure
21058 forms can be used anywhere a procedure call would be valid, and
21059 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
21060 be used to intersperse machine instructions with other Ada statements.
21061 Second, the function forms, which return a dummy value of the limited
21062 private type @code{Asm_Insn}, can be used in code statements, and indeed
21063 this is the only context where such calls are allowed.  Code statements
21064 appear as aggregates of the form:
21066 @smallexample @c ada
21067 Asm_Insn'(Asm (@dots{}));
21068 Asm_Insn'(Asm_Volatile (@dots{}));
21069 @end smallexample
21071 @noindent
21072 In accordance with RM rules, such code statements are allowed only
21073 within subprograms whose entire body consists of such statements.  It is
21074 not permissible to intermix such statements with other Ada statements.
21076 Typically the form using intrinsic procedure calls is more convenient
21077 and more flexible.  The code statement form is provided to meet the RM
21078 suggestion that such a facility should be made available.  The following
21079 is the exact syntax of the call to @code{Asm}. As usual, if named notation
21080 is used, the arguments may be given in arbitrary order, following the
21081 normal rules for use of positional and named arguments:
21083 @smallexample
21084 ASM_CALL ::= Asm (
21085                  [Template =>] static_string_EXPRESSION
21086                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
21087                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
21088                [,[Clobber  =>] static_string_EXPRESSION ]
21089                [,[Volatile =>] static_boolean_EXPRESSION] )
21091 OUTPUT_OPERAND_LIST ::=
21092   [PREFIX.]No_Output_Operands
21093 | OUTPUT_OPERAND_ATTRIBUTE
21094 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
21096 OUTPUT_OPERAND_ATTRIBUTE ::=
21097   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
21099 INPUT_OPERAND_LIST ::=
21100   [PREFIX.]No_Input_Operands
21101 | INPUT_OPERAND_ATTRIBUTE
21102 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
21104 INPUT_OPERAND_ATTRIBUTE ::=
21105   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
21106 @end smallexample
21108 @noindent
21109 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
21110 are declared in the package @code{Machine_Code} and must be referenced
21111 according to normal visibility rules. In particular if there is no
21112 @code{use} clause for this package, then appropriate package name
21113 qualification is required.
21115 @node GNAT Implementation of Tasking
21116 @section GNAT Implementation of Tasking
21118 @noindent
21119 This chapter outlines the basic GNAT approach to tasking (in particular,
21120 a multi-layered library for portability) and discusses issues related
21121 to compliance with the Real-Time Systems Annex.
21123 @menu
21124 * Mapping Ada Tasks onto the Underlying Kernel Threads::
21125 * Ensuring Compliance with the Real-Time Annex::
21126 @end menu
21128 @node Mapping Ada Tasks onto the Underlying Kernel Threads
21129 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
21131 @noindent
21132 GNAT's run-time support comprises two layers:
21134 @itemize @bullet
21135 @item GNARL (GNAT Run-time Layer)
21136 @item GNULL (GNAT Low-level Library)
21137 @end itemize
21139 @noindent
21140 In GNAT, Ada's tasking services rely on a platform and OS independent
21141 layer known as GNARL@.  This code is responsible for implementing the
21142 correct semantics of Ada's task creation, rendezvous, protected
21143 operations etc.
21145 GNARL decomposes Ada's tasking semantics into simpler lower level
21146 operations such as create a thread, set the priority of a thread,
21147 yield, create a lock, lock/unlock, etc.  The spec for these low-level
21148 operations constitutes GNULLI, the GNULL Interface.  This interface is
21149 directly inspired from the POSIX real-time API@.
21151 If the underlying executive or OS implements the POSIX standard
21152 faithfully, the GNULL Interface maps as is to the services offered by
21153 the underlying kernel.  Otherwise, some target dependent glue code maps
21154 the services offered by the underlying kernel to the semantics expected
21155 by GNARL@.
21157 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
21158 key point is that each Ada task is mapped on a thread in the underlying
21159 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
21161 In addition Ada task priorities map onto the underlying thread priorities.
21162 Mapping Ada tasks onto the underlying kernel threads has several advantages:
21164 @itemize @bullet
21165 @item
21166 The underlying scheduler is used to schedule the Ada tasks.  This
21167 makes Ada tasks as efficient as kernel threads from a scheduling
21168 standpoint.
21170 @item
21171 Interaction with code written in C containing threads is eased
21172 since at the lowest level Ada tasks and C threads map onto the same
21173 underlying kernel concept.
21175 @item
21176 When an Ada task is blocked during I/O the remaining Ada tasks are
21177 able to proceed.
21179 @item
21180 On multiprocessor systems Ada tasks can execute in parallel.
21181 @end itemize
21183 @noindent
21184 Some threads libraries offer a mechanism to fork a new process, with the
21185 child process duplicating the threads from the parent.
21186 GNAT does not
21187 support this functionality when the parent contains more than one task.
21188 @cindex Forking a new process
21190 @node Ensuring Compliance with the Real-Time Annex
21191 @subsection Ensuring Compliance with the Real-Time Annex
21192 @cindex Real-Time Systems Annex compliance
21194 @noindent
21195 Although mapping Ada tasks onto
21196 the underlying threads has significant advantages, it does create some
21197 complications when it comes to respecting the scheduling semantics
21198 specified in the real-time annex (Annex D).
21200 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
21201 scheduling policy states:
21203 @quotation
21204 @emph{When the active priority of a ready task that is not running
21205 changes, or the setting of its base priority takes effect, the
21206 task is removed from the ready queue for its old active priority
21207 and is added at the tail of the ready queue for its new active
21208 priority, except in the case where the active priority is lowered
21209 due to the loss of inherited priority, in which case the task is
21210 added at the head of the ready queue for its new active priority.}
21211 @end quotation
21213 @noindent
21214 While most kernels do put tasks at the end of the priority queue when
21215 a task changes its priority, (which respects the main
21216 FIFO_Within_Priorities requirement), almost none keep a thread at the
21217 beginning of its priority queue when its priority drops from the loss
21218 of inherited priority.
21220 As a result most vendors have provided incomplete Annex D implementations.
21222 The GNAT run-time, has a nice cooperative solution to this problem
21223 which ensures that accurate FIFO_Within_Priorities semantics are
21224 respected.
21226 The principle is as follows.  When an Ada task T is about to start
21227 running, it checks whether some other Ada task R with the same
21228 priority as T has been suspended due to the loss of priority
21229 inheritance.  If this is the case, T yields and is placed at the end of
21230 its priority queue.  When R arrives at the front of the queue it
21231 executes.
21233 Note that this simple scheme preserves the relative order of the tasks
21234 that were ready to execute in the priority queue where R has been
21235 placed at the end.
21237 @node GNAT Implementation of Shared Passive Packages
21238 @section GNAT Implementation of Shared Passive Packages
21239 @cindex Shared passive packages
21241 @noindent
21242 GNAT fully implements the pragma @code{Shared_Passive} for
21243 @cindex pragma @code{Shared_Passive}
21244 the purpose of designating shared passive packages.
21245 This allows the use of passive partitions in the
21246 context described in the Ada Reference Manual; i.e., for communication
21247 between separate partitions of a distributed application using the
21248 features in Annex E.
21249 @cindex Annex E
21250 @cindex Distribution Systems Annex
21252 However, the implementation approach used by GNAT provides for more
21253 extensive usage as follows:
21255 @table @emph
21256 @item Communication between separate programs
21258 This allows separate programs to access the data in passive
21259 partitions, using protected objects for synchronization where
21260 needed. The only requirement is that the two programs have a
21261 common shared file system. It is even possible for programs
21262 running on different machines with different architectures
21263 (e.g.@: different endianness) to communicate via the data in
21264 a passive partition.
21266 @item Persistence between program runs
21268 The data in a passive package can persist from one run of a
21269 program to another, so that a later program sees the final
21270 values stored by a previous run of the same program.
21272 @end table
21274 @noindent
21275 The implementation approach used is to store the data in files. A
21276 separate stream file is created for each object in the package, and
21277 an access to an object causes the corresponding file to be read or
21278 written.
21280 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
21281 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
21282 set to the directory to be used for these files.
21283 The files in this directory
21284 have names that correspond to their fully qualified names. For
21285 example, if we have the package
21287 @smallexample @c ada
21288 package X is
21289   pragma Shared_Passive (X);
21290   Y : Integer;
21291   Z : Float;
21292 end X;
21293 @end smallexample
21295 @noindent
21296 and the environment variable is set to @code{/stemp/}, then the files created
21297 will have the names:
21299 @smallexample
21300 /stemp/x.y
21301 /stemp/x.z
21302 @end smallexample
21304 @noindent
21305 These files are created when a value is initially written to the object, and
21306 the files are retained until manually deleted. This provides the persistence
21307 semantics. If no file exists, it means that no partition has assigned a value
21308 to the variable; in this case the initial value declared in the package
21309 will be used. This model ensures that there are no issues in synchronizing
21310 the elaboration process, since elaboration of passive packages elaborates the
21311 initial values, but does not create the files.
21313 The files are written using normal @code{Stream_IO} access.
21314 If you want to be able
21315 to communicate between programs or partitions running on different
21316 architectures, then you should use the XDR versions of the stream attribute
21317 routines, since these are architecture independent.
21319 If active synchronization is required for access to the variables in the
21320 shared passive package, then as described in the Ada Reference Manual, the
21321 package may contain protected objects used for this purpose. In this case
21322 a lock file (whose name is @file{___lock} (three underscores)
21323 is created in the shared memory directory.
21324 @cindex @file{___lock} file (for shared passive packages)
21325 This is used to provide the required locking
21326 semantics for proper protected object synchronization.
21328 As of January 2003, GNAT supports shared passive packages on all platforms
21329 except for OpenVMS.
21331 @node Code Generation for Array Aggregates
21332 @section Code Generation for Array Aggregates
21334 @menu
21335 * Static constant aggregates with static bounds::
21336 * Constant aggregates with unconstrained nominal types::
21337 * Aggregates with static bounds::
21338 * Aggregates with non-static bounds::
21339 * Aggregates in assignment statements::
21340 @end menu
21342 @noindent
21343 Aggregates have a rich syntax and allow the user to specify the values of
21344 complex data structures by means of a single construct.  As a result, the
21345 code generated for aggregates can be quite complex and involve loops, case
21346 statements and multiple assignments.  In the simplest cases, however, the
21347 compiler will recognize aggregates whose components and constraints are
21348 fully static, and in those cases the compiler will generate little or no
21349 executable code.  The following is an outline of the code that GNAT generates
21350 for various aggregate constructs.  For further details, you will find it
21351 useful to examine the output produced by the -gnatG flag to see the expanded
21352 source that is input to the code generator.  You may also want to examine
21353 the assembly code generated at various levels of optimization.
21355 The code generated for aggregates depends on the context, the component values,
21356 and the type.  In the context of an object declaration the code generated is
21357 generally simpler than in the case of an assignment.  As a general rule, static
21358 component values and static subtypes also lead to simpler code.
21360 @node Static constant aggregates with static bounds
21361 @subsection Static constant aggregates with static bounds
21363 @noindent
21364 For the declarations:
21365 @smallexample @c ada
21366     type One_Dim is array (1..10) of integer;
21367     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
21368 @end smallexample
21370 @noindent
21371 GNAT generates no executable code: the constant ar0 is placed in static memory.
21372 The same is true for constant aggregates with named associations:
21374 @smallexample @c ada
21375     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
21376     Cr3 : constant One_Dim := (others => 7777);
21377 @end smallexample
21379 @noindent
21380 The same is true for multidimensional constant arrays such as:
21382 @smallexample @c ada
21383     type two_dim is array (1..3, 1..3) of integer;
21384     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
21385 @end smallexample
21387 @noindent
21388 The same is true for arrays of one-dimensional arrays: the following are
21389 static:
21391 @smallexample @c ada
21392 type ar1b  is array (1..3) of boolean;
21393 type ar_ar is array (1..3) of ar1b;
21394 None  : constant ar1b := (others => false);     --  fully static
21395 None2 : constant ar_ar := (1..3 => None);       --  fully static
21396 @end smallexample
21398 @noindent
21399 However, for multidimensional aggregates with named associations, GNAT will
21400 generate assignments and loops, even if all associations are static.  The
21401 following two declarations generate a loop for the first dimension, and
21402 individual component assignments for the second dimension:
21404 @smallexample @c ada
21405 Zero1: constant two_dim := (1..3 => (1..3 => 0));
21406 Zero2: constant two_dim := (others => (others => 0));
21407 @end smallexample
21409 @node Constant aggregates with unconstrained nominal types
21410 @subsection Constant aggregates with unconstrained nominal types
21412 @noindent
21413 In such cases the aggregate itself establishes the subtype, so that
21414 associations with @code{others} cannot be used.  GNAT determines the
21415 bounds for the actual subtype of the aggregate, and allocates the
21416 aggregate statically as well.  No code is generated for the following:
21418 @smallexample @c ada
21419     type One_Unc is array (natural range <>) of integer;
21420     Cr_Unc : constant One_Unc := (12,24,36);
21421 @end smallexample
21423 @node Aggregates with static bounds
21424 @subsection Aggregates with static bounds
21426 @noindent
21427 In all previous examples the aggregate was the initial (and immutable) value
21428 of a constant.  If the aggregate initializes a variable, then code is generated
21429 for it as a combination of individual assignments and loops over the target
21430 object.  The declarations
21432 @smallexample @c ada
21433        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
21434        Cr_Var2 : One_Dim := (others > -1);
21435 @end smallexample
21437 @noindent
21438 generate the equivalent of
21440 @smallexample @c ada
21441        Cr_Var1 (1) := 2;
21442        Cr_Var1 (2) := 3;
21443        Cr_Var1 (3) := 5;
21444        Cr_Var1 (4) := 11;
21446        for I in Cr_Var2'range loop
21447           Cr_Var2 (I) := -1;
21448        end loop;
21449 @end smallexample
21451 @node Aggregates with non-static bounds
21452 @subsection Aggregates with non-static bounds
21454 @noindent
21455 If the bounds of the aggregate are not statically compatible with the bounds
21456 of the nominal subtype  of the target, then constraint checks have to be
21457 generated on the bounds.  For a multidimensional array, constraint checks may
21458 have to be applied to sub-arrays individually, if they do not have statically
21459 compatible subtypes.
21461 @node Aggregates in assignment statements
21462 @subsection Aggregates in assignment statements
21464 @noindent
21465 In general, aggregate assignment requires the construction of a temporary,
21466 and a copy from the temporary to the target of the assignment.  This is because
21467 it is not always possible to convert the assignment into a series of individual
21468 component assignments.  For example, consider the simple case:
21470 @smallexample @c ada
21471         A := (A(2), A(1));
21472 @end smallexample
21474 @noindent
21475 This cannot be converted into:
21477 @smallexample @c ada
21478         A(1) := A(2);
21479         A(2) := A(1);
21480 @end smallexample
21482 @noindent
21483 So the aggregate has to be built first in a separate location, and then
21484 copied into the target.  GNAT recognizes simple cases where this intermediate
21485 step is not required, and the assignments can be performed in place, directly
21486 into the target.  The following sufficient criteria are applied:
21488 @itemize @bullet
21489 @item
21490 The bounds of the aggregate are static, and the associations are static.
21491 @item
21492 The components of the aggregate are static constants, names of
21493 simple variables that are not renamings, or expressions not involving
21494 indexed components whose operands obey these rules.
21495 @end itemize
21497 @noindent
21498 If any of these conditions are violated, the aggregate will be built in
21499 a temporary (created either by the front-end or the code generator) and then
21500 that temporary will be copied onto the target.
21502 @node The Size of Discriminated Records with Default Discriminants
21503 @section The Size of Discriminated Records with Default Discriminants
21505 @noindent
21506 If a discriminated type @code{T} has discriminants with default values, it is
21507 possible to declare an object of this type without providing an explicit
21508 constraint:
21510 @smallexample @c ada
21511 @group
21512 type Size is range 1..100;
21514 type Rec (D : Size := 15) is record
21515    Name : String (1..D);
21516 end T;
21518 Word : Rec;
21519 @end group
21520 @end smallexample
21522 @noindent
21523 Such an object is said to be @emph{unconstrained}.
21524 The discriminant of the object
21525 can be modified by a full assignment to the object, as long as it preserves the
21526 relation between the value of the discriminant, and the value of the components
21527 that depend on it:
21529 @smallexample @c ada
21530 @group
21531 Word := (3, "yes");
21533 Word := (5, "maybe");
21535 Word := (5, "no"); -- raises Constraint_Error
21536 @end group
21537 @end smallexample
21539 @noindent
21540 In order to support this behavior efficiently, an unconstrained object is
21541 given the maximum size that any value of the type requires. In the case
21542 above, @code{Word} has storage for the discriminant and for
21543 a @code{String} of length 100.
21544 It is important to note that unconstrained objects do not require dynamic
21545 allocation. It would be an improper implementation to place on the heap those
21546 components whose size depends on discriminants. (This improper implementation
21547 was used by some Ada83 compilers, where the @code{Name} component above
21548 would have
21549 been stored as a pointer to a dynamic string). Following the principle that
21550 dynamic storage management should never be introduced implicitly,
21551 an Ada compiler should reserve the full size for an unconstrained declared
21552 object, and place it on the stack.
21554 This maximum size approach
21555 has been a source of surprise to some users, who expect the default
21556 values of the discriminants to determine the size reserved for an
21557 unconstrained object: ``If the default is 15, why should the object occupy
21558 a larger size?''
21559 The answer, of course, is that the discriminant may be later modified,
21560 and its full range of values must be taken into account. This is why the
21561 declaration:
21563 @smallexample
21564 @group
21565 type Rec (D : Positive := 15) is record
21566    Name : String (1..D);
21567 end record;
21569 Too_Large : Rec;
21570 @end group
21571 @end smallexample
21573 @noindent
21574 is flagged by the compiler with a warning:
21575 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
21576 because the required size includes @code{Positive'Last}
21577 bytes. As the first example indicates, the proper approach is to declare an
21578 index type of ``reasonable'' range so that unconstrained objects are not too
21579 large.
21581 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
21582 created in the heap by means of an allocator, then it is @emph{not}
21583 unconstrained:
21584 it is constrained by the default values of the discriminants, and those values
21585 cannot be modified by full assignment. This is because in the presence of
21586 aliasing all views of the object (which may be manipulated by different tasks,
21587 say) must be consistent, so it is imperative that the object, once created,
21588 remain invariant.
21590 @node Strict Conformance to the Ada Reference Manual
21591 @section Strict Conformance to the Ada Reference Manual
21593 @noindent
21594 The dynamic semantics defined by the Ada Reference Manual impose a set of
21595 run-time checks to be generated. By default, the GNAT compiler will insert many
21596 run-time checks into the compiled code, including most of those required by the
21597 Ada Reference Manual. However, there are three checks that are not enabled
21598 in the default mode for efficiency reasons: arithmetic overflow checking for
21599 integer operations (including division by zero), checks for access before
21600 elaboration on subprogram calls, and stack overflow checking (most operating
21601 systems do not perform this check by default).
21603 Strict conformance to the Ada Reference Manual can be achieved by adding
21604 three compiler options for overflow checking for integer operations
21605 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
21606 calls and generic instantiations (@option{-gnatE}), and stack overflow
21607 checking (@option{-fstack-check}).
21609 Note that the result of a floating point arithmetic operation in overflow and
21610 invalid situations, when the @code{Machine_Overflows} attribute of the result
21611 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
21612 case for machines compliant with the IEEE floating-point standard, but on
21613 machines that are not fully compliant with this standard, such as Alpha, the
21614 @option{-mieee} compiler flag must be used for achieving IEEE confirming
21615 behavior (although at the cost of a significant performance penalty), so
21616 infinite and NaN values are properly generated.
21619 @node Implementation of Ada 2012 Features
21620 @chapter Implementation of Ada 2012 Features
21621 @cindex Ada 2012 implementation status
21623 This chapter contains a complete list of Ada 2012 features that have been
21624 implemented as of GNAT version 6.4. Generally, these features are only
21625 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
21626 @cindex @option{-gnat12} option
21627 or if the configuration pragma @code{Ada_2012} is used.
21628 @cindex pragma @code{Ada_2012}
21629 @cindex configuration pragma @code{Ada_2012}
21630 @cindex @code{Ada_2012} configuration pragma
21631 However, new pragmas, attributes, and restrictions are
21632 unconditionally available, since the Ada 95 standard allows the addition of
21633 new pragmas, attributes, and restrictions (there are exceptions, which are
21634 documented in the individual descriptions), and also certain packages
21635 were made available in earlier versions of Ada.
21637 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
21638 This date shows the implementation date of the feature. Any wavefront
21639 subsequent to this date will contain the indicated feature, as will any
21640 subsequent releases. A date of 0000-00-00 means that GNAT has always
21641 implemented the feature, or implemented it as soon as it appeared as a
21642 binding interpretation.
21644 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
21645 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
21646 The features are ordered based on the relevant sections of the Ada
21647 Reference Manual (``RM'').  When a given AI relates to multiple points
21648 in the RM, the earliest is used.
21650 A complete description of the AIs may be found in
21651 @url{www.ada-auth.org/ai05-summary.html}.
21653 @itemize @bullet
21655 @item
21656 @emph{AI-0176 Quantified expressions (2010-09-29)}
21657 @cindex AI-0176 (Ada 2012 feature)
21659 @noindent
21660   Both universally and existentially quantified expressions are implemented.
21661   They use the new syntax for iterators proposed in AI05-139-2, as well as
21662   the standard Ada loop syntax.
21664 @noindent
21665   RM References:  1.01.04 (12)   2.09 (2/2)   4.04 (7)   4.05.09 (0)
21667 @item
21668 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
21669 @cindex AI-0079 (Ada 2012 feature)
21671 @noindent
21672   Wide characters in the unicode category @i{other_format} are now allowed in
21673   source programs between tokens, but not within a token such as an identifier.
21675 @noindent
21676   RM References:  2.01 (4/2)   2.02 (7)
21678 @item
21679 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
21680 @cindex AI-0091 (Ada 2012 feature)
21682 @noindent
21683   Wide characters in the unicode category @i{other_format} are not permitted
21684   within  an identifier, since this can be a security problem. The error
21685   message for this case has been improved to be more specific, but GNAT has
21686   never allowed such characters to appear in identifiers.
21688 @noindent
21689   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)
21691 @item
21692 @emph{AI-0100 Placement of pragmas  (2010-07-01)}
21693 @cindex AI-0100 (Ada 2012 feature)
21695 @noindent
21696   This AI is an earlier version of AI-163. It simplifies the rules
21697   for legal placement of pragmas. In the case of lists that allow pragmas, if
21698   the list may have no elements, then the list may consist solely of pragmas.
21700 @noindent
21701   RM References:  2.08 (7)
21703 @item
21704 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
21705 @cindex AI-0163 (Ada 2012 feature)
21707 @noindent
21708   A statement sequence may be composed entirely of pragmas. It is no longer
21709   necessary to add a dummy @code{null} statement to make the sequence legal.
21711 @noindent
21712   RM References:  2.08 (7)   2.08 (16)
21715 @item
21716 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
21717 @cindex AI-0080 (Ada 2012 feature)
21719 @noindent
21720   This is an editorial change only, described as non-testable in the AI.
21722 @noindent
21723   RM References:  3.01 (7)
21726 @item
21727 @emph{AI-0183 Aspect specifications (2010-08-16)}
21728 @cindex AI-0183 (Ada 2012 feature)
21730 @noindent
21731   Aspect specifications have been fully implemented except for pre and post-
21732   conditions, and type invariants, which have their own separate AI's. All
21733   forms of declarations listed in the AI are supported. The following is a
21734   list of the aspects supported (with GNAT implementation aspects marked)
21736 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
21737 @item @code{Ada_2005} @tab                      -- GNAT
21738 @item @code{Ada_2012} @tab                      -- GNAT
21739 @item @code{Address} @tab
21740 @item @code{Alignment} @tab
21741 @item @code{Atomic} @tab
21742 @item @code{Atomic_Components} @tab
21743 @item @code{Bit_Order} @tab
21744 @item @code{Component_Size} @tab
21745 @item @code{Contract_Cases} @tab                -- GNAT
21746 @item @code{Discard_Names} @tab
21747 @item @code{External_Tag} @tab
21748 @item @code{Favor_Top_Level} @tab               -- GNAT
21749 @item @code{Inline} @tab
21750 @item @code{Inline_Always} @tab                 -- GNAT
21751 @item @code{Invariant} @tab                     -- GNAT
21752 @item @code{Machine_Radix} @tab
21753 @item @code{No_Return} @tab
21754 @item @code{Object_Size} @tab                   -- GNAT
21755 @item @code{Pack} @tab
21756 @item @code{Persistent_BSS} @tab                -- GNAT
21757 @item @code{Post} @tab
21758 @item @code{Pre} @tab
21759 @item @code{Predicate} @tab
21760 @item @code{Preelaborable_Initialization} @tab
21761 @item @code{Pure_Function} @tab                 -- GNAT
21762 @item @code{Remote_Access_Type} @tab            -- GNAT
21763 @item @code{Shared} @tab                        -- GNAT
21764 @item @code{Size} @tab
21765 @item @code{Storage_Pool} @tab
21766 @item @code{Storage_Size} @tab
21767 @item @code{Stream_Size} @tab
21768 @item @code{Suppress} @tab
21769 @item @code{Suppress_Debug_Info} @tab           -- GNAT
21770 @item @code{Test_Case} @tab                     -- GNAT
21771 @item @code{Thread_Local_Storage} @tab          -- GNAT
21772 @item @code{Type_Invariant} @tab
21773 @item @code{Unchecked_Union} @tab
21774 @item @code{Universal_Aliasing} @tab            -- GNAT
21775 @item @code{Unmodified} @tab                    -- GNAT
21776 @item @code{Unreferenced} @tab                  -- GNAT
21777 @item @code{Unreferenced_Objects} @tab          -- GNAT
21778 @item @code{Unsuppress} @tab
21779 @item @code{Value_Size} @tab                    -- GNAT
21780 @item @code{Volatile} @tab
21781 @item @code{Volatile_Components}
21782 @item @code{Warnings} @tab                      -- GNAT
21783 @end multitable
21785 @noindent
21786   Note that for aspects with an expression, e.g. @code{Size}, the expression is
21787   treated like a default expression (visibility is analyzed at the point of
21788   occurrence of the aspect, but evaluation of the expression occurs at the
21789   freeze point of the entity involved).
21791 @noindent
21792   RM References:  3.02.01 (3)   3.02.02 (2)   3.03.01 (2/2)   3.08 (6)
21793   3.09.03 (1.1/2)   6.01 (2/2)   6.07 (2/2)   9.05.02 (2/2)   7.01 (3)   7.03
21794   (2)   7.03 (3)   9.01 (2/2)   9.01 (3/2)   9.04 (2/2)   9.04 (3/2)
21795   9.05.02 (2/2)   11.01 (2)   12.01 (3)   12.03 (2/2)   12.04 (2/2)   12.05 (2)
21796   12.06 (2.1/2)   12.06 (2.2/2)   12.07 (2)   13.01 (0.1/2)   13.03 (5/1)
21797   13.03.01 (0)
21800 @item
21801 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
21802 @cindex AI-0128 (Ada 2012 feature)
21804 @noindent
21805   If an equality operator ("=") is declared for a type, then the implicitly
21806   declared inequality operator ("/=") is a primitive operation of the type.
21807   This is the only reasonable interpretation, and is the one always implemented
21808   by GNAT, but the RM was not entirely clear in making this point.
21810 @noindent
21811   RM References:  3.02.03 (6)   6.06 (6)
21813 @item
21814 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
21815 @cindex AI-0003 (Ada 2012 feature)
21817 @noindent
21818    In Ada 2012, a qualified expression is considered to be syntactically a name,
21819    meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
21820    useful in disambiguating some cases of overloading.
21822 @noindent
21823   RM References:  3.03 (11)   3.03 (21)   4.01 (2)   4.04 (7)   4.07 (3)
21824   5.04 (7)
21826 @item
21827 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
21828 @cindex AI-0120 (Ada 2012 feature)
21830 @noindent
21831   This is an RM editorial change only. The section that lists objects that are
21832   constant failed to include the current instance of a protected object
21833   within a protected function. This has always been treated as a constant
21834   in GNAT.
21836 @noindent
21837   RM References:  3.03 (21)
21839 @item
21840 @emph{AI-0008 General access to constrained objects (0000-00-00)}
21841 @cindex AI-0008 (Ada 2012 feature)
21843 @noindent
21844   The wording in the RM implied that if you have a general access to a
21845   constrained object, it could be used to modify the discriminants. This was
21846   obviously not intended. @code{Constraint_Error} should be raised, and GNAT
21847   has always done so in this situation.
21849 @noindent
21850   RM References:  3.03 (23)   3.10.02 (26/2)   4.01 (9)   6.04.01 (17)   8.05.01 (5/2)
21853 @item
21854 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
21855 @cindex AI-0093 (Ada 2012 feature)
21857 @noindent
21858   This is an editorial change only, to make more widespread use of the Ada 2012
21859   ``immutably limited''.
21861 @noindent
21862   RM References:  3.03 (23.4/3)
21866 @item
21867 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
21868 @cindex AI-0096 (Ada 2012 feature)
21870 @noindent
21871   In general it is illegal for a type derived from a formal limited type to be
21872   nonlimited.  This AI makes an exception to this rule: derivation is legal
21873   if it appears in the private part of the generic, and the formal type is not
21874   tagged. If the type is tagged, the legality check must be applied to the
21875   private part of the package.
21877 @noindent
21878   RM References:  3.04 (5.1/2)   6.02 (7)
21881 @item
21882 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
21883 @cindex AI-0181 (Ada 2012 feature)
21885 @noindent
21886   From Ada 2005 on, soft hyphen is considered a non-graphic character, which
21887   means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
21888   @code{Image} and @code{Value} attributes for the character types. Strictly
21889   speaking this is an inconsistency with Ada 95, but in practice the use of
21890   these attributes is so obscure that it will not cause problems.
21892 @noindent
21893   RM References:  3.05.02 (2/2)   A.01 (35/2)   A.03.03 (21)
21896 @item
21897 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
21898 @cindex AI-0182 (Ada 2012 feature)
21900 @noindent
21901   This AI allows @code{Character'Value} to accept the string @code{'?'} where
21902   @code{?} is any character including non-graphic control characters. GNAT has
21903   always accepted such strings. It also allows strings such as
21904   @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
21905   permission and raises @code{Constraint_Error}, as is certainly still
21906   permitted.
21908 @noindent
21909   RM References:  3.05 (56/2)
21912 @item
21913 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
21914 @cindex AI-0214 (Ada 2012 feature)
21916 @noindent
21917   Ada 2012 relaxes the restriction that forbids discriminants of tagged types
21918   to have default expressions by allowing them when the type is limited. It
21919   is often useful to define a default value for a discriminant even though
21920   it can't be changed by assignment.
21922 @noindent
21923   RM References:  3.07 (9.1/2)   3.07.02 (3)
21926 @item
21927 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
21928 @cindex AI-0102 (Ada 2012 feature)
21930 @noindent
21931   It is illegal to assign an anonymous access constant to an anonymous access
21932   variable. The RM did not have a clear rule to prevent this, but GNAT has
21933   always generated an error for this usage.
21935 @noindent
21936   RM References:  3.07 (16)   3.07.01 (9)   6.04.01 (6)   8.06 (27/2)
21939 @item
21940 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
21941 @cindex AI-0158 (Ada 2012 feature)
21943 @noindent
21944   This AI extends the syntax of membership tests to simplify complex conditions
21945   that can be expressed as membership in a subset of values of any type. It
21946   introduces syntax for a list of expressions that may be used in loop contexts
21947   as well.
21949 @noindent
21950   RM References:  3.08.01 (5)   4.04 (3)   4.05.02 (3)   4.05.02 (5)   4.05.02 (27)
21953 @item
21954 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
21955 @cindex AI-0173 (Ada 2012 feature)
21957 @noindent
21958   The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
21959   with the tag of an abstract type, and @code{False} otherwise.
21961 @noindent
21962   RM References:  3.09 (7.4/2)   3.09 (12.4/2)
21966 @item
21967 @emph{AI-0076 function with controlling result (0000-00-00)}
21968 @cindex AI-0076 (Ada 2012 feature)
21970 @noindent
21971   This is an editorial change only. The RM defines calls with controlling
21972   results, but uses the term ``function with controlling result'' without an
21973   explicit definition.
21975 @noindent
21976   RM References:  3.09.02 (2/2)
21979 @item
21980 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
21981 @cindex AI-0126 (Ada 2012 feature)
21983 @noindent
21984   This AI clarifies dispatching rules, and simply confirms that dispatching
21985   executes the operation of the parent type when there is no explicitly or
21986   implicitly declared operation for the descendant type. This has always been
21987   the case in all versions of GNAT.
21989 @noindent
21990   RM References:  3.09.02 (20/2)   3.09.02 (20.1/2)   3.09.02 (20.2/2)
21993 @item
21994 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
21995 @cindex AI-0097 (Ada 2012 feature)
21997 @noindent
21998   The RM as written implied that in some cases it was possible to create an
21999   object of an abstract type, by having an abstract extension inherit a non-
22000   abstract constructor from its parent type. This mistake has been corrected
22001   in GNAT and in the RM, and this construct is now illegal.
22003 @noindent
22004   RM References:  3.09.03 (4/2)
22007 @item
22008 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
22009 @cindex AI-0203 (Ada 2012 feature)
22011 @noindent
22012   A return_subtype_indication cannot denote an abstract subtype. GNAT has never
22013   permitted such usage.
22015 @noindent
22016   RM References:  3.09.03 (8/3)
22019 @item
22020 @emph{AI-0198 Inheriting abstract operators  (0000-00-00)}
22021 @cindex AI-0198 (Ada 2012 feature)
22023 @noindent
22024   This AI resolves a conflict between two rules involving inherited abstract
22025   operations and predefined operators. If a derived numeric type inherits
22026   an abstract operator, it overrides the predefined one. This interpretation
22027   was always the one implemented in GNAT.
22029 @noindent
22030   RM References:  3.09.03 (4/3)
22032 @item
22033 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
22034 @cindex AI-0073 (Ada 2012 feature)
22036 @noindent
22037   This AI covers a number of issues regarding returning abstract types. In
22038   particular generic functions cannot have abstract result types or access
22039   result types designated an abstract type. There are some other cases which
22040   are detailed in the AI. Note that this binding interpretation has not been
22041   retrofitted to operate before Ada 2012 mode, since it caused a significant
22042   number of regressions.
22044 @noindent
22045   RM References:  3.09.03 (8)   3.09.03 (10)   6.05 (8/2)
22048 @item
22049 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
22050 @cindex AI-0070 (Ada 2012 feature)
22052 @noindent
22053   This is an editorial change only, there are no testable consequences short of
22054   checking for the absence of generated code for an interface declaration.
22056 @noindent
22057   RM References:  3.09.04 (18/2)
22060 @item
22061 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
22062 @cindex AI-0208 (Ada 2012 feature)
22064 @noindent
22065   The wording in the Ada 2005 RM concerning characteristics of incomplete views
22066   was incorrect and implied that some programs intended to be legal were now
22067   illegal. GNAT had never considered such programs illegal, so it has always
22068   implemented the intent of this AI.
22070 @noindent
22071   RM References:  3.10.01 (2.4/2)   3.10.01 (2.6/2)
22074 @item
22075 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
22076 @cindex AI-0162 (Ada 2012 feature)
22078 @noindent
22079   Incomplete types are made more useful by allowing them to be completed by
22080   private types and private extensions.
22082 @noindent
22083   RM References:  3.10.01 (2.5/2)   3.10.01 (2.6/2)   3.10.01 (3)   3.10.01 (4/2)
22087 @item
22088 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
22089 @cindex AI-0098 (Ada 2012 feature)
22091 @noindent
22092   An unintentional omission in the RM implied some inconsistent restrictions on
22093   the use of anonymous access to subprogram values. These restrictions were not
22094   intentional, and have never been enforced by GNAT.
22096 @noindent
22097   RM References:  3.10.01 (6)   3.10.01 (9.2/2)
22100 @item
22101 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
22102 @cindex AI-0199 (Ada 2012 feature)
22104 @noindent
22105   A choice list in a record aggregate can include several components of
22106   (distinct) anonymous access types as long as they have matching designated
22107   subtypes.
22109 @noindent
22110   RM References:  4.03.01 (16)
22113 @item
22114 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
22115 @cindex AI-0220 (Ada 2012 feature)
22117 @noindent
22118   This AI addresses a wording problem in the RM that appears to permit some
22119   complex cases of aggregates with non-static discriminants. GNAT has always
22120   implemented the intended semantics.
22122 @noindent
22123   RM References:  4.03.01 (17)
22125 @item
22126 @emph{AI-0147 Conditional expressions (2009-03-29)}
22127 @cindex AI-0147 (Ada 2012 feature)
22129 @noindent
22130   Conditional expressions are permitted. The form of such an expression is:
22132 @smallexample
22133     (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
22134 @end smallexample
22136   The parentheses can be omitted in contexts where parentheses are present
22137   anyway, such as subprogram arguments and pragma arguments. If the @b{else}
22138   clause is omitted, @b{else True} is assumed;
22139   thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
22140   @emph{(A implies B)} in standard logic.
22142 @noindent
22143   RM References:  4.03.03 (15)   4.04 (1)   4.04 (7)   4.05.07 (0)   4.07 (2)
22144   4.07 (3)   4.09 (12)   4.09 (33)   5.03 (3)   5.03 (4)   7.05 (2.1/2)
22147 @item
22148 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
22149 @cindex AI-0037 (Ada 2012 feature)
22151 @noindent
22152   This AI confirms that an association of the form @code{Indx => <>} in an
22153   array aggregate must raise @code{Constraint_Error} if @code{Indx}
22154   is out of range. The RM specified a range check on other associations, but
22155   not when the value of the association was defaulted. GNAT has always inserted
22156   a constraint check on the index value.
22158 @noindent
22159   RM References:  4.03.03 (29)
22162 @item
22163 @emph{AI-0123 Composability of equality (2010-04-13)}
22164 @cindex AI-0123 (Ada 2012 feature)
22166 @noindent
22167   Equality of untagged record composes, so that the predefined equality for a
22168   composite type that includes a component of some untagged record type
22169   @code{R} uses the equality operation of @code{R} (which may be user-defined
22170   or predefined). This makes the behavior of untagged records identical to that
22171   of tagged types in this respect.
22173   This change is an incompatibility with previous versions of Ada, but it
22174   corrects a non-uniformity that was often a source of confusion. Analysis of
22175   a large number of industrial programs indicates that in those rare cases
22176   where a composite type had an untagged record component with a user-defined
22177   equality, either there was no use of the composite equality, or else the code
22178   expected the same composability as for tagged types, and thus had a bug that
22179   would be fixed by this change.
22181 @noindent
22182   RM References:  4.05.02 (9.7/2)   4.05.02 (14)   4.05.02 (15)   4.05.02 (24)
22183   8.05.04 (8)
22186 @item
22187 @emph{AI-0088 The value of exponentiation (0000-00-00)}
22188 @cindex AI-0088 (Ada 2012 feature)
22190 @noindent
22191   This AI clarifies the equivalence rule given for the dynamic semantics of
22192   exponentiation: the value of the operation can be obtained by repeated
22193   multiplication, but the operation can be implemented otherwise (for example
22194   using the familiar divide-by-two-and-square algorithm, even if this is less
22195   accurate), and does not imply repeated reads of a volatile base.
22197 @noindent
22198   RM References:  4.05.06 (11)
22200 @item
22201 @emph{AI-0188 Case expressions (2010-01-09)}
22202 @cindex AI-0188 (Ada 2012 feature)
22204 @noindent
22205   Case expressions are permitted. This allows use of constructs such as:
22206 @smallexample
22207   X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
22208 @end smallexample
22210 @noindent
22211   RM References:  4.05.07 (0)   4.05.08 (0)   4.09 (12)   4.09 (33)
22213 @item
22214 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
22215 @cindex AI-0104 (Ada 2012 feature)
22217 @noindent
22218   The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
22219   @code{Constraint_Error} because the default value of the allocated object is
22220   @b{null}. This useless construct is illegal in Ada 2012.
22222 @noindent
22223   RM References:  4.08 (2)
22225 @item
22226 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
22227 @cindex AI-0157 (Ada 2012 feature)
22229 @noindent
22230   Allocation and Deallocation from an empty storage pool (i.e. allocation or
22231   deallocation of a pointer for which a static storage size clause of zero
22232   has been given) is now illegal and is detected as such. GNAT
22233   previously gave a warning but not an error.
22235 @noindent
22236   RM References:  4.08 (5.3/2)   13.11.02 (4)   13.11.02 (17)
22238 @item
22239 @emph{AI-0179 Statement not required after label (2010-04-10)}
22240 @cindex AI-0179 (Ada 2012 feature)
22242 @noindent
22243   It is not necessary to have a statement following a label, so a label
22244   can appear at the end of a statement sequence without the need for putting a
22245   null statement afterwards, but it is not allowable to have only labels and
22246   no real statements in a statement sequence.
22248 @noindent
22249   RM References:  5.01 (2)
22252 @item
22253 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
22254 @cindex AI-139-2 (Ada 2012 feature)
22256 @noindent
22257   The new syntax for iterating over arrays and containers is now implemented.
22258   Iteration over containers is for now limited to read-only iterators. Only
22259   default iterators are supported, with the syntax:  @code{@b{for} Elem @b{of} C}.
22261 @noindent
22262   RM References:  5.05
22264 @item
22265 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
22266 @cindex AI-0134 (Ada 2012 feature)
22268 @noindent
22269   For full conformance, the profiles of anonymous-access-to-subprogram
22270   parameters must match. GNAT has always enforced this rule.
22272 @noindent
22273   RM References:  6.03.01 (18)
22275 @item
22276 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
22277 @cindex AI-0207 (Ada 2012 feature)
22279 @noindent
22280   This AI confirms that access_to_constant indication must match for mode
22281   conformance. This was implemented in GNAT when the qualifier was originally
22282   introduced in Ada 2005.
22284 @noindent
22285   RM References:  6.03.01 (16/2)
22288 @item
22289 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
22290 @cindex AI-0046 (Ada 2012 feature)
22292 @noindent
22293   For full conformance, in the case of access parameters, the null exclusion
22294   must match (either both or neither must have @code{@b{not null}}).
22296 @noindent
22297   RM References:  6.03.02 (18)
22300 @item
22301 @emph{AI-0118 The association of parameter associations (0000-00-00)}
22302 @cindex AI-0118 (Ada 2012 feature)
22304 @noindent
22305   This AI clarifies the rules for named associations in subprogram calls and
22306   generic instantiations. The rules have been in place since Ada 83.
22308 @noindent
22309   RM References:  6.04.01 (2)   12.03 (9)
22312 @item
22313 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
22314 @cindex AI-0196 (Ada 2012 feature)
22316 @noindent
22317   Null exclusion checks are not made for @code{@b{out}} parameters when
22318   evaluating the actual parameters. GNAT has never generated these checks.
22320 @noindent
22321   RM References:  6.04.01 (13)
22323 @item
22324 @emph{AI-0015 Constant return objects (0000-00-00)}
22325 @cindex AI-0015 (Ada 2012 feature)
22327 @noindent
22328   The return object declared in an @i{extended_return_statement} may be
22329   declared constant. This was always intended, and GNAT has always allowed it.
22331 @noindent
22332   RM References:  6.05 (2.1/2)   3.03 (10/2)   3.03 (21)   6.05 (5/2)
22333   6.05 (5.7/2)
22336 @item
22337 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
22338 @cindex AI-0032 (Ada 2012 feature)
22340 @noindent
22341   If a function returns a class-wide type, the object of an extended return
22342   statement can be declared with a specific type that is covered by the class-
22343   wide type. This has been implemented in GNAT since the introduction of
22344   extended returns. Note AI-0103 complements this AI by imposing matching
22345   rules for constrained return types.
22347 @noindent
22348   RM References:  6.05 (5.2/2)   6.05 (5.3/2)   6.05 (5.6/2)   6.05 (5.8/2)
22349   6.05 (8/2)
22351 @item
22352 @emph{AI-0103 Static matching for extended return (2010-07-23)}
22353 @cindex AI-0103 (Ada 2012 feature)
22355 @noindent
22356   If the return subtype of a function is an elementary type or a constrained
22357   type, the subtype indication in an extended return statement must match
22358   statically this return subtype.
22360 @noindent
22361   RM References:  6.05 (5.2/2)
22364 @item
22365 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
22366 @cindex AI-0058 (Ada 2012 feature)
22368 @noindent
22369   The RM had some incorrect wording implying wrong treatment of abnormal
22370   completion in an extended return. GNAT has always implemented the intended
22371   correct semantics as described by this AI.
22373 @noindent
22374   RM References:  6.05 (22/2)
22377 @item
22378 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
22379 @cindex AI-0050 (Ada 2012 feature)
22381 @noindent
22382   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
22383   not take advantage of these incorrect permissions in any case.
22385 @noindent
22386   RM References:  6.05 (24/2)
22389 @item
22390 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
22391 @cindex AI-0125 (Ada 2012 feature)
22393 @noindent
22394   In Ada 2012, the declaration of a primitive operation of a type extension
22395   or private extension can also override an inherited primitive that is not
22396   visible at the point of this declaration.
22398 @noindent
22399   RM References:  7.03.01 (6)   8.03 (23)   8.03.01 (5/2)   8.03.01 (6/2)
22401 @item
22402 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
22403 @cindex AI-0062 (Ada 2012 feature)
22405 @noindent
22406   A full constant may have a null exclusion even if its associated deferred
22407   constant does not. GNAT has always allowed this.
22409 @noindent
22410   RM References:  7.04 (6/2)   7.04 (7.1/2)
22413 @item
22414 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
22415 @cindex AI-0178 (Ada 2012 feature)
22417 @noindent
22418   This AI clarifies the role of incomplete views and plugs an omission in the
22419   RM. GNAT always correctly restricted the use of incomplete views and types.
22421 @noindent
22422   RM References:  7.05 (3/2)   7.05 (6/2)
22424 @item
22425 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
22426 @cindex AI-0087 (Ada 2012 feature)
22428 @noindent
22429   The actual for a formal nonlimited derived type cannot be limited. In
22430   particular, a formal derived type that extends a limited interface but which
22431   is not explicitly limited cannot be instantiated with a limited type.
22433 @noindent
22434   RM References:  7.05 (5/2)   12.05.01 (5.1/2)
22436 @item
22437 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
22438 @cindex AI-0099 (Ada 2012 feature)
22440 @noindent
22441   This AI clarifies that ``needs finalization'' is part of dynamic semantics,
22442   and therefore depends on the run-time characteristics of an object (i.e. its
22443   tag) and not on its nominal type. As the AI indicates: ``we do not expect
22444   this to affect any implementation''.
22446 @noindent
22447   RM References:  7.06.01 (6)   7.06.01 (7)   7.06.01 (8)   7.06.01 (9/2)
22451 @item
22452 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
22453 @cindex AI-0064 (Ada 2012 feature)
22455 @noindent
22456   This is an editorial change only. The intended behavior is already checked
22457   by an existing ACATS test, which GNAT has always executed correctly.
22459 @noindent
22460   RM References:  7.06.01 (17.1/1)
22462 @item
22463 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
22464 @cindex AI-0026 (Ada 2012 feature)
22466 @noindent
22467   Record representation clauses concerning Unchecked_Union types cannot mention
22468   the discriminant of the type. The type of a component declared in the variant
22469   part of an Unchecked_Union cannot be controlled, have controlled components,
22470   nor have protected or task parts. If an Unchecked_Union type is declared
22471   within the body of a generic unit or its descendants, then the type of a
22472   component declared in the variant part cannot be a formal private type or a
22473   formal private extension declared within the same generic unit.
22475 @noindent
22476   RM References:  7.06 (9.4/2)   B.03.03 (9/2)   B.03.03 (10/2)
22479 @item
22480 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
22481 @cindex AI-0205 (Ada 2012 feature)
22483 @noindent
22484   This AI corrects a simple omission in the RM. Return objects have always
22485   been visible within an extended return statement.
22487 @noindent
22488   RM References:  8.03 (17)
22491 @item
22492 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
22493 @cindex AI-0042 (Ada 2012 feature)
22495 @noindent
22496   This AI fixes a wording gap in the RM. An operation of a synchronized
22497   interface can be implemented by a protected or task entry, but the abstract
22498   operation is not being overridden in the usual sense, and it must be stated
22499   separately that this implementation is legal. This has always been the case
22500   in GNAT.
22502 @noindent
22503   RM References:  9.01 (9.2/2)   9.04 (11.1/2)
22505 @item
22506 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
22507 @cindex AI-0030 (Ada 2012 feature)
22509 @noindent
22510   Requeue is permitted to a protected, synchronized or task interface primitive
22511   providing it is known that the overriding operation is an entry. Otherwise
22512   the requeue statement has the same effect as a procedure call. Use of pragma
22513   @code{Implemented} provides a way to impose a static requirement on the
22514   overriding operation by adhering to one of the implementation kinds: entry,
22515   protected procedure or any of the above.
22517 @noindent
22518   RM References:  9.05 (9)   9.05.04 (2)   9.05.04 (3)   9.05.04 (5)
22519   9.05.04 (6)   9.05.04 (7)   9.05.04 (12)
22522 @item
22523 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
22524 @cindex AI-0201 (Ada 2012 feature)
22526 @noindent
22527   If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
22528   attribute, then individual components may not be addressable by independent
22529   tasks. However, if the representation clause has no effect (is confirming),
22530   then independence is not compromised. Furthermore, in GNAT, specification of
22531   other appropriately addressable component sizes (e.g. 16 for 8-bit
22532   characters) also preserves independence. GNAT now gives very clear warnings
22533   both for the declaration of such a type, and for any assignment to its components.
22535 @noindent
22536   RM References:  9.10 (1/3)   C.06 (22/2)   C.06 (23/2)
22538 @item
22539 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
22540 @cindex AI-0009 (Ada 2012 feature)
22542 @noindent
22543   This AI introduces the new pragmas @code{Independent} and
22544   @code{Independent_Components},
22545   which control guaranteeing independence of access to objects and components.
22546   The AI also requires independence not unaffected by confirming rep clauses.
22548 @noindent
22549   RM References:  9.10 (1)   13.01 (15/1)   13.02 (9)   13.03 (13)   C.06 (2)
22550   C.06 (4)   C.06 (6)   C.06 (9)   C.06 (13)   C.06 (14)
22553 @item
22554 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
22555 @cindex AI-0072 (Ada 2012 feature)
22557 @noindent
22558   This AI clarifies that task signalling for reading @code{'Terminated} only
22559   occurs if the result is True. GNAT semantics has always been consistent with
22560   this notion of task signalling.
22562 @noindent
22563   RM References:  9.10 (6.1/1)
22565 @item
22566 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
22567 @cindex AI-0108 (Ada 2012 feature)
22569 @noindent
22570   This AI confirms that an incomplete type from a limited view does not have
22571   discriminants. This has always been the case in GNAT.
22573 @noindent
22574   RM References:  10.01.01 (12.3/2)
22576 @item
22577 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
22578 @cindex AI-0129 (Ada 2012 feature)
22580 @noindent
22581   This AI clarifies the description of limited views: a limited view of a
22582   package includes only one view of a type that has an incomplete declaration
22583   and a full declaration (there is no possible ambiguity in a client package).
22584   This AI also fixes an omission: a nested package in the private part has no
22585   limited view. GNAT always implemented this correctly.
22587 @noindent
22588   RM References:  10.01.01 (12.2/2)   10.01.01 (12.3/2)
22592 @item
22593 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
22594 @cindex AI-0077 (Ada 2012 feature)
22596 @noindent
22597   This AI clarifies that a declaration does not include a context clause,
22598   and confirms that it is illegal to have a context in which both a limited
22599   and a nonlimited view of a package are accessible. Such double visibility
22600   was always rejected by GNAT.
22602 @noindent
22603   RM References:  10.01.02 (12/2)   10.01.02 (21/2)   10.01.02 (22/2)
22605 @item
22606 @emph{AI-0122 Private with and children of generics (0000-00-00)}
22607 @cindex AI-0122 (Ada 2012 feature)
22609 @noindent
22610   This AI clarifies the visibility of private children of generic units within
22611   instantiations of a parent. GNAT has always handled this correctly.
22613 @noindent
22614   RM References:  10.01.02 (12/2)
22618 @item
22619 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
22620 @cindex AI-0040 (Ada 2012 feature)
22622 @noindent
22623   This AI confirms that a limited with clause in a child unit cannot name
22624   an ancestor of the unit. This has always been checked in GNAT.
22626 @noindent
22627   RM References:  10.01.02 (20/2)
22629 @item
22630 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
22631 @cindex AI-0132 (Ada 2012 feature)
22633 @noindent
22634   This AI fills a gap in the description of library unit pragmas. The pragma
22635   clearly must apply to a library unit, even if it does not carry the name
22636   of the enclosing unit. GNAT has always enforced the required check.
22638 @noindent
22639   RM References:  10.01.05 (7)
22642 @item
22643 @emph{AI-0034 Categorization of limited views (0000-00-00)}
22644 @cindex AI-0034 (Ada 2012 feature)
22646 @noindent
22647   The RM makes certain limited with clauses illegal because of categorization
22648   considerations, when the corresponding normal with would be legal. This is
22649   not intended, and GNAT has always implemented the recommended behavior.
22651 @noindent
22652   RM References:  10.02.01 (11/1)   10.02.01 (17/2)
22655 @item
22656 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
22657 @cindex AI-0035 (Ada 2012 feature)
22659 @noindent
22660   This AI remedies some inconsistencies in the legality rules for Pure units.
22661   Derived access types are legal in a pure unit (on the assumption that the
22662   rule for a zero storage pool size has been enforced on the ancestor type).
22663   The rules are enforced in generic instances and in subunits. GNAT has always
22664   implemented the recommended behavior.
22666 @noindent
22667   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)
22670 @item
22671 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
22672 @cindex AI-0219 (Ada 2012 feature)
22674 @noindent
22675   This AI refines the rules for the cases with limited parameters which do not
22676   allow the implementations to omit ``redundant''. GNAT now properly conforms
22677   to the requirements of this binding interpretation.
22679 @noindent
22680   RM References:  10.02.01 (18/2)
22682 @item
22683 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
22684 @cindex AI-0043 (Ada 2012 feature)
22686 @noindent
22687   This AI covers various omissions in the RM regarding the raising of
22688   exceptions. GNAT has always implemented the intended semantics.
22690 @noindent
22691   RM References:  11.04.01 (10.1/2)   11 (2)
22694 @item
22695 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
22696 @cindex AI-0200 (Ada 2012 feature)
22698 @noindent
22699   This AI plugs a gap in the RM which appeared to allow some obviously intended
22700   illegal instantiations. GNAT has never allowed these instantiations.
22702 @noindent
22703   RM References:  12.07 (16)
22706 @item
22707 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
22708 @cindex AI-0112 (Ada 2012 feature)
22710 @noindent
22711   This AI concerns giving names to various representation aspects, but the
22712   practical effect is simply to make the use of duplicate
22713   @code{Atomic}[@code{_Components}],
22714   @code{Volatile}[@code{_Components}] and
22715   @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
22716   now performs this required check.
22718 @noindent
22719   RM References:  13.01 (8)
22721 @item
22722 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
22723 @cindex AI-0106 (Ada 2012 feature)
22725 @noindent
22726   The RM appeared to allow representation pragmas on generic formal parameters,
22727   but this was not intended, and GNAT has never permitted this usage.
22729 @noindent
22730   RM References:  13.01 (9.1/1)
22733 @item
22734 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
22735 @cindex AI-0012 (Ada 2012 feature)
22737 @noindent
22738   It is now illegal to give an inappropriate component size or a pragma
22739   @code{Pack} that attempts to change the component size in the case of atomic
22740   or aliased components. Previously GNAT ignored such an attempt with a
22741   warning.
22743 @noindent
22744   RM References:  13.02 (6.1/2)   13.02 (7)   C.06 (10)   C.06 (11)   C.06 (21)
22747 @item
22748 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
22749 @cindex AI-0039 (Ada 2012 feature)
22751 @noindent
22752   The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
22753   for stream attributes, but these were never useful and are now illegal. GNAT
22754   has always regarded such expressions as illegal.
22756 @noindent
22757   RM References:  13.03 (4)   13.03 (6)   13.13.02 (38/2)
22760 @item
22761 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
22762 @cindex AI-0095 (Ada 2012 feature)
22764 @noindent
22765   The prefix of @code{'Address} cannot statically denote a subprogram with
22766   convention @code{Intrinsic}. The use of the @code{Address} attribute raises
22767   @code{Program_Error} if the prefix denotes a subprogram with convention
22768   @code{Intrinsic}.
22770 @noindent
22771   RM References:  13.03 (11/1)
22774 @item
22775 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
22776 @cindex AI-0116 (Ada 2012 feature)
22778 @noindent
22779   This AI requires that the alignment of a class-wide object be no greater
22780   than the alignment of any type in the class. GNAT has always followed this
22781   recommendation.
22783 @noindent
22784   RM References:  13.03 (29)   13.11 (16)
22787 @item
22788 @emph{AI-0146 Type invariants (2009-09-21)}
22789 @cindex AI-0146 (Ada 2012 feature)
22791 @noindent
22792   Type invariants may be specified for private types using the aspect notation.
22793   Aspect @code{Type_Invariant} may be specified for any private type,
22794   @code{Type_Invariant'Class} can
22795   only be specified for tagged types, and is inherited by any descendent of the
22796   tagged types. The invariant is a boolean expression that is tested for being
22797   true in the following situations: conversions to the private type, object
22798   declarations for the private type that are default initialized, and
22799   [@b{in}] @b{out}
22800   parameters and returned result on return from any primitive operation for
22801   the type that is visible to a client.
22802   GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
22803   @code{Invariant'Class} for @code{Type_Invariant'Class}.
22805 @noindent
22806   RM References:  13.03.03 (00)
22808 @item
22809 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
22810 @cindex AI-0078 (Ada 2012 feature)
22812 @noindent
22813   In Ada 2012, compilers are required to support unchecked conversion where the
22814   target alignment is a multiple of the source alignment. GNAT always supported
22815   this case (and indeed all cases of differing alignments, doing copies where
22816   required if the alignment was reduced).
22818 @noindent
22819   RM References:  13.09 (7)
22822 @item
22823 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
22824 @cindex AI-0195 (Ada 2012 feature)
22826 @noindent
22827   The handling of invalid values is now designated to be implementation
22828   defined. This is a documentation change only, requiring Annex M in the GNAT
22829   Reference Manual to document this handling.
22830   In GNAT, checks for invalid values are made
22831   only when necessary to avoid erroneous behavior. Operations like assignments
22832   which cannot cause erroneous behavior ignore the possibility of invalid
22833   values and do not do a check. The date given above applies only to the
22834   documentation change, this behavior has always been implemented by GNAT.
22836 @noindent
22837   RM References:  13.09.01 (10)
22839 @item
22840 @emph{AI-0193 Alignment of allocators (2010-09-16)}
22841 @cindex AI-0193 (Ada 2012 feature)
22843 @noindent
22844   This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
22845   analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
22846   of size.
22848 @noindent
22849   RM References:  13.11 (16)   13.11 (21)   13.11.01 (0)   13.11.01 (1)
22850   13.11.01 (2)   13.11.01 (3)
22853 @item
22854 @emph{AI-0177 Parameterized expressions (2010-07-10)}
22855 @cindex AI-0177 (Ada 2012 feature)
22857 @noindent
22858   The new Ada 2012 notion of parameterized expressions is implemented. The form
22859   is:
22860 @smallexample
22861   @i{function specification} @b{is} (@i{expression})
22862 @end smallexample
22864 @noindent
22865   This is exactly equivalent to the
22866   corresponding function body that returns the expression, but it can appear
22867   in a package spec. Note that the expression must be parenthesized.
22869 @noindent
22870   RM References:  13.11.01 (3/2)
22872 @item
22873 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
22874 @cindex AI-0033 (Ada 2012 feature)
22876 @noindent
22877   Neither of these two pragmas may appear within a generic template, because
22878   the generic might be instantiated at other than the library level.
22880 @noindent
22881   RM References:  13.11.02 (16)   C.03.01 (7/2)   C.03.01 (8/2)
22884 @item
22885 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
22886 @cindex AI-0161 (Ada 2012 feature)
22888 @noindent
22889   A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
22890   of the default stream attributes for elementary types. If this restriction is
22891   in force, then it is necessary to provide explicit subprograms for any
22892   stream attributes used.
22894 @noindent
22895   RM References:  13.12.01 (4/2)   13.13.02 (40/2)   13.13.02 (52/2)
22897 @item
22898 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
22899 @cindex AI-0194 (Ada 2012 feature)
22901 @noindent
22902   The @code{Stream_Size} attribute returns the default number of bits in the
22903   stream representation of the given type.
22904   This value is not affected by the presence
22905   of stream subprogram attributes for the type. GNAT has always implemented
22906   this interpretation.
22908 @noindent
22909   RM References:  13.13.02 (1.2/2)
22911 @item
22912 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
22913 @cindex AI-0109 (Ada 2012 feature)
22915 @noindent
22916   This AI is an editorial change only. It removes the need for a tag check
22917   that can never fail.
22919 @noindent
22920   RM References:  13.13.02 (34/2)
22922 @item
22923 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
22924 @cindex AI-0007 (Ada 2012 feature)
22926 @noindent
22927   The RM as written appeared to limit the possibilities of declaring read
22928   attribute procedures for private scalar types. This limitation was not
22929   intended, and has never been enforced by GNAT.
22931 @noindent
22932   RM References:  13.13.02 (50/2)   13.13.02 (51/2)
22935 @item
22936 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
22937 @cindex AI-0065 (Ada 2012 feature)
22939 @noindent
22940   This AI clarifies the fact that all remote access types support external
22941   streaming. This fixes an obvious oversight in the definition of the
22942   language, and GNAT always implemented the intended correct rules.
22944 @noindent
22945   RM References:  13.13.02 (52/2)
22947 @item
22948 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
22949 @cindex AI-0019 (Ada 2012 feature)
22951 @noindent
22952   The RM suggests that primitive subprograms of a specific tagged type are
22953   frozen when the tagged type is frozen. This would be an incompatible change
22954   and is not intended. GNAT has never attempted this kind of freezing and its
22955   behavior is consistent with the recommendation of this AI.
22957 @noindent
22958   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)
22960 @item
22961 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
22962 @cindex AI-0017 (Ada 2012 feature)
22964 @noindent
22965   So-called ``Taft-amendment types'' (i.e., types that are completed in package
22966   bodies) are not frozen by the occurrence of bodies in the
22967   enclosing declarative part. GNAT always implemented this properly.
22969 @noindent
22970   RM References:  13.14 (3/1)
22973 @item
22974 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
22975 @cindex AI-0060 (Ada 2012 feature)
22977 @noindent
22978   This AI extends the definition of remote access types to include access
22979   to limited, synchronized, protected or task class-wide interface types.
22980   GNAT already implemented this extension.
22982 @noindent
22983   RM References:  A (4)   E.02.02 (9/1)   E.02.02 (9.2/1)   E.02.02 (14/2)   E.02.02 (18)
22985 @item
22986 @emph{AI-0114 Classification of letters (0000-00-00)}
22987 @cindex AI-0114 (Ada 2012 feature)
22989 @noindent
22990   The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
22991   181 (@code{MICRO SIGN}), and
22992   186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
22993   lower case letters by Unicode.
22994   However, they are not allowed in identifiers, and they
22995   return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
22996   This behavior is consistent with that defined in Ada 95.
22998 @noindent
22999   RM References:  A.03.02 (59)   A.04.06 (7)
23002 @item
23003 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
23004 @cindex AI-0185 (Ada 2012 feature)
23006 @noindent
23007   Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
23008   classification functions for @code{Wide_Character} and
23009   @code{Wide_Wide_Character}, as well as providing
23010   case folding routines for @code{Wide_[Wide_]Character} and
23011   @code{Wide_[Wide_]String}.
23013 @noindent
23014   RM References:  A.03.05 (0)   A.03.06 (0)
23017 @item
23018 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
23019 @cindex AI-0031 (Ada 2012 feature)
23021 @noindent
23022   A new version of @code{Find_Token} is added to all relevant string packages,
23023   with an extra parameter @code{From}. Instead of starting at the first
23024   character of the string, the search for a matching Token starts at the
23025   character indexed by the value of @code{From}.
23026   These procedures are available in all versions of Ada
23027   but if used in versions earlier than Ada 2012 they will generate a warning
23028   that an Ada 2012 subprogram is being used.
23030 @noindent
23031   RM References:  A.04.03 (16)   A.04.03 (67)   A.04.03 (68/1)   A.04.04 (51)
23032   A.04.05 (46)
23035 @item
23036 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
23037 @cindex AI-0056 (Ada 2012 feature)
23039 @noindent
23040   The wording in the Ada 2005 RM implied an incompatible handling of the
23041   @code{Index} functions, resulting in raising an exception instead of
23042   returning zero in some situations.
23043   This was not intended and has been corrected.
23044   GNAT always returned zero, and is thus consistent with this AI.
23046 @noindent
23047   RM References:  A.04.03 (56.2/2)   A.04.03 (58.5/2)
23050 @item
23051 @emph{AI-0137 String encoding package (2010-03-25)}
23052 @cindex AI-0137 (Ada 2012 feature)
23054 @noindent
23055   The packages @code{Ada.Strings.UTF_Encoding}, together with its child
23056   packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
23057   and @code{Wide_Wide_Strings} have been
23058   implemented. These packages (whose documentation can be found in the spec
23059   files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
23060   @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
23061   @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
23062   values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
23063   UTF-16), as well as conversions between the different UTF encodings. With
23064   the exception of @code{Wide_Wide_Strings}, these packages are available in
23065   Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
23066   The @code{Wide_Wide_Strings package}
23067   is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
23068   mode since it uses @code{Wide_Wide_Character}).
23070 @noindent
23071   RM References:  A.04.11
23073 @item
23074 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
23075 @cindex AI-0038 (Ada 2012 feature)
23077 @noindent
23078   These are minor errors in the description on three points. The intent on
23079   all these points has always been clear, and GNAT has always implemented the
23080   correct intended semantics.
23082 @noindent
23083   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)
23085 @item
23086 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
23087 @cindex AI-0044 (Ada 2012 feature)
23089 @noindent
23090   This AI places restrictions on allowed instantiations of generic containers.
23091   These restrictions are not checked by the compiler, so there is nothing to
23092   change in the implementation. This affects only the RM documentation.
23094 @noindent
23095   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)
23097 @item
23098 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
23099 @cindex AI-0127 (Ada 2012 feature)
23101 @noindent
23102   This package provides an interface for identifying the current locale.
23104 @noindent
23105   RM References:  A.19    A.19.01    A.19.02    A.19.03    A.19.05    A.19.06
23106   A.19.07    A.19.08    A.19.09    A.19.10    A.19.11    A.19.12    A.19.13
23110 @item
23111 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
23112 @cindex AI-0002 (Ada 2012 feature)
23114 @noindent
23115   The compiler is not required to support exporting an Ada subprogram with
23116   convention C if there are parameters or a return type of an unconstrained
23117   array type (such as @code{String}). GNAT allows such declarations but
23118   generates warnings. It is possible, but complicated, to write the
23119   corresponding C code and certainly such code would be specific to GNAT and
23120   non-portable.
23122 @noindent
23123   RM References:  B.01 (17)   B.03 (62)   B.03 (71.1/2)
23126 @item
23127 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
23128 @cindex AI05-0216 (Ada 2012 feature)
23130 @noindent
23131   It is clearly the intention that @code{No_Task_Hierarchy} is intended to
23132   forbid tasks declared locally within subprograms, or functions returning task
23133   objects, and that is the implementation that GNAT has always provided.
23134   However the language in the RM was not sufficiently clear on this point.
23135   Thus this is a documentation change in the RM only.
23137 @noindent
23138   RM References:  D.07 (3/3)
23140 @item
23141 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
23142 @cindex AI-0211 (Ada 2012 feature)
23144 @noindent
23145   The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
23146   @code{Ada.Real_Time.Timing_Events.Set_Handler}.
23148 @noindent
23149   RM References:  D.07 (5)   D.07 (10/2)   D.07 (10.4/2)   D.07 (10.7/2)
23151 @item
23152 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
23153 @cindex AI-0190 (Ada 2012 feature)
23155 @noindent
23156   This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
23157   used to control storage pools globally.
23158   In particular, you can force every access
23159   type that is used for allocation (@b{new}) to have an explicit storage pool,
23160   or you can declare a pool globally to be used for all access types that lack
23161   an explicit one.
23163 @noindent
23164   RM References:  D.07 (8)
23166 @item
23167 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
23168 @cindex AI-0189 (Ada 2012 feature)
23170 @noindent
23171   This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
23172   which says that no dynamic allocation will occur once elaboration is
23173   completed.
23174   In general this requires a run-time check, which is not required, and which
23175   GNAT does not attempt. But the static cases of allocators in a task body or
23176   in the body of the main program are detected and flagged at compile or bind
23177   time.
23179 @noindent
23180   RM References:  D.07 (19.1/2)   H.04 (23.3/2)
23182 @item
23183 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
23184 @cindex AI-0171 (Ada 2012 feature)
23186 @noindent
23187   A new package @code{System.Multiprocessors} is added, together with the
23188   definition of pragma @code{CPU} for controlling task affinity. A new no
23189   dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
23190   is added to the Ravenscar profile.
23192 @noindent
23193   RM References:  D.13.01 (4/2)   D.16
23196 @item
23197 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
23198 @cindex AI-0210 (Ada 2012 feature)
23200 @noindent
23201   This is a documentation only issue regarding wording of metric requirements,
23202   that does not affect the implementation of the compiler.
23204 @noindent
23205   RM References:  D.15 (24/2)
23208 @item
23209 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
23210 @cindex AI-0206 (Ada 2012 feature)
23212 @noindent
23213   Remote types packages are now allowed to depend on preelaborated packages.
23214   This was formerly considered illegal.
23216 @noindent
23217   RM References:  E.02.02 (6)
23221 @item
23222 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
23223 @cindex AI-0152 (Ada 2012 feature)
23225 @noindent
23226   Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
23227   where the type of the returned value is an anonymous access type.
23229 @noindent
23230   RM References:  H.04 (8/1)
23231 @end itemize
23234 @node Obsolescent Features
23235 @chapter Obsolescent Features
23237 @noindent
23238 This chapter describes features that are provided by GNAT, but are
23239 considered obsolescent since there are preferred ways of achieving
23240 the same effect. These features are provided solely for historical
23241 compatibility purposes.
23243 @menu
23244 * pragma No_Run_Time::
23245 * pragma Ravenscar::
23246 * pragma Restricted_Run_Time::
23247 * pragma Task_Info::
23248 * System.Task_Info (s-tasinf.ads)::
23249 @end menu
23251 @node pragma No_Run_Time
23252 @section pragma No_Run_Time
23254 The pragma @code{No_Run_Time} is used to achieve an affect similar
23255 to the use of the "Zero Foot Print" configurable run time, but without
23256 requiring a specially configured run time. The result of using this
23257 pragma, which must be used for all units in a partition, is to restrict
23258 the use of any language features requiring run-time support code. The
23259 preferred usage is to use an appropriately configured run-time that
23260 includes just those features that are to be made accessible.
23262 @node pragma Ravenscar
23263 @section pragma Ravenscar
23265 The pragma @code{Ravenscar} has exactly the same effect as pragma
23266 @code{Profile (Ravenscar)}. The latter usage is preferred since it
23267 is part of the new Ada 2005 standard.
23269 @node pragma Restricted_Run_Time
23270 @section pragma Restricted_Run_Time
23272 The pragma @code{Restricted_Run_Time} has exactly the same effect as
23273 pragma @code{Profile (Restricted)}. The latter usage is
23274 preferred since the Ada 2005 pragma @code{Profile} is intended for
23275 this kind of implementation dependent addition.
23277 @node pragma Task_Info
23278 @section pragma Task_Info
23280 The functionality provided by pragma @code{Task_Info} is now part of the
23281 Ada language. The @code{CPU} aspect and the package
23282 @code{System.Multiprocessors} offer a less system-dependent way to specify
23283 task affinity or to query the number of processsors.
23285 @noindent
23286 Syntax
23288 @smallexample @c ada
23289 pragma Task_Info (EXPRESSION);
23290 @end smallexample
23292 @noindent
23293 This pragma appears within a task definition (like pragma
23294 @code{Priority}) and applies to the task in which it appears.  The
23295 argument must be of type @code{System.Task_Info.Task_Info_Type}.
23296 The @code{Task_Info} pragma provides system dependent control over
23297 aspects of tasking implementation, for example, the ability to map
23298 tasks to specific processors.  For details on the facilities available
23299 for the version of GNAT that you are using, see the documentation
23300 in the spec of package System.Task_Info in the runtime
23301 library.
23303 @node System.Task_Info (s-tasinf.ads)
23304 @section package System.Task_Info (@file{s-tasinf.ads})
23306 @noindent
23307 This package provides target dependent functionality that is used
23308 to support the @code{Task_Info} pragma. The predefined Ada package
23309  @code{System.Multiprocessors} and the @code{CPU} aspect now provide a
23310 standard replacement for GNAT's @code{Task_Info} functionality.
23312 @include fdl.texi
23313 @c GNU Free Documentation License
23315 @node Concept Index
23316 @unnumbered Index
23318 @printindex cp
23320 @contents
23322 @bye