2014-09-15 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
[official-gcc.git] / gcc / ada / gnat_rm.texi
blobe5a52bc23f1c3153709215bd4a1c7941b2a09aca
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 Pre_Class::
231 * Pragma Priority_Specific_Dispatching::
232 * Pragma Profile::
233 * Pragma Profile_Warnings::
234 * Pragma Propagate_Exceptions::
235 * Pragma Provide_Shift_Operators::
236 * Pragma Psect_Object::
237 * Pragma Pure_Function::
238 * Pragma Rational::
239 * Pragma Ravenscar::
240 * Pragma Refined_Depends::
241 * Pragma Refined_Global::
242 * Pragma Refined_Post::
243 * Pragma Refined_State::
244 * Pragma Relative_Deadline::
245 * Pragma Remote_Access_Type::
246 * Pragma Restricted_Run_Time::
247 * Pragma Restriction_Warnings::
248 * Pragma Reviewable::
249 * Pragma Share_Generic::
250 * Pragma Shared::
251 * Pragma Short_Circuit_And_Or::
252 * Pragma Short_Descriptors::
253 * Pragma Simple_Storage_Pool_Type::
254 * Pragma Source_File_Name::
255 * Pragma Source_File_Name_Project::
256 * Pragma Source_Reference::
257 * Pragma SPARK_Mode::
258 * Pragma Static_Elaboration_Desired::
259 * Pragma Stream_Convert::
260 * Pragma Style_Checks::
261 * Pragma Subtitle::
262 * Pragma Suppress::
263 * Pragma Suppress_All::
264 * Pragma Suppress_Debug_Info::
265 * Pragma Suppress_Exception_Locations::
266 * Pragma Suppress_Initialization::
267 * Pragma Task_Name::
268 * Pragma Task_Storage::
269 * Pragma Test_Case::
270 * Pragma Thread_Local_Storage::
271 * Pragma Time_Slice::
272 * Pragma Title::
273 * Pragma Type_Invariant::
274 * Pragma Type_Invariant_Class::
275 * Pragma Unchecked_Union::
276 * Pragma Unevaluated_Use_Of_Old::
277 * Pragma Unimplemented_Unit::
278 * Pragma Universal_Aliasing ::
279 * Pragma Universal_Data::
280 * Pragma Unmodified::
281 * Pragma Unreferenced::
282 * Pragma Unreferenced_Objects::
283 * Pragma Unreserve_All_Interrupts::
284 * Pragma Unsuppress::
285 * Pragma Use_VADS_Size::
286 * Pragma Validity_Checks::
287 * Pragma Volatile::
288 * Pragma Warning_As_Error::
289 * Pragma Warnings::
290 * Pragma Weak_External::
291 * Pragma Wide_Character_Encoding::
293 Implementation Defined Aspects
295 * Aspect Abstract_State::
296 * Aspect Annotate::
297 * Aspect Async_Readers::
298 * Aspect Async_Writers::
299 * Aspect Contract_Cases::
300 * Aspect Depends::
301 * Aspect Dimension::
302 * Aspect Dimension_System::
303 * Aspect Effective_Reads::
304 * Aspect Effective_Writes::
305 * Aspect Favor_Top_Level::
306 * Aspect Global::
307 * Aspect Initial_Condition::
308 * Aspect Initializes::
309 * Aspect Inline_Always::
310 * Aspect Invariant::
311 * Aspect Invariant'Class::
312 * Aspect Iterable::
313 * Aspect Linker_Section::
314 * Aspect No_Elaboration_Code_All::
315 * Aspect Object_Size::
316 * Aspect Obsolescent::
317 * Aspect Part_Of::
318 * Aspect Persistent_BSS::
319 * Aspect Predicate::
320 * Aspect Pure_Function::
321 * Aspect Refined_Depends::
322 * Aspect Refined_Global::
323 * Aspect Refined_Post::
324 * Aspect Refined_State::
325 * Aspect Remote_Access_Type::
326 * Aspect Scalar_Storage_Order::
327 * Aspect Shared::
328 * Aspect Simple_Storage_Pool::
329 * Aspect Simple_Storage_Pool_Type::
330 * Aspect SPARK_Mode::
331 * Aspect Suppress_Debug_Info::
332 * Aspect Test_Case::
333 * Aspect Thread_Local_Storage::
334 * Aspect Universal_Aliasing::
335 * Aspect Universal_Data::
336 * Aspect Unmodified::
337 * Aspect Unreferenced::
338 * Aspect Unreferenced_Objects::
339 * Aspect Value_Size::
340 * Aspect Warnings::
342 Implementation Defined Attributes
344 * Attribute Abort_Signal::
345 * Attribute Address_Size::
346 * Attribute Asm_Input::
347 * Attribute Asm_Output::
348 * Attribute AST_Entry::
349 * Attribute Atomic_Always_Lock_Free::
350 * Attribute Bit::
351 * Attribute Bit_Position::
352 * Attribute Code_Address::
353 * Attribute Compiler_Version::
354 * Attribute Constrained::
355 * Attribute Default_Bit_Order::
356 * Attribute Default_Scalar_Storage_Order::
357 * Attribute Descriptor_Size::
358 * Attribute Elaborated::
359 * Attribute Elab_Body::
360 * Attribute Elab_Spec::
361 * Attribute Elab_Subp_Body::
362 * Attribute Emax::
363 * Attribute Enabled::
364 * Attribute Enum_Rep::
365 * Attribute Enum_Val::
366 * Attribute Epsilon::
367 * Attribute Fast_Math::
368 * Attribute Fixed_Value::
369 * Attribute From_Any::
370 * Attribute Has_Access_Values::
371 * Attribute Has_Discriminants::
372 * Attribute Img::
373 * Attribute Integer_Value::
374 * Attribute Invalid_Value::
375 * Attribute Iterable::
376 * Attribute Large::
377 * Attribute Library_Level::
378 * Attribute Lock_Free::
379 * Attribute Loop_Entry::
380 * Attribute Machine_Size::
381 * Attribute Mantissa::
382 * Attribute Maximum_Alignment::
383 * Attribute Mechanism_Code::
384 * Attribute Null_Parameter::
385 * Attribute Object_Size::
386 * Attribute Old::
387 * Attribute Passed_By_Reference::
388 * Attribute Pool_Address::
389 * Attribute Range_Length::
390 * Attribute Ref::
391 * Attribute Restriction_Set::
392 * Attribute Result::
393 * Attribute Safe_Emax::
394 * Attribute Safe_Large::
395 * Attribute Safe_Small::
396 * Attribute Scalar_Storage_Order::
397 * Attribute Simple_Storage_Pool::
398 * Attribute Small::
399 * Attribute Storage_Unit::
400 * Attribute Stub_Type::
401 * Attribute System_Allocator_Alignment::
402 * Attribute Target_Name::
403 * Attribute To_Address::
404 * Attribute To_Any::
405 * Attribute Type_Class::
406 * Attribute Type_Key::
407 * Attribute TypeCode::
408 * Attribute UET_Address::
409 * Attribute Unconstrained_Array::
410 * Attribute Universal_Literal_String::
411 * Attribute Unrestricted_Access::
412 * Attribute Update::
413 * Attribute VADS_Size::
414 * Attribute Valid_Scalars::
415 * Attribute Value_Size::
416 * Attribute Wchar_T_Size::
417 * Attribute Word_Size::
419 Standard and Implementation Defined Restrictions
421 * Partition-Wide Restrictions::
422 * Program Unit Level Restrictions::
424 Partition-Wide Restrictions
426 * Immediate_Reclamation::
427 * Max_Asynchronous_Select_Nesting::
428 * Max_Entry_Queue_Length::
429 * Max_Protected_Entries::
430 * Max_Select_Alternatives::
431 * Max_Storage_At_Blocking::
432 * Max_Task_Entries::
433 * Max_Tasks::
434 * No_Abort_Statements::
435 * No_Access_Parameter_Allocators::
436 * No_Access_Subprograms::
437 * No_Allocators::
438 * No_Anonymous_Allocators::
439 * No_Calendar::
440 * No_Coextensions::
441 * No_Default_Initialization::
442 * No_Delay::
443 * No_Dependence::
444 * No_Direct_Boolean_Operators::
445 * No_Dispatch::
446 * No_Dispatching_Calls::
447 * No_Dynamic_Attachment::
448 * No_Dynamic_Priorities::
449 * No_Entry_Calls_In_Elaboration_Code::
450 * No_Enumeration_Maps::
451 * No_Exception_Handlers::
452 * No_Exception_Propagation::
453 * No_Exception_Registration::
454 * No_Exceptions::
455 * No_Finalization::
456 * No_Fixed_Point::
457 * No_Floating_Point::
458 * No_Implicit_Conditionals::
459 * No_Implicit_Dynamic_Code::
460 * No_Implicit_Heap_Allocations::
461 * No_Implicit_Loops::
462 * No_Initialize_Scalars::
463 * No_IO::
464 * No_Local_Allocators::
465 * No_Local_Protected_Objects::
466 * No_Local_Timing_Events::
467 * No_Long_Long_Integers::
468 * No_Multiple_Elaboration::
469 * No_Nested_Finalization::
470 * No_Protected_Type_Allocators::
471 * No_Protected_Types::
472 * No_Recursion::
473 * No_Reentrancy::
474 * No_Relative_Delay::
475 * No_Requeue_Statements::
476 * No_Secondary_Stack::
477 * No_Select_Statements::
478 * No_Specific_Termination_Handlers::
479 * No_Specification_of_Aspect::
480 * No_Standard_Allocators_After_Elaboration::
481 * No_Standard_Storage_Pools::
482 * No_Stream_Optimizations::
483 * No_Streams::
484 * No_Task_Allocators::
485 * No_Task_Attributes_Package::
486 * No_Task_Hierarchy::
487 * No_Task_Termination::
488 * No_Tasking::
489 * No_Terminate_Alternatives::
490 * No_Unchecked_Access::
491 * Simple_Barriers::
492 * Static_Priorities::
493 * Static_Storage_Size::
495 Program Unit Level Restrictions
497 * No_Elaboration_Code::
498 * No_Entry_Queue::
499 * No_Implementation_Aspect_Specifications::
500 * No_Implementation_Attributes::
501 * No_Implementation_Identifiers::
502 * No_Implementation_Pragmas::
503 * No_Implementation_Restrictions::
504 * No_Implementation_Units::
505 * No_Implicit_Aliasing::
506 * No_Obsolescent_Features::
507 * No_Wide_Characters::
508 * SPARK_05::
510 The Implementation of Standard I/O
512 * Standard I/O Packages::
513 * FORM Strings::
514 * Direct_IO::
515 * Sequential_IO::
516 * Text_IO::
517 * Wide_Text_IO::
518 * Wide_Wide_Text_IO::
519 * Stream_IO::
520 * Text Translation::
521 * Shared Files::
522 * Filenames encoding::
523 * File content encoding::
524 * Open Modes::
525 * Operations on C Streams::
526 * Interfacing to C Streams::
528 The GNAT Library
530 * Ada.Characters.Latin_9 (a-chlat9.ads)::
531 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
532 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
533 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
534 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
535 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
536 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
537 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
538 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
539 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
540 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
541 * Ada.Command_Line.Environment (a-colien.ads)::
542 * Ada.Command_Line.Remove (a-colire.ads)::
543 * Ada.Command_Line.Response_File (a-clrefi.ads)::
544 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
545 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
546 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
547 * Ada.Exceptions.Traceback (a-exctra.ads)::
548 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
549 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
550 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
551 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
552 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
553 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
554 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
555 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
556 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
557 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
558 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
559 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
560 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
561 * GNAT.Altivec (g-altive.ads)::
562 * GNAT.Altivec.Conversions (g-altcon.ads)::
563 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
564 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
565 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
566 * GNAT.Array_Split (g-arrspl.ads)::
567 * GNAT.AWK (g-awk.ads)::
568 * GNAT.Bounded_Buffers (g-boubuf.ads)::
569 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
570 * GNAT.Bubble_Sort (g-bubsor.ads)::
571 * GNAT.Bubble_Sort_A (g-busora.ads)::
572 * GNAT.Bubble_Sort_G (g-busorg.ads)::
573 * GNAT.Byte_Order_Mark (g-byorma.ads)::
574 * GNAT.Byte_Swapping (g-bytswa.ads)::
575 * GNAT.Calendar (g-calend.ads)::
576 * GNAT.Calendar.Time_IO (g-catiio.ads)::
577 * GNAT.Case_Util (g-casuti.ads)::
578 * GNAT.CGI (g-cgi.ads)::
579 * GNAT.CGI.Cookie (g-cgicoo.ads)::
580 * GNAT.CGI.Debug (g-cgideb.ads)::
581 * GNAT.Command_Line (g-comlin.ads)::
582 * GNAT.Compiler_Version (g-comver.ads)::
583 * GNAT.Ctrl_C (g-ctrl_c.ads)::
584 * GNAT.CRC32 (g-crc32.ads)::
585 * GNAT.Current_Exception (g-curexc.ads)::
586 * GNAT.Debug_Pools (g-debpoo.ads)::
587 * GNAT.Debug_Utilities (g-debuti.ads)::
588 * GNAT.Decode_String (g-decstr.ads)::
589 * GNAT.Decode_UTF8_String (g-deutst.ads)::
590 * GNAT.Directory_Operations (g-dirope.ads)::
591 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
592 * GNAT.Dynamic_HTables (g-dynhta.ads)::
593 * GNAT.Dynamic_Tables (g-dyntab.ads)::
594 * GNAT.Encode_String (g-encstr.ads)::
595 * GNAT.Encode_UTF8_String (g-enutst.ads)::
596 * GNAT.Exception_Actions (g-excact.ads)::
597 * GNAT.Exception_Traces (g-exctra.ads)::
598 * GNAT.Exceptions (g-except.ads)::
599 * GNAT.Expect (g-expect.ads)::
600 * GNAT.Expect.TTY (g-exptty.ads)::
601 * GNAT.Float_Control (g-flocon.ads)::
602 * GNAT.Formatted_String (g-forstr.ads)::
603 * GNAT.Heap_Sort (g-heasor.ads)::
604 * GNAT.Heap_Sort_A (g-hesora.ads)::
605 * GNAT.Heap_Sort_G (g-hesorg.ads)::
606 * GNAT.HTable (g-htable.ads)::
607 * GNAT.IO (g-io.ads)::
608 * GNAT.IO_Aux (g-io_aux.ads)::
609 * GNAT.Lock_Files (g-locfil.ads)::
610 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
611 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
612 * GNAT.MD5 (g-md5.ads)::
613 * GNAT.Memory_Dump (g-memdum.ads)::
614 * GNAT.Most_Recent_Exception (g-moreex.ads)::
615 * GNAT.OS_Lib (g-os_lib.ads)::
616 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
617 * GNAT.Random_Numbers (g-rannum.ads)::
618 * GNAT.Regexp (g-regexp.ads)::
619 * GNAT.Registry (g-regist.ads)::
620 * GNAT.Regpat (g-regpat.ads)::
621 * GNAT.Rewrite_Data (g-rewdat.ads)::
622 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
623 * GNAT.Semaphores (g-semaph.ads)::
624 * GNAT.Serial_Communications (g-sercom.ads)::
625 * GNAT.SHA1 (g-sha1.ads)::
626 * GNAT.SHA224 (g-sha224.ads)::
627 * GNAT.SHA256 (g-sha256.ads)::
628 * GNAT.SHA384 (g-sha384.ads)::
629 * GNAT.SHA512 (g-sha512.ads)::
630 * GNAT.Signals (g-signal.ads)::
631 * GNAT.Sockets (g-socket.ads)::
632 * GNAT.Source_Info (g-souinf.ads)::
633 * GNAT.Spelling_Checker (g-speche.ads)::
634 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
635 * GNAT.Spitbol.Patterns (g-spipat.ads)::
636 * GNAT.Spitbol (g-spitbo.ads)::
637 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
638 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
639 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
640 * GNAT.SSE (g-sse.ads)::
641 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
642 * GNAT.Strings (g-string.ads)::
643 * GNAT.String_Split (g-strspl.ads)::
644 * GNAT.Table (g-table.ads)::
645 * GNAT.Task_Lock (g-tasloc.ads)::
646 * GNAT.Threads (g-thread.ads)::
647 * GNAT.Time_Stamp (g-timsta.ads)::
648 * GNAT.Traceback (g-traceb.ads)::
649 * GNAT.Traceback.Symbolic (g-trasym.ads)::
650 * GNAT.UTF_32 (g-utf_32.ads)::
651 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
652 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
653 * GNAT.Wide_String_Split (g-wistsp.ads)::
654 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
655 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
656 * Interfaces.C.Extensions (i-cexten.ads)::
657 * Interfaces.C.Streams (i-cstrea.ads)::
658 * Interfaces.Packed_Decimal (i-pacdec.ads)::
659 * Interfaces.VxWorks (i-vxwork.ads)::
660 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
661 * System.Address_Image (s-addima.ads)::
662 * System.Assertions (s-assert.ads)::
663 * System.Memory (s-memory.ads)::
664 * System.Multiprocessors (s-multip.ads)::
665 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
666 * System.Partition_Interface (s-parint.ads)::
667 * System.Pool_Global (s-pooglo.ads)::
668 * System.Pool_Local (s-pooloc.ads)::
669 * System.Restrictions (s-restri.ads)::
670 * System.Rident (s-rident.ads)::
671 * System.Strings.Stream_Ops (s-ststop.ads)::
672 * System.Unsigned_Types (s-unstyp.ads)::
673 * System.Wch_Cnv (s-wchcnv.ads)::
674 * System.Wch_Con (s-wchcon.ads)::
676 Text_IO
678 * Text_IO Stream Pointer Positioning::
679 * Text_IO Reading and Writing Non-Regular Files::
680 * Get_Immediate::
681 * Treating Text_IO Files as Streams::
682 * Text_IO Extensions::
683 * Text_IO Facilities for Unbounded Strings::
685 Wide_Text_IO
687 * Wide_Text_IO Stream Pointer Positioning::
688 * Wide_Text_IO Reading and Writing Non-Regular Files::
690 Wide_Wide_Text_IO
692 * Wide_Wide_Text_IO Stream Pointer Positioning::
693 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
695 Interfacing to Other Languages
697 * Interfacing to C::
698 * Interfacing to C++::
699 * Interfacing to COBOL::
700 * Interfacing to Fortran::
701 * Interfacing to non-GNAT Ada code::
703 Specialized Needs Annexes
705 Implementation of Specific Ada Features
706 * Machine Code Insertions::
707 * GNAT Implementation of Tasking::
708 * GNAT Implementation of Shared Passive Packages::
709 * Code Generation for Array Aggregates::
710 * The Size of Discriminated Records with Default Discriminants::
711 * Strict Conformance to the Ada Reference Manual::
713 Implementation of Ada 2012 Features
715 Obsolescent Features
717 GNU Free Documentation License
719 Index
720 @end detailmenu
721 @end menu
723 @end ifnottex
725 @node About This Guide
726 @unnumbered About This Guide
728 @noindent
729 This manual contains useful information in writing programs using the
730 @value{EDITION} compiler.  It includes information on implementation dependent
731 characteristics of @value{EDITION}, including all the information required by
732 Annex M of the Ada language standard.
734 @value{EDITION} implements Ada 95, Ada 2005 and Ada 2012, and it may also be
735 invoked in Ada 83 compatibility mode.
736 By default, @value{EDITION} assumes Ada 2012,
737 but you can override with a compiler switch
738 to explicitly specify the language version.
739 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
740 @value{EDITION} User's Guide}, for details on these switches.)
741 Throughout this manual, references to ``Ada'' without a year suffix
742 apply to all the Ada versions of the language.
744 Ada is designed to be highly portable.
745 In general, a program will have the same effect even when compiled by
746 different compilers on different platforms.
747 However, since Ada is designed to be used in a
748 wide variety of applications, it also contains a number of system
749 dependent features to be used in interfacing to the external world.
750 @cindex Implementation-dependent features
751 @cindex Portability
753 Note: Any program that makes use of implementation-dependent features
754 may be non-portable.  You should follow good programming practice and
755 isolate and clearly document any sections of your program that make use
756 of these features in a non-portable manner.
758 @ifset PROEDITION
759 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
760 ``GNAT'' in the remainder of this document.
761 @end ifset
763 @menu
764 * What This Reference Manual Contains::
765 * Conventions::
766 * Related Information::
767 @end menu
769 @node What This Reference Manual Contains
770 @unnumberedsec What This Reference Manual Contains
772 @noindent
773 This reference manual contains the following chapters:
775 @itemize @bullet
776 @item
777 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
778 pragmas, which can be used to extend and enhance the functionality of the
779 compiler.
781 @item
782 @ref{Implementation Defined Attributes}, lists GNAT
783 implementation-dependent attributes, which can be used to extend and
784 enhance the functionality of the compiler.
786 @item
787 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
788 implementation-dependent restrictions, which can be used to extend and
789 enhance the functionality of the compiler.
791 @item
792 @ref{Implementation Advice}, provides information on generally
793 desirable behavior which are not requirements that all compilers must
794 follow since it cannot be provided on all systems, or which may be
795 undesirable on some systems.
797 @item
798 @ref{Implementation Defined Characteristics}, provides a guide to
799 minimizing implementation dependent features.
801 @item
802 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
803 implemented by GNAT, and how they can be imported into user
804 application programs.
806 @item
807 @ref{Representation Clauses and Pragmas}, describes in detail the
808 way that GNAT represents data, and in particular the exact set
809 of representation clauses and pragmas that is accepted.
811 @item
812 @ref{Standard Library Routines}, provides a listing of packages and a
813 brief description of the functionality that is provided by Ada's
814 extensive set of standard library routines as implemented by GNAT@.
816 @item
817 @ref{The Implementation of Standard I/O}, details how the GNAT
818 implementation of the input-output facilities.
820 @item
821 @ref{The GNAT Library}, is a catalog of packages that complement
822 the Ada predefined library.
824 @item
825 @ref{Interfacing to Other Languages}, describes how programs
826 written in Ada using GNAT can be interfaced to other programming
827 languages.
829 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
830 of the specialized needs annexes.
832 @item
833 @ref{Implementation of Specific Ada Features}, discusses issues related
834 to GNAT's implementation of machine code insertions, tasking, and several
835 other features.
837 @item
838 @ref{Implementation of Ada 2012 Features}, describes the status of the
839 GNAT implementation of the Ada 2012 language standard.
841 @item
842 @ref{Obsolescent Features} documents implementation dependent features,
843 including pragmas and attributes, which are considered obsolescent, since
844 there are other preferred ways of achieving the same results. These
845 obsolescent forms are retained for backwards compatibility.
847 @end itemize
849 @cindex Ada 95 Language Reference Manual
850 @cindex Ada 2005 Language Reference Manual
851 @noindent
852 This reference manual assumes a basic familiarity with the Ada 95 language, as
853 described in the International Standard ANSI/ISO/IEC-8652:1995,
854 January 1995.
855 It does not require knowledge of the new features introduced by Ada 2005,
856 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
857 and Amendment 1).
858 Both reference manuals are included in the GNAT documentation
859 package.
861 @node Conventions
862 @unnumberedsec Conventions
863 @cindex Conventions, typographical
864 @cindex Typographical conventions
866 @noindent
867 Following are examples of the typographical and graphic conventions used
868 in this guide:
870 @itemize @bullet
871 @item
872 @code{Functions}, @code{utility program names}, @code{standard names},
873 and @code{classes}.
875 @item
876 @code{Option flags}
878 @item
879 @file{File names}, @samp{button names}, and @samp{field names}.
881 @item
882 @code{Variables}, @env{environment variables}, and @var{metasyntactic
883 variables}.
885 @item
886 @emph{Emphasis}.
888 @item
889 [optional information or parameters]
891 @item
892 Examples are described by text
893 @smallexample
894 and then shown this way.
895 @end smallexample
896 @end itemize
898 @noindent
899 Commands that are entered by the user are preceded in this manual by the
900 characters @samp{$ } (dollar sign followed by space).  If your system uses this
901 sequence as a prompt, then the commands will appear exactly as you see them
902 in the manual.  If your system uses some other prompt, then the command will
903 appear with the @samp{$} replaced by whatever prompt character you are using.
905 @node Related Information
906 @unnumberedsec Related Information
907 @noindent
908 See the following documents for further information on GNAT:
910 @itemize @bullet
911 @item
912 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
913 @value{EDITION} User's Guide}, which provides information on how to use the
914 GNAT compiler system.
916 @item
917 @cite{Ada 95 Reference Manual}, which contains all reference
918 material for the Ada 95 programming language.
920 @item
921 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
922 of the Ada 95 standard.  The annotations describe
923 detailed aspects of the design decision, and in particular contain useful
924 sections on Ada 83 compatibility.
926 @item
927 @cite{Ada 2005 Reference Manual}, which contains all reference
928 material for the Ada 2005 programming language.
930 @item
931 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
932 of the Ada 2005 standard.  The annotations describe
933 detailed aspects of the design decision, and in particular contain useful
934 sections on Ada 83 and Ada 95 compatibility.
936 @item
937 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
938 which contains specific information on compatibility between GNAT and
939 DEC Ada 83 systems.
941 @item
942 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
943 describes in detail the pragmas and attributes provided by the DEC Ada 83
944 compiler system.
946 @end itemize
948 @node Implementation Defined Pragmas
949 @chapter Implementation Defined Pragmas
951 @noindent
952 Ada defines a set of pragmas that can be used to supply additional
953 information to the compiler.  These language defined pragmas are
954 implemented in GNAT and work as described in the Ada Reference Manual.
956 In addition, Ada allows implementations to define additional pragmas
957 whose meaning is defined by the implementation.  GNAT provides a number
958 of these implementation-defined pragmas, which can be used to extend
959 and enhance the functionality of the compiler.  This section of the GNAT
960 Reference Manual describes these additional pragmas.
962 Note that any program using these pragmas might not be portable to other
963 compilers (although GNAT implements this set of pragmas on all
964 platforms).  Therefore if portability to other compilers is an important
965 consideration, the use of these pragmas should be minimized.
967 @menu
968 * Pragma Abort_Defer::
969 * Pragma Abstract_State::
970 * Pragma Ada_83::
971 * Pragma Ada_95::
972 * Pragma Ada_05::
973 * Pragma Ada_2005::
974 * Pragma Ada_12::
975 * Pragma Ada_2012::
976 * Pragma Allow_Integer_Address::
977 * Pragma Annotate::
978 * Pragma Assert::
979 * Pragma Assert_And_Cut::
980 * Pragma Assertion_Policy::
981 * Pragma Assume::
982 * Pragma Assume_No_Invalid_Values::
983 * Pragma AST_Entry::
984 * Pragma Async_Readers::
985 * Pragma Async_Writers::
986 * Pragma Attribute_Definition::
987 * Pragma C_Pass_By_Copy::
988 * Pragma Check::
989 * Pragma Check_Float_Overflow::
990 * Pragma Check_Name::
991 * Pragma Check_Policy::
992 * Pragma CIL_Constructor::
993 * Pragma Comment::
994 * Pragma Common_Object::
995 * Pragma Compile_Time_Error::
996 * Pragma Compile_Time_Warning::
997 * Pragma Compiler_Unit::
998 * Pragma Compiler_Unit_Warning::
999 * Pragma Complete_Representation::
1000 * Pragma Complex_Representation::
1001 * Pragma Component_Alignment::
1002 * Pragma Contract_Cases::
1003 * Pragma Convention_Identifier::
1004 * Pragma CPP_Class::
1005 * Pragma CPP_Constructor::
1006 * Pragma CPP_Virtual::
1007 * Pragma CPP_Vtable::
1008 * Pragma CPU::
1009 * Pragma Debug::
1010 * Pragma Debug_Policy::
1011 * Pragma Default_Scalar_Storage_Order::
1012 * Pragma Default_Storage_Pool::
1013 * Pragma Depends::
1014 * Pragma Detect_Blocking::
1015 * Pragma Disable_Atomic_Synchronization::
1016 * Pragma Dispatching_Domain::
1017 * Pragma Effective_Reads::
1018 * Pragma Effective_Writes::
1019 * Pragma Elaboration_Checks::
1020 * Pragma Eliminate::
1021 * Pragma Enable_Atomic_Synchronization::
1022 * Pragma Export_Exception::
1023 * Pragma Export_Function::
1024 * Pragma Export_Object::
1025 * Pragma Export_Procedure::
1026 * Pragma Export_Value::
1027 * Pragma Export_Valued_Procedure::
1028 * Pragma Extend_System::
1029 * Pragma Extensions_Allowed::
1030 * Pragma External::
1031 * Pragma External_Name_Casing::
1032 * Pragma Fast_Math::
1033 * Pragma Favor_Top_Level::
1034 * Pragma Finalize_Storage_Only::
1035 * Pragma Float_Representation::
1036 * Pragma Global::
1037 * Pragma Ident::
1038 * Pragma Implementation_Defined::
1039 * Pragma Implemented::
1040 * Pragma Implicit_Packing::
1041 * Pragma Import_Exception::
1042 * Pragma Import_Function::
1043 * Pragma Import_Object::
1044 * Pragma Import_Procedure::
1045 * Pragma Import_Valued_Procedure::
1046 * Pragma Independent::
1047 * Pragma Independent_Components::
1048 * Pragma Initial_Condition::
1049 * Pragma Initialize_Scalars::
1050 * Pragma Initializes::
1051 * Pragma Inline_Always::
1052 * Pragma Inline_Generic::
1053 * Pragma Interface::
1054 * Pragma Interface_Name::
1055 * Pragma Interrupt_Handler::
1056 * Pragma Interrupt_State::
1057 * Pragma Invariant::
1058 * Pragma Java_Constructor::
1059 * Pragma Java_Interface::
1060 * Pragma Keep_Names::
1061 * Pragma License::
1062 * Pragma Link_With::
1063 * Pragma Linker_Alias::
1064 * Pragma Linker_Constructor::
1065 * Pragma Linker_Destructor::
1066 * Pragma Linker_Section::
1067 * Pragma Lock_Free::
1068 * Pragma Long_Float::
1069 * Pragma Loop_Invariant::
1070 * Pragma Loop_Optimize::
1071 * Pragma Loop_Variant::
1072 * Pragma Machine_Attribute::
1073 * Pragma Main::
1074 * Pragma Main_Storage::
1075 * Pragma No_Body::
1076 * Pragma No_Elaboration_Code_All::
1077 * Pragma No_Inline::
1078 * Pragma No_Return::
1079 * Pragma No_Run_Time::
1080 * Pragma No_Strict_Aliasing::
1081 * Pragma Normalize_Scalars::
1082 * Pragma Obsolescent::
1083 * Pragma Optimize_Alignment::
1084 * Pragma Ordered::
1085 * Pragma Overflow_Mode::
1086 * Pragma Overriding_Renamings::
1087 * Pragma Partition_Elaboration_Policy::
1088 * Pragma Part_Of::
1089 * Pragma Passive::
1090 * Pragma Persistent_BSS::
1091 * Pragma Polling::
1092 * Pragma Post::
1093 * Pragma Postcondition::
1094 * Pragma Post_Class::
1095 * Pragma Pre::
1096 * Pragma Precondition::
1097 * Pragma Predicate::
1098 * Pragma Preelaborable_Initialization::
1099 * Pragma Pre_Class::
1100 * Pragma Priority_Specific_Dispatching::
1101 * Pragma Profile::
1102 * Pragma Profile_Warnings::
1103 * Pragma Propagate_Exceptions::
1104 * Pragma Provide_Shift_Operators::
1105 * Pragma Psect_Object::
1106 * Pragma Pure_Function::
1107 * Pragma Rational::
1108 * Pragma Ravenscar::
1109 * Pragma Refined_Depends::
1110 * Pragma Refined_Global::
1111 * Pragma Refined_Post::
1112 * Pragma Refined_State::
1113 * Pragma Relative_Deadline::
1114 * Pragma Remote_Access_Type::
1115 * Pragma Restricted_Run_Time::
1116 * Pragma Restriction_Warnings::
1117 * Pragma Reviewable::
1118 * Pragma Share_Generic::
1119 * Pragma Shared::
1120 * Pragma Short_Circuit_And_Or::
1121 * Pragma Short_Descriptors::
1122 * Pragma Simple_Storage_Pool_Type::
1123 * Pragma Source_File_Name::
1124 * Pragma Source_File_Name_Project::
1125 * Pragma Source_Reference::
1126 * Pragma SPARK_Mode::
1127 * Pragma Static_Elaboration_Desired::
1128 * Pragma Stream_Convert::
1129 * Pragma Style_Checks::
1130 * Pragma Subtitle::
1131 * Pragma Suppress::
1132 * Pragma Suppress_All::
1133 * Pragma Suppress_Debug_Info::
1134 * Pragma Suppress_Exception_Locations::
1135 * Pragma Suppress_Initialization::
1136 * Pragma Task_Name::
1137 * Pragma Task_Storage::
1138 * Pragma Test_Case::
1139 * Pragma Thread_Local_Storage::
1140 * Pragma Time_Slice::
1141 * Pragma Title::
1142 * Pragma Type_Invariant::
1143 * Pragma Type_Invariant_Class::
1144 * Pragma Unchecked_Union::
1145 * Pragma Unevaluated_Use_Of_Old::
1146 * Pragma Unimplemented_Unit::
1147 * Pragma Universal_Aliasing ::
1148 * Pragma Universal_Data::
1149 * Pragma Unmodified::
1150 * Pragma Unreferenced::
1151 * Pragma Unreferenced_Objects::
1152 * Pragma Unreserve_All_Interrupts::
1153 * Pragma Unsuppress::
1154 * Pragma Use_VADS_Size::
1155 * Pragma Validity_Checks::
1156 * Pragma Volatile::
1157 * Pragma Warning_As_Error::
1158 * Pragma Warnings::
1159 * Pragma Weak_External::
1160 * Pragma Wide_Character_Encoding::
1161 @end menu
1163 @node Pragma Abort_Defer
1164 @unnumberedsec Pragma Abort_Defer
1165 @findex Abort_Defer
1166 @cindex Deferring aborts
1167 @noindent
1168 Syntax:
1169 @smallexample
1170 pragma Abort_Defer;
1171 @end smallexample
1173 @noindent
1174 This pragma must appear at the start of the statement sequence of a
1175 handled sequence of statements (right after the @code{begin}).  It has
1176 the effect of deferring aborts for the sequence of statements (but not
1177 for the declarations or handlers, if any, associated with this statement
1178 sequence).
1180 @node Pragma Abstract_State
1181 @unnumberedsec Pragma Abstract_State
1182 @findex Abstract_State
1183 @noindent
1184 For the description of this pragma, see SPARK 2014 Reference Manual,
1185 section 7.1.4.
1187 @node Pragma Ada_83
1188 @unnumberedsec Pragma Ada_83
1189 @findex Ada_83
1190 @noindent
1191 Syntax:
1192 @smallexample @c ada
1193 pragma Ada_83;
1194 @end smallexample
1196 @noindent
1197 A configuration pragma that establishes Ada 83 mode for the unit to
1198 which it applies, regardless of the mode set by the command line
1199 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
1200 the syntax and semantics of Ada 83, as defined in the original Ada
1201 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
1202 and Ada 2005 are not recognized, optional package bodies are allowed,
1203 and generics may name types with unknown discriminants without using
1204 the @code{(<>)} notation.  In addition, some but not all of the additional
1205 restrictions of Ada 83 are enforced.
1207 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
1208 Ada 83 code to be compiled and adapted to GNAT with less effort.
1209 Secondly, it aids in keeping code backwards compatible with Ada 83.
1210 However, there is no guarantee that code that is processed correctly
1211 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1212 83 compiler, since GNAT does not enforce all the additional checks
1213 required by Ada 83.
1215 @node Pragma Ada_95
1216 @unnumberedsec Pragma Ada_95
1217 @findex Ada_95
1218 @noindent
1219 Syntax:
1220 @smallexample @c ada
1221 pragma Ada_95;
1222 @end smallexample
1224 @noindent
1225 A configuration pragma that establishes Ada 95 mode for the unit to which
1226 it applies, regardless of the mode set by the command line switches.
1227 This mode is set automatically for the @code{Ada} and @code{System}
1228 packages and their children, so you need not specify it in these
1229 contexts.  This pragma is useful when writing a reusable component that
1230 itself uses Ada 95 features, but which is intended to be usable from
1231 either Ada 83 or Ada 95 programs.
1233 @node Pragma Ada_05
1234 @unnumberedsec Pragma Ada_05
1235 @findex Ada_05
1236 @noindent
1237 Syntax:
1238 @smallexample @c ada
1239 pragma Ada_05;
1240 pragma Ada_05 (local_NAME);
1241 @end smallexample
1243 @noindent
1244 A configuration pragma that establishes Ada 2005 mode for the unit to which
1245 it applies, regardless of the mode set by the command line switches.
1246 This pragma is useful when writing a reusable component that
1247 itself uses Ada 2005 features, but which is intended to be usable from
1248 either Ada 83 or Ada 95 programs.
1250 The one argument form (which is not a configuration pragma)
1251 is used for managing the transition from
1252 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
1253 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
1254 mode will generate a warning. In addition, in Ada_83 or Ada_95
1255 mode, a preference rule is established which does not choose
1256 such an entity unless it is unambiguously specified. This avoids
1257 extra subprograms marked this way from generating ambiguities in
1258 otherwise legal pre-Ada_2005 programs. The one argument form is
1259 intended for exclusive use in the GNAT run-time library.
1261 @node Pragma Ada_2005
1262 @unnumberedsec Pragma Ada_2005
1263 @findex Ada_2005
1264 @noindent
1265 Syntax:
1266 @smallexample @c ada
1267 pragma Ada_2005;
1268 @end smallexample
1270 @noindent
1271 This configuration pragma is a synonym for pragma Ada_05 and has the
1272 same syntax and effect.
1274 @node Pragma Ada_12
1275 @unnumberedsec Pragma Ada_12
1276 @findex Ada_12
1277 @noindent
1278 Syntax:
1279 @smallexample @c ada
1280 pragma Ada_12;
1281 pragma Ada_12 (local_NAME);
1282 @end smallexample
1284 @noindent
1285 A configuration pragma that establishes Ada 2012 mode for the unit to which
1286 it applies, regardless of the mode set by the command line switches.
1287 This mode is set automatically for the @code{Ada} and @code{System}
1288 packages and their children, so you need not specify it in these
1289 contexts.  This pragma is useful when writing a reusable component that
1290 itself uses Ada 2012 features, but which is intended to be usable from
1291 Ada 83, Ada 95, or Ada 2005 programs.
1293 The one argument form, which is not a configuration pragma,
1294 is used for managing the transition from Ada
1295 2005 to Ada 2012 in the run-time library. If an entity is marked
1296 as Ada_201 only, then referencing the entity in any pre-Ada_2012
1297 mode will generate a warning. In addition, in any pre-Ada_2012
1298 mode, a preference rule is established which does not choose
1299 such an entity unless it is unambiguously specified. This avoids
1300 extra subprograms marked this way from generating ambiguities in
1301 otherwise legal pre-Ada_2012 programs. The one argument form is
1302 intended for exclusive use in the GNAT run-time library.
1304 @node Pragma Ada_2012
1305 @unnumberedsec Pragma Ada_2012
1306 @findex Ada_2005
1307 @noindent
1308 Syntax:
1309 @smallexample @c ada
1310 pragma Ada_2012;
1311 @end smallexample
1313 @noindent
1314 This configuration pragma is a synonym for pragma Ada_12 and has the
1315 same syntax and effect.
1317 @node Pragma Allow_Integer_Address
1318 @unnumberedsec Pragma Allow_Integer_Address
1319 @findex Allow_Integer_Address
1320 @noindent
1321 Syntax:
1322 @smallexample @c ada
1323 pragma Allow_Integer_Address;
1324 @end smallexample
1326 @noindent
1327 In almost all versions of GNAT, @code{System.Address} is a private
1328 type in accordance with the implementation advice in the RM. This
1329 means that integer values,
1330 in particular integer literals, are not allowed as address values.
1331 If the configuration pragma
1332 @code{Allow_Integer_Address} is given, then integer expressions may
1333 be used anywhere a value of type @code{System.Address} is required.
1334 The effect is to introduce an implicit unchecked conversion from the
1335 integer value to type @code{System.Address}. The reverse case of using
1336 an address where an integer type is required is handled analogously.
1337 The following example compiles without errors:
1339 @smallexample @c ada
1340 pragma Allow_Integer_Address;
1341 with System; use System;
1342 package AddrAsInt is
1343    X : Integer;
1344    Y : Integer;
1345    for X'Address use 16#1240#;
1346    for Y use at 16#3230#;
1347    m : Address := 16#4000#;
1348    n : constant Address := 4000;
1349    p : constant Address := Address (X + Y);
1350    v : Integer := y'Address;
1351    w : constant Integer := Integer (Y'Address);
1352    type R is new integer;
1353    RR : R := 1000;
1354    Z : Integer;
1355    for Z'Address use RR;
1356 end AddrAsInt;
1357 @end smallexample
1359 @noindent
1360 Note that pragma @code{Allow_Integer_Address} is ignored if
1361 @code{System.Address}
1362 is not a private type. In implementations of @code{GNAT} where
1363 System.Address is a visible integer type (notably the implementations
1364 for @code{OpenVMS}), this pragma serves no purpose but is ignored
1365 rather than rejected to allow common sets of sources to be used
1366 in the two situations.
1368 @node Pragma Annotate
1369 @unnumberedsec Pragma Annotate
1370 @findex Annotate
1371 @noindent
1372 Syntax:
1373 @smallexample @c ada
1374 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}] [entity => local_NAME]);
1376 ARG ::= NAME | EXPRESSION
1377 @end smallexample
1379 @noindent
1380 This pragma is used to annotate programs.  @var{identifier} identifies
1381 the type of annotation.  GNAT verifies that it is an identifier, but does
1382 not otherwise analyze it. The second optional identifier is also left
1383 unanalyzed, and by convention is used to control the action of the tool to
1384 which the annotation is addressed.  The remaining @var{arg} arguments
1385 can be either string literals or more generally expressions.
1386 String literals are assumed to be either of type
1387 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1388 depending on the character literals they contain.
1389 All other kinds of arguments are analyzed as expressions, and must be
1390 unambiguous. The last argument if present must have the identifier
1391 @code{Entity} and GNAT verifies that a local name is given.
1393 The analyzed pragma is retained in the tree, but not otherwise processed
1394 by any part of the GNAT compiler, except to generate corresponding note
1395 lines in the generated ALI file. For the format of these note lines, see
1396 the compiler source file lib-writ.ads. This pragma is intended for use by
1397 external tools, including ASIS@. The use of pragma Annotate does not
1398 affect the compilation process in any way. This pragma may be used as
1399 a configuration pragma.
1401 @node Pragma Assert
1402 @unnumberedsec Pragma Assert
1403 @findex Assert
1404 @noindent
1405 Syntax:
1406 @smallexample @c ada
1407 pragma Assert (
1408   boolean_EXPRESSION
1409   [, string_EXPRESSION]);
1410 @end smallexample
1412 @noindent
1413 The effect of this pragma depends on whether the corresponding command
1414 line switch is set to activate assertions.  The pragma expands into code
1415 equivalent to the following:
1417 @smallexample @c ada
1418 if assertions-enabled then
1419    if not boolean_EXPRESSION then
1420       System.Assertions.Raise_Assert_Failure
1421         (string_EXPRESSION);
1422    end if;
1423 end if;
1424 @end smallexample
1426 @noindent
1427 The string argument, if given, is the message that will be associated
1428 with the exception occurrence if the exception is raised.  If no second
1429 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1430 where @var{file} is the name of the source file containing the assert,
1431 and @var{nnn} is the line number of the assert.  A pragma is not a
1432 statement, so if a statement sequence contains nothing but a pragma
1433 assert, then a null statement is required in addition, as in:
1435 @smallexample @c ada
1436 @dots{}
1437 if J > 3 then
1438    pragma Assert (K > 3, "Bad value for K");
1439    null;
1440 end if;
1441 @end smallexample
1443 @noindent
1444 Note that, as with the @code{if} statement to which it is equivalent, the
1445 type of the expression is either @code{Standard.Boolean}, or any type derived
1446 from this standard type.
1448 Assert checks can be either checked or ignored. By default they are ignored.
1449 They will be checked if either the command line switch @option{-gnata} is
1450 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1451 to enable @code{Assert_Checks}.
1453 If assertions are ignored, then there
1454 is no run-time effect (and in particular, any side effects from the
1455 expression will not occur at run time).  (The expression is still
1456 analyzed at compile time, and may cause types to be frozen if they are
1457 mentioned here for the first time).
1459 If assertions are checked, then the given expression is tested, and if
1460 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1461 which results in the raising of @code{Assert_Failure} with the given message.
1463 You should generally avoid side effects in the expression arguments of
1464 this pragma, because these side effects will turn on and off with the
1465 setting of the assertions mode, resulting in assertions that have an
1466 effect on the program.  However, the expressions are analyzed for
1467 semantic correctness whether or not assertions are enabled, so turning
1468 assertions on and off cannot affect the legality of a program.
1470 Note that the implementation defined policy @code{DISABLE}, given in a
1471 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1473 Note: this is a standard language-defined pragma in versions
1474 of Ada from 2005 on. In GNAT, it is implemented in all versions
1475 of Ada, and the DISABLE policy is an implementation-defined
1476 addition.
1478 @node Pragma Assert_And_Cut
1479 @unnumberedsec Pragma Assert_And_Cut
1480 @findex Assert_And_Cut
1481 @noindent
1482 Syntax:
1483 @smallexample @c ada
1484 pragma Assert_And_Cut (
1485   boolean_EXPRESSION
1486   [, string_EXPRESSION]);
1487 @end smallexample
1489 @noindent
1490 The effect of this pragma is identical to that of pragma @code{Assert},
1491 except that in an @code{Assertion_Policy} pragma, the identifier
1492 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1493 (or disabled).
1495 The intention is that this be used within a subprogram when the
1496 given test expresion sums up all the work done so far in the
1497 subprogram, so that the rest of the subprogram can be verified
1498 (informally or formally) using only the entry preconditions,
1499 and the expression in this pragma. This allows dividing up
1500 a subprogram into sections for the purposes of testing or
1501 formal verification. The pragma also serves as useful
1502 documentation.
1504 @node Pragma Assertion_Policy
1505 @unnumberedsec Pragma Assertion_Policy
1506 @findex Assertion_Policy
1507 @noindent
1508 Syntax:
1509 @smallexample @c ada
1510 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1512 pragma Assertion_Policy (
1513     ASSERTION_KIND => POLICY_IDENTIFIER
1514  @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1516 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1518 RM_ASSERTION_KIND ::= Assert               |
1519                       Static_Predicate     |
1520                       Dynamic_Predicate    |
1521                       Pre                  |
1522                       Pre'Class            |
1523                       Post                 |
1524                       Post'Class           |
1525                       Type_Invariant       |
1526                       Type_Invariant'Class
1528 ID_ASSERTION_KIND ::= Assertions           |
1529                       Assert_And_Cut       |
1530                       Assume               |
1531                       Contract_Cases       |
1532                       Debug                |
1533                       Invariant            |
1534                       Invariant'Class      |
1535                       Loop_Invariant       |
1536                       Loop_Variant         |
1537                       Postcondition        |
1538                       Precondition         |
1539                       Predicate            |
1540                       Refined_Post         |
1541                       Statement_Assertions
1543 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1544 @end smallexample
1546 @noindent
1547 This is a standard Ada 2012 pragma that is available as an
1548 implementation-defined pragma in earlier versions of Ada.
1549 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1550 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1551 are implementation defined additions recognized by the GNAT compiler.
1553 The pragma applies in both cases to pragmas and aspects with matching
1554 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1555 applies to both the @code{Precondition} pragma
1556 and the aspect @code{Precondition}. Note that the identifiers for
1557 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
1558 Pre_Class and Post_Class), since these pragmas are intended to be
1559 identical to the corresponding aspects).
1561 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1562 the corresponding pragma or aspect is activated.
1563 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1564 the corresponding pragma or aspect is deactivated.
1565 This pragma overrides the effect of the @option{-gnata} switch on the
1566 command line.
1568 The implementation defined policy @code{DISABLE} is like
1569 @code{IGNORE} except that it completely disables semantic
1570 checking of the corresponding pragma or aspect. This is
1571 useful when the pragma or aspect argument references subprograms
1572 in a with'ed package which is replaced by a dummy package
1573 for the final build.
1575 The implementation defined assertion kind @code{Assertions} applies to all
1576 assertion kinds. The form with no assertion kind given implies this
1577 choice, so it applies to all assertion kinds (RM defined, and
1578 implementation defined).
1580 The implementation defined assertion kind @code{Statement_Assertions}
1581 applies to @code{Assert}, @code{Assert_And_Cut},
1582 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
1584 @node Pragma Assume
1585 @unnumberedsec Pragma Assume
1586 @findex Assume
1587 @noindent
1588 Syntax:
1589 @smallexample @c ada
1590 pragma Assume (
1591   boolean_EXPRESSION
1592   [, string_EXPRESSION]);
1593 @end smallexample
1595 @noindent
1596 The effect of this pragma is identical to that of pragma @code{Assert},
1597 except that in an @code{Assertion_Policy} pragma, the identifier
1598 @code{Assume} is used to control whether it is ignored or checked
1599 (or disabled).
1601 The intention is that this be used for assumptions about the
1602 external environment. So you cannot expect to verify formally
1603 or informally that the condition is met, this must be
1604 established by examining things outside the program itself.
1605 For example, we may have code that depends on the size of
1606 @code{Long_Long_Integer} being at least 64. So we could write:
1608 @smallexample @c ada
1609 pragma Assume (Long_Long_Integer'Size >= 64);
1610 @end smallexample
1612 @noindent
1613 This assumption cannot be proved from the program itself,
1614 but it acts as a useful run-time check that the assumption
1615 is met, and documents the need to ensure that it is met by
1616 reference to information outside the program.
1618 @node Pragma Assume_No_Invalid_Values
1619 @unnumberedsec Pragma Assume_No_Invalid_Values
1620 @findex Assume_No_Invalid_Values
1621 @cindex Invalid representations
1622 @cindex Invalid values
1623 @noindent
1624 Syntax:
1625 @smallexample @c ada
1626 pragma Assume_No_Invalid_Values (On | Off);
1627 @end smallexample
1629 @noindent
1630 This is a configuration pragma that controls the assumptions made by the
1631 compiler about the occurrence of invalid representations (invalid values)
1632 in the code.
1634 The default behavior (corresponding to an Off argument for this pragma), is
1635 to assume that values may in general be invalid unless the compiler can
1636 prove they are valid. Consider the following example:
1638 @smallexample @c ada
1639 V1 : Integer range 1 .. 10;
1640 V2 : Integer range 11 .. 20;
1642 for J in V2 .. V1 loop
1643    ...
1644 end loop;
1645 @end smallexample
1647 @noindent
1648 if V1 and V2 have valid values, then the loop is known at compile
1649 time not to execute since the lower bound must be greater than the
1650 upper bound. However in default mode, no such assumption is made,
1651 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1652 is given, the compiler will assume that any occurrence of a variable
1653 other than in an explicit @code{'Valid} test always has a valid
1654 value, and the loop above will be optimized away.
1656 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1657 you know your code is free of uninitialized variables and other
1658 possible sources of invalid representations, and may result in
1659 more efficient code. A program that accesses an invalid representation
1660 with this pragma in effect is erroneous, so no guarantees can be made
1661 about its behavior.
1663 It is peculiar though permissible to use this pragma in conjunction
1664 with validity checking (-gnatVa). In such cases, accessing invalid
1665 values will generally give an exception, though formally the program
1666 is erroneous so there are no guarantees that this will always be the
1667 case, and it is recommended that these two options not be used together.
1669 @node Pragma Async_Readers
1670 @unnumberedsec Pragma Async_Readers
1671 @findex Async_Readers
1672 @noindent
1673 For the description of this pragma, see SPARK 2014 Reference Manual,
1674 section 7.1.2.
1676 @node Pragma Async_Writers
1677 @unnumberedsec Pragma Async_Writers
1678 @findex Async_Writers
1679 @noindent
1680 For the description of this pragma, see SPARK 2014 Reference Manual,
1681 section 7.1.2.
1683 @node Pragma AST_Entry
1684 @unnumberedsec Pragma AST_Entry
1685 @cindex OpenVMS
1686 @findex AST_Entry
1687 @noindent
1688 Syntax:
1689 @smallexample @c ada
1690 pragma AST_Entry (entry_IDENTIFIER);
1691 @end smallexample
1693 @noindent
1694 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1695 argument is the simple name of a single entry; at most one @code{AST_Entry}
1696 pragma is allowed for any given entry.  This pragma must be used in
1697 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1698 the entry declaration and in the same task type specification or single task
1699 as the entry to which it applies.  This pragma specifies that the given entry
1700 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1701 resulting from an OpenVMS system service call.  The pragma does not affect
1702 normal use of the entry.  For further details on this pragma, see the
1703 DEC Ada Language Reference Manual, section 9.12a.
1705 @node Pragma Attribute_Definition
1706 @unnumberedsec Pragma Attribute_Definition
1707 @findex Attribute_Definition
1708 @noindent
1709 Syntax:
1710 @smallexample @c ada
1711 pragma Attribute_Definition
1712   ([Attribute  =>] ATTRIBUTE_DESIGNATOR,
1713    [Entity     =>] LOCAL_NAME,
1714    [Expression =>] EXPRESSION | NAME);
1715 @end smallexample
1717 @noindent
1718 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1719 the attribute definition clause:
1721 @smallexample @c ada
1722   for Entity'Attribute use Expression;
1723 @end smallexample
1725 If @code{Attribute} is not a recognized attribute name, the pragma is
1726 ignored, and a warning is emitted. This allows source
1727 code to be written that takes advantage of some new attribute, while remaining
1728 compilable with earlier compilers.
1730 @node Pragma C_Pass_By_Copy
1731 @unnumberedsec Pragma C_Pass_By_Copy
1732 @cindex Passing by copy
1733 @findex C_Pass_By_Copy
1734 @noindent
1735 Syntax:
1736 @smallexample @c ada
1737 pragma C_Pass_By_Copy
1738   ([Max_Size =>] static_integer_EXPRESSION);
1739 @end smallexample
1741 @noindent
1742 Normally the default mechanism for passing C convention records to C
1743 convention subprograms is to pass them by reference, as suggested by RM
1744 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1745 this default, by requiring that record formal parameters be passed by
1746 copy if all of the following conditions are met:
1748 @itemize @bullet
1749 @item
1750 The size of the record type does not exceed the value specified for
1751 @code{Max_Size}.
1752 @item
1753 The record type has @code{Convention C}.
1754 @item
1755 The formal parameter has this record type, and the subprogram has a
1756 foreign (non-Ada) convention.
1757 @end itemize
1759 @noindent
1760 If these conditions are met the argument is passed by copy, i.e.@: in a
1761 manner consistent with what C expects if the corresponding formal in the
1762 C prototype is a struct (rather than a pointer to a struct).
1764 You can also pass records by copy by specifying the convention
1765 @code{C_Pass_By_Copy} for the record type, or by using the extended
1766 @code{Import} and @code{Export} pragmas, which allow specification of
1767 passing mechanisms on a parameter by parameter basis.
1769 @node Pragma Check
1770 @unnumberedsec Pragma Check
1771 @cindex Assertions
1772 @cindex Named assertions
1773 @findex Check
1774 @noindent
1775 Syntax:
1776 @smallexample @c ada
1777 pragma Check (
1778      [Name    =>] CHECK_KIND,
1779      [Check   =>] Boolean_EXPRESSION
1780   [, [Message =>] string_EXPRESSION] );
1782 CHECK_KIND ::= IDENTIFIER           |
1783                Pre'Class            |
1784                Post'Class           |
1785                Type_Invariant'Class |
1786                Invariant'Class
1787 @end smallexample
1789 @noindent
1790 This pragma is similar to the predefined pragma @code{Assert} except that an
1791 extra identifier argument is present. In conjunction with pragma
1792 @code{Check_Policy}, this can be used to define groups of assertions that can
1793 be independently controlled. The identifier @code{Assertion} is special, it
1794 refers to the normal set of pragma @code{Assert} statements.
1796 Checks introduced by this pragma are normally deactivated by default. They can
1797 be activated either by the command line option @option{-gnata}, which turns on
1798 all checks, or individually controlled using pragma @code{Check_Policy}.
1800 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1801 permitted as check kinds, since this would cause confusion with the use
1802 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1803 pragmas, where they are used to refer to sets of assertions.
1805 @node Pragma Check_Float_Overflow
1806 @unnumberedsec Pragma Check_Float_Overflow
1807 @cindex Floating-point overflow
1808 @findex Check_Float_Overflow
1809 @noindent
1810 Syntax:
1811 @smallexample @c ada
1812 pragma Check_Float_Overflow;
1813 @end smallexample
1815 @noindent
1816 In Ada, the predefined floating-point types (@code{Short_Float},
1817 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1818 defined to be @emph{unconstrained}. This means that even though each
1819 has a well-defined base range, an operation that delivers a result
1820 outside this base range is not required to raise an exception.
1821 This implementation permission accommodates the notion
1822 of infinities in IEEE floating-point, and corresponds to the
1823 efficient execution mode on most machines. GNAT will not raise
1824 overflow exceptions on these machines; instead it will generate
1825 infinities and NaN's as defined in the IEEE standard.
1827 Generating infinities, although efficient, is not always desirable.
1828 Often the preferable approach is to check for overflow, even at the
1829 (perhaps considerable) expense of run-time performance.
1830 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1831 range constraints -- and indeed such a subtype
1832 can have the same base range as its base type. For example:
1834 @smallexample @c ada
1835 subtype My_Float is Float range Float'Range;
1836 @end smallexample
1838 @noindent
1839 Here @code{My_Float} has the same range as
1840 @code{Float} but is constrained, so operations on
1841 @code{My_Float} values will be checked for overflow
1842 against this range.
1844 This style will achieve the desired goal, but
1845 it is often more convenient to be able to simply use
1846 the standard predefined floating-point types as long
1847 as overflow checking could be guaranteed.
1848 The @code{Check_Float_Overflow}
1849 configuration pragma achieves this effect. If a unit is compiled
1850 subject to this configuration pragma, then all operations
1851 on predefined floating-point types including operations on
1852 base types of these floating-point types will be treated as
1853 though those types were constrained, and overflow checks
1854 will be generated. The @code{Constraint_Error}
1855 exception is raised if the result is out of range.
1857 This mode can also be set by use of the compiler
1858 switch @option{-gnateF}.
1860 @node Pragma Check_Name
1861 @unnumberedsec Pragma Check_Name
1862 @cindex Defining check names
1863 @cindex Check names, defining
1864 @findex Check_Name
1865 @noindent
1866 Syntax:
1867 @smallexample @c ada
1868 pragma Check_Name (check_name_IDENTIFIER);
1869 @end smallexample
1871 @noindent
1872 This is a configuration pragma that defines a new implementation
1873 defined check name (unless IDENTIFIER matches one of the predefined
1874 check names, in which case the pragma has no effect). Check names
1875 are global to a partition, so if two or more configuration pragmas
1876 are present in a partition mentioning the same name, only one new
1877 check name is introduced.
1879 An implementation defined check name introduced with this pragma may
1880 be used in only three contexts: @code{pragma Suppress},
1881 @code{pragma Unsuppress},
1882 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1883 any of these three cases, the check name must be visible. A check
1884 name is visible if it is in the configuration pragmas applying to
1885 the current unit, or if it appears at the start of any unit that
1886 is part of the dependency set of the current unit (e.g., units that
1887 are mentioned in @code{with} clauses).
1889 Check names introduced by this pragma are subject to control by compiler
1890 switches (in particular -gnatp) in the usual manner.
1892 @node Pragma Check_Policy
1893 @unnumberedsec Pragma Check_Policy
1894 @cindex Controlling assertions
1895 @cindex Assertions, control
1896 @cindex Check pragma control
1897 @cindex Named assertions
1898 @findex Check
1899 @noindent
1900 Syntax:
1901 @smallexample @c ada
1902 pragma Check_Policy
1903  ([Name   =>] CHECK_KIND,
1904   [Policy =>] POLICY_IDENTIFIER);
1906 pragma Check_Policy (
1907     CHECK_KIND => POLICY_IDENTIFIER
1908  @{, CHECK_KIND => POLICY_IDENTIFIER@});
1910 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1912 CHECK_KIND ::= IDENTIFIER           |
1913                Pre'Class            |
1914                Post'Class           |
1915                Type_Invariant'Class |
1916                Invariant'Class
1918 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1919 avoids confusion between the two possible syntax forms for this pragma.
1921 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1922 @end smallexample
1924 @noindent
1925 This pragma is used to set the checking policy for assertions (specified
1926 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1927 to be checked using the @code{Check} pragma. It may appear either as
1928 a configuration pragma, or within a declarative part of package. In the
1929 latter case, it applies from the point where it appears to the end of
1930 the declarative region (like pragma @code{Suppress}).
1932 The @code{Check_Policy} pragma is similar to the
1933 predefined @code{Assertion_Policy} pragma,
1934 and if the check kind corresponds to one of the assertion kinds that
1935 are allowed by @code{Assertion_Policy}, then the effect is identical.
1937 If the first argument is Debug, then the policy applies to Debug pragmas,
1938 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1939 @code{IGNORE}, and allowing them to execute with normal semantics if
1940 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1941 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1942 be totally ignored and not analyzed semantically.
1944 Finally the first argument may be some other identifier than the above
1945 possibilities, in which case it controls a set of named assertions
1946 that can be checked using pragma @code{Check}. For example, if the pragma:
1948 @smallexample @c ada
1949 pragma Check_Policy (Critical_Error, OFF);
1950 @end smallexample
1952 @noindent
1953 is given, then subsequent @code{Check} pragmas whose first argument is also
1954 @code{Critical_Error} will be disabled.
1956 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1957 to turn on corresponding checks. The default for a set of checks for which no
1958 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1959 @option{-gnata} is given, which turns on all checks by default.
1961 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1962 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1963 compatibility with the standard @code{Assertion_Policy} pragma. The check
1964 policy setting @code{DISABLE} causes the second argument of a corresponding
1965 @code{Check} pragma to be completely ignored and not analyzed.
1967 @node Pragma CIL_Constructor
1968 @unnumberedsec Pragma CIL_Constructor
1969 @findex CIL_Constructor
1970 @noindent
1971 Syntax:
1973 @smallexample @c ada
1974 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1975 @end smallexample
1977 @noindent
1978 This pragma is used to assert that the specified Ada function should be
1979 mapped to the .NET constructor for some Ada tagged record type.
1981 See section 4.1 of the
1982 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1983 for related information.
1985 @node Pragma Comment
1986 @unnumberedsec Pragma Comment
1987 @findex Comment
1988 @noindent
1989 Syntax:
1991 @smallexample @c ada
1992 pragma Comment (static_string_EXPRESSION);
1993 @end smallexample
1995 @noindent
1996 This is almost identical in effect to pragma @code{Ident}.  It allows the
1997 placement of a comment into the object file and hence into the
1998 executable file if the operating system permits such usage.  The
1999 difference is that @code{Comment}, unlike @code{Ident}, has
2000 no limitations on placement of the pragma (it can be placed
2001 anywhere in the main source unit), and if more than one pragma
2002 is used, all comments are retained.
2004 @node Pragma Common_Object
2005 @unnumberedsec Pragma Common_Object
2006 @findex Common_Object
2007 @noindent
2008 Syntax:
2010 @smallexample @c ada
2011 pragma Common_Object (
2012      [Internal =>] LOCAL_NAME
2013   [, [External =>] EXTERNAL_SYMBOL]
2014   [, [Size     =>] EXTERNAL_SYMBOL] );
2016 EXTERNAL_SYMBOL ::=
2017   IDENTIFIER
2018 | static_string_EXPRESSION
2019 @end smallexample
2021 @noindent
2022 This pragma enables the shared use of variables stored in overlaid
2023 linker areas corresponding to the use of @code{COMMON}
2024 in Fortran.  The single
2025 object @var{LOCAL_NAME} is assigned to the area designated by
2026 the @var{External} argument.
2027 You may define a record to correspond to a series
2028 of fields.  The @var{Size} argument
2029 is syntax checked in GNAT, but otherwise ignored.
2031 @code{Common_Object} is not supported on all platforms.  If no
2032 support is available, then the code generator will issue a message
2033 indicating that the necessary attribute for implementation of this
2034 pragma is not available.
2036 @node Pragma Compile_Time_Error
2037 @unnumberedsec Pragma Compile_Time_Error
2038 @findex Compile_Time_Error
2039 @noindent
2040 Syntax:
2042 @smallexample @c ada
2043 pragma Compile_Time_Error
2044          (boolean_EXPRESSION, static_string_EXPRESSION);
2045 @end smallexample
2047 @noindent
2048 This pragma can be used to generate additional compile time
2049 error messages. It
2050 is particularly useful in generics, where errors can be issued for
2051 specific problematic instantiations. The first parameter is a boolean
2052 expression. The pragma is effective only if the value of this expression
2053 is known at compile time, and has the value True. The set of expressions
2054 whose values are known at compile time includes all static boolean
2055 expressions, and also other values which the compiler can determine
2056 at compile time (e.g., the size of a record type set by an explicit
2057 size representation clause, or the value of a variable which was
2058 initialized to a constant and is known not to have been modified).
2059 If these conditions are met, an error message is generated using
2060 the value given as the second argument. This string value may contain
2061 embedded ASCII.LF characters to break the message into multiple lines.
2063 @node Pragma Compile_Time_Warning
2064 @unnumberedsec Pragma Compile_Time_Warning
2065 @findex Compile_Time_Warning
2066 @noindent
2067 Syntax:
2069 @smallexample @c ada
2070 pragma Compile_Time_Warning
2071          (boolean_EXPRESSION, static_string_EXPRESSION);
2072 @end smallexample
2074 @noindent
2075 Same as pragma Compile_Time_Error, except a warning is issued instead
2076 of an error message. Note that if this pragma is used in a package that
2077 is with'ed by a client, the client will get the warning even though it
2078 is issued by a with'ed package (normally warnings in with'ed units are
2079 suppressed, but this is a special exception to that rule).
2081 One typical use is within a generic where compile time known characteristics
2082 of formal parameters are tested, and warnings given appropriately. Another use
2083 with a first parameter of True is to warn a client about use of a package,
2084 for example that it is not fully implemented.
2086 @node Pragma Compiler_Unit
2087 @unnumberedsec Pragma Compiler_Unit
2088 @findex Compiler_Unit
2089 @noindent
2090 Syntax:
2092 @smallexample @c ada
2093 pragma Compiler_Unit;
2094 @end smallexample
2096 @noindent
2097 This pragma is obsolete. It is equivalent to Compiler_Unit_Warning. It is
2098 retained so that old versions of the GNAT run-time that use this pragma can
2099 be compiled with newer versions of the compiler.
2101 @node Pragma Compiler_Unit_Warning
2102 @unnumberedsec Pragma Compiler_Unit_Warning
2103 @findex Compiler_Unit_Warning
2104 @noindent
2105 Syntax:
2107 @smallexample @c ada
2108 pragma Compiler_Unit_Warning;
2109 @end smallexample
2111 @noindent
2112 This pragma is intended only for internal use in the GNAT run-time library.
2113 It indicates that the unit is used as part of the compiler build. The effect
2114 is to generate warnings for the use of constructs (for example, conditional
2115 expressions) that would cause trouble when bootstrapping using an older
2116 version of GNAT. For the exact list of restrictions, see the compiler sources
2117 and references to Check_Compiler_Unit.
2119 @node Pragma Complete_Representation
2120 @unnumberedsec Pragma Complete_Representation
2121 @findex Complete_Representation
2122 @noindent
2123 Syntax:
2125 @smallexample @c ada
2126 pragma Complete_Representation;
2127 @end smallexample
2129 @noindent
2130 This pragma must appear immediately within a record representation
2131 clause. Typical placements are before the first component clause
2132 or after the last component clause. The effect is to give an error
2133 message if any component is missing a component clause. This pragma
2134 may be used to ensure that a record representation clause is
2135 complete, and that this invariant is maintained if fields are
2136 added to the record in the future.
2138 @node Pragma Complex_Representation
2139 @unnumberedsec Pragma Complex_Representation
2140 @findex Complex_Representation
2141 @noindent
2142 Syntax:
2144 @smallexample @c ada
2145 pragma Complex_Representation
2146         ([Entity =>] LOCAL_NAME);
2147 @end smallexample
2149 @noindent
2150 The @var{Entity} argument must be the name of a record type which has
2151 two fields of the same floating-point type.  The effect of this pragma is
2152 to force gcc to use the special internal complex representation form for
2153 this record, which may be more efficient.  Note that this may result in
2154 the code for this type not conforming to standard ABI (application
2155 binary interface) requirements for the handling of record types.  For
2156 example, in some environments, there is a requirement for passing
2157 records by pointer, and the use of this pragma may result in passing
2158 this type in floating-point registers.
2160 @node Pragma Component_Alignment
2161 @unnumberedsec Pragma Component_Alignment
2162 @cindex Alignments of components
2163 @findex Component_Alignment
2164 @noindent
2165 Syntax:
2167 @smallexample @c ada
2168 pragma Component_Alignment (
2169      [Form =>] ALIGNMENT_CHOICE
2170   [, [Name =>] type_LOCAL_NAME]);
2172 ALIGNMENT_CHOICE ::=
2173   Component_Size
2174 | Component_Size_4
2175 | Storage_Unit
2176 | Default
2177 @end smallexample
2179 @noindent
2180 Specifies the alignment of components in array or record types.
2181 The meaning of the @var{Form} argument is as follows:
2183 @table @code
2184 @findex Component_Size
2185 @item Component_Size
2186 Aligns scalar components and subcomponents of the array or record type
2187 on boundaries appropriate to their inherent size (naturally
2188 aligned).  For example, 1-byte components are aligned on byte boundaries,
2189 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2190 integer components are aligned on 4-byte boundaries and so on.  These
2191 alignment rules correspond to the normal rules for C compilers on all
2192 machines except the VAX@.
2194 @findex Component_Size_4
2195 @item Component_Size_4
2196 Naturally aligns components with a size of four or fewer
2197 bytes.  Components that are larger than 4 bytes are placed on the next
2198 4-byte boundary.
2200 @findex Storage_Unit
2201 @item Storage_Unit
2202 Specifies that array or record components are byte aligned, i.e.@:
2203 aligned on boundaries determined by the value of the constant
2204 @code{System.Storage_Unit}.
2206 @cindex OpenVMS
2207 @item Default
2208 Specifies that array or record components are aligned on default
2209 boundaries, appropriate to the underlying hardware or operating system or
2210 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
2211 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
2212 the @code{Default} choice is the same as @code{Component_Size} (natural
2213 alignment).
2214 @end table
2216 @noindent
2217 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2218 refer to a local record or array type, and the specified alignment
2219 choice applies to the specified type.  The use of
2220 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2221 @code{Component_Alignment} pragma to be ignored.  The use of
2222 @code{Component_Alignment} together with a record representation clause
2223 is only effective for fields not specified by the representation clause.
2225 If the @code{Name} parameter is absent, the pragma can be used as either
2226 a configuration pragma, in which case it applies to one or more units in
2227 accordance with the normal rules for configuration pragmas, or it can be
2228 used within a declarative part, in which case it applies to types that
2229 are declared within this declarative part, or within any nested scope
2230 within this declarative part.  In either case it specifies the alignment
2231 to be applied to any record or array type which has otherwise standard
2232 representation.
2234 If the alignment for a record or array type is not specified (using
2235 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2236 clause), the GNAT uses the default alignment as described previously.
2238 @node Pragma Contract_Cases
2239 @unnumberedsec Pragma Contract_Cases
2240 @cindex Contract cases
2241 @findex Contract_Cases
2242 @noindent
2243 Syntax:
2245 @smallexample @c ada
2246 pragma Contract_Cases (
2247    Condition => Consequence
2248  @{,Condition => Consequence@});
2249 @end smallexample
2251 @noindent
2252 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2253 that can complement or replace the contract given by a precondition and a
2254 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2255 by testing and formal verification tools. The compiler checks its validity and,
2256 depending on the assertion policy at the point of declaration of the pragma,
2257 it may insert a check in the executable. For code generation, the contract
2258 cases
2260 @smallexample @c ada
2261 pragma Contract_Cases (
2262   Cond1 => Pred1,
2263   Cond2 => Pred2);
2264 @end smallexample
2266 @noindent
2267 are equivalent to
2269 @smallexample @c ada
2270 C1 : constant Boolean := Cond1;  --  evaluated at subprogram entry
2271 C2 : constant Boolean := Cond2;  --  evaluated at subprogram entry
2272 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2273 pragma Postcondition (if C1 then Pred1);
2274 pragma Postcondition (if C2 then Pred2);
2275 @end smallexample
2277 @noindent
2278 The precondition ensures that one and only one of the conditions is
2279 satisfied on entry to the subprogram.
2280 The postcondition ensures that for the condition that was True on entry,
2281 the corrresponding consequence is True on exit. Other consequence expressions
2282 are not evaluated.
2284 A precondition @code{P} and postcondition @code{Q} can also be
2285 expressed as contract cases:
2287 @smallexample @c ada
2288 pragma Contract_Cases (P => Q);
2289 @end smallexample
2291 The placement and visibility rules for @code{Contract_Cases} pragmas are
2292 identical to those described for preconditions and postconditions.
2294 The compiler checks that boolean expressions given in conditions and
2295 consequences are valid, where the rules for conditions are the same as
2296 the rule for an expression in @code{Precondition} and the rules for
2297 consequences are the same as the rule for an expression in
2298 @code{Postcondition}. In particular, attributes @code{'Old} and
2299 @code{'Result} can only be used within consequence expressions.
2300 The condition for the last contract case may be @code{others}, to denote
2301 any case not captured by the previous cases. The
2302 following is an example of use within a package spec:
2304 @smallexample @c ada
2305 package Math_Functions is
2306    ...
2307    function Sqrt (Arg : Float) return Float;
2308    pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2309                           Arg >= 100       => Sqrt'Result >= 10,
2310                           others           => Sqrt'Result = 0);
2311    ...
2312 end Math_Functions;
2313 @end smallexample
2315 @noindent
2316 The meaning of contract cases is that only one case should apply at each
2317 call, as determined by the corresponding condition evaluating to True,
2318 and that the consequence for this case should hold when the subprogram
2319 returns.
2321 @node Pragma Convention_Identifier
2322 @unnumberedsec Pragma Convention_Identifier
2323 @findex Convention_Identifier
2324 @cindex Conventions, synonyms
2325 @noindent
2326 Syntax:
2328 @smallexample @c ada
2329 pragma Convention_Identifier (
2330          [Name =>]       IDENTIFIER,
2331          [Convention =>] convention_IDENTIFIER);
2332 @end smallexample
2334 @noindent
2335 This pragma provides a mechanism for supplying synonyms for existing
2336 convention identifiers. The @code{Name} identifier can subsequently
2337 be used as a synonym for the given convention in other pragmas (including
2338 for example pragma @code{Import} or another @code{Convention_Identifier}
2339 pragma). As an example of the use of this, suppose you had legacy code
2340 which used Fortran77 as the identifier for Fortran. Then the pragma:
2342 @smallexample @c ada
2343 pragma Convention_Identifier (Fortran77, Fortran);
2344 @end smallexample
2346 @noindent
2347 would allow the use of the convention identifier @code{Fortran77} in
2348 subsequent code, avoiding the need to modify the sources. As another
2349 example, you could use this to parameterize convention requirements
2350 according to systems. Suppose you needed to use @code{Stdcall} on
2351 windows systems, and @code{C} on some other system, then you could
2352 define a convention identifier @code{Library} and use a single
2353 @code{Convention_Identifier} pragma to specify which convention
2354 would be used system-wide.
2356 @node Pragma CPP_Class
2357 @unnumberedsec Pragma CPP_Class
2358 @findex CPP_Class
2359 @cindex Interfacing with C++
2360 @noindent
2361 Syntax:
2363 @smallexample @c ada
2364 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2365 @end smallexample
2367 @noindent
2368 The argument denotes an entity in the current declarative region that is
2369 declared as a record type. It indicates that the type corresponds to an
2370 externally declared C++ class type, and is to be laid out the same way
2371 that C++ would lay out the type. If the C++ class has virtual primitives
2372 then the record must be declared as a tagged record type.
2374 Types for which @code{CPP_Class} is specified do not have assignment or
2375 equality operators defined (such operations can be imported or declared
2376 as subprograms as required). Initialization is allowed only by constructor
2377 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2378 limited if not explicitly declared as limited or derived from a limited
2379 type, and an error is issued in that case.
2381 See @ref{Interfacing to C++} for related information.
2383 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2384 for backward compatibility but its functionality is available
2385 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2387 @node Pragma CPP_Constructor
2388 @unnumberedsec Pragma CPP_Constructor
2389 @cindex Interfacing with C++
2390 @findex CPP_Constructor
2391 @noindent
2392 Syntax:
2394 @smallexample @c ada
2395 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2396   [, [External_Name =>] static_string_EXPRESSION ]
2397   [, [Link_Name     =>] static_string_EXPRESSION ]);
2398 @end smallexample
2400 @noindent
2401 This pragma identifies an imported function (imported in the usual way
2402 with pragma @code{Import}) as corresponding to a C++ constructor. If
2403 @code{External_Name} and @code{Link_Name} are not specified then the
2404 @code{Entity} argument is a name that must have been previously mentioned
2405 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2406 must be of one of the following forms:
2408 @itemize @bullet
2409 @item
2410 @code{function @var{Fname} return @var{T}}
2412 @itemize @bullet
2413 @item
2414 @code{function @var{Fname} return @var{T}'Class}
2416 @item
2417 @code{function @var{Fname} (@dots{}) return @var{T}}
2418 @end itemize
2420 @item
2421 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2422 @end itemize
2424 @noindent
2425 where @var{T} is a limited record type imported from C++ with pragma
2426 @code{Import} and @code{Convention} = @code{CPP}.
2428 The first two forms import the default constructor, used when an object
2429 of type @var{T} is created on the Ada side with no explicit constructor.
2430 The latter two forms cover all the non-default constructors of the type.
2431 See the @value{EDITION} User's Guide for details.
2433 If no constructors are imported, it is impossible to create any objects
2434 on the Ada side and the type is implicitly declared abstract.
2436 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2437 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2438 GCC switch).
2439 See @ref{Interfacing to C++} for more related information.
2441 Note: The use of functions returning class-wide types for constructors is
2442 currently obsolete. They are supported for backward compatibility. The
2443 use of functions returning the type T leave the Ada sources more clear
2444 because the imported C++ constructors always return an object of type T;
2445 that is, they never return an object whose type is a descendant of type T.
2447 @node Pragma CPP_Virtual
2448 @unnumberedsec Pragma CPP_Virtual
2449 @cindex Interfacing to C++
2450 @findex CPP_Virtual
2451 @noindent
2452 This pragma is now obsolete and, other than generating a warning if warnings
2453 on obsolescent features are enabled, is completely ignored.
2454 It is retained for compatibility
2455 purposes. It used to be required to ensure compoatibility with C++, but
2456 is no longer required for that purpose because GNAT generates
2457 the same object layout as the G++ compiler by default.
2459 See @ref{Interfacing to C++} for related information.
2461 @node Pragma CPP_Vtable
2462 @unnumberedsec Pragma CPP_Vtable
2463 @cindex Interfacing with C++
2464 @findex CPP_Vtable
2465 @noindent
2466 This pragma is now obsolete and, other than generating a warning if warnings
2467 on obsolescent features are enabled, is completely ignored.
2468 It used to be required to ensure compatibility with C++, but
2469 is no longer required for that purpose because GNAT generates
2470 the same object layout as the G++ compiler by default.
2472 See @ref{Interfacing to C++} for related information.
2474 @node Pragma CPU
2475 @unnumberedsec Pragma CPU
2476 @findex CPU
2477 @noindent
2478 Syntax:
2480 @smallexample @c ada
2481 pragma CPU (EXPRESSION);
2482 @end smallexample
2484 @noindent
2485 This pragma is standard in Ada 2012, but is available in all earlier
2486 versions of Ada as an implementation-defined pragma.
2487 See Ada 2012 Reference Manual for details.
2489 @node Pragma Debug
2490 @unnumberedsec Pragma Debug
2491 @findex Debug
2492 @noindent
2493 Syntax:
2495 @smallexample @c ada
2496 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2498 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2499   PROCEDURE_NAME
2500 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2501 @end smallexample
2503 @noindent
2504 The procedure call argument has the syntactic form of an expression, meeting
2505 the syntactic requirements for pragmas.
2507 If debug pragmas are not enabled or if the condition is present and evaluates
2508 to False, this pragma has no effect. If debug pragmas are enabled, the
2509 semantics of the pragma is exactly equivalent to the procedure call statement
2510 corresponding to the argument with a terminating semicolon. Pragmas are
2511 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2512 intersperse calls to debug procedures in the middle of declarations. Debug
2513 pragmas can be enabled either by use of the command line switch @option{-gnata}
2514 or by use of the pragma @code{Check_Policy} with a first argument of
2515 @code{Debug}.
2517 @node Pragma Debug_Policy
2518 @unnumberedsec Pragma Debug_Policy
2519 @findex Debug_Policy
2520 @noindent
2521 Syntax:
2523 @smallexample @c ada
2524 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2525 @end smallexample
2527 @noindent
2528 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2529 with a first argument of @code{Debug}. It is retained for historical
2530 compatibility reasons.
2532 @node Pragma Default_Scalar_Storage_Order
2533 @unnumberedsec Pragma Default_Scalar_Storage_Order
2534 @cindex Default_Scalar_Storage_Order
2535 @cindex Scalar_Storage_Order
2536 @findex Default_Scalar_Storage_Order
2537 @noindent
2538 Syntax:
2540 @smallexample @c ada
2541 pragma Default_Scalar_Storage_Order (High_Order_First | Low_Order_First);
2542 @end smallexample
2544 @noindent
2545 Normally if no explicit @code{Scalar_Storage_Order} is given for a record
2546 type or array type, then the scalar storage order defaults to the ordinary
2547 default for the target. But this default may be overridden using this pragma.
2548 The pragma may appear as a configuration pragma, or locally within a package
2549 spec or declarative part. In the latter case, it applies to all subsequent
2550 types declared within that package spec or declarative part.
2552 If this pragma is used as a configuration pragma which appears within a
2553 configuration pragma file (as opposed to appearing explicitly at the start
2554 of a single unit), then the binder will require that all units in a partition
2555 be compiled in a similar manner, including all units in the run-time that
2556 are included in the partition.
2558 The following example shows the use of this pragma:
2560 @smallexample @c ada
2561 pragma Default_Scalar_Storage_Order (High_Order_First);
2562 with System; use System;
2563 package DSSO1 is
2564    type H1 is record
2565       a : Integer;
2566    end record;
2568    type L2 is record
2569       a : Integer;
2570    end record;
2571    for L2'Scalar_Storage_Order use Low_Order_First;
2573    type L2a is new L2;
2575    package Inner is
2576       type H3 is record
2577          a : Integer;
2578       end record;
2580       pragma Default_Scalar_Storage_Order (Low_Order_First);
2582       type L4 is record
2583          a : Integer;
2584       end record;
2585    end Inner;
2587    type H4a is new Inner.L4;
2589    type H5 is record
2590       a : Integer;
2591    end record;
2592 end DSSO1;
2593 @end smallexample
2595 @noindent
2596 In this example record types L.. have @code{Low_Order_First} scalar
2597 storage order, and record types H.. have @code{High_Order_First}.
2598 Note that in the case of @code{H4a}, the order is not inherited
2599 from the parent type. Only an explicitly set @code{Scalar_Storage_Order}
2600 gets inherited on type derivation.
2602 @node Pragma Default_Storage_Pool
2603 @unnumberedsec Pragma Default_Storage_Pool
2604 @cindex Default_Storage_Pool
2605 @findex Default_Storage_Pool
2606 @noindent
2607 Syntax:
2609 @smallexample @c ada
2610 pragma Default_Storage_Pool (storage_pool_NAME | null);
2611 @end smallexample
2613 @noindent
2614 This pragma is standard in Ada 2012, but is available in all earlier
2615 versions of Ada as an implementation-defined pragma.
2616 See Ada 2012 Reference Manual for details.
2618 @node Pragma Depends
2619 @unnumberedsec Pragma Depends
2620 @findex Depends
2621 @noindent
2622 For the description of this pragma, see SPARK 2014 Reference Manual,
2623 section 6.1.5.
2625 @node Pragma Detect_Blocking
2626 @unnumberedsec Pragma Detect_Blocking
2627 @findex Detect_Blocking
2628 @noindent
2629 Syntax:
2631 @smallexample @c ada
2632 pragma Detect_Blocking;
2633 @end smallexample
2635 @noindent
2636 This is a standard pragma in Ada 2005, that is available in all earlier
2637 versions of Ada as an implementation-defined pragma.
2639 This is a configuration pragma that forces the detection of potentially
2640 blocking operations within a protected operation, and to raise Program_Error
2641 if that happens.
2643 @node Pragma Disable_Atomic_Synchronization
2644 @unnumberedsec Pragma Disable_Atomic_Synchronization
2645 @cindex Atomic Synchronization
2646 @findex Disable_Atomic_Synchronization
2647 @noindent
2648 Syntax:
2650 @smallexample @c ada
2651 pragma Disable_Atomic_Synchronization [(Entity)];
2652 @end smallexample
2654 @noindent
2655 Ada requires that accesses (reads or writes) of an atomic variable be
2656 regarded as synchronization points in the case of multiple tasks.
2657 Particularly in the case of multi-processors this may require special
2658 handling, e.g. the generation of memory barriers. This capability may
2659 be turned off using this pragma in cases where it is known not to be
2660 required.
2662 The placement and scope rules for this pragma are the same as those
2663 for @code{pragma Suppress}. In particular it can be used as a
2664 configuration  pragma, or in a declaration sequence where it applies
2665 till the end of the scope. If an @code{Entity} argument is present,
2666 the action applies only to that entity.
2668 @node Pragma Dispatching_Domain
2669 @unnumberedsec Pragma Dispatching_Domain
2670 @findex Dispatching_Domain
2671 @noindent
2672 Syntax:
2674 @smallexample @c ada
2675 pragma Dispatching_Domain (EXPRESSION);
2676 @end smallexample
2678 @noindent
2679 This pragma is standard in Ada 2012, but is available in all earlier
2680 versions of Ada as an implementation-defined pragma.
2681 See Ada 2012 Reference Manual for details.
2683 @node Pragma Effective_Reads
2684 @unnumberedsec Pragma Effective_Reads
2685 @findex Effective_Reads
2686 @noindent
2687 For the description of this pragma, see SPARK 2014 Reference Manual,
2688 section 7.1.2.
2690 @node Pragma Effective_Writes
2691 @unnumberedsec Pragma Effective_Writes
2692 @findex Effective_Writes
2693 @noindent
2694 For the description of this pragma, see SPARK 2014 Reference Manual,
2695 section 7.1.2.
2697 @node Pragma Elaboration_Checks
2698 @unnumberedsec Pragma Elaboration_Checks
2699 @cindex Elaboration control
2700 @findex Elaboration_Checks
2701 @noindent
2702 Syntax:
2704 @smallexample @c ada
2705 pragma Elaboration_Checks (Dynamic | Static);
2706 @end smallexample
2708 @noindent
2709 This is a configuration pragma that provides control over the
2710 elaboration model used by the compilation affected by the
2711 pragma.  If the parameter is @code{Dynamic},
2712 then the dynamic elaboration
2713 model described in the Ada Reference Manual is used, as though
2714 the @option{-gnatE} switch had been specified on the command
2715 line.  If the parameter is @code{Static}, then the default GNAT static
2716 model is used.  This configuration pragma overrides the setting
2717 of the command line.  For full details on the elaboration models
2718 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2719 gnat_ugn, @value{EDITION} User's Guide}.
2721 @node Pragma Eliminate
2722 @unnumberedsec Pragma Eliminate
2723 @cindex Elimination of unused subprograms
2724 @findex Eliminate
2725 @noindent
2726 Syntax:
2728 @smallexample @c ada
2729 pragma Eliminate ([Entity          =>] DEFINING_DESIGNATOR,
2730                   [Source_Location =>] STRING_LITERAL);
2731 @end smallexample
2733 @noindent
2734 The string literal given for the source location is a string which
2735 specifies the line number of the occurrence of the entity, using
2736 the syntax for SOURCE_TRACE given below:
2738 @smallexample @c ada
2739  SOURCE_TRACE     ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2741  LBRACKET         ::= [
2742  RBRACKET         ::= ]
2744  SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2746  LINE_NUMBER      ::= DIGIT @{DIGIT@}
2747 @end smallexample
2749 @noindent
2750 Spaces around the colon in a @code{Source_Reference} are optional.
2752 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2753 explicit subprogram declaration, where the @code{entity} name in this
2754 designator appears on the source line specified by the source location.
2756 The source trace that is given as the @code{Source_Location} shall obey the
2757 following rules. The @code{FILE_NAME} is the short name (with no directory
2758 information) of an Ada source file, given using exactly the required syntax
2759 for the underlying file system (e.g. case is important if the underlying
2760 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2761 number of the occurrence of the @code{entity}
2762 as a decimal literal without an exponent or point. If an @code{entity} is not
2763 declared in a generic instantiation (this includes generic subprogram
2764 instances), the source trace includes only one source reference. If an entity
2765 is declared inside a generic instantiation, its source trace (when parsing
2766 from left to right) starts with the source location of the declaration of the
2767 entity in the generic unit and ends with the source location of the
2768 instantiation (it is given in square brackets). This approach is recursively
2769 used in case of nested instantiations: the rightmost (nested most deeply in
2770 square brackets) element of the source trace is the location of the outermost
2771 instantiation, the next to left element is the location of the next (first
2772 nested) instantiation in the code of the corresponding generic unit, and so
2773 on, and the leftmost element (that is out of any square brackets) is the
2774 location of the declaration of the entity to eliminate in a generic unit.
2776 Note that the @code{Source_Location} argument specifies which of a set of
2777 similarly named entities is being eliminated, dealing both with overloading,
2778 and also appearance of the same entity name in different scopes.
2780 This pragma indicates that the given entity is not used in the program to be
2781 compiled and built. The effect of the pragma is to allow the compiler to
2782 eliminate the code or data associated with the named entity. Any reference to
2783 an eliminated entity causes a compile-time or link-time error.
2785 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2786 in a system-independent manner, with unused entities eliminated, without
2787 needing to modify the source text. Normally the required set of
2788 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2790 Any source file change that removes, splits, or
2791 adds lines may make the set of Eliminate pragmas invalid because their
2792 @code{Source_Location} argument values may get out of date.
2794 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2795 operation. In this case all the subprograms to which the given operation can
2796 dispatch are considered to be unused (are never called as a result of a direct
2797 or a dispatching call).
2799 @node Pragma Enable_Atomic_Synchronization
2800 @unnumberedsec Pragma Enable_Atomic_Synchronization
2801 @cindex Atomic Synchronization
2802 @findex Enable_Atomic_Synchronization
2803 @noindent
2804 Syntax:
2806 @smallexample @c ada
2807 pragma Enable_Atomic_Synchronization [(Entity)];
2808 @end smallexample
2810 @noindent
2811 Ada requires that accesses (reads or writes) of an atomic variable be
2812 regarded as synchronization points in the case of multiple tasks.
2813 Particularly in the case of multi-processors this may require special
2814 handling, e.g. the generation of memory barriers. This synchronization
2815 is performed by default, but can be turned off using
2816 @code{pragma Disable_Atomic_Synchronization}. The
2817 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2818 it back on.
2820 The placement and scope rules for this pragma are the same as those
2821 for @code{pragma Unsuppress}. In particular it can be used as a
2822 configuration  pragma, or in a declaration sequence where it applies
2823 till the end of the scope. If an @code{Entity} argument is present,
2824 the action applies only to that entity.
2826 @node Pragma Export_Exception
2827 @unnumberedsec Pragma Export_Exception
2828 @cindex OpenVMS
2829 @findex Export_Exception
2830 @noindent
2831 Syntax:
2833 @smallexample @c ada
2834 pragma Export_Exception (
2835      [Internal =>] LOCAL_NAME
2836   [, [External =>] EXTERNAL_SYMBOL]
2837   [, [Form     =>] Ada | VMS]
2838   [, [Code     =>] static_integer_EXPRESSION]);
2840 EXTERNAL_SYMBOL ::=
2841   IDENTIFIER
2842 | static_string_EXPRESSION
2843 @end smallexample
2845 @noindent
2846 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
2847 causes the specified exception to be propagated outside of the Ada program,
2848 so that it can be handled by programs written in other OpenVMS languages.
2849 This pragma establishes an external name for an Ada exception and makes the
2850 name available to the OpenVMS Linker as a global symbol.  For further details
2851 on this pragma, see the
2852 DEC Ada Language Reference Manual, section 13.9a3.2.
2854 @node Pragma Export_Function
2855 @unnumberedsec Pragma Export_Function
2856 @cindex Argument passing mechanisms
2857 @findex Export_Function
2859 @noindent
2860 Syntax:
2862 @smallexample @c ada
2863 pragma Export_Function (
2864      [Internal         =>] LOCAL_NAME
2865   [, [External         =>] EXTERNAL_SYMBOL]
2866   [, [Parameter_Types  =>] PARAMETER_TYPES]
2867   [, [Result_Type      =>] result_SUBTYPE_MARK]
2868   [, [Mechanism        =>] MECHANISM]
2869   [, [Result_Mechanism =>] MECHANISM_NAME]);
2871 EXTERNAL_SYMBOL ::=
2872   IDENTIFIER
2873 | static_string_EXPRESSION
2874 | ""
2876 PARAMETER_TYPES ::=
2877   null
2878 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2880 TYPE_DESIGNATOR ::=
2881   subtype_NAME
2882 | subtype_Name ' Access
2884 MECHANISM ::=
2885   MECHANISM_NAME
2886 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2888 MECHANISM_ASSOCIATION ::=
2889   [formal_parameter_NAME =>] MECHANISM_NAME
2891 MECHANISM_NAME ::= Value | Reference
2892 @end smallexample
2894 @noindent
2895 Use this pragma to make a function externally callable and optionally
2896 provide information on mechanisms to be used for passing parameter and
2897 result values.  We recommend, for the purposes of improving portability,
2898 this pragma always be used in conjunction with a separate pragma
2899 @code{Export}, which must precede the pragma @code{Export_Function}.
2900 GNAT does not require a separate pragma @code{Export}, but if none is
2901 present, @code{Convention Ada} is assumed, which is usually
2902 not what is wanted, so it is usually appropriate to use this
2903 pragma in conjunction with a @code{Export} or @code{Convention}
2904 pragma that specifies the desired foreign convention.
2905 Pragma @code{Export_Function}
2906 (and @code{Export}, if present) must appear in the same declarative
2907 region as the function to which they apply.
2909 @var{internal_name} must uniquely designate the function to which the
2910 pragma applies.  If more than one function name exists of this name in
2911 the declarative part you must use the @code{Parameter_Types} and
2912 @code{Result_Type} parameters is mandatory to achieve the required
2913 unique designation.  @var{subtype_mark}s in these parameters must
2914 exactly match the subtypes in the corresponding function specification,
2915 using positional notation to match parameters with subtype marks.
2916 The form with an @code{'Access} attribute can be used to match an
2917 anonymous access parameter.
2919 @cindex Suppressing external name
2920 Special treatment is given if the EXTERNAL is an explicit null
2921 string or a static string expressions that evaluates to the null
2922 string. In this case, no external name is generated. This form
2923 still allows the specification of parameter mechanisms.
2925 @node Pragma Export_Object
2926 @unnumberedsec Pragma Export_Object
2927 @findex Export_Object
2928 @noindent
2929 Syntax:
2931 @smallexample @c ada
2932 pragma Export_Object
2933       [Internal =>] LOCAL_NAME
2934    [, [External =>] EXTERNAL_SYMBOL]
2935    [, [Size     =>] EXTERNAL_SYMBOL]
2937 EXTERNAL_SYMBOL ::=
2938   IDENTIFIER
2939 | static_string_EXPRESSION
2940 @end smallexample
2942 @noindent
2943 This pragma designates an object as exported, and apart from the
2944 extended rules for external symbols, is identical in effect to the use of
2945 the normal @code{Export} pragma applied to an object.  You may use a
2946 separate Export pragma (and you probably should from the point of view
2947 of portability), but it is not required.  @var{Size} is syntax checked,
2948 but otherwise ignored by GNAT@.
2950 @node Pragma Export_Procedure
2951 @unnumberedsec Pragma Export_Procedure
2952 @findex Export_Procedure
2953 @noindent
2954 Syntax:
2956 @smallexample @c ada
2957 pragma Export_Procedure (
2958      [Internal        =>] LOCAL_NAME
2959   [, [External        =>] EXTERNAL_SYMBOL]
2960   [, [Parameter_Types =>] PARAMETER_TYPES]
2961   [, [Mechanism       =>] MECHANISM]);
2963 EXTERNAL_SYMBOL ::=
2964   IDENTIFIER
2965 | static_string_EXPRESSION
2966 | ""
2968 PARAMETER_TYPES ::=
2969   null
2970 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2972 TYPE_DESIGNATOR ::=
2973   subtype_NAME
2974 | subtype_Name ' Access
2976 MECHANISM ::=
2977   MECHANISM_NAME
2978 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2980 MECHANISM_ASSOCIATION ::=
2981   [formal_parameter_NAME =>] MECHANISM_NAME
2983 MECHANISM_NAME ::= Value | Reference
2984 @end smallexample
2986 @noindent
2987 This pragma is identical to @code{Export_Function} except that it
2988 applies to a procedure rather than a function and the parameters
2989 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2990 GNAT does not require a separate pragma @code{Export}, but if none is
2991 present, @code{Convention Ada} is assumed, which is usually
2992 not what is wanted, so it is usually appropriate to use this
2993 pragma in conjunction with a @code{Export} or @code{Convention}
2994 pragma that specifies the desired foreign convention.
2996 @cindex Suppressing external name
2997 Special treatment is given if the EXTERNAL is an explicit null
2998 string or a static string expressions that evaluates to the null
2999 string. In this case, no external name is generated. This form
3000 still allows the specification of parameter mechanisms.
3002 @node Pragma Export_Value
3003 @unnumberedsec Pragma Export_Value
3004 @findex Export_Value
3005 @noindent
3006 Syntax:
3008 @smallexample @c ada
3009 pragma Export_Value (
3010   [Value     =>] static_integer_EXPRESSION,
3011   [Link_Name =>] static_string_EXPRESSION);
3012 @end smallexample
3014 @noindent
3015 This pragma serves to export a static integer value for external use.
3016 The first argument specifies the value to be exported. The Link_Name
3017 argument specifies the symbolic name to be associated with the integer
3018 value. This pragma is useful for defining a named static value in Ada
3019 that can be referenced in assembly language units to be linked with
3020 the application. This pragma is currently supported only for the
3021 AAMP target and is ignored for other targets.
3023 @node Pragma Export_Valued_Procedure
3024 @unnumberedsec Pragma Export_Valued_Procedure
3025 @findex Export_Valued_Procedure
3026 @noindent
3027 Syntax:
3029 @smallexample @c ada
3030 pragma Export_Valued_Procedure (
3031      [Internal        =>] LOCAL_NAME
3032   [, [External        =>] EXTERNAL_SYMBOL]
3033   [, [Parameter_Types =>] PARAMETER_TYPES]
3034   [, [Mechanism       =>] MECHANISM]);
3036 EXTERNAL_SYMBOL ::=
3037   IDENTIFIER
3038 | static_string_EXPRESSION
3039 | ""
3041 PARAMETER_TYPES ::=
3042   null
3043 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3045 TYPE_DESIGNATOR ::=
3046   subtype_NAME
3047 | subtype_Name ' Access
3049 MECHANISM ::=
3050   MECHANISM_NAME
3051 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3053 MECHANISM_ASSOCIATION ::=
3054   [formal_parameter_NAME =>] MECHANISM_NAME
3056 MECHANISM_NAME ::= Value | Reference
3057 @end smallexample
3059 @noindent
3060 This pragma is identical to @code{Export_Procedure} except that the
3061 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3062 mode @code{OUT}, and externally the subprogram is treated as a function
3063 with this parameter as the result of the function.  GNAT provides for
3064 this capability to allow the use of @code{OUT} and @code{IN OUT}
3065 parameters in interfacing to external functions (which are not permitted
3066 in Ada functions).
3067 GNAT does not require a separate pragma @code{Export}, but if none is
3068 present, @code{Convention Ada} is assumed, which is almost certainly
3069 not what is wanted since the whole point of this pragma is to interface
3070 with foreign language functions, so it is usually appropriate to use this
3071 pragma in conjunction with a @code{Export} or @code{Convention}
3072 pragma that specifies the desired foreign convention.
3074 @cindex Suppressing external name
3075 Special treatment is given if the EXTERNAL is an explicit null
3076 string or a static string expressions that evaluates to the null
3077 string. In this case, no external name is generated. This form
3078 still allows the specification of parameter mechanisms.
3080 @node Pragma Extend_System
3081 @unnumberedsec Pragma Extend_System
3082 @cindex @code{system}, extending
3083 @cindex Dec Ada 83
3084 @findex Extend_System
3085 @noindent
3086 Syntax:
3088 @smallexample @c ada
3089 pragma Extend_System ([Name =>] IDENTIFIER);
3090 @end smallexample
3092 @noindent
3093 This pragma is used to provide backwards compatibility with other
3094 implementations that extend the facilities of package @code{System}.  In
3095 GNAT, @code{System} contains only the definitions that are present in
3096 the Ada RM@.  However, other implementations, notably the DEC Ada 83
3097 implementation, provide many extensions to package @code{System}.
3099 For each such implementation accommodated by this pragma, GNAT provides a
3100 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
3101 implementation, which provides the required additional definitions.  You
3102 can use this package in two ways.  You can @code{with} it in the normal
3103 way and access entities either by selection or using a @code{use}
3104 clause.  In this case no special processing is required.
3106 However, if existing code contains references such as
3107 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
3108 definitions provided in package @code{System}, you may use this pragma
3109 to extend visibility in @code{System} in a non-standard way that
3110 provides greater compatibility with the existing code.  Pragma
3111 @code{Extend_System} is a configuration pragma whose single argument is
3112 the name of the package containing the extended definition
3113 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
3114 control of this pragma will be processed using special visibility
3115 processing that looks in package @code{System.Aux_@var{xxx}} where
3116 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
3117 package @code{System}, but not found in package @code{System}.
3119 You can use this pragma either to access a predefined @code{System}
3120 extension supplied with the compiler, for example @code{Aux_DEC} or
3121 you can construct your own extension unit following the above
3122 definition.  Note that such a package is a child of @code{System}
3123 and thus is considered part of the implementation.
3124 To compile it you will have to use the @option{-gnatg} switch,
3125 or the @option{/GNAT_INTERNAL} qualifier on OpenVMS,
3126 for compiling System units, as explained in the
3127 @value{EDITION} User's Guide.
3129 @node Pragma Extensions_Allowed
3130 @unnumberedsec Pragma Extensions_Allowed
3131 @cindex Ada Extensions
3132 @cindex GNAT Extensions
3133 @findex Extensions_Allowed
3134 @noindent
3135 Syntax:
3137 @smallexample @c ada
3138 pragma Extensions_Allowed (On | Off);
3139 @end smallexample
3141 @noindent
3142 This configuration pragma enables or disables the implementation
3143 extension mode (the use of Off as a parameter cancels the effect
3144 of the @option{-gnatX} command switch).
3146 In extension mode, the latest version of the Ada language is
3147 implemented (currently Ada 2012), and in addition a small number
3148 of GNAT specific extensions are recognized as follows:
3150 @table @asis
3151 @item Constrained attribute for generic objects
3152 The @code{Constrained} attribute is permitted for objects of
3153 generic types. The result indicates if the corresponding actual
3154 is constrained.
3156 @end table
3158 @node Pragma External
3159 @unnumberedsec Pragma External
3160 @findex External
3161 @noindent
3162 Syntax:
3164 @smallexample @c ada
3165 pragma External (
3166   [   Convention    =>] convention_IDENTIFIER,
3167   [   Entity        =>] LOCAL_NAME
3168   [, [External_Name =>] static_string_EXPRESSION ]
3169   [, [Link_Name     =>] static_string_EXPRESSION ]);
3170 @end smallexample
3172 @noindent
3173 This pragma is identical in syntax and semantics to pragma
3174 @code{Export} as defined in the Ada Reference Manual.  It is
3175 provided for compatibility with some Ada 83 compilers that
3176 used this pragma for exactly the same purposes as pragma
3177 @code{Export} before the latter was standardized.
3179 @node Pragma External_Name_Casing
3180 @unnumberedsec Pragma External_Name_Casing
3181 @cindex Dec Ada 83 casing compatibility
3182 @cindex External Names, casing
3183 @cindex Casing of External names
3184 @findex External_Name_Casing
3185 @noindent
3186 Syntax:
3188 @smallexample @c ada
3189 pragma External_Name_Casing (
3190   Uppercase | Lowercase
3191   [, Uppercase | Lowercase | As_Is]);
3192 @end smallexample
3194 @noindent
3195 This pragma provides control over the casing of external names associated
3196 with Import and Export pragmas.  There are two cases to consider:
3198 @table @asis
3199 @item Implicit external names
3200 Implicit external names are derived from identifiers.  The most common case
3201 arises when a standard Ada Import or Export pragma is used with only two
3202 arguments, as in:
3204 @smallexample @c ada
3205    pragma Import (C, C_Routine);
3206 @end smallexample
3208 @noindent
3209 Since Ada is a case-insensitive language, the spelling of the identifier in
3210 the Ada source program does not provide any information on the desired
3211 casing of the external name, and so a convention is needed.  In GNAT the
3212 default treatment is that such names are converted to all lower case
3213 letters.  This corresponds to the normal C style in many environments.
3214 The first argument of pragma @code{External_Name_Casing} can be used to
3215 control this treatment.  If @code{Uppercase} is specified, then the name
3216 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3217 then the normal default of all lower case letters will be used.
3219 This same implicit treatment is also used in the case of extended DEC Ada 83
3220 compatible Import and Export pragmas where an external name is explicitly
3221 specified using an identifier rather than a string.
3223 @item Explicit external names
3224 Explicit external names are given as string literals.  The most common case
3225 arises when a standard Ada Import or Export pragma is used with three
3226 arguments, as in:
3228 @smallexample @c ada
3229 pragma Import (C, C_Routine, "C_routine");
3230 @end smallexample
3232 @noindent
3233 In this case, the string literal normally provides the exact casing required
3234 for the external name.  The second argument of pragma
3235 @code{External_Name_Casing} may be used to modify this behavior.
3236 If @code{Uppercase} is specified, then the name
3237 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3238 then the name will be forced to all lowercase letters.  A specification of
3239 @code{As_Is} provides the normal default behavior in which the casing is
3240 taken from the string provided.
3241 @end table
3243 @noindent
3244 This pragma may appear anywhere that a pragma is valid.  In particular, it
3245 can be used as a configuration pragma in the @file{gnat.adc} file, in which
3246 case it applies to all subsequent compilations, or it can be used as a program
3247 unit pragma, in which case it only applies to the current unit, or it can
3248 be used more locally to control individual Import/Export pragmas.
3250 It is primarily intended for use with OpenVMS systems, where many
3251 compilers convert all symbols to upper case by default.  For interfacing to
3252 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3253 the pragma:
3255 @smallexample @c ada
3256 pragma External_Name_Casing (Uppercase, Uppercase);
3257 @end smallexample
3259 @noindent
3260 to enforce the upper casing of all external symbols.
3262 @node Pragma Fast_Math
3263 @unnumberedsec Pragma Fast_Math
3264 @findex Fast_Math
3265 @noindent
3266 Syntax:
3268 @smallexample @c ada
3269 pragma Fast_Math;
3270 @end smallexample
3272 @noindent
3273 This is a configuration pragma which activates a mode in which speed is
3274 considered more important for floating-point operations than absolutely
3275 accurate adherence to the requirements of the standard. Currently the
3276 following operations are affected:
3278 @table @asis
3279 @item Complex Multiplication
3280 The normal simple formula for complex multiplication can result in intermediate
3281 overflows for numbers near the end of the range. The Ada standard requires that
3282 this situation be detected and corrected by scaling, but in Fast_Math mode such
3283 cases will simply result in overflow. Note that to take advantage of this you
3284 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3285 under control of the pragma, rather than use the preinstantiated versions.
3286 @end table
3288 @node Pragma Favor_Top_Level
3289 @unnumberedsec Pragma Favor_Top_Level
3290 @findex Favor_Top_Level
3291 @noindent
3292 Syntax:
3294 @smallexample @c ada
3295 pragma Favor_Top_Level (type_NAME);
3296 @end smallexample
3298 @noindent
3299 The named type must be an access-to-subprogram type. This pragma is an
3300 efficiency hint to the compiler, regarding the use of 'Access or
3301 'Unrestricted_Access on nested (non-library-level) subprograms. The
3302 pragma means that nested subprograms are not used with this type, or
3303 are rare, so that the generated code should be efficient in the
3304 top-level case. When this pragma is used, dynamically generated
3305 trampolines may be used on some targets for nested subprograms.
3306 See also the No_Implicit_Dynamic_Code restriction.
3308 @node Pragma Finalize_Storage_Only
3309 @unnumberedsec Pragma Finalize_Storage_Only
3310 @findex Finalize_Storage_Only
3311 @noindent
3312 Syntax:
3314 @smallexample @c ada
3315 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3316 @end smallexample
3318 @noindent
3319 This pragma allows the compiler not to emit a Finalize call for objects
3320 defined at the library level.  This is mostly useful for types where
3321 finalization is only used to deal with storage reclamation since in most
3322 environments it is not necessary to reclaim memory just before terminating
3323 execution, hence the name.
3325 @node Pragma Float_Representation
3326 @unnumberedsec Pragma Float_Representation
3327 @cindex OpenVMS
3328 @findex Float_Representation
3329 @noindent
3330 Syntax:
3332 @smallexample @c ada
3333 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3335 FLOAT_REP ::= VAX_Float | IEEE_Float
3336 @end smallexample
3338 @noindent
3339 In the one argument form, this pragma is a configuration pragma which
3340 allows control over the internal representation chosen for the predefined
3341 floating point types declared in the packages @code{Standard} and
3342 @code{System}. On all systems other than OpenVMS, the argument must
3343 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3344 argument may be @code{VAX_Float} to specify the use of the VAX float
3345 format for the floating-point types in Standard. This requires that
3346 the standard runtime libraries be recompiled.
3348 The two argument form specifies the representation to be used for
3349 the specified floating-point type. On all systems other than OpenVMS,
3350 the argument must
3351 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3353 @itemize @bullet
3354 @item
3355 For a digits value of 6, 32-bit IEEE short format will be used.
3356 @item
3357 For a digits value of 15, 64-bit IEEE long format will be used.
3358 @item
3359 No other value of digits is permitted.
3360 @end itemize
3362 On OpenVMS, the
3363 argument may be @code{VAX_Float} to specify the use of the VAX float
3364 format, as follows:
3366 @itemize @bullet
3367 @item
3368 For digits values up to 6, F float format will be used.
3369 @item
3370 For digits values from 7 to 9, D float format will be used.
3371 @item
3372 For digits values from 10 to 15, G float format will be used.
3373 @item
3374 Digits values above 15 are not allowed.
3375 @end itemize
3377 @node Pragma Global
3378 @unnumberedsec Pragma Global
3379 @findex Global
3380 @noindent
3381 For the description of this pragma, see SPARK 2014 Reference Manual,
3382 section 6.1.4.
3384 @node Pragma Ident
3385 @unnumberedsec Pragma Ident
3386 @findex Ident
3387 @noindent
3388 Syntax:
3390 @smallexample @c ada
3391 pragma Ident (static_string_EXPRESSION);
3392 @end smallexample
3394 @noindent
3395 This pragma is identical in effect to pragma @code{Comment}. It is provided
3396 for compatibility with other Ada compilers providing this pragma.
3398 @node Pragma Implementation_Defined
3399 @unnumberedsec Pragma Implementation_Defined
3400 @findex Implementation_Defined
3401 @noindent
3402 Syntax:
3404 @smallexample @c ada
3405 pragma Implementation_Defined (local_NAME);
3406 @end smallexample
3408 @noindent
3409 This pragma marks a previously declared entioty as implementation-defined.
3410 For an overloaded entity, applies to the most recent homonym.
3412 @smallexample @c ada
3413 pragma Implementation_Defined;
3414 @end smallexample
3416 @noindent
3417 The form with no arguments appears anywhere within a scope, most
3418 typically a package spec, and indicates that all entities that are
3419 defined within the package spec are Implementation_Defined.
3421 This pragma is used within the GNAT runtime library to identify
3422 implementation-defined entities introduced in language-defined units,
3423 for the purpose of implementing the No_Implementation_Identifiers
3424 restriction.
3426 @node Pragma Implemented
3427 @unnumberedsec Pragma Implemented
3428 @findex Implemented
3429 @noindent
3430 Syntax:
3432 @smallexample @c ada
3433 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3435 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3436 @end smallexample
3438 @noindent
3439 This is an Ada 2012 representation pragma which applies to protected, task
3440 and synchronized interface primitives. The use of pragma Implemented provides
3441 a way to impose a static requirement on the overriding operation by adhering
3442 to one of the three implementation kinds: entry, protected procedure or any of
3443 the above. This pragma is available in all earlier versions of Ada as an
3444 implementation-defined pragma.
3446 @smallexample @c ada
3447 type Synch_Iface is synchronized interface;
3448 procedure Prim_Op (Obj : in out Iface) is abstract;
3449 pragma Implemented (Prim_Op, By_Protected_Procedure);
3451 protected type Prot_1 is new Synch_Iface with
3452    procedure Prim_Op;  --  Legal
3453 end Prot_1;
3455 protected type Prot_2 is new Synch_Iface with
3456    entry Prim_Op;      --  Illegal
3457 end Prot_2;
3459 task type Task_Typ is new Synch_Iface with
3460    entry Prim_Op;      --  Illegal
3461 end Task_Typ;
3462 @end smallexample
3464 @noindent
3465 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3466 Implemented determines the runtime behavior of the requeue. Implementation kind
3467 By_Entry guarantees that the action of requeueing will proceed from an entry to
3468 another entry. Implementation kind By_Protected_Procedure transforms the
3469 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3470 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3471 the target's overriding subprogram kind.
3473 @node Pragma Implicit_Packing
3474 @unnumberedsec Pragma Implicit_Packing
3475 @findex Implicit_Packing
3476 @cindex Rational Profile
3477 @noindent
3478 Syntax:
3480 @smallexample @c ada
3481 pragma Implicit_Packing;
3482 @end smallexample
3484 @noindent
3485 This is a configuration pragma that requests implicit packing for packed
3486 arrays for which a size clause is given but no explicit pragma Pack or
3487 specification of Component_Size is present. It also applies to records
3488 where no record representation clause is present. Consider this example:
3490 @smallexample @c ada
3491 type R is array (0 .. 7) of Boolean;
3492 for R'Size use 8;
3493 @end smallexample
3495 @noindent
3496 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3497 does not change the layout of a composite object. So the Size clause in the
3498 above example is normally rejected, since the default layout of the array uses
3499 8-bit components, and thus the array requires a minimum of 64 bits.
3501 If this declaration is compiled in a region of code covered by an occurrence
3502 of the configuration pragma Implicit_Packing, then the Size clause in this
3503 and similar examples will cause implicit packing and thus be accepted. For
3504 this implicit packing to occur, the type in question must be an array of small
3505 components whose size is known at compile time, and the Size clause must
3506 specify the exact size that corresponds to the number of elements in the array
3507 multiplied by the size in bits of the component type (both single and
3508 multi-dimensioned arrays can be controlled with this pragma).
3510 @cindex Array packing
3512 Similarly, the following example shows the use in the record case
3514 @smallexample @c ada
3515 type r is record
3516    a, b, c, d, e, f, g, h : boolean;
3517    chr                    : character;
3518 end record;
3519 for r'size use 16;
3520 @end smallexample
3522 @noindent
3523 Without a pragma Pack, each Boolean field requires 8 bits, so the
3524 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3525 sufficient. The use of pragma Implicit_Packing allows this record
3526 declaration to compile without an explicit pragma Pack.
3527 @node Pragma Import_Exception
3528 @unnumberedsec Pragma Import_Exception
3529 @cindex OpenVMS
3530 @findex Import_Exception
3531 @noindent
3532 Syntax:
3534 @smallexample @c ada
3535 pragma Import_Exception (
3536      [Internal =>] LOCAL_NAME
3537   [, [External =>] EXTERNAL_SYMBOL]
3538   [, [Form     =>] Ada | VMS]
3539   [, [Code     =>] static_integer_EXPRESSION]);
3541 EXTERNAL_SYMBOL ::=
3542   IDENTIFIER
3543 | static_string_EXPRESSION
3544 @end smallexample
3546 @noindent
3547 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3548 It allows OpenVMS conditions (for example, from OpenVMS system services or
3549 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3550 The pragma specifies that the exception associated with an exception
3551 declaration in an Ada program be defined externally (in non-Ada code).
3552 For further details on this pragma, see the
3553 DEC Ada Language Reference Manual, section 13.9a.3.1.
3555 @node Pragma Import_Function
3556 @unnumberedsec Pragma Import_Function
3557 @findex Import_Function
3558 @noindent
3559 Syntax:
3561 @smallexample @c ada
3562 pragma Import_Function (
3563      [Internal                 =>] LOCAL_NAME,
3564   [, [External                 =>] EXTERNAL_SYMBOL]
3565   [, [Parameter_Types          =>] PARAMETER_TYPES]
3566   [, [Result_Type              =>] SUBTYPE_MARK]
3567   [, [Mechanism                =>] MECHANISM]
3568   [, [Result_Mechanism         =>] MECHANISM_NAME]);
3570 EXTERNAL_SYMBOL ::=
3571   IDENTIFIER
3572 | static_string_EXPRESSION
3574 PARAMETER_TYPES ::=
3575   null
3576 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3578 TYPE_DESIGNATOR ::=
3579   subtype_NAME
3580 | subtype_Name ' Access
3582 MECHANISM ::=
3583   MECHANISM_NAME
3584 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3586 MECHANISM_ASSOCIATION ::=
3587   [formal_parameter_NAME =>] MECHANISM_NAME
3589 MECHANISM_NAME ::=
3590   Value
3591 | Reference
3592 @end smallexample
3594 @noindent
3595 This pragma is used in conjunction with a pragma @code{Import} to
3596 specify additional information for an imported function.  The pragma
3597 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3598 @code{Import_Function} pragma and both must appear in the same
3599 declarative part as the function specification.
3601 The @var{Internal} argument must uniquely designate
3602 the function to which the
3603 pragma applies.  If more than one function name exists of this name in
3604 the declarative part you must use the @code{Parameter_Types} and
3605 @var{Result_Type} parameters to achieve the required unique
3606 designation.  Subtype marks in these parameters must exactly match the
3607 subtypes in the corresponding function specification, using positional
3608 notation to match parameters with subtype marks.
3609 The form with an @code{'Access} attribute can be used to match an
3610 anonymous access parameter.
3612 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3613 parameters to specify passing mechanisms for the
3614 parameters and result.  If you specify a single mechanism name, it
3615 applies to all parameters.  Otherwise you may specify a mechanism on a
3616 parameter by parameter basis using either positional or named
3617 notation.  If the mechanism is not specified, the default mechanism
3618 is used.
3620 @node Pragma Import_Object
3621 @unnumberedsec Pragma Import_Object
3622 @findex Import_Object
3623 @noindent
3624 Syntax:
3626 @smallexample @c ada
3627 pragma Import_Object
3628      [Internal =>] LOCAL_NAME
3629   [, [External =>] EXTERNAL_SYMBOL]
3630   [, [Size     =>] EXTERNAL_SYMBOL]);
3632 EXTERNAL_SYMBOL ::=
3633   IDENTIFIER
3634 | static_string_EXPRESSION
3635 @end smallexample
3637 @noindent
3638 This pragma designates an object as imported, and apart from the
3639 extended rules for external symbols, is identical in effect to the use of
3640 the normal @code{Import} pragma applied to an object.  Unlike the
3641 subprogram case, you need not use a separate @code{Import} pragma,
3642 although you may do so (and probably should do so from a portability
3643 point of view).  @var{size} is syntax checked, but otherwise ignored by
3644 GNAT@.
3646 @node Pragma Import_Procedure
3647 @unnumberedsec Pragma Import_Procedure
3648 @findex Import_Procedure
3649 @noindent
3650 Syntax:
3652 @smallexample @c ada
3653 pragma Import_Procedure (
3654      [Internal                 =>] LOCAL_NAME
3655   [, [External                 =>] EXTERNAL_SYMBOL]
3656   [, [Parameter_Types          =>] PARAMETER_TYPES]
3657   [, [Mechanism                =>] MECHANISM]);
3659 EXTERNAL_SYMBOL ::=
3660   IDENTIFIER
3661 | static_string_EXPRESSION
3663 PARAMETER_TYPES ::=
3664   null
3665 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3667 TYPE_DESIGNATOR ::=
3668   subtype_NAME
3669 | subtype_Name ' Access
3671 MECHANISM ::=
3672   MECHANISM_NAME
3673 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3675 MECHANISM_ASSOCIATION ::=
3676   [formal_parameter_NAME =>] MECHANISM_NAME
3678 MECHANISM_NAME ::= Value | Reference
3679 @end smallexample
3681 @noindent
3682 This pragma is identical to @code{Import_Function} except that it
3683 applies to a procedure rather than a function and the parameters
3684 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3686 @node Pragma Import_Valued_Procedure
3687 @unnumberedsec Pragma Import_Valued_Procedure
3688 @findex Import_Valued_Procedure
3689 @noindent
3690 Syntax:
3692 @smallexample @c ada
3693 pragma Import_Valued_Procedure (
3694      [Internal                 =>] LOCAL_NAME
3695   [, [External                 =>] EXTERNAL_SYMBOL]
3696   [, [Parameter_Types          =>] PARAMETER_TYPES]
3697   [, [Mechanism                =>] MECHANISM]);
3699 EXTERNAL_SYMBOL ::=
3700   IDENTIFIER
3701 | static_string_EXPRESSION
3703 PARAMETER_TYPES ::=
3704   null
3705 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3707 TYPE_DESIGNATOR ::=
3708   subtype_NAME
3709 | subtype_Name ' Access
3711 MECHANISM ::=
3712   MECHANISM_NAME
3713 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3715 MECHANISM_ASSOCIATION ::=
3716   [formal_parameter_NAME =>] MECHANISM_NAME
3718 MECHANISM_NAME ::= Value | Reference
3719 @end smallexample
3721 @noindent
3722 This pragma is identical to @code{Import_Procedure} except that the
3723 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3724 mode @code{OUT}, and externally the subprogram is treated as a function
3725 with this parameter as the result of the function.  The purpose of this
3726 capability is to allow the use of @code{OUT} and @code{IN OUT}
3727 parameters in interfacing to external functions (which are not permitted
3728 in Ada functions).  You may optionally use the @code{Mechanism}
3729 parameters to specify passing mechanisms for the parameters.
3730 If you specify a single mechanism name, it applies to all parameters.
3731 Otherwise you may specify a mechanism on a parameter by parameter
3732 basis using either positional or named notation.  If the mechanism is not
3733 specified, the default mechanism is used.
3735 Note that it is important to use this pragma in conjunction with a separate
3736 pragma Import that specifies the desired convention, since otherwise the
3737 default convention is Ada, which is almost certainly not what is required.
3739 @node Pragma Independent
3740 @unnumberedsec Pragma Independent
3741 @findex Independent
3742 @noindent
3743 Syntax:
3745 @smallexample @c ada
3746 pragma Independent (Local_NAME);
3747 @end smallexample
3749 @noindent
3750 This pragma is standard in Ada 2012 mode (which also provides an aspect
3751 of the same name). It is also available as an implementation-defined
3752 pragma in all earlier versions. It specifies that the
3753 designated object or all objects of the designated type must be
3754 independently addressable. This means that separate tasks can safely
3755 manipulate such objects. For example, if two components of a record are
3756 independent, then two separate tasks may access these two components.
3757 This may place
3758 constraints on the representation of the object (for instance prohibiting
3759 tight packing).
3761 @node Pragma Independent_Components
3762 @unnumberedsec Pragma Independent_Components
3763 @findex Independent_Components
3764 @noindent
3765 Syntax:
3767 @smallexample @c ada
3768 pragma Independent_Components (Local_NAME);
3769 @end smallexample
3771 @noindent
3772 This pragma is standard in Ada 2012 mode (which also provides an aspect
3773 of the same name). It is also available as an implementation-defined
3774 pragma in all earlier versions. It specifies that the components of the
3775 designated object, or the components of each object of the designated
3776 type, must be
3777 independently addressable. This means that separate tasks can safely
3778 manipulate separate components in the composite object. This may place
3779 constraints on the representation of the object (for instance prohibiting
3780 tight packing).
3782 @node Pragma Initial_Condition
3783 @unnumberedsec Pragma Initial_Condition
3784 @findex Initial_Condition
3785 @noindent
3786 For the description of this pragma, see SPARK 2014 Reference Manual,
3787 section 7.1.6.
3789 @node Pragma Initialize_Scalars
3790 @unnumberedsec Pragma Initialize_Scalars
3791 @findex Initialize_Scalars
3792 @cindex debugging with Initialize_Scalars
3793 @noindent
3794 Syntax:
3796 @smallexample @c ada
3797 pragma Initialize_Scalars;
3798 @end smallexample
3800 @noindent
3801 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3802 two important differences.  First, there is no requirement for the pragma
3803 to be used uniformly in all units of a partition, in particular, it is fine
3804 to use this just for some or all of the application units of a partition,
3805 without needing to recompile the run-time library.
3807 In the case where some units are compiled with the pragma, and some without,
3808 then a declaration of a variable where the type is defined in package
3809 Standard or is locally declared will always be subject to initialization,
3810 as will any declaration of a scalar variable.  For composite variables,
3811 whether the variable is initialized may also depend on whether the package
3812 in which the type of the variable is declared is compiled with the pragma.
3814 The other important difference is that you can control the value used
3815 for initializing scalar objects.  At bind time, you can select several
3816 options for initialization. You can
3817 initialize with invalid values (similar to Normalize_Scalars, though for
3818 Initialize_Scalars it is not always possible to determine the invalid
3819 values in complex cases like signed component fields with non-standard
3820 sizes). You can also initialize with high or
3821 low values, or with a specified bit pattern.  See the @value{EDITION}
3822 User's Guide for binder options for specifying these cases.
3824 This means that you can compile a program, and then without having to
3825 recompile the program, you can run it with different values being used
3826 for initializing otherwise uninitialized values, to test if your program
3827 behavior depends on the choice.  Of course the behavior should not change,
3828 and if it does, then most likely you have an incorrect reference to an
3829 uninitialized value.
3831 It is even possible to change the value at execution time eliminating even
3832 the need to rebind with a different switch using an environment variable.
3833 See the @value{EDITION} User's Guide for details.
3835 Note that pragma @code{Initialize_Scalars} is particularly useful in
3836 conjunction with the enhanced validity checking that is now provided
3837 in GNAT, which checks for invalid values under more conditions.
3838 Using this feature (see description of the @option{-gnatV} flag in the
3839 @value{EDITION} User's Guide) in conjunction with
3840 pragma @code{Initialize_Scalars}
3841 provides a powerful new tool to assist in the detection of problems
3842 caused by uninitialized variables.
3844 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3845 effect on the generated code. This may cause your code to be
3846 substantially larger. It may also cause an increase in the amount
3847 of stack required, so it is probably a good idea to turn on stack
3848 checking (see description of stack checking in the @value{EDITION}
3849 User's Guide) when using this pragma.
3851 @node Pragma Initializes
3852 @unnumberedsec Pragma Initializes
3853 @findex Initializes
3854 @noindent
3855 For the description of this pragma, see SPARK 2014 Reference Manual,
3856 section 7.1.5.
3858 @node Pragma Inline_Always
3859 @unnumberedsec Pragma Inline_Always
3860 @findex Inline_Always
3861 @noindent
3862 Syntax:
3864 @smallexample @c ada
3865 pragma Inline_Always (NAME [, NAME]);
3866 @end smallexample
3868 @noindent
3869 Similar to pragma @code{Inline} except that inlining is not subject to
3870 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3871 happens regardless of whether these options are used.
3873 @node Pragma Inline_Generic
3874 @unnumberedsec Pragma Inline_Generic
3875 @findex Inline_Generic
3876 @noindent
3877 Syntax:
3879 @smallexample @c ada
3880 pragma Inline_Generic (GNAME @{, GNAME@});
3882 GNAME ::= generic_unit_NAME | generic_instance_NAME
3883 @end smallexample
3885 @noindent
3886 This pragma is provided for compatibility with Dec Ada 83. It has
3887 no effect in @code{GNAT} (which always inlines generics), other
3888 than to check that the given names are all names of generic units or
3889 generic instances.
3891 @node Pragma Interface
3892 @unnumberedsec Pragma Interface
3893 @findex Interface
3894 @noindent
3895 Syntax:
3897 @smallexample @c ada
3898 pragma Interface (
3899      [Convention    =>] convention_identifier,
3900      [Entity        =>] local_NAME
3901   [, [External_Name =>] static_string_expression]
3902   [, [Link_Name     =>] static_string_expression]);
3903 @end smallexample
3905 @noindent
3906 This pragma is identical in syntax and semantics to
3907 the standard Ada pragma @code{Import}.  It is provided for compatibility
3908 with Ada 83.  The definition is upwards compatible both with pragma
3909 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3910 with some extended implementations of this pragma in certain Ada 83
3911 implementations.  The only difference between pragma @code{Interface}
3912 and pragma @code{Import} is that there is special circuitry to allow
3913 both pragmas to appear for the same subprogram entity (normally it
3914 is illegal to have multiple @code{Import} pragmas. This is useful in
3915 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3916 Ada 83 compilers.
3918 @node Pragma Interface_Name
3919 @unnumberedsec Pragma Interface_Name
3920 @findex Interface_Name
3921 @noindent
3922 Syntax:
3924 @smallexample @c ada
3925 pragma Interface_Name (
3926      [Entity        =>] LOCAL_NAME
3927   [, [External_Name =>] static_string_EXPRESSION]
3928   [, [Link_Name     =>] static_string_EXPRESSION]);
3929 @end smallexample
3931 @noindent
3932 This pragma provides an alternative way of specifying the interface name
3933 for an interfaced subprogram, and is provided for compatibility with Ada
3934 83 compilers that use the pragma for this purpose.  You must provide at
3935 least one of @var{External_Name} or @var{Link_Name}.
3937 @node Pragma Interrupt_Handler
3938 @unnumberedsec Pragma Interrupt_Handler
3939 @findex Interrupt_Handler
3940 @noindent
3941 Syntax:
3943 @smallexample @c ada
3944 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3945 @end smallexample
3947 @noindent
3948 This program unit pragma is supported for parameterless protected procedures
3949 as described in Annex C of the Ada Reference Manual. On the AAMP target
3950 the pragma can also be specified for nonprotected parameterless procedures
3951 that are declared at the library level (which includes procedures
3952 declared at the top level of a library package). In the case of AAMP,
3953 when this pragma is applied to a nonprotected procedure, the instruction
3954 @code{IERET} is generated for returns from the procedure, enabling
3955 maskable interrupts, in place of the normal return instruction.
3957 @node Pragma Interrupt_State
3958 @unnumberedsec Pragma Interrupt_State
3959 @findex Interrupt_State
3960 @noindent
3961 Syntax:
3963 @smallexample @c ada
3964 pragma Interrupt_State
3965  ([Name  =>] value,
3966   [State =>] SYSTEM | RUNTIME | USER);
3967 @end smallexample
3969 @noindent
3970 Normally certain interrupts are reserved to the implementation.  Any attempt
3971 to attach an interrupt causes Program_Error to be raised, as described in
3972 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3973 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3974 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3975 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
3976 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3977 Ada exceptions, or used to implement run-time functions such as the
3978 @code{abort} statement and stack overflow checking.
3980 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3981 such uses of interrupts.  It subsumes the functionality of pragma
3982 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
3983 available on Windows or VMS.  On all other platforms than VxWorks,
3984 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3985 and may be used to mark interrupts required by the board support package
3986 as reserved.
3988 Interrupts can be in one of three states:
3989 @itemize @bullet
3990 @item System
3992 The interrupt is reserved (no Ada handler can be installed), and the
3993 Ada run-time may not install a handler. As a result you are guaranteed
3994 standard system default action if this interrupt is raised.
3996 @item Runtime
3998 The interrupt is reserved (no Ada handler can be installed). The run time
3999 is allowed to install a handler for internal control purposes, but is
4000 not required to do so.
4002 @item User
4004 The interrupt is unreserved.  The user may install a handler to provide
4005 some other action.
4006 @end itemize
4008 @noindent
4009 These states are the allowed values of the @code{State} parameter of the
4010 pragma.  The @code{Name} parameter is a value of the type
4011 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
4012 @code{Ada.Interrupts.Names}.
4014 This is a configuration pragma, and the binder will check that there
4015 are no inconsistencies between different units in a partition in how a
4016 given interrupt is specified. It may appear anywhere a pragma is legal.
4018 The effect is to move the interrupt to the specified state.
4020 By declaring interrupts to be SYSTEM, you guarantee the standard system
4021 action, such as a core dump.
4023 By declaring interrupts to be USER, you guarantee that you can install
4024 a handler.
4026 Note that certain signals on many operating systems cannot be caught and
4027 handled by applications.  In such cases, the pragma is ignored.  See the
4028 operating system documentation, or the value of the array @code{Reserved}
4029 declared in the spec of package @code{System.OS_Interface}.
4031 Overriding the default state of signals used by the Ada runtime may interfere
4032 with an application's runtime behavior in the cases of the synchronous signals,
4033 and in the case of the signal used to implement the @code{abort} statement.
4035 @node Pragma Invariant
4036 @unnumberedsec Pragma Invariant
4037 @findex Invariant
4038 @noindent
4039 Syntax:
4041 @smallexample @c ada
4042 pragma Invariant
4043   ([Entity =>]    private_type_LOCAL_NAME,
4044    [Check  =>]    EXPRESSION
4045    [,[Message =>] String_Expression]);
4046 @end smallexample
4048 @noindent
4049 This pragma provides exactly the same capabilities as the Type_Invariant aspect
4050 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
4051 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
4052 requires the use of the aspect syntax, which is not available except in 2012
4053 mode, it is not possible to use the Type_Invariant aspect in earlier versions
4054 of Ada. However the Invariant pragma may be used in any version of Ada. Also
4055 note that the aspect Invariant is a synonym in GNAT for the aspect
4056 Type_Invariant, but there is no pragma Type_Invariant.
4058 The pragma must appear within the visible part of the package specification,
4059 after the type to which its Entity argument appears. As with the Invariant
4060 aspect, the Check expression is not analyzed until the end of the visible
4061 part of the package, so it may contain forward references. The Message
4062 argument, if present, provides the exception message used if the invariant
4063 is violated. If no Message parameter is provided, a default message that
4064 identifies the line on which the pragma appears is used.
4066 It is permissible to have multiple Invariants for the same type entity, in
4067 which case they are and'ed together. It is permissible to use this pragma
4068 in Ada 2012 mode, but you cannot have both an invariant aspect and an
4069 invariant pragma for the same entity.
4071 For further details on the use of this pragma, see the Ada 2012 documentation
4072 of the Type_Invariant aspect.
4074 @node Pragma Java_Constructor
4075 @unnumberedsec Pragma Java_Constructor
4076 @findex Java_Constructor
4077 @noindent
4078 Syntax:
4080 @smallexample @c ada
4081 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
4082 @end smallexample
4084 @noindent
4085 This pragma is used to assert that the specified Ada function should be
4086 mapped to the Java constructor for some Ada tagged record type.
4088 See section 7.3.2 of the
4089 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4090 for related information.
4092 @node Pragma Java_Interface
4093 @unnumberedsec Pragma Java_Interface
4094 @findex Java_Interface
4095 @noindent
4096 Syntax:
4098 @smallexample @c ada
4099 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
4100 @end smallexample
4102 @noindent
4103 This pragma is used to assert that the specified Ada abstract tagged type
4104 is to be mapped to a Java interface name.
4106 See sections 7.1 and 7.2 of the
4107 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4108 for related information.
4110 @node Pragma Keep_Names
4111 @unnumberedsec Pragma Keep_Names
4112 @findex Keep_Names
4113 @noindent
4114 Syntax:
4116 @smallexample @c ada
4117 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4118 @end smallexample
4120 @noindent
4121 The @var{LOCAL_NAME} argument
4122 must refer to an enumeration first subtype
4123 in the current declarative part. The effect is to retain the enumeration
4124 literal names for use by @code{Image} and @code{Value} even if a global
4125 @code{Discard_Names} pragma applies. This is useful when you want to
4126 generally suppress enumeration literal names and for example you therefore
4127 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
4128 want to retain the names for specific enumeration types.
4130 @node Pragma License
4131 @unnumberedsec Pragma License
4132 @findex License
4133 @cindex License checking
4134 @noindent
4135 Syntax:
4137 @smallexample @c ada
4138 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4139 @end smallexample
4141 @noindent
4142 This pragma is provided to allow automated checking for appropriate license
4143 conditions with respect to the standard and modified GPL@.  A pragma
4144 @code{License}, which is a configuration pragma that typically appears at
4145 the start of a source file or in a separate @file{gnat.adc} file, specifies
4146 the licensing conditions of a unit as follows:
4148 @itemize @bullet
4149 @item Unrestricted
4150 This is used for a unit that can be freely used with no license restrictions.
4151 Examples of such units are public domain units, and units from the Ada
4152 Reference Manual.
4154 @item GPL
4155 This is used for a unit that is licensed under the unmodified GPL, and which
4156 therefore cannot be @code{with}'ed by a restricted unit.
4158 @item Modified_GPL
4159 This is used for a unit licensed under the GNAT modified GPL that includes
4160 a special exception paragraph that specifically permits the inclusion of
4161 the unit in programs without requiring the entire program to be released
4162 under the GPL@.
4164 @item Restricted
4165 This is used for a unit that is restricted in that it is not permitted to
4166 depend on units that are licensed under the GPL@.  Typical examples are
4167 proprietary code that is to be released under more restrictive license
4168 conditions.  Note that restricted units are permitted to @code{with} units
4169 which are licensed under the modified GPL (this is the whole point of the
4170 modified GPL).
4172 @end itemize
4174 @noindent
4175 Normally a unit with no @code{License} pragma is considered to have an
4176 unknown license, and no checking is done.  However, standard GNAT headers
4177 are recognized, and license information is derived from them as follows.
4179 A GNAT license header starts with a line containing 78 hyphens.  The following
4180 comment text is searched for the appearance of any of the following strings.
4182 If the string ``GNU General Public License'' is found, then the unit is assumed
4183 to have GPL license, unless the string ``As a special exception'' follows, in
4184 which case the license is assumed to be modified GPL@.
4186 If one of the strings
4187 ``This specification is adapted from the Ada Semantic Interface'' or
4188 ``This specification is derived from the Ada Reference Manual'' is found
4189 then the unit is assumed to be unrestricted.
4191 @noindent
4192 These default actions means that a program with a restricted license pragma
4193 will automatically get warnings if a GPL unit is inappropriately
4194 @code{with}'ed.  For example, the program:
4196 @smallexample @c ada
4197 with Sem_Ch3;
4198 with GNAT.Sockets;
4199 procedure Secret_Stuff is
4200   @dots{}
4201 end Secret_Stuff
4202 @end smallexample
4204 @noindent
4205 if compiled with pragma @code{License} (@code{Restricted}) in a
4206 @file{gnat.adc} file will generate the warning:
4208 @smallexample
4209 1.  with Sem_Ch3;
4210         |
4211    >>> license of withed unit "Sem_Ch3" is incompatible
4213 2.  with GNAT.Sockets;
4214 3.  procedure Secret_Stuff is
4215 @end smallexample
4217 @noindent
4218 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4219 compiler and is licensed under the
4220 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4221 run time, and is therefore licensed under the modified GPL@.
4223 @node Pragma Link_With
4224 @unnumberedsec Pragma Link_With
4225 @findex Link_With
4226 @noindent
4227 Syntax:
4229 @smallexample @c ada
4230 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4231 @end smallexample
4233 @noindent
4234 This pragma is provided for compatibility with certain Ada 83 compilers.
4235 It has exactly the same effect as pragma @code{Linker_Options} except
4236 that spaces occurring within one of the string expressions are treated
4237 as separators. For example, in the following case:
4239 @smallexample @c ada
4240 pragma Link_With ("-labc -ldef");
4241 @end smallexample
4243 @noindent
4244 results in passing the strings @code{-labc} and @code{-ldef} as two
4245 separate arguments to the linker. In addition pragma Link_With allows
4246 multiple arguments, with the same effect as successive pragmas.
4248 @node Pragma Linker_Alias
4249 @unnumberedsec Pragma Linker_Alias
4250 @findex Linker_Alias
4251 @noindent
4252 Syntax:
4254 @smallexample @c ada
4255 pragma Linker_Alias (
4256   [Entity =>] LOCAL_NAME,
4257   [Target =>] static_string_EXPRESSION);
4258 @end smallexample
4260 @noindent
4261 @var{LOCAL_NAME} must refer to an object that is declared at the library
4262 level. This pragma establishes the given entity as a linker alias for the
4263 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4264 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4265 @var{static_string_EXPRESSION} in the object file, that is to say no space
4266 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4267 to the same address as @var{static_string_EXPRESSION} by the linker.
4269 The actual linker name for the target must be used (e.g.@: the fully
4270 encoded name with qualification in Ada, or the mangled name in C++),
4271 or it must be declared using the C convention with @code{pragma Import}
4272 or @code{pragma Export}.
4274 Not all target machines support this pragma. On some of them it is accepted
4275 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4277 @smallexample @c ada
4278 --  Example of the use of pragma Linker_Alias
4280 package p is
4281   i : Integer := 1;
4282   pragma Export (C, i);
4284   new_name_for_i : Integer;
4285   pragma Linker_Alias (new_name_for_i, "i");
4286 end p;
4287 @end smallexample
4289 @node Pragma Linker_Constructor
4290 @unnumberedsec Pragma Linker_Constructor
4291 @findex Linker_Constructor
4292 @noindent
4293 Syntax:
4295 @smallexample @c ada
4296 pragma Linker_Constructor (procedure_LOCAL_NAME);
4297 @end smallexample
4299 @noindent
4300 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4301 is declared at the library level. A procedure to which this pragma is
4302 applied will be treated as an initialization routine by the linker.
4303 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4304 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4305 of the executable is called (or immediately after the shared library is
4306 loaded if the procedure is linked in a shared library), in particular
4307 before the Ada run-time environment is set up.
4309 Because of these specific contexts, the set of operations such a procedure
4310 can perform is very limited and the type of objects it can manipulate is
4311 essentially restricted to the elementary types. In particular, it must only
4312 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4314 This pragma is used by GNAT to implement auto-initialization of shared Stand
4315 Alone Libraries, which provides a related capability without the restrictions
4316 listed above. Where possible, the use of Stand Alone Libraries is preferable
4317 to the use of this pragma.
4319 @node Pragma Linker_Destructor
4320 @unnumberedsec Pragma Linker_Destructor
4321 @findex Linker_Destructor
4322 @noindent
4323 Syntax:
4325 @smallexample @c ada
4326 pragma Linker_Destructor (procedure_LOCAL_NAME);
4327 @end smallexample
4329 @noindent
4330 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4331 is declared at the library level. A procedure to which this pragma is
4332 applied will be treated as a finalization routine by the linker.
4333 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4334 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4335 of the executable has exited (or immediately before the shared library
4336 is unloaded if the procedure is linked in a shared library), in particular
4337 after the Ada run-time environment is shut down.
4339 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4340 because of these specific contexts.
4342 @node Pragma Linker_Section
4343 @unnumberedsec Pragma Linker_Section
4344 @findex Linker_Section
4345 @noindent
4346 Syntax:
4348 @smallexample @c ada
4349 pragma Linker_Section (
4350   [Entity  =>] LOCAL_NAME,
4351   [Section =>] static_string_EXPRESSION);
4352 @end smallexample
4354 @noindent
4355 @var{LOCAL_NAME} must refer to an object, type, or subprogram that is
4356 declared at the library level. This pragma specifies the name of the
4357 linker section for the given entity. It is equivalent to
4358 @code{__attribute__((section))} in GNU C and causes @var{LOCAL_NAME} to
4359 be placed in the @var{static_string_EXPRESSION} section of the
4360 executable (assuming the linker doesn't rename the section).
4361 GNAT also provides an implementation defined aspect of the same name.
4363 In the case of specifying this aspect for a type, the effect is to
4364 specify the corresponding for all library level objects of the type which
4365 do not have an explicit linker section set. Note that this only applies to
4366 whole objects, not to components of composite objects.
4368 In the case of a subprogram, the linker section applies to all previously
4369 declared matching overloaded subprograms in the current declarative part
4370 which do not already have a linker section assigned. The linker section
4371 aspect is useful in this case for specifying different linker sections
4372 for different elements of such an overloaded set.
4374 Note that an empty string specifies that no linker section is specified.
4375 This is not quite the same as omitting the pragma or aspect, since it
4376 can be used to specify that one element of an overloaded set of subprograms
4377 has the default linker section, or that one object of a type for which a
4378 linker section is specified should has the default linker section.
4380 The compiler normally places library-level entities in standard sections
4381 depending on the class: procedures and functions generally go in the
4382 @code{.text} section, initialized variables in the @code{.data} section
4383 and uninitialized variables in the @code{.bss} section.
4385 Other, special sections may exist on given target machines to map special
4386 hardware, for example I/O ports or flash memory. This pragma is a means to
4387 defer the final layout of the executable to the linker, thus fully working
4388 at the symbolic level with the compiler.
4390 Some file formats do not support arbitrary sections so not all target
4391 machines support this pragma. The use of this pragma may cause a program
4392 execution to be erroneous if it is used to place an entity into an
4393 inappropriate section (e.g.@: a modified variable into the @code{.text}
4394 section). See also @code{pragma Persistent_BSS}.
4396 @smallexample @c ada
4397 --  Example of the use of pragma Linker_Section
4399 package IO_Card is
4400   Port_A : Integer;
4401   pragma Volatile (Port_A);
4402   pragma Linker_Section (Port_A, ".bss.port_a");
4404   Port_B : Integer;
4405   pragma Volatile (Port_B);
4406   pragma Linker_Section (Port_B, ".bss.port_b");
4408   type Port_Type is new Integer with Linker_Section => ".bss";
4409   PA : Port_Type with Linker_Section => ".bss.PA";
4410   PB : Port_Type; --  ends up in linker section ".bss"
4412   procedure Q with Linker_Section => "Qsection";
4413 end IO_Card;
4414 @end smallexample
4416 @node Pragma Lock_Free
4417 @unnumberedsec Pragma Lock_Free
4418 @findex Lock_Free
4419 @noindent
4420 Syntax:
4421 This pragma may be specified for protected types or objects. It specifies that
4422 the implementation of protected operations must be implemented without locks.
4423 Compilation fails if the compiler cannot generate lock-free code for the
4424 operations.
4426 @node Pragma Long_Float
4427 @unnumberedsec Pragma Long_Float
4428 @cindex OpenVMS
4429 @findex Long_Float
4430 @noindent
4431 Syntax:
4433 @smallexample @c ada
4434 pragma Long_Float (FLOAT_FORMAT);
4436 FLOAT_FORMAT ::= D_Float | G_Float
4437 @end smallexample
4439 @noindent
4440 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4441 It allows control over the internal representation chosen for the predefined
4442 type @code{Long_Float} and for floating point type representations with
4443 @code{digits} specified in the range 7 through 15.
4444 For further details on this pragma, see the
4445 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
4446 this pragma, the standard runtime libraries must be recompiled.
4448 @node Pragma Loop_Invariant
4449 @unnumberedsec Pragma Loop_Invariant
4450 @findex Loop_Invariant
4451 @noindent
4452 Syntax:
4454 @smallexample @c ada
4455 pragma Loop_Invariant ( boolean_EXPRESSION );
4456 @end smallexample
4458 @noindent
4459 The effect of this pragma is similar to that of pragma @code{Assert},
4460 except that in an @code{Assertion_Policy} pragma, the identifier
4461 @code{Loop_Invariant} is used to control whether it is ignored or checked
4462 (or disabled).
4464 @code{Loop_Invariant} can only appear as one of the items in the sequence
4465 of statements of a loop body, or nested inside block statements that
4466 appear in the sequence of statements of a loop body.
4467 The intention is that it be used to
4468 represent a "loop invariant" assertion, i.e. something that is true each
4469 time through the loop, and which can be used to show that the loop is
4470 achieving its purpose.
4472 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4473 apply to the same loop should be grouped in the same sequence of
4474 statements.
4476 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4477 may be used to refer to the value of an expression on entry to the loop. This
4478 attribute can only be used within the expression of a @code{Loop_Invariant}
4479 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4481 @node Pragma Loop_Optimize
4482 @unnumberedsec Pragma Loop_Optimize
4483 @findex Loop_Optimize
4484 @noindent
4485 Syntax:
4487 @smallexample @c ada
4488 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4490 OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
4491 @end smallexample
4493 @noindent
4494 This pragma must appear immediately within a loop statement.  It allows the
4495 programmer to specify optimization hints for the enclosing loop.  The hints
4496 are not mutually exclusive and can be freely mixed, but not all combinations
4497 will yield a sensible outcome.
4499 There are five supported optimization hints for a loop:
4501 @itemize @bullet
4502 @item Ivdep
4504 The programmer asserts that there are no loop-carried dependencies
4505 which would prevent consecutive iterations of the loop from being
4506 executed simultaneously.
4508 @item No_Unroll
4510 The loop must not be unrolled.  This is a strong hint: the compiler will not
4511 unroll a loop marked with this hint.
4513 @item Unroll
4515 The loop should be unrolled.  This is a weak hint: the compiler will try to
4516 apply unrolling to this loop preferably to other optimizations, notably
4517 vectorization, but there is no guarantee that the loop will be unrolled.
4519 @item No_Vector
4521 The loop must not be vectorized.  This is a strong hint: the compiler will not
4522 vectorize a loop marked with this hint.
4524 @item Vector
4526 The loop should be vectorized.  This is a weak hint: the compiler will try to
4527 apply vectorization to this loop preferably to other optimizations, notably
4528 unrolling, but there is no guarantee that the loop will be vectorized.
4530 @end itemize
4532 These hints do not remove the need to pass the appropriate switches to the
4533 compiler in order to enable the relevant optimizations, that is to say
4534 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4535 vectorization.
4537 @node Pragma Loop_Variant
4538 @unnumberedsec Pragma Loop_Variant
4539 @findex Loop_Variant
4540 @noindent
4541 Syntax:
4543 @smallexample @c ada
4544 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4545 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4546 CHANGE_DIRECTION ::= Increases | Decreases
4547 @end smallexample
4549 @noindent
4550 @code{Loop_Variant} can only appear as one of the items in the sequence
4551 of statements of a loop body, or nested inside block statements that
4552 appear in the sequence of statements of a loop body.
4553 It allows the specification of quantities which must always
4554 decrease or increase in successive iterations of the loop. In its simplest
4555 form, just one expression is specified, whose value must increase or decrease
4556 on each iteration of the loop.
4558 In a more complex form, multiple arguments can be given which are intepreted
4559 in a nesting lexicographic manner. For example:
4561 @smallexample @c ada
4562 pragma Loop_Variant (Increases => X, Decreases => Y);
4563 @end smallexample
4565 @noindent
4566 specifies that each time through the loop either X increases, or X stays
4567 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4568 loop is making progress. It can be useful in helping to show informally
4569 or prove formally that the loop always terminates.
4571 @code{Loop_Variant} is an assertion whose effect can be controlled using
4572 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4573 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4574 to ignore the check (in which case the pragma has no effect on the program),
4575 or @code{Disable} in which case the pragma is not even checked for correct
4576 syntax.
4578 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4579 apply to the same loop should be grouped in the same sequence of
4580 statements.
4582 The @code{Loop_Entry} attribute may be used within the expressions of the
4583 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4585 @node Pragma Machine_Attribute
4586 @unnumberedsec Pragma Machine_Attribute
4587 @findex Machine_Attribute
4588 @noindent
4589 Syntax:
4591 @smallexample @c ada
4592 pragma Machine_Attribute (
4593      [Entity         =>] LOCAL_NAME,
4594      [Attribute_Name =>] static_string_EXPRESSION
4595   [, [Info           =>] static_EXPRESSION] );
4596 @end smallexample
4598 @noindent
4599 Machine-dependent attributes can be specified for types and/or
4600 declarations.  This pragma is semantically equivalent to
4601 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4602 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4603 in GNU C, where @code{@var{attribute_name}} is recognized by the
4604 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4605 specific macro.  A string literal for the optional parameter @var{info}
4606 is transformed into an identifier, which may make this pragma unusable
4607 for some attributes.  @xref{Target Attributes,, Defining target-specific
4608 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4609 Internals}, further information.
4611 @node Pragma Main
4612 @unnumberedsec Pragma Main
4613 @cindex OpenVMS
4614 @findex Main
4615 @noindent
4616 Syntax:
4618 @smallexample @c ada
4619 pragma Main
4620  (MAIN_OPTION [, MAIN_OPTION]);
4622 MAIN_OPTION ::=
4623   [Stack_Size              =>] static_integer_EXPRESSION
4624 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4625 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
4626 @end smallexample
4628 @noindent
4629 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4630 no effect in GNAT, other than being syntax checked.
4632 @node Pragma Main_Storage
4633 @unnumberedsec Pragma Main_Storage
4634 @cindex OpenVMS
4635 @findex Main_Storage
4636 @noindent
4637 Syntax:
4639 @smallexample @c ada
4640 pragma Main_Storage
4641   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4643 MAIN_STORAGE_OPTION ::=
4644   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4645 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
4646 @end smallexample
4648 @noindent
4649 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4650 no effect in GNAT, other than being syntax checked.  Note that the pragma
4651 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4653 @node Pragma No_Body
4654 @unnumberedsec Pragma No_Body
4655 @findex No_Body
4656 @noindent
4657 Syntax:
4659 @smallexample @c ada
4660 pragma No_Body;
4661 @end smallexample
4663 @noindent
4664 There are a number of cases in which a package spec does not require a body,
4665 and in fact a body is not permitted. GNAT will not permit the spec to be
4666 compiled if there is a body around. The pragma No_Body allows you to provide
4667 a body file, even in a case where no body is allowed. The body file must
4668 contain only comments and a single No_Body pragma. This is recognized by
4669 the compiler as indicating that no body is logically present.
4671 This is particularly useful during maintenance when a package is modified in
4672 such a way that a body needed before is no longer needed. The provision of a
4673 dummy body with a No_Body pragma ensures that there is no interference from
4674 earlier versions of the package body.
4676 @node Pragma No_Elaboration_Code_All
4677 @unnumberedsec Pragma No_Elaboration_Code_All
4678 @findex No_Elaboration_Code_All
4679 @noindent
4680 Syntax:
4682 @smallexample @c ada
4683 pragma No_Elaboration_Code_All [(program_unit_NAME)];
4684 @end smallexample
4686 @noindent
4687 This is a program unit pragma (there is also an equivalent aspect of the
4688 same name) that establishes the restriction @code{No_Elaboration_Code} for
4689 the current unit and any extended main source units (body and subunits.
4690 It also has has the effect of enforcing a transitive application of this
4691 aspect, so that if any unit is implicitly or explicitly WITH'ed by the
4692 current unit, it must also have the No_Elaboration_Code_All aspect set.
4694 @node Pragma No_Inline
4695 @unnumberedsec Pragma No_Inline
4696 @findex No_Inline
4697 @noindent
4698 Syntax:
4700 @smallexample @c ada
4701 pragma No_Inline (NAME @{, NAME@});
4702 @end smallexample
4704 @noindent
4705 This pragma suppresses inlining for the callable entity or the instances of
4706 the generic subprogram designated by @var{NAME}, including inlining that
4707 results from the use of pragma @code{Inline}.  This pragma is always active,
4708 in particular it is not subject to the use of option @option{-gnatn} or
4709 @option{-gnatN}.  It is illegal to specify both pragma @code{No_Inline} and
4710 pragma @code{Inline_Always} for the same @var{NAME}.
4712 @node Pragma No_Return
4713 @unnumberedsec Pragma No_Return
4714 @findex No_Return
4715 @noindent
4716 Syntax:
4718 @smallexample @c ada
4719 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4720 @end smallexample
4722 @noindent
4723 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4724 declarations in the current declarative part.  A procedure to which this
4725 pragma is applied may not contain any explicit @code{return} statements.
4726 In addition, if the procedure contains any implicit returns from falling
4727 off the end of a statement sequence, then execution of that implicit
4728 return will cause Program_Error to be raised.
4730 One use of this pragma is to identify procedures whose only purpose is to raise
4731 an exception. Another use of this pragma is to suppress incorrect warnings
4732 about missing returns in functions, where the last statement of a function
4733 statement sequence is a call to such a procedure.
4735 Note that in Ada 2005 mode, this pragma is part of the language. It is
4736 available in all earlier versions of Ada as an implementation-defined
4737 pragma.
4739 @node Pragma No_Run_Time
4740 @unnumberedsec Pragma No_Run_Time
4741 @findex No_Run_Time
4742 @noindent
4743 Syntax:
4745 @smallexample @c ada
4746 pragma No_Run_Time;
4747 @end smallexample
4749 @noindent
4750 This is an obsolete configuration pragma that historically was used to
4751 setup what is now called the "zero footprint" library. It causes any
4752 library units outside this basic library to be ignored. The use of
4753 this pragma has been superseded by the general configurable run-time
4754 capability of @code{GNAT} where the compiler takes into account whatever
4755 units happen to be accessible in the library.
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 Pre_Class
5698 @unnumberedsec Pragma Pre_Class
5699 @cindex Pre_Class
5700 @cindex Checks, preconditions
5701 @findex Preconditions
5702 @noindent
5703 Syntax:
5705 @smallexample @c ada
5706 pragma Pre_Class (Boolean_Expression);
5707 @end smallexample
5709 @noindent
5710 The @code{Pre_Class} pragma is intended to be an exact replacement for
5711 the language-defined
5712 @code{Pre'Class} aspect, and shares its restrictions and semantics.
5713 It must appear either immediately following the corresponding
5714 subprogram declaration (only other pragmas may intervene), or
5715 if there is no separate subprogram declaration, then it can
5716 appear at the start of the declarations in a subprogram body
5717 (preceded only by other pragmas).
5719 Note: This pragma is called @code{Pre_Class} rather than
5720 @code{Pre'Class} because the latter would not be strictly
5721 conforming to the allowed syntax for pragmas. The motivation
5722 for providing pragmas equivalent to the aspects is to allow a program
5723 to be written using the pragmas, and then compiled if necessary
5724 using an Ada compiler that does not recognize the pragmas or
5725 aspects, but is prepared to ignore the pragmas. The assertion
5726 policy that controls this pragma is @code{Pre'Class}, not
5727 @code{Pre_Class}.
5729 @node Pragma Priority_Specific_Dispatching
5730 @unnumberedsec Pragma Priority_Specific_Dispatching
5731 @findex Priority_Specific_Dispatching
5732 @noindent
5733 Syntax:
5735 @smallexample @c ada
5736 pragma Priority_Specific_Dispatching (
5737    POLICY_IDENTIFIER,
5738    first_priority_EXPRESSION,
5739    last_priority_EXPRESSION)
5741 POLICY_IDENTIFIER ::=
5742    EDF_Across_Priorities            |
5743    FIFO_Within_Priorities           |
5744    Non_Preemptive_Within_Priorities |
5745    Round_Robin_Within_Priorities
5746 @end smallexample
5748 @noindent
5749 This pragma is standard in Ada 2005, but is available in all earlier
5750 versions of Ada as an implementation-defined pragma.
5751 See Ada 2012 Reference Manual for details.
5753 @node Pragma Profile
5754 @unnumberedsec Pragma Profile
5755 @findex Profile
5756 @noindent
5757 Syntax:
5759 @smallexample @c ada
5760 pragma Profile (Ravenscar | Restricted | Rational);
5761 @end smallexample
5763 @noindent
5764 This pragma is standard in Ada 2005, but is available in all earlier
5765 versions of Ada as an implementation-defined pragma. This is a
5766 configuration pragma that establishes a set of configiuration pragmas
5767 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5768 The other two possibilities (@code{Restricted} or @code{Rational})
5769 are implementation-defined. The set of configuration pragmas
5770 is defined in the following sections.
5772 @itemize
5774 @item Pragma Profile (Ravenscar)
5775 @findex Ravenscar
5776 @noindent
5778 The @code{Ravenscar} profile is standard in Ada 2005,
5779 but is available in all earlier
5780 versions of Ada as an implementation-defined pragma. This profile
5781 establishes the following set of configuration pragmas:
5783 @table @code
5784 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5785 [RM D.2.2] Tasks are dispatched following a preemptive
5786 priority-ordered scheduling policy.
5788 @item Locking_Policy (Ceiling_Locking)
5789 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5790 the ceiling priority of the corresponding protected object.
5792 @item Detect_Blocking
5793 This pragma forces the detection of potentially blocking operations within a
5794 protected operation, and to raise Program_Error if that happens.
5795 @end table
5796 @noindent
5798 plus the following set of restrictions:
5800 @table @code
5801 @item Max_Entry_Queue_Length => 1
5802 No task can be queued on a protected entry.
5803 @item Max_Protected_Entries => 1
5804 @item Max_Task_Entries => 0
5805 No rendezvous statements are allowed.
5806 @item No_Abort_Statements
5807 @item No_Dynamic_Attachment
5808 @item No_Dynamic_Priorities
5809 @item No_Implicit_Heap_Allocations
5810 @item No_Local_Protected_Objects
5811 @item No_Local_Timing_Events
5812 @item No_Protected_Type_Allocators
5813 @item No_Relative_Delay
5814 @item No_Requeue_Statements
5815 @item No_Select_Statements
5816 @item No_Specific_Termination_Handlers
5817 @item No_Task_Allocators
5818 @item No_Task_Hierarchy
5819 @item No_Task_Termination
5820 @item Simple_Barriers
5821 @end table
5822 @noindent
5824 The Ravenscar profile also includes the following restrictions that specify
5825 that there are no semantic dependences on the corresponding predefined
5826 packages:
5828 @table @code
5829 @item No_Dependence => Ada.Asynchronous_Task_Control
5830 @item No_Dependence => Ada.Calendar
5831 @item No_Dependence => Ada.Execution_Time.Group_Budget
5832 @item No_Dependence => Ada.Execution_Time.Timers
5833 @item No_Dependence => Ada.Task_Attributes
5834 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5835 @end table
5837 @noindent
5839 This set of configuration pragmas and restrictions correspond to the
5840 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5841 published by the @cite{International Real-Time Ada Workshop}, 1997,
5842 and whose most recent description is available at
5843 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5845 The original definition of the profile was revised at subsequent IRTAW
5846 meetings. It has been included in the ISO
5847 @cite{Guide for the Use of the Ada Programming Language in High
5848 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5849 the next revision of the standard. The formal definition given by
5850 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5851 AI-305) available at
5852 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5853 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5855 The above set is a superset of the restrictions provided by pragma
5856 @code{Profile (Restricted)}, it includes six additional restrictions
5857 (@code{Simple_Barriers}, @code{No_Select_Statements},
5858 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5859 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
5860 that pragma @code{Profile (Ravenscar)}, like the pragma
5861 @code{Profile (Restricted)},
5862 automatically causes the use of a simplified,
5863 more efficient version of the tasking run-time system.
5865 @item Pragma Profile (Restricted)
5866 @findex Restricted Run Time
5867 @noindent
5868 This profile corresponds to the GNAT restricted run time. It
5869 establishes the following set of restrictions:
5871 @itemize @bullet
5872 @item No_Abort_Statements
5873 @item No_Entry_Queue
5874 @item No_Task_Hierarchy
5875 @item No_Task_Allocators
5876 @item No_Dynamic_Priorities
5877 @item No_Terminate_Alternatives
5878 @item No_Dynamic_Attachment
5879 @item No_Protected_Type_Allocators
5880 @item No_Local_Protected_Objects
5881 @item No_Requeue_Statements
5882 @item No_Task_Attributes_Package
5883 @item Max_Asynchronous_Select_Nesting =  0
5884 @item Max_Task_Entries =  0
5885 @item Max_Protected_Entries = 1
5886 @item Max_Select_Alternatives = 0
5887 @end itemize
5889 @noindent
5890 This set of restrictions causes the automatic selection of a simplified
5891 version of the run time that provides improved performance for the
5892 limited set of tasking functionality permitted by this set of restrictions.
5894 @item Pragma Profile (Rational)
5895 @findex Rational compatibility mode
5896 @noindent
5897 The Rational profile is intended to facilitate porting legacy code that
5898 compiles with the Rational APEX compiler, even when the code includes non-
5899 conforming Ada constructs.  The profile enables the following three pragmas:
5901 @itemize @bullet
5902 @item pragma Implicit_Packing
5903 @item pragma Overriding_Renamings
5904 @item pragma Use_VADS_Size
5905 @end itemize
5907 @end itemize
5909 @node Pragma Profile_Warnings
5910 @unnumberedsec Pragma Profile_Warnings
5911 @findex Profile_Warnings
5912 @noindent
5913 Syntax:
5915 @smallexample @c ada
5916 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5917 @end smallexample
5919 @noindent
5920 This is an implementation-defined pragma that is similar in
5921 effect to @code{pragma Profile} except that instead of
5922 generating @code{Restrictions} pragmas, it generates
5923 @code{Restriction_Warnings} pragmas. The result is that
5924 violations of the profile generate warning messages instead
5925 of error messages.
5927 @node Pragma Propagate_Exceptions
5928 @unnumberedsec Pragma Propagate_Exceptions
5929 @cindex Interfacing to C++
5930 @findex Propagate_Exceptions
5931 @noindent
5932 Syntax:
5934 @smallexample @c ada
5935 pragma Propagate_Exceptions;
5936 @end smallexample
5938 @noindent
5939 This pragma is now obsolete and, other than generating a warning if warnings
5940 on obsolescent features are enabled, is ignored.
5941 It is retained for compatibility
5942 purposes. It used to be used in connection with optimization of
5943 a now-obsolete mechanism for implementation of exceptions.
5945 @node Pragma Provide_Shift_Operators
5946 @unnumberedsec Pragma Provide_Shift_Operators
5947 @cindex Shift operators
5948 @findex Provide_Shift_Operators
5949 @noindent
5950 Syntax:
5952 @smallexample @c ada
5953 pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
5954 @end smallexample
5956 @noindent
5957 This pragma can be applied to a first subtype local name that specifies
5958 either an unsigned or signed type. It has the effect of providing the
5959 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
5960 Rotate_Left and Rotate_Right) for the given type. It is similar to
5961 including the function declarations for these five operators, together
5962 with the pragma Import (Intrinsic, ...) statements.
5964 @node Pragma Psect_Object
5965 @unnumberedsec Pragma Psect_Object
5966 @findex Psect_Object
5967 @noindent
5968 Syntax:
5970 @smallexample @c ada
5971 pragma Psect_Object (
5972      [Internal =>] LOCAL_NAME,
5973   [, [External =>] EXTERNAL_SYMBOL]
5974   [, [Size     =>] EXTERNAL_SYMBOL]);
5976 EXTERNAL_SYMBOL ::=
5977   IDENTIFIER
5978 | static_string_EXPRESSION
5979 @end smallexample
5981 @noindent
5982 This pragma is identical in effect to pragma @code{Common_Object}.
5984 @node Pragma Pure_Function
5985 @unnumberedsec Pragma Pure_Function
5986 @findex Pure_Function
5987 @noindent
5988 Syntax:
5990 @smallexample @c ada
5991 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5992 @end smallexample
5994 @noindent
5995 This pragma appears in the same declarative part as a function
5996 declaration (or a set of function declarations if more than one
5997 overloaded declaration exists, in which case the pragma applies
5998 to all entities).  It specifies that the function @code{Entity} is
5999 to be considered pure for the purposes of code generation.  This means
6000 that the compiler can assume that there are no side effects, and
6001 in particular that two calls with identical arguments produce the
6002 same result.  It also means that the function can be used in an
6003 address clause.
6005 Note that, quite deliberately, there are no static checks to try
6006 to ensure that this promise is met, so @code{Pure_Function} can be used
6007 with functions that are conceptually pure, even if they do modify
6008 global variables.  For example, a square root function that is
6009 instrumented to count the number of times it is called is still
6010 conceptually pure, and can still be optimized, even though it
6011 modifies a global variable (the count).  Memo functions are another
6012 example (where a table of previous calls is kept and consulted to
6013 avoid re-computation).
6015 Note also that the normal rules excluding optimization of subprograms
6016 in pure units (when parameter types are descended from System.Address,
6017 or when the full view of a parameter type is limited), do not apply
6018 for the Pure_Function case. If you explicitly specify Pure_Function,
6019 the compiler may optimize away calls with identical arguments, and
6020 if that results in unexpected behavior, the proper action is not to
6021 use the pragma for subprograms that are not (conceptually) pure.
6023 @findex Pure
6024 Note: Most functions in a @code{Pure} package are automatically pure, and
6025 there is no need to use pragma @code{Pure_Function} for such functions.  One
6026 exception is any function that has at least one formal of type
6027 @code{System.Address} or a type derived from it.  Such functions are not
6028 considered pure by default, since the compiler assumes that the
6029 @code{Address} parameter may be functioning as a pointer and that the
6030 referenced data may change even if the address value does not.
6031 Similarly, imported functions are not considered to be pure by default,
6032 since there is no way of checking that they are in fact pure.  The use
6033 of pragma @code{Pure_Function} for such a function will override these default
6034 assumption, and cause the compiler to treat a designated subprogram as pure
6035 in these cases.
6037 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
6038 applies to the underlying renamed function.  This can be used to
6039 disambiguate cases of overloading where some but not all functions
6040 in a set of overloaded functions are to be designated as pure.
6042 If pragma @code{Pure_Function} is applied to a library level function, the
6043 function is also considered pure from an optimization point of view, but the
6044 unit is not a Pure unit in the categorization sense. So for example, a function
6045 thus marked is free to @code{with} non-pure units.
6047 @node Pragma Rational
6048 @unnumberedsec Pragma Rational
6049 @findex Rational
6050 @noindent
6051 Syntax:
6053 @smallexample @c ada
6054 pragma Rational;
6055 @end smallexample
6057 @noindent
6058 This pragma is considered obsolescent, but is retained for
6059 compatibility purposes. It is equivalent to:
6061 @smallexample @c ada
6062 pragma Profile (Rational);
6063 @end smallexample
6065 @node Pragma Ravenscar
6066 @unnumberedsec Pragma Ravenscar
6067 @findex Pragma Ravenscar
6068 @noindent
6069 Syntax:
6071 @smallexample @c ada
6072 pragma Ravenscar;
6073 @end smallexample
6075 @noindent
6076 This pragma is considered obsolescent, but is retained for
6077 compatibility purposes. It is equivalent to:
6079 @smallexample @c ada
6080 pragma Profile (Ravenscar);
6081 @end smallexample
6083 @noindent
6084 which is the preferred method of setting the @code{Ravenscar} profile.
6086 @node Pragma Refined_Depends
6087 @unnumberedsec Pragma Refined_Depends
6088 @findex Refined_Depends
6089 @noindent
6090 For the description of this pragma, see SPARK 2014 Reference Manual,
6091 section 6.1.5.
6093 @node Pragma Refined_Global
6094 @unnumberedsec Pragma Refined_Global
6095 @findex Refined_Global
6096 @noindent
6097 For the description of this pragma, see SPARK 2014 Reference Manual,
6098 section 6.1.4.
6100 @node Pragma Refined_Post
6101 @unnumberedsec Pragma Refined_Post
6102 @findex Refined_Post
6103 @noindent
6104 For the description of this pragma, see SPARK 2014 Reference Manual,
6105 section 7.2.7.
6107 @node Pragma Refined_State
6108 @unnumberedsec Pragma Refined_State
6109 @findex Refined_State
6110 @noindent
6111 For the description of this pragma, see SPARK 2014 Reference Manual,
6112 section 7.2.2.
6114 @node Pragma Relative_Deadline
6115 @unnumberedsec Pragma Relative_Deadline
6116 @findex Relative_Deadline
6117 @noindent
6118 Syntax:
6120 @smallexample @c ada
6121 pragma Relative_Deadline (time_span_EXPRESSION);
6122 @end smallexample
6124 @noindent
6125 This pragma is standard in Ada 2005, but is available in all earlier
6126 versions of Ada as an implementation-defined pragma.
6127 See Ada 2012 Reference Manual for details.
6129 @node Pragma Remote_Access_Type
6130 @unnumberedsec Pragma Remote_Access_Type
6131 @findex Remote_Access_Type
6132 @noindent
6133 Syntax:
6135 @smallexample @c ada
6136 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
6137 @end smallexample
6139 @noindent
6140 This pragma appears in the formal part of a generic declaration.
6141 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
6142 the use of a remote access to class-wide type as actual for a formal
6143 access type.
6145 When this pragma applies to a formal access type @code{Entity}, that
6146 type is treated as a remote access to class-wide type in the generic.
6147 It must be a formal general access type, and its designated type must
6148 be the class-wide type of a formal tagged limited private type from the
6149 same generic declaration.
6151 In the generic unit, the formal type is subject to all restrictions
6152 pertaining to remote access to class-wide types. At instantiation, the
6153 actual type must be a remote access to class-wide type.
6155 @node Pragma Restricted_Run_Time
6156 @unnumberedsec Pragma Restricted_Run_Time
6157 @findex Pragma Restricted_Run_Time
6158 @noindent
6159 Syntax:
6161 @smallexample @c ada
6162 pragma Restricted_Run_Time;
6163 @end smallexample
6165 @noindent
6166 This pragma is considered obsolescent, but is retained for
6167 compatibility purposes. It is equivalent to:
6169 @smallexample @c ada
6170 pragma Profile (Restricted);
6171 @end smallexample
6173 @noindent
6174 which is the preferred method of setting the restricted run time
6175 profile.
6177 @node Pragma Restriction_Warnings
6178 @unnumberedsec Pragma Restriction_Warnings
6179 @findex Restriction_Warnings
6180 @noindent
6181 Syntax:
6183 @smallexample @c ada
6184 pragma Restriction_Warnings
6185   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
6186 @end smallexample
6188 @noindent
6189 This pragma allows a series of restriction identifiers to be
6190 specified (the list of allowed identifiers is the same as for
6191 pragma @code{Restrictions}). For each of these identifiers
6192 the compiler checks for violations of the restriction, but
6193 generates a warning message rather than an error message
6194 if the restriction is violated.
6196 One use of this is in situations where you want to know
6197 about violations of a restriction, but you want to ignore some of
6198 these violations. Consider this example, where you want to set
6199 Ada_95 mode and enable style checks, but you want to know about
6200 any other use of implementation pragmas:
6202 @smallexample @c ada
6203 pragma Restriction_Warnings (No_Implementation_Pragmas);
6204 pragma Warnings (Off, "violation of*No_Implementation_Pragmas*");
6205 pragma Ada_95;
6206 pragma Style_Checks ("2bfhkM160");
6207 pragma Warnings (On, "violation of*No_Implementation_Pragmas*");
6208 @end smallexample
6210 @noindent
6211 By including the above lines in a configuration pragmas file,
6212 the Ada_95 and Style_Checks pragmas are accepted without
6213 generating a warning, but any other use of implementation
6214 defined pragmas will cause a warning to be generated.
6216 @node Pragma Reviewable
6217 @unnumberedsec Pragma Reviewable
6218 @findex Reviewable
6219 @noindent
6220 Syntax:
6222 @smallexample @c ada
6223 pragma Reviewable;
6224 @end smallexample
6226 @noindent
6227 This pragma is an RM-defined standard pragma, but has no effect on the
6228 program being compiled, or on the code generated for the program.
6230 To obtain the required output specified in RM H.3.1, the compiler must be
6231 run with various special switches as follows:
6233 @table @i
6235 @item Where compiler-generated run-time checks remain
6237 The switch @option{-gnatGL}
6238 @findex @option{-gnatGL}
6239 may be used to list the expanded code in pseudo-Ada form.
6240 Runtime checks show up in the listing either as explicit
6241 checks or operators marked with @{@} to indicate a check is present.
6243 @item An identification of known exceptions at compile time
6245 If the program is compiled with @option{-gnatwa},
6246 @findex @option{-gnatwa}
6247 the compiler warning messages will indicate all cases where the compiler
6248 detects that an exception is certain to occur at run time.
6250 @item Possible reads of uninitialized variables
6252 The compiler warns of many such cases, but its output is incomplete.
6253 @ifclear FSFEDITION
6254 The CodePeer analysis tool
6255 @findex CodePeer static analysis tool
6256 @end ifclear
6257 @ifset FSFEDITION
6258 A supplemental static analysis tool
6259 @end ifset
6260 may be used to obtain a comprehensive list of all
6261 possible points at which uninitialized data may be read.
6263 @item Where run-time support routines are implicitly invoked
6265 In the output from @option{-gnatGL},
6266 @findex @option{-gnatGL}
6267 run-time calls are explicitly listed as calls to the relevant
6268 run-time routine.
6270 @item Object code listing
6272 This may be obtained either by using the @option{-S} switch,
6273 @findex @option{-S}
6274 or the objdump utility.
6275 @findex objdump
6277 @item Constructs known to be erroneous at compile time
6279 These are identified by warnings issued by the compiler (use @option{-gnatwa}).
6280 @findex @option{-gnatwa}
6282 @item Stack usage information
6284 Static stack usage data (maximum per-subprogram) can be obtained via the
6285 @option{-fstack-usage} switch to the compiler.
6286 @findex @option{-fstack-usage}
6287 Dynamic stack usage data (per task) can be obtained via the @option{-u} switch
6288 to gnatbind
6289 @findex @option{-u}
6290 @ifclear FSFEDITION
6291 The gnatstack utility
6292 @findex gnatstack
6293 can be used to provide additional information on stack usage.
6294 @end ifclear
6296 @item Object code listing of entire partition
6298 This can be obtained by compiling the partition with @option{-S},
6299 @findex @option{-S}
6300 or by applying objdump
6301 @findex objdump
6302 to all the object files that are part of the partition.
6304 @item A description of the run-time model
6306 The full sources of the run-time are available, and the documentation of
6307 these routines describes how these run-time routines interface to the
6308 underlying operating system facilities.
6310 @item Control and data-flow information
6312 @ifclear FSFEDITION
6313 The CodePeer tool
6314 @findex CodePeer static analysis tool
6315 @end ifclear
6316 @ifset FSFEDITION
6317 A supplemental static analysis tool
6318 @end ifset
6319 may be used to obtain complete control and data-flow information, as well as
6320 comprehensive messages identifying possible problems based on this
6321 information.
6322 @end table
6324 @node Pragma Share_Generic
6325 @unnumberedsec Pragma Share_Generic
6326 @findex Share_Generic
6327 @noindent
6328 Syntax:
6330 @smallexample @c ada
6331 pragma Share_Generic (GNAME @{, GNAME@});
6333 GNAME ::= generic_unit_NAME | generic_instance_NAME
6334 @end smallexample
6336 @noindent
6337 This pragma is provided for compatibility with Dec Ada 83. It has
6338 no effect in @code{GNAT} (which does not implement shared generics), other
6339 than to check that the given names are all names of generic units or
6340 generic instances.
6342 @node Pragma Shared
6343 @unnumberedsec Pragma Shared
6344 @findex Shared
6346 @noindent
6347 This pragma is provided for compatibility with Ada 83. The syntax and
6348 semantics are identical to pragma Atomic.
6350 @node Pragma Short_Circuit_And_Or
6351 @unnumberedsec Pragma Short_Circuit_And_Or
6352 @findex Short_Circuit_And_Or
6353 @noindent
6354 Syntax:
6356 @smallexample @c ada
6357 pragma Short_Circuit_And_Or;
6358 @end smallexample
6360 @noindent
6361 This configuration pragma causes any occurrence of the AND operator applied to
6362 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
6363 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
6364 may be useful in the context of certification protocols requiring the use of
6365 short-circuited logical operators. If this configuration pragma occurs locally
6366 within the file being compiled, it applies only to the file being compiled.
6367 There is no requirement that all units in a partition use this option.
6369 @node Pragma Short_Descriptors
6370 @unnumberedsec Pragma Short_Descriptors
6371 @findex Short_Descriptors
6372 @noindent
6373 Syntax:
6375 @smallexample @c ada
6376 pragma Short_Descriptors
6377 @end smallexample
6379 @noindent
6380 This pragma is provided for compatibility with other Ada implementations. It
6381 is recognized but ignored by all current versions of GNAT.
6383 @node Pragma Simple_Storage_Pool_Type
6384 @unnumberedsec Pragma Simple_Storage_Pool_Type
6385 @findex Simple_Storage_Pool_Type
6386 @cindex Storage pool, simple
6387 @cindex Simple storage pool
6388 @noindent
6389 Syntax:
6391 @smallexample @c ada
6392 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
6393 @end smallexample
6395 @noindent
6396 A type can be established as a ``simple storage pool type'' by applying
6397 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
6398 A type named in the pragma must be a library-level immutably limited record
6399 type or limited tagged type declared immediately within a package declaration.
6400 The type can also be a limited private type whose full type is allowed as
6401 a simple storage pool type.
6403 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
6404 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
6405 are subtype conformant with the following subprogram declarations:
6407 @smallexample @c ada
6408 procedure Allocate
6409   (Pool                     : in out SSP;
6410    Storage_Address          : out System.Address;
6411    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6412    Alignment                : System.Storage_Elements.Storage_Count);
6414 procedure Deallocate
6415   (Pool : in out SSP;
6416    Storage_Address          : System.Address;
6417    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6418    Alignment                : System.Storage_Elements.Storage_Count);
6420 function Storage_Size (Pool : SSP)
6421   return System.Storage_Elements.Storage_Count;
6422 @end smallexample
6424 @noindent
6425 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
6426 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
6427 applying an unchecked deallocation has no effect other than to set its actual
6428 parameter to null. If @code{Storage_Size} is not declared, then the
6429 @code{Storage_Size} attribute applied to an access type associated with
6430 a pool object of type SSP returns zero. Additional operations can be declared
6431 for a simple storage pool type (such as for supporting a mark/release
6432 storage-management discipline).
6434 An object of a simple storage pool type can be associated with an access
6435 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
6437 @smallexample @c ada
6439 My_Pool : My_Simple_Storage_Pool_Type;
6441 type Acc is access My_Data_Type;
6443 for Acc'Simple_Storage_Pool use My_Pool;
6445 @end smallexample
6447 @noindent
6448 See attribute @code{Simple_Storage_Pool} for further details.
6450 @node Pragma Source_File_Name
6451 @unnumberedsec Pragma Source_File_Name
6452 @findex Source_File_Name
6453 @noindent
6454 Syntax:
6456 @smallexample @c ada
6457 pragma Source_File_Name (
6458   [Unit_Name   =>] unit_NAME,
6459   Spec_File_Name =>  STRING_LITERAL,
6460   [Index => INTEGER_LITERAL]);
6462 pragma Source_File_Name (
6463   [Unit_Name   =>] unit_NAME,
6464   Body_File_Name =>  STRING_LITERAL,
6465   [Index => INTEGER_LITERAL]);
6466 @end smallexample
6468 @noindent
6469 Use this to override the normal naming convention.  It is a configuration
6470 pragma, and so has the usual applicability of configuration pragmas
6471 (i.e.@: it applies to either an entire partition, or to all units in a
6472 compilation, or to a single unit, depending on how it is used.
6473 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
6474 the second argument is required, and indicates whether this is the file
6475 name for the spec or for the body.
6477 The optional Index argument should be used when a file contains multiple
6478 units, and when you do not want to use @code{gnatchop} to separate then
6479 into multiple files (which is the recommended procedure to limit the
6480 number of recompilations that are needed when some sources change).
6481 For instance, if the source file @file{source.ada} contains
6483 @smallexample @c ada
6484 package B is
6486 end B;
6488 with B;
6489 procedure A is
6490 begin
6491    ..
6492 end A;
6493 @end smallexample
6495 you could use the following configuration pragmas:
6497 @smallexample @c ada
6498 pragma Source_File_Name
6499   (B, Spec_File_Name => "source.ada", Index => 1);
6500 pragma Source_File_Name
6501   (A, Body_File_Name => "source.ada", Index => 2);
6502 @end smallexample
6504 Note that the @code{gnatname} utility can also be used to generate those
6505 configuration pragmas.
6507 Another form of the @code{Source_File_Name} pragma allows
6508 the specification of patterns defining alternative file naming schemes
6509 to apply to all files.
6511 @smallexample @c ada
6512 pragma Source_File_Name
6513   (  [Spec_File_Name  =>] STRING_LITERAL
6514    [,[Casing          =>] CASING_SPEC]
6515    [,[Dot_Replacement =>] STRING_LITERAL]);
6517 pragma Source_File_Name
6518   (  [Body_File_Name  =>] STRING_LITERAL
6519    [,[Casing          =>] CASING_SPEC]
6520    [,[Dot_Replacement =>] STRING_LITERAL]);
6522 pragma Source_File_Name
6523   (  [Subunit_File_Name =>] STRING_LITERAL
6524    [,[Casing            =>] CASING_SPEC]
6525    [,[Dot_Replacement   =>] STRING_LITERAL]);
6527 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
6528 @end smallexample
6530 @noindent
6531 The first argument is a pattern that contains a single asterisk indicating
6532 the point at which the unit name is to be inserted in the pattern string
6533 to form the file name.  The second argument is optional.  If present it
6534 specifies the casing of the unit name in the resulting file name string.
6535 The default is lower case.  Finally the third argument allows for systematic
6536 replacement of any dots in the unit name by the specified string literal.
6538 Note that Source_File_Name pragmas should not be used if you are using
6539 project files. The reason for this rule is that the project manager is not
6540 aware of these pragmas, and so other tools that use the projet file would not
6541 be aware of the intended naming conventions. If you are using project files,
6542 file naming is controlled by Source_File_Name_Project pragmas, which are
6543 usually supplied automatically by the project manager. A pragma
6544 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
6546 For more details on the use of the @code{Source_File_Name} pragma,
6547 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
6548 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
6549 User's Guide}.
6551 @node Pragma Source_File_Name_Project
6552 @unnumberedsec Pragma Source_File_Name_Project
6553 @findex Source_File_Name_Project
6554 @noindent
6556 This pragma has the same syntax and semantics as pragma Source_File_Name.
6557 It is only allowed as a stand alone configuration pragma.
6558 It cannot appear after a @ref{Pragma Source_File_Name}, and
6559 most importantly, once pragma Source_File_Name_Project appears,
6560 no further Source_File_Name pragmas are allowed.
6562 The intention is that Source_File_Name_Project pragmas are always
6563 generated by the Project Manager in a manner consistent with the naming
6564 specified in a project file, and when naming is controlled in this manner,
6565 it is not permissible to attempt to modify this naming scheme using
6566 Source_File_Name or Source_File_Name_Project pragmas (which would not be
6567 known to the project manager).
6569 @node Pragma Source_Reference
6570 @unnumberedsec Pragma Source_Reference
6571 @findex Source_Reference
6572 @noindent
6573 Syntax:
6575 @smallexample @c ada
6576 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
6577 @end smallexample
6579 @noindent
6580 This pragma must appear as the first line of a source file.
6581 @var{integer_literal} is the logical line number of the line following
6582 the pragma line (for use in error messages and debugging
6583 information).  @var{string_literal} is a static string constant that
6584 specifies the file name to be used in error messages and debugging
6585 information.  This is most notably used for the output of @code{gnatchop}
6586 with the @option{-r} switch, to make sure that the original unchopped
6587 source file is the one referred to.
6589 The second argument must be a string literal, it cannot be a static
6590 string expression other than a string literal.  This is because its value
6591 is needed for error messages issued by all phases of the compiler.
6593 @node Pragma SPARK_Mode
6594 @unnumberedsec Pragma SPARK_Mode
6595 @findex SPARK_Mode
6596 @noindent
6597 Syntax:
6599 @smallexample @c ada
6600 pragma SPARK_Mode [(On | Off)] ;
6601 @end smallexample
6603 @noindent
6604 In general a program can have some parts that are in SPARK 2014 (and
6605 follow all the rules in the SPARK Reference Manual), and some parts
6606 that are full Ada 2012.
6608 The SPARK_Mode pragma is used to identify which parts are in SPARK
6609 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
6610 be used in the following places:
6612 @itemize @bullet
6614 @item
6615 As a configuration pragma, in which case it sets the default mode for
6616 all units compiled with this pragma.
6618 @item
6619 Immediately following a library-level subprogram spec
6621 @item
6622 Immediately within a library-level package body
6624 @item
6625 Immediately following the @code{private} keyword of a library-level
6626 package spec
6628 @item
6629 Immediately following the @code{begin} keyword of a library-level
6630 package body
6632 @item
6633 Immediately within a library-level subprogram body
6635 @end itemize
6637 @noindent
6638 Normally a subprogram or package spec/body inherits the current mode
6639 that is active at the point it is declared. But this can be overridden
6640 by pragma within the spec or body as above.
6642 The basic consistency rule is that you can't turn SPARK_Mode back
6643 @code{On}, once you have explicitly (with a pragma) turned if
6644 @code{Off}. So the following rules apply:
6646 @noindent
6647 If a subprogram spec has SPARK_Mode @code{Off}, then the body must
6648 also have SPARK_Mode @code{Off}.
6650 @noindent
6651 For a package, we have four parts:
6653 @itemize
6654 @item
6655 the package public declarations
6656 @item
6657 the package private part
6658 @item
6659 the body of the package
6660 @item
6661 the elaboration code after @code{begin}
6662 @end itemize
6664 @noindent
6665 For a package, the rule is that if you explicitly turn SPARK_Mode
6666 @code{Off} for any part, then all the following parts must have
6667 SPARK_Mode @code{Off}. Note that this may require repeating a pragma
6668 SPARK_Mode (@code{Off}) in the body. For example, if we have a
6669 configuration pragma SPARK_Mode (@code{On}) that turns the mode on by
6670 default everywhere, and one particular package spec has pragma
6671 SPARK_Mode (@code{Off}), then that pragma will need to be repeated in
6672 the package body.
6674 @node Pragma Static_Elaboration_Desired
6675 @unnumberedsec Pragma Static_Elaboration_Desired
6676 @findex Static_Elaboration_Desired
6677 @noindent
6678 Syntax:
6680 @smallexample @c ada
6681 pragma Static_Elaboration_Desired;
6682 @end smallexample
6684 @noindent
6685 This pragma is used to indicate that the compiler should attempt to initialize
6686 statically the objects declared in the library unit to which the pragma applies,
6687 when these objects are initialized (explicitly or implicitly) by an aggregate.
6688 In the absence of this pragma, aggregates in object declarations are expanded
6689 into assignments and loops, even when the aggregate components are static
6690 constants. When the aggregate is present the compiler builds a static expression
6691 that requires no run-time code, so that the initialized object can be placed in
6692 read-only data space. If the components are not static, or the aggregate has
6693 more that 100 components, the compiler emits a warning that the pragma cannot
6694 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6695 construction of larger aggregates with static components that include an others
6696 choice.)
6698 @node Pragma Stream_Convert
6699 @unnumberedsec Pragma Stream_Convert
6700 @findex Stream_Convert
6701 @noindent
6702 Syntax:
6704 @smallexample @c ada
6705 pragma Stream_Convert (
6706   [Entity =>] type_LOCAL_NAME,
6707   [Read   =>] function_NAME,
6708   [Write  =>] function_NAME);
6709 @end smallexample
6711 @noindent
6712 This pragma provides an efficient way of providing user-defined stream
6713 attributes.  Not only is it simpler to use than specifying the attributes
6714 directly, but more importantly, it allows the specification to be made in such
6715 a way that the predefined unit Ada.Streams is not loaded unless it is actually
6716 needed (i.e. unless the stream attributes are actually used); the use of
6717 the Stream_Convert pragma adds no overhead at all, unless the stream
6718 attributes are actually used on the designated type.
6720 The first argument specifies the type for which stream functions are
6721 provided.  The second parameter provides a function used to read values
6722 of this type.  It must name a function whose argument type may be any
6723 subtype, and whose returned type must be the type given as the first
6724 argument to the pragma.
6726 The meaning of the @var{Read} parameter is that if a stream attribute directly
6727 or indirectly specifies reading of the type given as the first parameter,
6728 then a value of the type given as the argument to the Read function is
6729 read from the stream, and then the Read function is used to convert this
6730 to the required target type.
6732 Similarly the @var{Write} parameter specifies how to treat write attributes
6733 that directly or indirectly apply to the type given as the first parameter.
6734 It must have an input parameter of the type specified by the first parameter,
6735 and the return type must be the same as the input type of the Read function.
6736 The effect is to first call the Write function to convert to the given stream
6737 type, and then write the result type to the stream.
6739 The Read and Write functions must not be overloaded subprograms.  If necessary
6740 renamings can be supplied to meet this requirement.
6741 The usage of this attribute is best illustrated by a simple example, taken
6742 from the GNAT implementation of package Ada.Strings.Unbounded:
6744 @smallexample @c ada
6745 function To_Unbounded (S : String)
6746            return Unbounded_String
6747   renames To_Unbounded_String;
6749 pragma Stream_Convert
6750   (Unbounded_String, To_Unbounded, To_String);
6751 @end smallexample
6753 @noindent
6754 The specifications of the referenced functions, as given in the Ada
6755 Reference Manual are:
6757 @smallexample @c ada
6758 function To_Unbounded_String (Source : String)
6759   return Unbounded_String;
6761 function To_String (Source : Unbounded_String)
6762   return String;
6763 @end smallexample
6765 @noindent
6766 The effect is that if the value of an unbounded string is written to a stream,
6767 then the representation of the item in the stream is in the same format that
6768 would be used for @code{Standard.String'Output}, and this same representation
6769 is expected when a value of this type is read from the stream. Note that the
6770 value written always includes the bounds, even for Unbounded_String'Write,
6771 since Unbounded_String is not an array type.
6773 Note that the @code{Stream_Convert} pragma is not effective in the case of
6774 a derived type of a non-limited tagged type. If such a type is specified then
6775 the pragma is silently ignored, and the default implementation of the stream
6776 attributes is used instead.
6778 @node Pragma Style_Checks
6779 @unnumberedsec Pragma Style_Checks
6780 @findex Style_Checks
6781 @noindent
6782 Syntax:
6784 @smallexample @c ada
6785 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6786                      On | Off [, LOCAL_NAME]);
6787 @end smallexample
6789 @noindent
6790 This pragma is used in conjunction with compiler switches to control the
6791 built in style checking provided by GNAT@.  The compiler switches, if set,
6792 provide an initial setting for the switches, and this pragma may be used
6793 to modify these settings, or the settings may be provided entirely by
6794 the use of the pragma.  This pragma can be used anywhere that a pragma
6795 is legal, including use as a configuration pragma (including use in
6796 the @file{gnat.adc} file).
6798 The form with a string literal specifies which style options are to be
6799 activated.  These are additive, so they apply in addition to any previously
6800 set style check options.  The codes for the options are the same as those
6801 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6802 For example the following two methods can be used to enable
6803 layout checking:
6805 @itemize @bullet
6806 @item
6807 @smallexample @c ada
6808 pragma Style_Checks ("l");
6809 @end smallexample
6811 @item
6812 @smallexample
6813 gcc -c -gnatyl @dots{}
6814 @end smallexample
6815 @end itemize
6817 @noindent
6818 The form ALL_CHECKS activates all standard checks (its use is equivalent
6819 to the use of the @code{gnaty} switch with no options.  @xref{Top,
6820 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6821 @value{EDITION} User's Guide}, for details.)
6823 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6824 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6825 options (i.e. equivalent to -gnatyg).
6827 The forms with @code{Off} and @code{On}
6828 can be used to temporarily disable style checks
6829 as shown in the following example:
6831 @smallexample @c ada
6832 @iftex
6833 @leftskip=0cm
6834 @end iftex
6835 pragma Style_Checks ("k"); -- requires keywords in lower case
6836 pragma Style_Checks (Off); -- turn off style checks
6837 NULL;                      -- this will not generate an error message
6838 pragma Style_Checks (On);  -- turn style checks back on
6839 NULL;                      -- this will generate an error message
6840 @end smallexample
6842 @noindent
6843 Finally the two argument form is allowed only if the first argument is
6844 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
6845 for the specified entity, as shown in the following example:
6847 @smallexample @c ada
6848 @iftex
6849 @leftskip=0cm
6850 @end iftex
6851 pragma Style_Checks ("r"); -- require consistency of identifier casing
6852 Arg : Integer;
6853 Rf1 : Integer := ARG;      -- incorrect, wrong case
6854 pragma Style_Checks (Off, Arg);
6855 Rf2 : Integer := ARG;      -- OK, no error
6856 @end smallexample
6858 @node Pragma Subtitle
6859 @unnumberedsec Pragma Subtitle
6860 @findex Subtitle
6861 @noindent
6862 Syntax:
6864 @smallexample @c ada
6865 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6866 @end smallexample
6868 @noindent
6869 This pragma is recognized for compatibility with other Ada compilers
6870 but is ignored by GNAT@.
6872 @node Pragma Suppress
6873 @unnumberedsec Pragma Suppress
6874 @findex Suppress
6875 @noindent
6876 Syntax:
6878 @smallexample @c ada
6879 pragma Suppress (Identifier [, [On =>] Name]);
6880 @end smallexample
6882 @noindent
6883 This is a standard pragma, and supports all the check names required in
6884 the RM. It is included here because GNAT recognizes some additional check
6885 names that are implementation defined (as permitted by the RM):
6887 @itemize @bullet
6889 @item
6890 @code{Alignment_Check} can be used to suppress alignment checks
6891 on addresses used in address clauses. Such checks can also be suppressed
6892 by suppressing range checks, but the specific use of @code{Alignment_Check}
6893 allows suppression of alignment checks without suppressing other range checks.
6895 @item
6896 @code{Atomic_Synchronization} can be used to suppress the special memory
6897 synchronization instructions that are normally generated for access to
6898 @code{Atomic} variables to ensure correct synchronization between tasks
6899 that use such variables for synchronization purposes.
6901 @item
6902 @code{Duplicated_Tag_Check} Can be used to suppress the check that is generated
6903 for a duplicated tag value when a tagged type is declared.
6905 @item
6906 @code{Predicate_Check} can be used to control whether predicate checks are
6907 active. It is applicable only to predicates for which the policy is
6908 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6909 predicate is ignored or checked for the whole program, the use of
6910 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6911 predicate to be turned on and off at specific points in the program.
6913 @item
6914 @code{Validity_Check} can be used specifically to control validity checks.
6915 If @code{Suppress} is used to suppress validity checks, then no validity
6916 checks are performed, including those specified by the appropriate compiler
6917 switch or the @code{Validity_Checks} pragma.
6919 @item
6920 Additional check names previously introduced by use of the @code{Check_Name}
6921 pragma are also allowed.
6923 @end itemize
6925 @noindent
6926 Note that pragma Suppress gives the compiler permission to omit
6927 checks, but does not require the compiler to omit checks. The compiler
6928 will generate checks if they are essentially free, even when they are
6929 suppressed. In particular, if the compiler can prove that a certain
6930 check will necessarily fail, it will generate code to do an
6931 unconditional ``raise'', even if checks are suppressed. The compiler
6932 warns in this case.
6934 Of course, run-time checks are omitted whenever the compiler can prove
6935 that they will not fail, whether or not checks are suppressed.
6937 @node Pragma Suppress_All
6938 @unnumberedsec Pragma Suppress_All
6939 @findex Suppress_All
6940 @noindent
6941 Syntax:
6943 @smallexample @c ada
6944 pragma Suppress_All;
6945 @end smallexample
6947 @noindent
6948 This pragma can appear anywhere within a unit.
6949 The effect is to apply @code{Suppress (All_Checks)} to the unit
6950 in which it appears.  This pragma is implemented for compatibility with DEC
6951 Ada 83 usage where it appears at the end of a unit, and for compatibility
6952 with Rational Ada, where it appears as a program unit pragma.
6953 The use of the standard Ada pragma @code{Suppress (All_Checks)}
6954 as a normal configuration pragma is the preferred usage in GNAT@.
6956 @node Pragma Suppress_Debug_Info
6957 @unnumberedsec Pragma Suppress_Debug_Info
6958 @findex Suppress_Debug_Info
6959 @noindent
6960 Syntax:
6962 @smallexample @c ada
6963 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
6964 @end smallexample
6966 @noindent
6967 This pragma can be used to suppress generation of debug information
6968 for the specified entity. It is intended primarily for use in debugging
6969 the debugger, and navigating around debugger problems.
6971 @node Pragma Suppress_Exception_Locations
6972 @unnumberedsec Pragma Suppress_Exception_Locations
6973 @findex Suppress_Exception_Locations
6974 @noindent
6975 Syntax:
6977 @smallexample @c ada
6978 pragma Suppress_Exception_Locations;
6979 @end smallexample
6981 @noindent
6982 In normal mode, a raise statement for an exception by default generates
6983 an exception message giving the file name and line number for the location
6984 of the raise. This is useful for debugging and logging purposes, but this
6985 entails extra space for the strings for the messages. The configuration
6986 pragma @code{Suppress_Exception_Locations} can be used to suppress the
6987 generation of these strings, with the result that space is saved, but the
6988 exception message for such raises is null. This configuration pragma may
6989 appear in a global configuration pragma file, or in a specific unit as
6990 usual. It is not required that this pragma be used consistently within
6991 a partition, so it is fine to have some units within a partition compiled
6992 with this pragma and others compiled in normal mode without it.
6994 @node Pragma Suppress_Initialization
6995 @unnumberedsec Pragma Suppress_Initialization
6996 @findex Suppress_Initialization
6997 @cindex Suppressing initialization
6998 @cindex Initialization, suppression of
6999 @noindent
7000 Syntax:
7002 @smallexample @c ada
7003 pragma Suppress_Initialization ([Entity =>] subtype_Name);
7004 @end smallexample
7006 @noindent
7007 Here subtype_Name is the name introduced by a type declaration
7008 or subtype declaration.
7009 This pragma suppresses any implicit or explicit initialization
7010 for all variables of the given type or subtype,
7011 including initialization resulting from the use of pragmas
7012 Normalize_Scalars or Initialize_Scalars.
7014 This is considered a representation item, so it cannot be given after
7015 the type is frozen. It applies to all subsequent object declarations,
7016 and also any allocator that creates objects of the type.
7018 If the pragma is given for the first subtype, then it is considered
7019 to apply to the base type and all its subtypes. If the pragma is given
7020 for other than a first subtype, then it applies only to the given subtype.
7021 The pragma may not be given after the type is frozen.
7023 Note that this includes eliminating initialization of discriminants
7024 for discriminated types, and tags for tagged types. In these cases,
7025 you will have to use some non-portable mechanism (e.g. address
7026 overlays or unchecked conversion) to achieve required initialization
7027 of these fields before accessing any object of the corresponding type.
7029 @node Pragma Task_Name
7030 @unnumberedsec Pragma Task_Name
7031 @findex Task_Name
7032 @noindent
7033 Syntax
7035 @smallexample @c ada
7036 pragma Task_Name (string_EXPRESSION);
7037 @end smallexample
7039 @noindent
7040 This pragma appears within a task definition (like pragma
7041 @code{Priority}) and applies to the task in which it appears.  The
7042 argument must be of type String, and provides a name to be used for
7043 the task instance when the task is created.  Note that this expression
7044 is not required to be static, and in particular, it can contain
7045 references to task discriminants.  This facility can be used to
7046 provide different names for different tasks as they are created,
7047 as illustrated in the example below.
7049 The task name is recorded internally in the run-time structures
7050 and is accessible to tools like the debugger.  In addition the
7051 routine @code{Ada.Task_Identification.Image} will return this
7052 string, with a unique task address appended.
7054 @smallexample @c ada
7055 --  Example of the use of pragma Task_Name
7057 with Ada.Task_Identification;
7058 use Ada.Task_Identification;
7059 with Text_IO; use Text_IO;
7060 procedure t3 is
7062    type Astring is access String;
7064    task type Task_Typ (Name : access String) is
7065       pragma Task_Name (Name.all);
7066    end Task_Typ;
7068    task body Task_Typ is
7069       Nam : constant String := Image (Current_Task);
7070    begin
7071       Put_Line ("-->" & Nam (1 .. 14) & "<--");
7072    end Task_Typ;
7074    type Ptr_Task is access Task_Typ;
7075    Task_Var : Ptr_Task;
7077 begin
7078    Task_Var :=
7079      new Task_Typ (new String'("This is task 1"));
7080    Task_Var :=
7081      new Task_Typ (new String'("This is task 2"));
7082 end;
7083 @end smallexample
7085 @node Pragma Task_Storage
7086 @unnumberedsec Pragma Task_Storage
7087 @findex Task_Storage
7088 Syntax:
7090 @smallexample @c ada
7091 pragma Task_Storage (
7092   [Task_Type =>] LOCAL_NAME,
7093   [Top_Guard =>] static_integer_EXPRESSION);
7094 @end smallexample
7096 @noindent
7097 This pragma specifies the length of the guard area for tasks.  The guard
7098 area is an additional storage area allocated to a task.  A value of zero
7099 means that either no guard area is created or a minimal guard area is
7100 created, depending on the target.  This pragma can appear anywhere a
7101 @code{Storage_Size} attribute definition clause is allowed for a task
7102 type.
7104 @node Pragma Test_Case
7105 @unnumberedsec Pragma Test_Case
7106 @cindex Test cases
7107 @findex Test_Case
7108 @noindent
7109 Syntax:
7111 @smallexample @c ada
7112 pragma Test_Case (
7113    [Name     =>] static_string_Expression
7114   ,[Mode     =>] (Nominal | Robustness)
7115  [, Requires =>  Boolean_Expression]
7116  [, Ensures  =>  Boolean_Expression]);
7117 @end smallexample
7119 @noindent
7120 The @code{Test_Case} pragma allows defining fine-grain specifications
7121 for use by testing tools.
7122 The compiler checks the validity of the @code{Test_Case} pragma, but its
7123 presence does not lead to any modification of the code generated by the
7124 compiler.
7126 @code{Test_Case} pragmas may only appear immediately following the
7127 (separate) declaration of a subprogram in a package declaration, inside
7128 a package spec unit. Only other pragmas may intervene (that is appear
7129 between the subprogram declaration and a test case).
7131 The compiler checks that boolean expressions given in @code{Requires} and
7132 @code{Ensures} are valid, where the rules for @code{Requires} are the
7133 same as the rule for an expression in @code{Precondition} and the rules
7134 for @code{Ensures} are the same as the rule for an expression in
7135 @code{Postcondition}. In particular, attributes @code{'Old} and
7136 @code{'Result} can only be used within the @code{Ensures}
7137 expression. The following is an example of use within a package spec:
7139 @smallexample @c ada
7140 package Math_Functions is
7141    ...
7142    function Sqrt (Arg : Float) return Float;
7143    pragma Test_Case (Name     => "Test 1",
7144                      Mode     => Nominal,
7145                      Requires => Arg < 10000,
7146                      Ensures  => Sqrt'Result < 10);
7147    ...
7148 end Math_Functions;
7149 @end smallexample
7151 @noindent
7152 The meaning of a test case is that there is at least one context where
7153 @code{Requires} holds such that, if the associated subprogram is executed in
7154 that context, then @code{Ensures} holds when the subprogram returns.
7155 Mode @code{Nominal} indicates that the input context should also satisfy the
7156 precondition of the subprogram, and the output context should also satisfy its
7157 postcondition. Mode @code{Robustness} indicates that the precondition and
7158 postcondition of the subprogram should be ignored for this test case.
7160 @node Pragma Thread_Local_Storage
7161 @unnumberedsec Pragma Thread_Local_Storage
7162 @findex Thread_Local_Storage
7163 @cindex Task specific storage
7164 @cindex TLS (Thread Local Storage)
7165 @cindex Task_Attributes
7166 Syntax:
7168 @smallexample @c ada
7169 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
7170 @end smallexample
7172 @noindent
7173 This pragma specifies that the specified entity, which must be
7174 a variable declared in a library level package, is to be marked as
7175 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
7176 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
7177 (and hence each Ada task) to see a distinct copy of the variable.
7179 The variable may not have default initialization, and if there is
7180 an explicit initialization, it must be either @code{null} for an
7181 access variable, or a static expression for a scalar variable.
7182 This provides a low level mechanism similar to that provided by
7183 the @code{Ada.Task_Attributes} package, but much more efficient
7184 and is also useful in writing interface code that will interact
7185 with foreign threads.
7187 If this pragma is used on a system where @code{TLS} is not supported,
7188 then an error message will be generated and the program will be rejected.
7190 @node Pragma Time_Slice
7191 @unnumberedsec Pragma Time_Slice
7192 @findex Time_Slice
7193 @noindent
7194 Syntax:
7196 @smallexample @c ada
7197 pragma Time_Slice (static_duration_EXPRESSION);
7198 @end smallexample
7200 @noindent
7201 For implementations of GNAT on operating systems where it is possible
7202 to supply a time slice value, this pragma may be used for this purpose.
7203 It is ignored if it is used in a system that does not allow this control,
7204 or if it appears in other than the main program unit.
7205 @cindex OpenVMS
7206 Note that the effect of this pragma is identical to the effect of the
7207 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
7209 @node Pragma Title
7210 @unnumberedsec Pragma Title
7211 @findex Title
7212 @noindent
7213 Syntax:
7215 @smallexample @c ada
7216 pragma Title (TITLING_OPTION [, TITLING OPTION]);
7218 TITLING_OPTION ::=
7219   [Title    =>] STRING_LITERAL,
7220 | [Subtitle =>] STRING_LITERAL
7221 @end smallexample
7223 @noindent
7224 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
7225 pragma used in DEC Ada 83 implementations to provide a title and/or
7226 subtitle for the program listing.  The program listing generated by GNAT
7227 does not have titles or subtitles.
7229 Unlike other pragmas, the full flexibility of named notation is allowed
7230 for this pragma, i.e.@: the parameters may be given in any order if named
7231 notation is used, and named and positional notation can be mixed
7232 following the normal rules for procedure calls in Ada.
7234 @node Pragma Type_Invariant
7235 @unnumberedsec Pragma Type_Invariant
7236 @findex Invariant
7237 @findex Type_Invariant pragma
7238 @noindent
7239 Syntax:
7241 @smallexample @c ada
7242 pragma Type_Invariant
7243   ([Entity =>] type_LOCAL_NAME,
7244    [Check  =>] EXPRESSION);
7245 @end smallexample
7247 @noindent
7248 The @code{Type_Invariant} pragma is intended to be an exact
7249 replacement for the language-defined @code{Type_Invariant}
7250 aspect, and shares its restrictions and semantics. It differs
7251 from the language defined @code{Invariant} pragma in that it
7252 does not permit a string parameter, and it is
7253 controlled by the assertion identifier @code{Type_Invariant}
7254 rather than @code{Invariant}.
7256 @node Pragma Type_Invariant_Class
7257 @unnumberedsec Pragma Type_Invariant_Class
7258 @findex Invariant
7259 @findex Type_Invariant_Class pragma
7260 @noindent
7261 Syntax:
7263 @smallexample @c ada
7264 pragma Type_Invariant_Class
7265   ([Entity =>] type_LOCAL_NAME,
7266    [Check  =>] EXPRESSION);
7267 @end smallexample
7269 @noindent
7270 The @code{Type_Invariant_Class} pragma is intended to be an exact
7271 replacement for the language-defined @code{Type_Invariant'Class}
7272 aspect, and shares its restrictions and semantics.
7274 Note: This pragma is called @code{Type_Invariant_Class} rather than
7275 @code{Type_Invariant'Class} because the latter would not be strictly
7276 conforming to the allowed syntax for pragmas. The motivation
7277 for providing pragmas equivalent to the aspects is to allow a program
7278 to be written using the pragmas, and then compiled if necessary
7279 using an Ada compiler that does not recognize the pragmas or
7280 aspects, but is prepared to ignore the pragmas. The assertion
7281 policy that controls this pragma is @code{Type_Invariant'Class},
7282 not @code{Type_Invariant_Class}.
7284 @node Pragma Unchecked_Union
7285 @unnumberedsec Pragma Unchecked_Union
7286 @cindex Unions in C
7287 @findex Unchecked_Union
7288 @noindent
7289 Syntax:
7291 @smallexample @c ada
7292 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
7293 @end smallexample
7295 @noindent
7296 This pragma is used to specify a representation of a record type that is
7297 equivalent to a C union. It was introduced as a GNAT implementation defined
7298 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
7299 pragma, making it language defined, and GNAT fully implements this extended
7300 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
7301 details, consult the Ada 2012 Reference Manual, section B.3.3.
7303 @node Pragma Unevaluated_Use_Of_Old
7304 @unnumberedsec Pragma Unevaluated_Use_Of_Old
7305 @cindex Attribute Old
7306 @cindex Attribute Loop_Entry
7307 @cindex Unevaluated_Use_Of_Old
7308 @findex Unevaluated_Use_Of_Old
7309 @noindent
7310 Syntax:
7312 @smallexample @c ada
7313 pragma Unevaluated_Use_Of_Old (Error | Warn | Allow);
7314 @end smallexample
7316 @noindent
7317 This pragma controls the processing of attributes Old and Loop_Entry.
7318 If either of these attributes is used in a potentially unevaluated
7319 expression  (e.g. the then or else parts of an if expression), then
7320 normally this usage is considered illegal if the prefix of the attribute
7321 is other than an entity name. The language requires this
7322 behavior for Old, and GNAT copies the same rule for Loop_Entry.
7324 The reason for this rule is that otherwise, we can have a situation
7325 where we save the Old value, and this results in an exception, even
7326 though we might not evaluate the attribute. Consider this example:
7328 @smallexample @c ada
7329 package UnevalOld is
7330    K : Character;
7331    procedure U (A : String; C : Boolean)  -- ERROR
7332      with Post => (if C then A(1)'Old = K else True);
7333 end;
7334 @end smallexample
7336 @noindent
7337 If procedure U is called with a string with a lower bound of 2, and
7338 C false, then an exception would be raised trying to evaluate A(1)
7339 on entry even though the value would not be actually used.
7341 Although the rule guarantees against this possibility, it is sometimes
7342 too restrictive. For example if we know that the string has a lower
7343 bound of 1, then we will never raise an exception.
7344 The pragma @code{Unevaluated_Use_Of_Old} can be
7345 used to modify this behavior. If the argument is @code{Error} then an
7346 error is given (this is the default RM behavior). If the argument is
7347 @code{Warn} then the usage is allowed as legal but with a warning
7348 that an exception might be raised. If the argument is @code{Allow}
7349 then the usage is allowed as legal without generating a warning.
7351 This pragma may appear as a configuration pragma, or in a declarative
7352 part or package specification. In the latter case it applies to
7353 uses up to the end of the corresponding statement sequence or
7354 sequence of package declarations.
7356 @node Pragma Unimplemented_Unit
7357 @unnumberedsec Pragma Unimplemented_Unit
7358 @findex Unimplemented_Unit
7359 @noindent
7360 Syntax:
7362 @smallexample @c ada
7363 pragma Unimplemented_Unit;
7364 @end smallexample
7366 @noindent
7367 If this pragma occurs in a unit that is processed by the compiler, GNAT
7368 aborts with the message @samp{@var{xxx} not implemented}, where
7369 @var{xxx} is the name of the current compilation unit.  This pragma is
7370 intended to allow the compiler to handle unimplemented library units in
7371 a clean manner.
7373 The abort only happens if code is being generated.  Thus you can use
7374 specs of unimplemented packages in syntax or semantic checking mode.
7376 @node Pragma Universal_Aliasing
7377 @unnumberedsec Pragma Universal_Aliasing
7378 @findex Universal_Aliasing
7379 @noindent
7380 Syntax:
7382 @smallexample @c ada
7383 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
7384 @end smallexample
7386 @noindent
7387 @var{type_LOCAL_NAME} must refer to a type declaration in the current
7388 declarative part.  The effect is to inhibit strict type-based aliasing
7389 optimization for the given type.  In other words, the effect is as though
7390 access types designating this type were subject to pragma No_Strict_Aliasing.
7391 For a detailed description of the strict aliasing optimization, and the
7392 situations in which it must be suppressed, @xref{Optimization and Strict
7393 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
7395 @node Pragma Universal_Data
7396 @unnumberedsec Pragma Universal_Data
7397 @findex Universal_Data
7398 @noindent
7399 Syntax:
7401 @smallexample @c ada
7402 pragma Universal_Data [(library_unit_Name)];
7403 @end smallexample
7405 @noindent
7406 This pragma is supported only for the AAMP target and is ignored for
7407 other targets. The pragma specifies that all library-level objects
7408 (Counter 0 data) associated with the library unit are to be accessed
7409 and updated using universal addressing (24-bit addresses for AAMP5)
7410 rather than the default of 16-bit Data Environment (DENV) addressing.
7411 Use of this pragma will generally result in less efficient code for
7412 references to global data associated with the library unit, but
7413 allows such data to be located anywhere in memory. This pragma is
7414 a library unit pragma, but can also be used as a configuration pragma
7415 (including use in the @file{gnat.adc} file). The functionality
7416 of this pragma is also available by applying the -univ switch on the
7417 compilations of units where universal addressing of the data is desired.
7419 @node Pragma Unmodified
7420 @unnumberedsec Pragma Unmodified
7421 @findex Unmodified
7422 @cindex Warnings, unmodified
7423 @noindent
7424 Syntax:
7426 @smallexample @c ada
7427 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
7428 @end smallexample
7430 @noindent
7431 This pragma signals that the assignable entities (variables,
7432 @code{out} parameters, @code{in out} parameters) whose names are listed are
7433 deliberately not assigned in the current source unit. This
7434 suppresses warnings about the
7435 entities being referenced but not assigned, and in addition a warning will be
7436 generated if one of these entities is in fact assigned in the
7437 same unit as the pragma (or in the corresponding body, or one
7438 of its subunits).
7440 This is particularly useful for clearly signaling that a particular
7441 parameter is not modified, even though the spec suggests that it might
7444 For the variable case, warnings are never given for unreferenced variables
7445 whose name contains one of the substrings
7446 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7447 are typically to be used in cases where such warnings are expected.
7448 Thus it is never necessary to use @code{pragma Unmodified} for such
7449 variables, though it is harmless to do so.
7451 @node Pragma Unreferenced
7452 @unnumberedsec Pragma Unreferenced
7453 @findex Unreferenced
7454 @cindex Warnings, unreferenced
7455 @noindent
7456 Syntax:
7458 @smallexample @c ada
7459 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
7460 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
7461 @end smallexample
7463 @noindent
7464 This pragma signals that the entities whose names are listed are
7465 deliberately not referenced in the current source unit after the
7466 occurrence of the pragma. This
7467 suppresses warnings about the
7468 entities being unreferenced, and in addition a warning will be
7469 generated if one of these entities is in fact subsequently referenced in the
7470 same unit as the pragma (or in the corresponding body, or one
7471 of its subunits).
7473 This is particularly useful for clearly signaling that a particular
7474 parameter is not referenced in some particular subprogram implementation
7475 and that this is deliberate. It can also be useful in the case of
7476 objects declared only for their initialization or finalization side
7477 effects.
7479 If @code{LOCAL_NAME} identifies more than one matching homonym in the
7480 current scope, then the entity most recently declared is the one to which
7481 the pragma applies. Note that in the case of accept formals, the pragma
7482 Unreferenced may appear immediately after the keyword @code{do} which
7483 allows the indication of whether or not accept formals are referenced
7484 or not to be given individually for each accept statement.
7486 The left hand side of an assignment does not count as a reference for the
7487 purpose of this pragma. Thus it is fine to assign to an entity for which
7488 pragma Unreferenced is given.
7490 Note that if a warning is desired for all calls to a given subprogram,
7491 regardless of whether they occur in the same unit as the subprogram
7492 declaration, then this pragma should not be used (calls from another
7493 unit would not be flagged); pragma Obsolescent can be used instead
7494 for this purpose, see @xref{Pragma Obsolescent}.
7496 The second form of pragma @code{Unreferenced} is used within a context
7497 clause. In this case the arguments must be unit names of units previously
7498 mentioned in @code{with} clauses (similar to the usage of pragma
7499 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
7500 units and unreferenced entities within these units.
7502 For the variable case, warnings are never given for unreferenced variables
7503 whose name contains one of the substrings
7504 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7505 are typically to be used in cases where such warnings are expected.
7506 Thus it is never necessary to use @code{pragma Unreferenced} for such
7507 variables, though it is harmless to do so.
7509 @node Pragma Unreferenced_Objects
7510 @unnumberedsec Pragma Unreferenced_Objects
7511 @findex Unreferenced_Objects
7512 @cindex Warnings, unreferenced
7513 @noindent
7514 Syntax:
7516 @smallexample @c ada
7517 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
7518 @end smallexample
7520 @noindent
7521 This pragma signals that for the types or subtypes whose names are
7522 listed, objects which are declared with one of these types or subtypes may
7523 not be referenced, and if no references appear, no warnings are given.
7525 This is particularly useful for objects which are declared solely for their
7526 initialization and finalization effect. Such variables are sometimes referred
7527 to as RAII variables (Resource Acquisition Is Initialization). Using this
7528 pragma on the relevant type (most typically a limited controlled type), the
7529 compiler will automatically suppress unwanted warnings about these variables
7530 not being referenced.
7532 @node Pragma Unreserve_All_Interrupts
7533 @unnumberedsec Pragma Unreserve_All_Interrupts
7534 @findex Unreserve_All_Interrupts
7535 @noindent
7536 Syntax:
7538 @smallexample @c ada
7539 pragma Unreserve_All_Interrupts;
7540 @end smallexample
7542 @noindent
7543 Normally certain interrupts are reserved to the implementation.  Any attempt
7544 to attach an interrupt causes Program_Error to be raised, as described in
7545 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
7546 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
7547 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
7548 interrupt execution.
7550 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
7551 a program, then all such interrupts are unreserved.  This allows the
7552 program to handle these interrupts, but disables their standard
7553 functions.  For example, if this pragma is used, then pressing
7554 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
7555 a program can then handle the @code{SIGINT} interrupt as it chooses.
7557 For a full list of the interrupts handled in a specific implementation,
7558 see the source code for the spec of @code{Ada.Interrupts.Names} in
7559 file @file{a-intnam.ads}.  This is a target dependent file that contains the
7560 list of interrupts recognized for a given target.  The documentation in
7561 this file also specifies what interrupts are affected by the use of
7562 the @code{Unreserve_All_Interrupts} pragma.
7564 For a more general facility for controlling what interrupts can be
7565 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
7566 of the @code{Unreserve_All_Interrupts} pragma.
7568 @node Pragma Unsuppress
7569 @unnumberedsec Pragma Unsuppress
7570 @findex Unsuppress
7571 @noindent
7572 Syntax:
7574 @smallexample @c ada
7575 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
7576 @end smallexample
7578 @noindent
7579 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
7580 there is no corresponding pragma @code{Suppress} in effect, it has no
7581 effect.  The range of the effect is the same as for pragma
7582 @code{Suppress}.  The meaning of the arguments is identical to that used
7583 in pragma @code{Suppress}.
7585 One important application is to ensure that checks are on in cases where
7586 code depends on the checks for its correct functioning, so that the code
7587 will compile correctly even if the compiler switches are set to suppress
7588 checks. For example, in a program that depends on external names of tagged
7589 types and wants to ensure that the duplicated tag check occurs even if all
7590 run-time checks are suppressed by a compiler switch, the following
7591 configuration pragma will ensure this test is not suppressed:
7593 @smallexample @c ada
7594 pragma Unsuppress (Duplicated_Tag_Check);
7595 @end smallexample
7597 @noindent
7598 This pragma is standard in Ada 2005. It is available in all earlier versions
7599 of Ada as an implementation-defined pragma.
7601 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
7602 a number of implementation-defined check names. See description of pragma
7603 @code{Suppress} for full details.
7605 @node Pragma Use_VADS_Size
7606 @unnumberedsec Pragma Use_VADS_Size
7607 @cindex @code{Size}, VADS compatibility
7608 @cindex Rational profile
7609 @findex Use_VADS_Size
7610 @noindent
7611 Syntax:
7613 @smallexample @c ada
7614 pragma Use_VADS_Size;
7615 @end smallexample
7617 @noindent
7618 This is a configuration pragma.  In a unit to which it applies, any use
7619 of the 'Size attribute is automatically interpreted as a use of the
7620 'VADS_Size attribute.  Note that this may result in incorrect semantic
7621 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
7622 the handling of existing code which depends on the interpretation of Size
7623 as implemented in the VADS compiler.  See description of the VADS_Size
7624 attribute for further details.
7626 @node Pragma Validity_Checks
7627 @unnumberedsec Pragma Validity_Checks
7628 @findex Validity_Checks
7629 @noindent
7630 Syntax:
7632 @smallexample @c ada
7633 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
7634 @end smallexample
7636 @noindent
7637 This pragma is used in conjunction with compiler switches to control the
7638 built-in validity checking provided by GNAT@.  The compiler switches, if set
7639 provide an initial setting for the switches, and this pragma may be used
7640 to modify these settings, or the settings may be provided entirely by
7641 the use of the pragma.  This pragma can be used anywhere that a pragma
7642 is legal, including use as a configuration pragma (including use in
7643 the @file{gnat.adc} file).
7645 The form with a string literal specifies which validity options are to be
7646 activated.  The validity checks are first set to include only the default
7647 reference manual settings, and then a string of letters in the string
7648 specifies the exact set of options required.  The form of this string
7649 is exactly as described for the @option{-gnatVx} compiler switch (see the
7650 @value{EDITION} User's Guide for details).  For example the following two
7651 methods can be used to enable validity checking for mode @code{in} and
7652 @code{in out} subprogram parameters:
7654 @itemize @bullet
7655 @item
7656 @smallexample @c ada
7657 pragma Validity_Checks ("im");
7658 @end smallexample
7660 @item
7661 @smallexample
7662 gcc -c -gnatVim @dots{}
7663 @end smallexample
7664 @end itemize
7666 @noindent
7667 The form ALL_CHECKS activates all standard checks (its use is equivalent
7668 to the use of the @code{gnatva} switch.
7670 The forms with @code{Off} and @code{On}
7671 can be used to temporarily disable validity checks
7672 as shown in the following example:
7674 @smallexample @c ada
7675 @iftex
7676 @leftskip=0cm
7677 @end iftex
7678 pragma Validity_Checks ("c"); -- validity checks for copies
7679 pragma Validity_Checks (Off); -- turn off validity checks
7680 A := B;                       -- B will not be validity checked
7681 pragma Validity_Checks (On);  -- turn validity checks back on
7682 A := C;                       -- C will be validity checked
7683 @end smallexample
7685 @node Pragma Volatile
7686 @unnumberedsec Pragma Volatile
7687 @findex Volatile
7688 @noindent
7689 Syntax:
7691 @smallexample @c ada
7692 pragma Volatile (LOCAL_NAME);
7693 @end smallexample
7695 @noindent
7696 This pragma is defined by the Ada Reference Manual, and the GNAT
7697 implementation is fully conformant with this definition.  The reason it
7698 is mentioned in this section is that a pragma of the same name was supplied
7699 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
7700 implementation of pragma Volatile is upwards compatible with the
7701 implementation in DEC Ada 83.
7703 @node Pragma Warning_As_Error
7704 @unnumberedsec Pragma Warning_As_Error
7705 @findex Warning_As_Error
7706 @noindent
7707 Syntax:
7709 @smallexample @c ada
7710 pragma Warning_As_Error (static_string_EXPRESSION);
7711 @end smallexample
7713 @noindent
7714 This configuration pragma allows the programmer to specify a set
7715 of warnings that will be treated as errors. Any warning which
7716 matches the pattern given by the pragma argument will be treated
7717 as an error. This gives much more precise control that -gnatwe
7718 which treats all warnings as errors.
7720 The pattern may contain asterisks, which match zero or more characters in
7721 the message. For example, you can use
7722 @code{pragma Warning_As_Error ("bits of*unused")} to treat the warning
7723 message @code{warning: 960 bits of "a" unused} as an error. No other regular
7724 expression notations are permitted. All characters other than asterisk in
7725 these three specific cases are treated as literal characters in the match.
7726 The match is case insensitive, for example XYZ matches xyz.
7728 Note that the pattern matches if it occurs anywhere within the warning
7729 message string (it is not necessary to put an asterisk at the start and
7730 the end of the message, since this is implied).
7732 Another possibility for the static_string_EXPRESSION which works whether
7733 or not error tags are enabled (@option{-gnatw.d}) is to use the
7734 @option{-gnatw} tag string, enclosed in brackets,
7735 as shown in the example below, to treat a class of warnings as errors.
7737 The above use of patterns to match the message applies only to warning
7738 messages generated by the front end. This pragma can also be applied to
7739 warnings provided by the back end and mentioned in @ref{Pragma Warnings}.
7740 By using a single full @option{-Wxxx} switch in the pragma, such warnings
7741 can also be treated as errors.
7743 The pragma can appear either in a global configuration pragma file
7744 (e.g. @file{gnat.adc}), or at the start of a file. Given a global
7745 configuration pragma file containing:
7747 @smallexample @c ada
7748 pragma Warning_As_Error ("[-gnatwj]");
7749 @end smallexample
7751 @noindent
7752 which will treat all obsolescent feature warnings as errors, the
7753 following program compiles as shown (compile options here are
7754 @option{-gnatwa.d -gnatl -gnatj55}).
7756 @smallexample @c ada
7757      1. pragma Warning_As_Error ("*never assigned*");
7758      2. function Warnerr return String is
7759      3.    X : Integer;
7760            |
7761         >>> error: variable "X" is never read and
7762             never assigned [-gnatwv] [warning-as-error]
7764      4.    Y : Integer;
7765            |
7766         >>> warning: variable "Y" is assigned but
7767             never read [-gnatwu]
7769      5. begin
7770      6.    Y := 0;
7771      7.    return %ABC%;
7772                   |
7773         >>> error: use of "%" is an obsolescent
7774             feature (RM J.2(4)), use """ instead
7775             [-gnatwj] [warning-as-error]
7777      8. end;
7779  8 lines: No errors, 3 warnings (2 treated as errors)
7780 @end smallexample
7782 @noindent
7783 Note that this pragma does not affect the set of warnings issued in
7784 any way, it merely changes the effect of a matching warning if one
7785 is produced as a result of other warnings options. As shown in this
7786 example, if the pragma results in a warning being treated as an error,
7787 the tag is changed from "warning:" to "error:" and the string
7788 "[warning-as-error]" is appended to the end of the message.
7790 @node Pragma Warnings
7791 @unnumberedsec Pragma Warnings
7792 @findex Warnings
7793 @noindent
7794 Syntax:
7796 @smallexample @c ada
7797 pragma Warnings (On | Off [,REASON]);
7798 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
7799 pragma Warnings (static_string_EXPRESSION [,REASON]);
7800 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
7802 REASON ::= Reason => STRING_LITERAL @{& STRING_LITERAL@}
7803 @end smallexample
7805 @noindent
7806 Normally warnings are enabled, with the output being controlled by
7807 the command line switch.  Warnings (@code{Off}) turns off generation of
7808 warnings until a Warnings (@code{On}) is encountered or the end of the
7809 current unit.  If generation of warnings is turned off using this
7810 pragma, then some or all of the warning messages are suppressed,
7811 regardless of the setting of the command line switches.
7813 The @code{Reason} parameter may optionally appear as the last argument
7814 in any of the forms of this pragma. It is intended purely for the
7815 purposes of documenting the reason for the @code{Warnings} pragma.
7816 The compiler will check that the argument is a static string but
7817 otherwise ignore this argument. Other tools may provide specialized
7818 processing for this string.
7820 The form with a single argument (or two arguments if Reason present),
7821 where the first argument is @code{ON} or @code{OFF}
7822 may be used as a configuration pragma.
7824 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
7825 the specified entity.  This suppression is effective from the point where
7826 it occurs till the end of the extended scope of the variable (similar to
7827 the scope of @code{Suppress}). This form cannot be used as a configuration
7828 pragma.
7830 The form with a single static_string_EXPRESSION argument (and possible
7831 reason) provides more precise
7832 control over which warnings are active. The string is a list of letters
7833 specifying which warnings are to be activated and which deactivated. The
7834 code for these letters is the same as the string used in the command
7835 line switch controlling warnings. For a brief summary, use the gnatmake
7836 command with no arguments, which will generate usage information containing
7837 the list of warnings switches supported. For
7838 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
7839 User's Guide}. This form can also be used as a configuration pragma.
7841 @noindent
7842 The warnings controlled by the @option{-gnatw} switch are generated by the
7843 front end of the compiler. The GCC back end can provide additional warnings
7844 and they are controlled by the @option{-W} switch. Such warnings can be
7845 identified by the appearance of a string of the form @code{[-Wxxx]} in the
7846 message which designates the @option{-Wxxx} switch that controls the message.
7847 The form with a single static_string_EXPRESSION argument also works for these
7848 warnings, but the string must be a single full @option{-Wxxx} switch in this
7849 case. The above reference lists a few examples of these additional warnings.
7851 @noindent
7852 The specified warnings will be in effect until the end of the program
7853 or another pragma Warnings is encountered. The effect of the pragma is
7854 cumulative. Initially the set of warnings is the standard default set
7855 as possibly modified by compiler switches. Then each pragma Warning
7856 modifies this set of warnings as specified. This form of the pragma may
7857 also be used as a configuration pragma.
7859 The fourth form, with an @code{On|Off} parameter and a string, is used to
7860 control individual messages, based on their text. The string argument
7861 is a pattern that is used to match against the text of individual
7862 warning messages (not including the initial "warning: " tag).
7864 The pattern may contain asterisks, which match zero or more characters in
7865 the message. For example, you can use
7866 @code{pragma Warnings (Off, "bits of*unused")} to suppress the warning
7867 message @code{warning: 960 bits of "a" unused}. No other regular
7868 expression notations are permitted. All characters other than asterisk in
7869 these three specific cases are treated as literal characters in the match.
7870 The match is case insensitive, for example XYZ matches xyz.
7872 Note that the pattern matches if it occurs anywhere within the warning
7873 message string (it is not necessary to put an asterisk at the start and
7874 the end of the message, since this is implied).
7876 The above use of patterns to match the message applies only to warning
7877 messages generated by the front end. This form of the pragma with a string
7878 argument can also be used to control warnings provided by the back end and
7879 mentioned above. By using a single full @option{-Wxxx} switch in the pragma,
7880 such warnings can be turned on and off.
7882 There are two ways to use the pragma in this form. The OFF form can be used
7883 as a configuration pragma. The effect is to suppress all warnings (if any)
7884 that match the pattern string throughout the compilation (or match the
7885 -W switch in the back end case).
7887 The second usage is to suppress a warning locally, and in this case, two
7888 pragmas must appear in sequence:
7890 @smallexample @c ada
7891 pragma Warnings (Off, Pattern);
7892 @dots{} code where given warning is to be suppressed
7893 pragma Warnings (On, Pattern);
7894 @end smallexample
7896 @noindent
7897 In this usage, the pattern string must match in the Off and On pragmas,
7898 and at least one matching warning must be suppressed.
7900 Note: to write a string that will match any warning, use the string
7901 @code{"***"}. It will not work to use a single asterisk or two asterisks
7902 since this looks like an operator name. This form with three asterisks
7903 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
7904 matching @code{pragma Warnings (On, "***")} will be required. This can be
7905 helpful in avoiding forgetting to turn warnings back on.
7907 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7908 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7909 be useful in checking whether obsolete pragmas in existing programs are hiding
7910 real problems.
7912 Note: pragma Warnings does not affect the processing of style messages. See
7913 separate entry for pragma Style_Checks for control of style messages.
7915 @node Pragma Weak_External
7916 @unnumberedsec Pragma Weak_External
7917 @findex Weak_External
7918 @noindent
7919 Syntax:
7921 @smallexample @c ada
7922 pragma Weak_External ([Entity =>] LOCAL_NAME);
7923 @end smallexample
7925 @noindent
7926 @var{LOCAL_NAME} must refer to an object that is declared at the library
7927 level. This pragma specifies that the given entity should be marked as a
7928 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
7929 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
7930 of a regular symbol, that is to say a symbol that does not have to be
7931 resolved by the linker if used in conjunction with a pragma Import.
7933 When a weak symbol is not resolved by the linker, its address is set to
7934 zero. This is useful in writing interfaces to external modules that may
7935 or may not be linked in the final executable, for example depending on
7936 configuration settings.
7938 If a program references at run time an entity to which this pragma has been
7939 applied, and the corresponding symbol was not resolved at link time, then
7940 the execution of the program is erroneous. It is not erroneous to take the
7941 Address of such an entity, for example to guard potential references,
7942 as shown in the example below.
7944 Some file formats do not support weak symbols so not all target machines
7945 support this pragma.
7947 @smallexample @c ada
7948 --  Example of the use of pragma Weak_External
7950 package External_Module is
7951   key : Integer;
7952   pragma Import (C, key);
7953   pragma Weak_External (key);
7954   function Present return boolean;
7955 end External_Module;
7957 with System; use System;
7958 package body External_Module is
7959   function Present return boolean is
7960   begin
7961     return key'Address /= System.Null_Address;
7962   end Present;
7963 end External_Module;
7964 @end smallexample
7966 @node Pragma Wide_Character_Encoding
7967 @unnumberedsec Pragma Wide_Character_Encoding
7968 @findex Wide_Character_Encoding
7969 @noindent
7970 Syntax:
7972 @smallexample @c ada
7973 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
7974 @end smallexample
7976 @noindent
7977 This pragma specifies the wide character encoding to be used in program
7978 source text appearing subsequently. It is a configuration pragma, but may
7979 also be used at any point that a pragma is allowed, and it is permissible
7980 to have more than one such pragma in a file, allowing multiple encodings
7981 to appear within the same file.
7983 The argument can be an identifier or a character literal. In the identifier
7984 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
7985 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
7986 case it is correspondingly one of the characters @samp{h}, @samp{u},
7987 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
7989 Note that when the pragma is used within a file, it affects only the
7990 encoding within that file, and does not affect withed units, specs,
7991 or subunits.
7993 @node Implementation Defined Aspects
7994 @chapter Implementation Defined Aspects
7995 Ada defines (throughout the Ada 2012 reference manual, summarized
7996 in Annex K) a set of aspects that can be specified for certain entities.
7997 These language defined aspects are implemented in GNAT in Ada 2012 mode
7998 and work as described in the Ada 2012 Reference Manual.
8000 In addition, Ada 2012 allows implementations to define additional aspects
8001 whose meaning is defined by the implementation.  GNAT provides
8002 a number of these implementation-defined aspects which can be used
8003 to extend and enhance the functionality of the compiler.  This section of
8004 the GNAT reference manual describes these additional aspects.
8006 Note that any program using these aspects may not be portable to
8007 other compilers (although GNAT implements this set of aspects on all
8008 platforms).  Therefore if portability to other compilers is an important
8009 consideration, you should minimize the use of these aspects.
8011 Note that for many of these aspects, the effect is essentially similar
8012 to the use of a pragma or attribute specification with the same name
8013 applied to the entity. For example, if we write:
8015 @smallexample @c ada
8016 type R is range 1 .. 100
8017   with Value_Size => 10;
8018 @end smallexample
8020 @noindent
8021 then the effect is the same as:
8023 @smallexample @c ada
8024 type R is range 1 .. 100;
8025 for R'Value_Size use 10;
8026 @end smallexample
8028 @noindent
8029 and if we write:
8031 @smallexample @c ada
8032 type R is new Integer
8033   with Shared => True;
8034 @end smallexample
8036 @noindent
8037 then the effect is the same as:
8039 @smallexample @c ada
8040 type R is new Integer;
8041 pragma Shared (R);
8042 @end smallexample
8044 @noindent
8045 In the documentation below, such cases are simply marked
8046 as being equivalent to the corresponding pragma or attribute definition
8047 clause.
8049 @menu
8050 * Aspect Abstract_State::
8051 * Aspect Annotate::
8052 * Aspect Async_Readers::
8053 * Aspect Async_Writers::
8054 * Aspect Contract_Cases::
8055 * Aspect Depends::
8056 * Aspect Dimension::
8057 * Aspect Dimension_System::
8058 * Aspect Effective_Reads::
8059 * Aspect Effective_Writes::
8060 * Aspect Favor_Top_Level::
8061 * Aspect Global::
8062 * Aspect Initial_Condition::
8063 * Aspect Initializes::
8064 * Aspect Inline_Always::
8065 * Aspect Invariant::
8066 * Aspect Invariant'Class::
8067 * Aspect Iterable::
8068 * Aspect Linker_Section::
8069 * Aspect Lock_Free::
8070 * Aspect No_Elaboration_Code_All::
8071 * Aspect Object_Size::
8072 * Aspect Obsolescent::
8073 * Aspect Part_Of::
8074 * Aspect Persistent_BSS::
8075 * Aspect Predicate::
8076 * Aspect Pure_Function::
8077 * Aspect Refined_Depends::
8078 * Aspect Refined_Global::
8079 * Aspect Refined_Post::
8080 * Aspect Refined_State::
8081 * Aspect Remote_Access_Type::
8082 * Aspect Scalar_Storage_Order::
8083 * Aspect Shared::
8084 * Aspect Simple_Storage_Pool::
8085 * Aspect Simple_Storage_Pool_Type::
8086 * Aspect SPARK_Mode::
8087 * Aspect Suppress_Debug_Info::
8088 * Aspect Test_Case::
8089 * Aspect Thread_Local_Storage::
8090 * Aspect Universal_Aliasing::
8091 * Aspect Universal_Data::
8092 * Aspect Unmodified::
8093 * Aspect Unreferenced::
8094 * Aspect Unreferenced_Objects::
8095 * Aspect Value_Size::
8096 * Aspect Warnings::
8097 @end menu
8099 @node Aspect Abstract_State
8100 @unnumberedsec Aspect Abstract_State
8101 @findex Abstract_State
8102 @noindent
8103 This aspect is equivalent to pragma @code{Abstract_State}.
8105 @node Aspect Annotate
8106 @unnumberedsec Annotate
8107 @findex Annotate
8108 @noindent
8109 There are three forms of this aspect (where ID is an identifier,
8110 and ARG is a general expression).
8112 @table @code
8113 @item Annotate => ID
8114 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
8116 @item Annotate => (ID)
8117 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
8119 @item Annotate => (ID ,ID @{, ARG@})
8120 Equivalent to @code{pragma Annotate (ID, ID @{, ARG@}, Entity => Name);}
8121 @end table
8123 @node Aspect Async_Readers
8124 @unnumberedsec Aspect Async_Readers
8125 @findex Async_Readers
8126 @noindent
8127 This aspect is equivalent to pragma @code{Async_Readers}.
8129 @node Aspect Async_Writers
8130 @unnumberedsec Aspect Async_Writers
8131 @findex Async_Writers
8132 @noindent
8133 This aspect is equivalent to pragma @code{Async_Writers}.
8135 @node Aspect Contract_Cases
8136 @unnumberedsec Aspect Contract_Cases
8137 @findex Contract_Cases
8138 @noindent
8139 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
8140 of clauses being enclosed in parentheses so that syntactically it is an
8141 aggregate.
8143 @node Aspect Depends
8144 @unnumberedsec Aspect Depends
8145 @findex Depends
8146 @noindent
8147 This aspect is equivalent to pragma @code{Depends}.
8149 @node Aspect Dimension
8150 @unnumberedsec Aspect Dimension
8151 @findex Dimension
8152 @noindent
8153 The @code{Dimension} aspect is used to specify the dimensions of a given
8154 subtype of a dimensioned numeric type. The aspect also specifies a symbol
8155 used when doing formatted output of dimensioned quantities. The syntax is:
8157 @smallexample @c ada
8158 with Dimension =>
8159   ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
8161 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
8163 DIMENSION_VALUE ::=
8164   RATIONAL
8165 | others               => RATIONAL
8166 | DISCRETE_CHOICE_LIST => RATIONAL
8168 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
8169 @end smallexample
8171 @noindent
8172 This aspect can only be applied to a subtype whose parent type has
8173 a @code{Dimension_Systen} aspect. The aspect must specify values for
8174 all dimensions of the system. The rational values are the powers of the
8175 corresponding dimensions that are used by the compiler to verify that
8176 physical (numeric) computations are dimensionally consistent. For example,
8177 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
8178 For further examples of the usage
8179 of this aspect, see package @code{System.Dim.Mks}.
8180 Note that when the dimensioned type is an integer type, then any
8181 dimension value must be an integer literal.
8183 @node Aspect Dimension_System
8184 @unnumberedsec Aspect Dimension_System
8185 @findex Dimension_System
8186 @noindent
8187 The @code{Dimension_System} aspect is used to define a system of
8188 dimensions that will be used in subsequent subtype declarations with
8189 @code{Dimension} aspects that reference this system. The syntax is:
8191 @smallexample @c ada
8192 with Dimension_System => (DIMENSION @{, DIMENSION@});
8194 DIMENSION ::= ([Unit_Name   =>] IDENTIFIER,
8195                [Unit_Symbol =>] SYMBOL,
8196                [Dim_Symbol  =>] SYMBOL)
8198 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
8199 @end smallexample
8201 @noindent
8202 This aspect is applied to a type, which must be a numeric derived type
8203 (typically a floating-point type), that
8204 will represent values within the dimension system. Each @code{DIMENSION}
8205 corresponds to one particular dimension. A maximum of 7 dimensions may
8206 be specified. @code{Unit_Name} is the name of the dimension (for example
8207 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
8208 of this dimension (for example @code{m} for @code{Meter}).
8209 @code{Dim_Symbol} gives
8210 the identification within the dimension system (typically this is a
8211 single letter, e.g. @code{L} standing for length for unit name @code{Meter}).
8212 The @code{Unit_Symbol} is used in formatted output of dimensioned quantities.
8213 The @code{Dim_Symbol} is used in error messages when numeric operations have
8214 inconsistent dimensions.
8216 GNAT provides the standard definition of the International MKS system in
8217 the run-time package @code{System.Dim.Mks}. You can easily define
8218 similar packages for cgs units or British units, and define conversion factors
8219 between values in different systems. The MKS system is characterized by the
8220 following aspect:
8222 @smallexample @c ada
8223    type Mks_Type is new Long_Long_Float with
8224      Dimension_System => (
8225        (Unit_Name => Meter,    Unit_Symbol => 'm',   Dim_Symbol => 'L'),
8226        (Unit_Name => Kilogram, Unit_Symbol => "kg",  Dim_Symbol => 'M'),
8227        (Unit_Name => Second,   Unit_Symbol => 's',   Dim_Symbol => 'T'),
8228        (Unit_Name => Ampere,   Unit_Symbol => 'A',   Dim_Symbol => 'I'),
8229        (Unit_Name => Kelvin,   Unit_Symbol => 'K',   Dim_Symbol => '@'),
8230        (Unit_Name => Mole,     Unit_Symbol => "mol", Dim_Symbol => 'N'),
8231        (Unit_Name => Candela,  Unit_Symbol => "cd",  Dim_Symbol => 'J'));
8232 @end smallexample
8234 @noindent
8235 Note that in the above type definition, we use the symbol @code{@@} to
8236 represent a theta character (avoiding the use of extended Latin-1
8237 characters in this context).
8239 See section ``Performing Dimensionality Analysis in GNAT'' in the GNAT Users
8240 Guide for detailed examples of use of the dimension system.
8242 @node Aspect Effective_Reads
8243 @unnumberedsec Aspect Effective_Reads
8244 @findex Effective_Reads
8245 @noindent
8246 This aspect is equivalent to pragma @code{Effective_Reads}.
8248 @node Aspect Effective_Writes
8249 @unnumberedsec Aspect Effective_Writes
8250 @findex Effective_Writes
8251 @noindent
8252 This aspect is equivalent to pragma @code{Effective_Writes}.
8254 @node Aspect Favor_Top_Level
8255 @unnumberedsec Aspect Favor_Top_Level
8256 @findex Favor_Top_Level
8257 @noindent
8258 This aspect is equivalent to pragma @code{Favor_Top_Level}.
8260 @node Aspect Global
8261 @unnumberedsec Aspect Global
8262 @findex Global
8263 @noindent
8264 This aspect is equivalent to pragma @code{Global}.
8266 @node Aspect Initial_Condition
8267 @unnumberedsec Aspect Initial_Condition
8268 @findex Initial_Condition
8269 @noindent
8270 This aspect is equivalent to pragma @code{Initial_Condition}.
8272 @node Aspect Initializes
8273 @unnumberedsec Aspect Initializes
8274 @findex Initializes
8275 @noindent
8276 This aspect is equivalent to pragma @code{Initializes}.
8278 @node Aspect Inline_Always
8279 @unnumberedsec Aspect Inline_Always
8280 @findex Inline_Always
8281 @noindent
8282 This aspect is equivalent to pragma @code{Inline_Always}.
8284 @node Aspect Invariant
8285 @unnumberedsec Aspect Invariant
8286 @findex Invariant
8287 @noindent
8288 This aspect is equivalent to pragma @code{Invariant}. It is a
8289 synonym for the language defined aspect @code{Type_Invariant} except
8290 that it is separately controllable using pragma @code{Assertion_Policy}.
8292 @node Aspect Invariant'Class
8293 @unnumberedsec Aspect Invariant'Class
8294 @findex Invariant'Class
8295 @noindent
8296 This aspect is equivalent to pragma @code{Type_Invariant_Class}. It is a
8297 synonym for the language defined aspect @code{Type_Invariant'Class} except
8298 that it is separately controllable using pragma @code{Assertion_Policy}.
8300 @node Aspect Iterable
8301 @unnumberedsec Aspect Iterable
8302 @findex Iterable
8303 @noindent
8304 This aspect is used in the GNAT-defined formal container packages, to provide
8305 a light-weight mechanism for loops over such containers, without the overhead
8306 imposed by the tampering checks of standard Ada2012 iterators. The value of the
8307 aspect is a aggregate with four named  components: First, Next, Has_Element,
8308 and Element. The following is a typical example of use:
8310 @smallexample @c ada
8311 type List is private with
8312     Iterable => (First        => First_Element,
8313                  Next         => Advance,
8314                  Has_Element  => Get_Element,
8315                  Element      => List_Element);
8316 @end smallexample
8317 @itemize @bullet
8318 @item The value denoted by @code{First} must denote a primitive operation of
8319 the  container type that returns a Cursor, which must a be a type declared in
8320 the container package.
8321 @item The value of @code{Next} is a primitive operation of the container type
8322 that takes a cursor and yields a cursor.
8323 @item @code{Has_Element} is an operation that applies to a cursor a yields an
8324 element of the container.
8325 @item @code{Element} is the type of the elements of the container type, and
8326 thus the result of the function denoted by Has_Element.
8327 @end itemize
8329 @node Aspect Linker_Section
8330 @unnumberedsec Aspect Linker_Section
8331 @findex Linker_Section
8332 @noindent
8333 This aspect is equivalent to an @code{Linker_Section} pragma.
8335 @node Aspect Lock_Free
8336 @unnumberedsec Aspect Lock_Free
8337 @findex Lock_Free
8338 @noindent
8339 This aspect is equivalent to pragma @code{Lock_Free}.
8341 @node Aspect No_Elaboration_Code_All
8342 @unnumberedsec Aspect No_Elaboration_Code_All
8343 @findex No_Elaboration_Code_All
8344 @noindent
8345 This aspect is equivalent to a @code{pragma No_Elaboration_Code_All}
8346 statement for a program unit.
8348 @node Aspect Object_Size
8349 @unnumberedsec Aspect Object_Size
8350 @findex Object_Size
8351 @noindent
8352 This aspect is equivalent to an @code{Object_Size} attribute definition
8353 clause.
8355 @node Aspect Obsolescent
8356 @unnumberedsec Aspect Obsolescent
8357 @findex Obsolsecent
8358 @noindent
8359 This aspect is equivalent to an @code{Obsolescent} pragma. Note that the
8360 evaluation of this aspect happens at the point of occurrence, it is not
8361 delayed until the freeze point.
8363 @node Aspect Part_Of
8364 @unnumberedsec Aspect Part_Of
8365 @findex Part_Of
8366 @noindent
8367 This aspect is equivalent to pragma @code{Part_Of}.
8369 @node Aspect Persistent_BSS
8370 @unnumberedsec Aspect Persistent_BSS
8371 @findex Persistent_BSS
8372 @noindent
8373 This aspect is equivalent to pragma @code{Persistent_BSS}.
8375 @node Aspect Predicate
8376 @unnumberedsec Aspect Predicate
8377 @findex Predicate
8378 @noindent
8379 This aspect is equivalent to pragma @code{Predicate}. It is thus
8380 similar to the language defined aspects @code{Dynamic_Predicate}
8381 and @code{Static_Predicate} except that whether the resulting
8382 predicate is static or dynamic is controlled by the form of the
8383 expression. It is also separately controllable using pragma
8384 @code{Assertion_Policy}.
8386 @node Aspect Pure_Function
8387 @unnumberedsec Aspect Pure_Function
8388 @findex Pure_Function
8389 @noindent
8390 This aspect is equivalent to pragma @code{Pure_Function}.
8392 @node Aspect Refined_Depends
8393 @unnumberedsec Aspect Refined_Depends
8394 @findex Refined_Depends
8395 @noindent
8396 This aspect is equivalent to pragma @code{Refined_Depends}.
8398 @node Aspect Refined_Global
8399 @unnumberedsec Aspect Refined_Global
8400 @findex Refined_Global
8401 @noindent
8402 This aspect is equivalent to pragma @code{Refined_Global}.
8404 @node Aspect Refined_Post
8405 @unnumberedsec Aspect Refined_Post
8406 @findex Refined_Post
8407 @noindent
8408 This aspect is equivalent to pragma @code{Refined_Post}.
8410 @node Aspect Refined_State
8411 @unnumberedsec Aspect Refined_State
8412 @findex Refined_State
8413 @noindent
8414 This aspect is equivalent to pragma @code{Refined_State}.
8416 @node Aspect Remote_Access_Type
8417 @unnumberedsec Aspect Remote_Access_Type
8418 @findex Remote_Access_Type
8419 @noindent
8420 This aspect is equivalent to pragma @code{Remote_Access_Type}.
8422 @node Aspect Scalar_Storage_Order
8423 @unnumberedsec Aspect Scalar_Storage_Order
8424 @findex Scalar_Storage_Order
8425 @noindent
8426 This aspect is equivalent to a @code{Scalar_Storage_Order}
8427 attribute definition clause.
8429 @node Aspect Shared
8430 @unnumberedsec Aspect Shared
8431 @findex Shared
8432 @noindent
8433 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
8434 for aspect @code{Atomic}.
8436 @node Aspect Simple_Storage_Pool
8437 @unnumberedsec Aspect Simple_Storage_Pool
8438 @findex Simple_Storage_Pool
8439 @noindent
8440 This aspect is equivalent to a @code{Simple_Storage_Pool}
8441 attribute definition clause.
8443 @node Aspect Simple_Storage_Pool_Type
8444 @unnumberedsec Aspect Simple_Storage_Pool_Type
8445 @findex Simple_Storage_Pool_Type
8446 @noindent
8447 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
8449 @node Aspect SPARK_Mode
8450 @unnumberedsec Aspect SPARK_Mode
8451 @findex SPARK_Mode
8452 @noindent
8453 This aspect is equivalent to pragma @code{SPARK_Mode} and
8454 may be specified for either or both of the specification and body
8455 of a subprogram or package.
8457 @node Aspect Suppress_Debug_Info
8458 @unnumberedsec Aspect Suppress_Debug_Info
8459 @findex Suppress_Debug_Info
8460 @noindent
8461 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
8463 @node Aspect Test_Case
8464 @unnumberedsec Aspect Test_Case
8465 @findex Test_Case
8466 @noindent
8467 This aspect is equivalent to pragma @code{Test_Case}.
8469 @node Aspect Thread_Local_Storage
8470 @unnumberedsec Aspect Thread_Local_Storage
8471 @findex Thread_Local_Storage
8472 @noindent
8473 This aspect is equivalent to pragma @code{Thread_Local_Storage}.
8475 @node Aspect Universal_Aliasing
8476 @unnumberedsec Aspect Universal_Aliasing
8477 @findex Universal_Aliasing
8478 @noindent
8479 This aspect is equivalent to pragma @code{Universal_Aliasing}.
8481 @node Aspect Universal_Data
8482 @unnumberedsec Aspect Universal_Data
8483 @findex Universal_Data
8484 @noindent
8485 This aspect is equivalent to pragma @code{Universal_Data}.
8487 @node Aspect Unmodified
8488 @unnumberedsec Aspect Unmodified
8489 @findex Unmodified
8490 @noindent
8491 This aspect is equivalent to pragma @code{Unmodified}.
8493 @node Aspect Unreferenced
8494 @unnumberedsec Aspect Unreferenced
8495 @findex Unreferenced
8496 @noindent
8497 This aspect is equivalent to pragma @code{Unreferenced}.
8499 @node Aspect Unreferenced_Objects
8500 @unnumberedsec Aspect Unreferenced_Objects
8501 @findex Unreferenced_Objects
8502 @noindent
8503 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
8505 @node Aspect Value_Size
8506 @unnumberedsec Aspect Value_Size
8507 @findex Value_Size
8508 @noindent
8509 This aspect is equivalent to a @code{Value_Size}
8510 attribute definition clause.
8512 @node Aspect Warnings
8513 @unnumberedsec Aspect Warnings
8514 @findex Warnings
8515 @noindent
8516 This aspect is equivalent to the two argument form of pragma @code{Warnings},
8517 where the first argument is @code{ON} or @code{OFF} and the second argument
8518 is the entity.
8521 @node Implementation Defined Attributes
8522 @chapter Implementation Defined Attributes
8523 Ada defines (throughout the Ada reference manual,
8524 summarized in Annex K),
8525 a set of attributes that provide useful additional functionality in all
8526 areas of the language.  These language defined attributes are implemented
8527 in GNAT and work as described in the Ada Reference Manual.
8529 In addition, Ada allows implementations to define additional
8530 attributes whose meaning is defined by the implementation.  GNAT provides
8531 a number of these implementation-dependent attributes which can be used
8532 to extend and enhance the functionality of the compiler.  This section of
8533 the GNAT reference manual describes these additional attributes.  It also
8534 describes additional implementation-dependent features of standard
8535 language-defined attributes.
8537 Note that any program using these attributes may not be portable to
8538 other compilers (although GNAT implements this set of attributes on all
8539 platforms).  Therefore if portability to other compilers is an important
8540 consideration, you should minimize the use of these attributes.
8542 @menu
8543 * Attribute Abort_Signal::
8544 * Attribute Address_Size::
8545 * Attribute Asm_Input::
8546 * Attribute Asm_Output::
8547 * Attribute AST_Entry::
8548 * Attribute Atomic_Always_Lock_Free::
8549 * Attribute Bit::
8550 * Attribute Bit_Position::
8551 * Attribute Code_Address::
8552 * Attribute Compiler_Version::
8553 * Attribute Constrained::
8554 * Attribute Default_Bit_Order::
8555 * Attribute Default_Scalar_Storage_Order::
8556 * Attribute Descriptor_Size::
8557 * Attribute Elaborated::
8558 * Attribute Elab_Body::
8559 * Attribute Elab_Spec::
8560 * Attribute Elab_Subp_Body::
8561 * Attribute Emax::
8562 * Attribute Enabled::
8563 * Attribute Enum_Rep::
8564 * Attribute Enum_Val::
8565 * Attribute Epsilon::
8566 * Attribute Fast_Math::
8567 * Attribute Fixed_Value::
8568 * Attribute From_Any::
8569 * Attribute Has_Access_Values::
8570 * Attribute Has_Discriminants::
8571 * Attribute Img::
8572 * Attribute Integer_Value::
8573 * Attribute Invalid_Value::
8574 * Attribute Iterable::
8575 * Attribute Large::
8576 * Attribute Library_Level::
8577 * Attribute Lock_Free::
8578 * Attribute Loop_Entry::
8579 * Attribute Machine_Size::
8580 * Attribute Mantissa::
8581 * Attribute Maximum_Alignment::
8582 * Attribute Mechanism_Code::
8583 * Attribute Null_Parameter::
8584 * Attribute Object_Size::
8585 * Attribute Old::
8586 * Attribute Passed_By_Reference::
8587 * Attribute Pool_Address::
8588 * Attribute Range_Length::
8589 * Attribute Ref::
8590 * Attribute Restriction_Set::
8591 * Attribute Result::
8592 * Attribute Safe_Emax::
8593 * Attribute Safe_Large::
8594 * Attribute Safe_Small::
8595 * Attribute Scalar_Storage_Order::
8596 * Attribute Simple_Storage_Pool::
8597 * Attribute Small::
8598 * Attribute Storage_Unit::
8599 * Attribute Stub_Type::
8600 * Attribute System_Allocator_Alignment::
8601 * Attribute Target_Name::
8602 * Attribute To_Address::
8603 * Attribute To_Any::
8604 * Attribute Type_Class::
8605 * Attribute Type_Key::
8606 * Attribute TypeCode::
8607 * Attribute UET_Address::
8608 * Attribute Unconstrained_Array::
8609 * Attribute Universal_Literal_String::
8610 * Attribute Unrestricted_Access::
8611 * Attribute Update::
8612 * Attribute VADS_Size::
8613 * Attribute Valid_Scalars::
8614 * Attribute Value_Size::
8615 * Attribute Wchar_T_Size::
8616 * Attribute Word_Size::
8617 @end menu
8619 @node Attribute Abort_Signal
8620 @unnumberedsec Attribute Abort_Signal
8621 @findex Abort_Signal
8622 @noindent
8623 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
8624 prefix) provides the entity for the special exception used to signal
8625 task abort or asynchronous transfer of control.  Normally this attribute
8626 should only be used in the tasking runtime (it is highly peculiar, and
8627 completely outside the normal semantics of Ada, for a user program to
8628 intercept the abort exception).
8630 @node Attribute Address_Size
8631 @unnumberedsec Attribute Address_Size
8632 @cindex Size of @code{Address}
8633 @findex Address_Size
8634 @noindent
8635 @code{Standard'Address_Size} (@code{Standard} is the only allowed
8636 prefix) is a static constant giving the number of bits in an
8637 @code{Address}. It is the same value as System.Address'Size,
8638 but has the advantage of being static, while a direct
8639 reference to System.Address'Size is non-static because Address
8640 is a private type.
8642 @node Attribute Asm_Input
8643 @unnumberedsec Attribute Asm_Input
8644 @findex Asm_Input
8645 @noindent
8646 The @code{Asm_Input} attribute denotes a function that takes two
8647 parameters.  The first is a string, the second is an expression of the
8648 type designated by the prefix.  The first (string) argument is required
8649 to be a static expression, and is the constraint for the parameter,
8650 (e.g.@: what kind of register is required).  The second argument is the
8651 value to be used as the input argument.  The possible values for the
8652 constant are the same as those used in the RTL, and are dependent on
8653 the configuration file used to built the GCC back end.
8654 @ref{Machine Code Insertions}
8656 @node Attribute Asm_Output
8657 @unnumberedsec Attribute Asm_Output
8658 @findex Asm_Output
8659 @noindent
8660 The @code{Asm_Output} attribute denotes a function that takes two
8661 parameters.  The first is a string, the second is the name of a variable
8662 of the type designated by the attribute prefix.  The first (string)
8663 argument is required to be a static expression and designates the
8664 constraint for the parameter (e.g.@: what kind of register is
8665 required).  The second argument is the variable to be updated with the
8666 result.  The possible values for constraint are the same as those used in
8667 the RTL, and are dependent on the configuration file used to build the
8668 GCC back end.  If there are no output operands, then this argument may
8669 either be omitted, or explicitly given as @code{No_Output_Operands}.
8670 @ref{Machine Code Insertions}
8672 @node Attribute AST_Entry
8673 @unnumberedsec Attribute AST_Entry
8674 @cindex OpenVMS
8675 @findex AST_Entry
8676 @noindent
8677 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
8678 the name of an entry, it yields a value of the predefined type AST_Handler
8679 (declared in the predefined package System, as extended by the use of
8680 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
8681 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
8682 Language Reference Manual}, section 9.12a.
8684 @node Attribute Atomic_Always_Lock_Free
8685 @unnumberedsec Attribute Atomic_Always_Lock_Free
8686 @findex Atomic_Always_Lock_Free
8687 @noindent
8689 The prefix of the @code{Atomic_Always_Lock_Free} attribute is a type.
8690 The result is a Boolean value which is True if the type has discriminants,
8691 and False otherwise.  The result indicate whether atomic operations are
8692 supported by the target for the given type.
8694 @node Attribute Bit
8695 @unnumberedsec Attribute Bit
8696 @findex Bit
8697 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
8698 offset within the storage unit (byte) that contains the first bit of
8699 storage allocated for the object.  The value of this attribute is of the
8700 type @code{Universal_Integer}, and is always a non-negative number not
8701 exceeding the value of @code{System.Storage_Unit}.
8703 For an object that is a variable or a constant allocated in a register,
8704 the value is zero.  (The use of this attribute does not force the
8705 allocation of a variable to memory).
8707 For an object that is a formal parameter, this attribute applies
8708 to either the matching actual parameter or to a copy of the
8709 matching actual parameter.
8711 For an access object the value is zero.  Note that
8712 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
8713 designated object.  Similarly for a record component
8714 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
8715 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
8716 are subject to index checks.
8718 This attribute is designed to be compatible with the DEC Ada 83 definition
8719 and implementation of the @code{Bit} attribute.
8721 @node Attribute Bit_Position
8722 @unnumberedsec Attribute Bit_Position
8723 @findex Bit_Position
8724 @noindent
8725 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
8726 of the fields of the record type, yields the bit
8727 offset within the record contains the first bit of
8728 storage allocated for the object.  The value of this attribute is of the
8729 type @code{Universal_Integer}.  The value depends only on the field
8730 @var{C} and is independent of the alignment of
8731 the containing record @var{R}.
8733 @node Attribute Code_Address
8734 @unnumberedsec Attribute Code_Address
8735 @findex Code_Address
8736 @cindex Subprogram address
8737 @cindex Address of subprogram code
8738 @noindent
8739 The @code{'Address}
8740 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
8741 intended effect seems to be to provide
8742 an address value which can be used to call the subprogram by means of
8743 an address clause as in the following example:
8745 @smallexample @c ada
8746 procedure K is @dots{}
8748 procedure L;
8749 for L'Address use K'Address;
8750 pragma Import (Ada, L);
8751 @end smallexample
8753 @noindent
8754 A call to @code{L} is then expected to result in a call to @code{K}@.
8755 In Ada 83, where there were no access-to-subprogram values, this was
8756 a common work-around for getting the effect of an indirect call.
8757 GNAT implements the above use of @code{Address} and the technique
8758 illustrated by the example code works correctly.
8760 However, for some purposes, it is useful to have the address of the start
8761 of the generated code for the subprogram.  On some architectures, this is
8762 not necessarily the same as the @code{Address} value described above.
8763 For example, the @code{Address} value may reference a subprogram
8764 descriptor rather than the subprogram itself.
8766 The @code{'Code_Address} attribute, which can only be applied to
8767 subprogram entities, always returns the address of the start of the
8768 generated code of the specified subprogram, which may or may not be
8769 the same value as is returned by the corresponding @code{'Address}
8770 attribute.
8772 @node Attribute Compiler_Version
8773 @unnumberedsec Attribute Compiler_Version
8774 @findex Compiler_Version
8775 @noindent
8776 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
8777 prefix) yields a static string identifying the version of the compiler
8778 being used to compile the unit containing the attribute reference. A
8779 typical result would be something like
8780 "@value{EDITION} @value{gnat_version} (20090221)".
8782 @node Attribute Constrained
8783 @unnumberedsec Attribute Constrained
8784 @findex Constrained
8785 @noindent
8786 In addition to the usage of this attribute in the Ada RM, @code{GNAT}
8787 also permits the use of the @code{'Constrained} attribute
8788 in a generic template
8789 for any type, including types without discriminants. The value of this
8790 attribute in the generic instance when applied to a scalar type or a
8791 record type without discriminants is always @code{True}. This usage is
8792 compatible with older Ada compilers, including notably DEC Ada.
8794 @node Attribute Default_Bit_Order
8795 @unnumberedsec Attribute Default_Bit_Order
8796 @cindex Big endian
8797 @cindex Little endian
8798 @findex Default_Bit_Order
8799 @noindent
8800 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
8801 permissible prefix), provides the value @code{System.Default_Bit_Order}
8802 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
8803 @code{Low_Order_First}).  This is used to construct the definition of
8804 @code{Default_Bit_Order} in package @code{System}.
8806 @node Attribute Default_Scalar_Storage_Order
8807 @unnumberedsec Attribute Default_Scalar_Storage_Order
8808 @cindex Big endian
8809 @cindex Little endian
8810 @findex Default_Scalar_Storage_Order
8811 @noindent
8812 @code{Standard'Default_Scalar_Storage_Order} (@code{Standard} is the only
8813 permissible prefix), provides the current value of the default scalar storage
8814 order (as specified using pragma @code{Default_Scalar_Storage_Order}, or
8815 equal to @code{Default_Bit_Order} if unspecified) as a
8816 @code{System.Bit_Order} value. This is a static attribute.
8818 @node Attribute Descriptor_Size
8819 @unnumberedsec Attribute Descriptor_Size
8820 @cindex Descriptor
8821 @cindex Dope vector
8822 @findex Descriptor_Size
8823 @noindent
8824 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
8825 descriptor allocated for a type.  The result is non-zero only for unconstrained
8826 array types and the returned value is of type universal integer.  In GNAT, an
8827 array descriptor contains bounds information and is located immediately before
8828 the first element of the array.
8830 @smallexample @c ada
8831 type Unconstr_Array is array (Positive range <>) of Boolean;
8832 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
8833 @end smallexample
8835 @noindent
8836 The attribute takes into account any additional padding due to type alignment.
8837 In the example above, the descriptor contains two values of type
8838 @code{Positive} representing the low and high bound.  Since @code{Positive} has
8839 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
8840 Positive'Size + 2} or 64 bits.
8842 @node Attribute Elaborated
8843 @unnumberedsec Attribute Elaborated
8844 @findex Elaborated
8845 @noindent
8846 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
8847 value is a Boolean which indicates whether or not the given unit has been
8848 elaborated.  This attribute is primarily intended for internal use by the
8849 generated code for dynamic elaboration checking, but it can also be used
8850 in user programs.  The value will always be True once elaboration of all
8851 units has been completed.  An exception is for units which need no
8852 elaboration, the value is always False for such units.
8854 @node Attribute Elab_Body
8855 @unnumberedsec Attribute Elab_Body
8856 @findex Elab_Body
8857 @noindent
8858 This attribute can only be applied to a program unit name.  It returns
8859 the entity for the corresponding elaboration procedure for elaborating
8860 the body of the referenced unit.  This is used in the main generated
8861 elaboration procedure by the binder and is not normally used in any
8862 other context.  However, there may be specialized situations in which it
8863 is useful to be able to call this elaboration procedure from Ada code,
8864 e.g.@: if it is necessary to do selective re-elaboration to fix some
8865 error.
8867 @node Attribute Elab_Spec
8868 @unnumberedsec Attribute Elab_Spec
8869 @findex Elab_Spec
8870 @noindent
8871 This attribute can only be applied to a program unit name.  It returns
8872 the entity for the corresponding elaboration procedure for elaborating
8873 the spec of the referenced unit.  This is used in the main
8874 generated elaboration procedure by the binder and is not normally used
8875 in any other context.  However, there may be specialized situations in
8876 which it is useful to be able to call this elaboration procedure from
8877 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
8878 some error.
8880 @node Attribute Elab_Subp_Body
8881 @unnumberedsec Attribute Elab_Subp_Body
8882 @findex Elab_Subp_Body
8883 @noindent
8884 This attribute can only be applied to a library level subprogram
8885 name and is only allowed in CodePeer mode. It returns the entity
8886 for the corresponding elaboration procedure for elaborating the body
8887 of the referenced subprogram unit. This is used in the main generated
8888 elaboration procedure by the binder in CodePeer mode only and is unrecognized
8889 otherwise.
8891 @node Attribute Emax
8892 @unnumberedsec Attribute Emax
8893 @cindex Ada 83 attributes
8894 @findex Emax
8895 @noindent
8896 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
8897 the Ada 83 reference manual for an exact description of the semantics of
8898 this attribute.
8900 @node Attribute Enabled
8901 @unnumberedsec Attribute Enabled
8902 @findex Enabled
8903 @noindent
8904 The @code{Enabled} attribute allows an application program to check at compile
8905 time to see if the designated check is currently enabled. The prefix is a
8906 simple identifier, referencing any predefined check name (other than
8907 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
8908 no argument is given for the attribute, the check is for the general state
8909 of the check, if an argument is given, then it is an entity name, and the
8910 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
8911 given naming the entity (if not, then the argument is ignored).
8913 Note that instantiations inherit the check status at the point of the
8914 instantiation, so a useful idiom is to have a library package that
8915 introduces a check name with @code{pragma Check_Name}, and then contains
8916 generic packages or subprograms which use the @code{Enabled} attribute
8917 to see if the check is enabled. A user of this package can then issue
8918 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
8919 the package or subprogram, controlling whether the check will be present.
8921 @node Attribute Enum_Rep
8922 @unnumberedsec Attribute Enum_Rep
8923 @cindex Representation of enums
8924 @findex Enum_Rep
8925 @noindent
8926 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
8927 function with the following spec:
8929 @smallexample @c ada
8930 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
8931   return @i{Universal_Integer};
8932 @end smallexample
8934 @noindent
8935 It is also allowable to apply @code{Enum_Rep} directly to an object of an
8936 enumeration type or to a non-overloaded enumeration
8937 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
8938 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
8939 enumeration literal or object.
8941 The function returns the representation value for the given enumeration
8942 value.  This will be equal to value of the @code{Pos} attribute in the
8943 absence of an enumeration representation clause.  This is a static
8944 attribute (i.e.@: the result is static if the argument is static).
8946 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
8947 in which case it simply returns the integer value.  The reason for this
8948 is to allow it to be used for @code{(<>)} discrete formal arguments in
8949 a generic unit that can be instantiated with either enumeration types
8950 or integer types.  Note that if @code{Enum_Rep} is used on a modular
8951 type whose upper bound exceeds the upper bound of the largest signed
8952 integer type, and the argument is a variable, so that the universal
8953 integer calculation is done at run time, then the call to @code{Enum_Rep}
8954 may raise @code{Constraint_Error}.
8956 @node Attribute Enum_Val
8957 @unnumberedsec Attribute Enum_Val
8958 @cindex Representation of enums
8959 @findex Enum_Val
8960 @noindent
8961 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
8962 function with the following spec:
8964 @smallexample @c ada
8965 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
8966   return @var{S}'Base};
8967 @end smallexample
8969 @noindent
8970 The function returns the enumeration value whose representation matches the
8971 argument, or raises Constraint_Error if no enumeration literal of the type
8972 has the matching value.
8973 This will be equal to value of the @code{Val} attribute in the
8974 absence of an enumeration representation clause.  This is a static
8975 attribute (i.e.@: the result is static if the argument is static).
8977 @node Attribute Epsilon
8978 @unnumberedsec Attribute Epsilon
8979 @cindex Ada 83 attributes
8980 @findex Epsilon
8981 @noindent
8982 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
8983 the Ada 83 reference manual for an exact description of the semantics of
8984 this attribute.
8986 @node Attribute Fast_Math
8987 @unnumberedsec Attribute Fast_Math
8988 @findex Fast_Math
8989 @noindent
8990 @code{Standard'Fast_Math} (@code{Standard} is the only allowed
8991 prefix) yields a static Boolean value that is True if pragma
8992 @code{Fast_Math} is active, and False otherwise.
8994 @node Attribute Fixed_Value
8995 @unnumberedsec Attribute Fixed_Value
8996 @findex Fixed_Value
8997 @noindent
8998 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
8999 function with the following specification:
9001 @smallexample @c ada
9002 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
9003   return @var{S};
9004 @end smallexample
9006 @noindent
9007 The value returned is the fixed-point value @var{V} such that
9009 @smallexample @c ada
9010 @var{V} = Arg * @var{S}'Small
9011 @end smallexample
9013 @noindent
9014 The effect is thus similar to first converting the argument to the
9015 integer type used to represent @var{S}, and then doing an unchecked
9016 conversion to the fixed-point type.  The difference is
9017 that there are full range checks, to ensure that the result is in range.
9018 This attribute is primarily intended for use in implementation of the
9019 input-output functions for fixed-point values.
9021 @node Attribute From_Any
9022 @unnumberedsec Attribute From_Any
9023 @findex From_Any
9024 @noindent
9025 This internal attribute is used for the generation of remote subprogram
9026 stubs in the context of the Distributed Systems Annex.
9028 @node Attribute Has_Access_Values
9029 @unnumberedsec Attribute Has_Access_Values
9030 @cindex Access values, testing for
9031 @findex Has_Access_Values
9032 @noindent
9033 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
9034 is a Boolean value which is True if the is an access type, or is a composite
9035 type with a component (at any nesting depth) that is an access type, and is
9036 False otherwise.
9037 The intended use of this attribute is in conjunction with generic
9038 definitions.  If the attribute is applied to a generic private type, it
9039 indicates whether or not the corresponding actual type has access values.
9041 @node Attribute Has_Discriminants
9042 @unnumberedsec Attribute Has_Discriminants
9043 @cindex Discriminants, testing for
9044 @findex Has_Discriminants
9045 @noindent
9046 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
9047 is a Boolean value which is True if the type has discriminants, and False
9048 otherwise.  The intended use of this attribute is in conjunction with generic
9049 definitions.  If the attribute is applied to a generic private type, it
9050 indicates whether or not the corresponding actual type has discriminants.
9052 @node Attribute Img
9053 @unnumberedsec Attribute Img
9054 @findex Img
9055 @noindent
9056 The @code{Img} attribute differs from @code{Image} in that it is applied
9057 directly to an object, and yields the same result as
9058 @code{Image} for the subtype of the object.  This is convenient for
9059 debugging:
9061 @smallexample @c ada
9062 Put_Line ("X = " & X'Img);
9063 @end smallexample
9065 @noindent
9066 has the same meaning as the more verbose:
9068 @smallexample @c ada
9069 Put_Line ("X = " & @var{T}'Image (X));
9070 @end smallexample
9072 @noindent
9073 where @var{T} is the (sub)type of the object @code{X}.
9075 Note that technically, in analogy to @code{Image},
9076 @code{X'Img} returns a parameterless function
9077 that returns the appropriate string when called. This means that
9078 @code{X'Img} can be renamed as a function-returning-string, or used
9079 in an instantiation as a function parameter.
9081 @node Attribute Integer_Value
9082 @unnumberedsec Attribute Integer_Value
9083 @findex Integer_Value
9084 @noindent
9085 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
9086 function with the following spec:
9088 @smallexample @c ada
9089 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
9090   return @var{S};
9091 @end smallexample
9093 @noindent
9094 The value returned is the integer value @var{V}, such that
9096 @smallexample @c ada
9097 Arg = @var{V} * @var{T}'Small
9098 @end smallexample
9100 @noindent
9101 where @var{T} is the type of @code{Arg}.
9102 The effect is thus similar to first doing an unchecked conversion from
9103 the fixed-point type to its corresponding implementation type, and then
9104 converting the result to the target integer type.  The difference is
9105 that there are full range checks, to ensure that the result is in range.
9106 This attribute is primarily intended for use in implementation of the
9107 standard input-output functions for fixed-point values.
9109 @node Attribute Invalid_Value
9110 @unnumberedsec Attribute Invalid_Value
9111 @findex Invalid_Value
9112 @noindent
9113 For every scalar type S, S'Invalid_Value returns an undefined value of the
9114 type. If possible this value is an invalid representation for the type. The
9115 value returned is identical to the value used to initialize an otherwise
9116 uninitialized value of the type if pragma Initialize_Scalars is used,
9117 including the ability to modify the value with the binder -Sxx flag and
9118 relevant environment variables at run time.
9120 @node Attribute Iterable
9121 @unnumberedsec Attribute Iterable
9122 @findex Iterable
9123 @noindent
9124 Equivalent to Aspect Iterable.
9126 @node Attribute Large
9127 @unnumberedsec Attribute Large
9128 @cindex Ada 83 attributes
9129 @findex Large
9130 @noindent
9131 The @code{Large} attribute is provided for compatibility with Ada 83.  See
9132 the Ada 83 reference manual for an exact description of the semantics of
9133 this attribute.
9135 @node Attribute Library_Level
9136 @unnumberedsec Attribute Library_Level
9137 @findex Library_Level
9138 @noindent
9139 @noindent
9140 @code{P'Library_Level}, where P is an entity name,
9141 returns a Boolean value which is True if the entity is declared
9142 at the library level, and False otherwise. Note that within a
9143 generic instantition, the name of the generic unit denotes the
9144 instance, which means that this attribute can be used to test
9145 if a generic is instantiated at the library level, as shown
9146 in this example:
9148 @smallexample @c ada
9149 generic
9150   ...
9151 package Gen is
9152   pragma Compile_Time_Error
9153     (not Gen'Library_Level,
9154      "Gen can only be instantiated at library level");
9155   ...
9156 end Gen;
9157 @end smallexample
9159 @node Attribute Lock_Free
9160 @unnumberedsec Attribute Lock_Free
9161 @findex Lock_Free
9162 @noindent
9163 @code{P'Lock_Free}, where P is a protected object, returns True if a
9164 pragma @code{Lock_Free} applies to P.
9166 @node Attribute Loop_Entry
9167 @unnumberedsec Attribute Loop_Entry
9168 @findex Loop_Entry
9169 @noindent
9170 Syntax:
9172 @smallexample @c ada
9173 X'Loop_Entry [(loop_name)]
9174 @end smallexample
9176 @noindent
9177 The @code{Loop_Entry} attribute is used to refer to the value that an
9178 expression had upon entry to a given loop in much the same way that the
9179 @code{Old} attribute in a subprogram postcondition can be used to refer
9180 to the value an expression had upon entry to the subprogram. The
9181 relevant loop is either identified by the given loop name, or it is the
9182 innermost enclosing loop when no loop name is given.
9184 @noindent
9185 A @code{Loop_Entry} attribute can only occur within a
9186 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
9187 @code{Loop_Entry} is to compare the current value of objects with their
9188 initial value at loop entry, in a @code{Loop_Invariant} pragma.
9190 @noindent
9191 The effect of using @code{X'Loop_Entry} is the same as declaring
9192 a constant initialized with the initial value of @code{X} at loop
9193 entry. This copy is not performed if the loop is not entered, or if the
9194 corresponding pragmas are ignored or disabled.
9196 @node Attribute Machine_Size
9197 @unnumberedsec Attribute Machine_Size
9198 @findex Machine_Size
9199 @noindent
9200 This attribute is identical to the @code{Object_Size} attribute.  It is
9201 provided for compatibility with the DEC Ada 83 attribute of this name.
9203 @node Attribute Mantissa
9204 @unnumberedsec Attribute Mantissa
9205 @cindex Ada 83 attributes
9206 @findex Mantissa
9207 @noindent
9208 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
9209 the Ada 83 reference manual for an exact description of the semantics of
9210 this attribute.
9212 @node Attribute Maximum_Alignment
9213 @unnumberedsec Attribute Maximum_Alignment
9214 @cindex Alignment, maximum
9215 @findex Maximum_Alignment
9216 @noindent
9217 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
9218 permissible prefix) provides the maximum useful alignment value for the
9219 target.  This is a static value that can be used to specify the alignment
9220 for an object, guaranteeing that it is properly aligned in all
9221 cases.
9223 @node Attribute Mechanism_Code
9224 @unnumberedsec Attribute Mechanism_Code
9225 @cindex Return values, passing mechanism
9226 @cindex Parameters, passing mechanism
9227 @findex Mechanism_Code
9228 @noindent
9229 @code{@var{function}'Mechanism_Code} yields an integer code for the
9230 mechanism used for the result of function, and
9231 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
9232 used for formal parameter number @var{n} (a static integer value with 1
9233 meaning the first parameter) of @var{subprogram}.  The code returned is:
9235 @table @asis
9236 @item 1
9237 by copy (value)
9238 @item 2
9239 by reference
9240 @end table
9242 @node Attribute Null_Parameter
9243 @unnumberedsec Attribute Null_Parameter
9244 @cindex Zero address, passing
9245 @findex Null_Parameter
9246 @noindent
9247 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
9248 type or subtype @var{T} allocated at machine address zero.  The attribute
9249 is allowed only as the default expression of a formal parameter, or as
9250 an actual expression of a subprogram call.  In either case, the
9251 subprogram must be imported.
9253 The identity of the object is represented by the address zero in the
9254 argument list, independent of the passing mechanism (explicit or
9255 default).
9257 This capability is needed to specify that a zero address should be
9258 passed for a record or other composite object passed by reference.
9259 There is no way of indicating this without the @code{Null_Parameter}
9260 attribute.
9262 @node Attribute Object_Size
9263 @unnumberedsec Attribute Object_Size
9264 @cindex Size, used for objects
9265 @findex Object_Size
9266 @noindent
9267 The size of an object is not necessarily the same as the size of the type
9268 of an object.  This is because by default object sizes are increased to be
9269 a multiple of the alignment of the object.  For example,
9270 @code{Natural'Size} is
9271 31, but by default objects of type @code{Natural} will have a size of 32 bits.
9272 Similarly, a record containing an integer and a character:
9274 @smallexample @c ada
9275 type Rec is record
9276    I : Integer;
9277    C : Character;
9278 end record;
9279 @end smallexample
9281 @noindent
9282 will have a size of 40 (that is @code{Rec'Size} will be 40).  The
9283 alignment will be 4, because of the
9284 integer field, and so the default size of record objects for this type
9285 will be 64 (8 bytes).
9287 If the alignment of the above record is specified to be 1, then the
9288 object size will be 40 (5 bytes). This is true by default, and also
9289 an object size of 40 can be explicitly specified in this case.
9291 A consequence of this capability is that different object sizes can be
9292 given to subtypes that would otherwise be considered in Ada to be
9293 statically matching.  But it makes no sense to consider such subtypes
9294 as statically matching.  Consequently, in @code{GNAT} we add a rule
9295 to the static matching rules that requires object sizes to match.
9296 Consider this example:
9298 @smallexample @c ada
9299  1. procedure BadAVConvert is
9300  2.    type R is new Integer;
9301  3.    subtype R1 is R range 1 .. 10;
9302  4.    subtype R2 is R range 1 .. 10;
9303  5.    for R1'Object_Size use 8;
9304  6.    for R2'Object_Size use 16;
9305  7.    type R1P is access all R1;
9306  8.    type R2P is access all R2;
9307  9.    R1PV : R1P := new R1'(4);
9308 10.    R2PV : R2P;
9309 11. begin
9310 12.    R2PV := R2P (R1PV);
9311                |
9312        >>> target designated subtype not compatible with
9313            type "R1" defined at line 3
9315 13. end;
9316 @end smallexample
9318 @noindent
9319 In the absence of lines 5 and 6,
9320 types @code{R1} and @code{R2} statically match and
9321 hence the conversion on line 12 is legal. But since lines 5 and 6
9322 cause the object sizes to differ, @code{GNAT} considers that types
9323 @code{R1} and @code{R2} are not statically matching, and line 12
9324 generates the diagnostic shown above.
9326 @noindent
9327 Similar additional checks are performed in other contexts requiring
9328 statically matching subtypes.
9330 @node Attribute Old
9331 @unnumberedsec Attribute Old
9332 @findex Old
9333 @noindent
9334 In addition to the usage of @code{Old} defined in the Ada 2012 RM (usage
9335 within @code{Post} aspect), GNAT also permits the use of this attribute
9336 in implementation defined pragmas @code{Postcondition},
9337 @code{Contract_Cases} and @code{Test_Case}. Also usages of
9338 @code{Old} which would be illegal according to the Ada 2012 RM
9339 definition are allowed under control of
9340 implementation defined pragma @code{Unevaluated_Use_Of_Old}.
9342 @node Attribute Passed_By_Reference
9343 @unnumberedsec Attribute Passed_By_Reference
9344 @cindex Parameters, when passed by reference
9345 @findex Passed_By_Reference
9346 @noindent
9347 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
9348 a value of type @code{Boolean} value that is @code{True} if the type is
9349 normally passed by reference and @code{False} if the type is normally
9350 passed by copy in calls.  For scalar types, the result is always @code{False}
9351 and is static.  For non-scalar types, the result is non-static.
9353 @node Attribute Pool_Address
9354 @unnumberedsec Attribute Pool_Address
9355 @cindex Parameters, when passed by reference
9356 @findex Pool_Address
9357 @noindent
9358 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
9359 of X within its storage pool. This is the same as
9360 @code{@var{X}'Address}, except that for an unconstrained array whose
9361 bounds are allocated just before the first component,
9362 @code{@var{X}'Pool_Address} returns the address of those bounds,
9363 whereas @code{@var{X}'Address} returns the address of the first
9364 component.
9366 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
9367 the object is allocated'', which could be a user-defined storage pool,
9368 the global heap, on the stack, or in a static memory area. For an
9369 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
9370 what is passed to @code{Allocate} and returned from @code{Deallocate}.
9372 @node Attribute Range_Length
9373 @unnumberedsec Attribute Range_Length
9374 @findex Range_Length
9375 @noindent
9376 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
9377 the number of values represented by the subtype (zero for a null
9378 range).  The result is static for static subtypes.  @code{Range_Length}
9379 applied to the index subtype of a one dimensional array always gives the
9380 same result as @code{Length} applied to the array itself.
9382 @node Attribute Ref
9383 @unnumberedsec Attribute Ref
9384 @findex Ref
9385 @noindent
9388 @node Attribute Restriction_Set
9389 @unnumberedsec Attribute Restriction_Set
9390 @findex Restriction_Set
9391 @cindex Restrictions
9392 @noindent
9393 This attribute allows compile time testing of restrictions that
9394 are currently in effect. It is primarily intended for specializing
9395 code in the run-time based on restrictions that are active (e.g.
9396 don't need to save fpt registers if restriction No_Floating_Point
9397 is known to be in effect), but can be used anywhere.
9399 There are two forms:
9401 @smallexample @c ada
9402 System'Restriction_Set (partition_boolean_restriction_NAME)
9403 System'Restriction_Set (No_Dependence => library_unit_NAME);
9404 @end smallexample
9406 @noindent
9407 In the case of the first form, the only restriction names
9408 allowed are parameterless restrictions that are checked
9409 for consistency at bind time. For a complete list see the
9410 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
9412 The result returned is True if the restriction is known to
9413 be in effect, and False if the restriction is known not to
9414 be in effect. An important guarantee is that the value of
9415 a Restriction_Set attribute is known to be consistent throughout
9416 all the code of a partition.
9418 This is trivially achieved if the entire partition is compiled
9419 with a consistent set of restriction pragmas. However, the
9420 compilation model does not require this. It is possible to
9421 compile one set of units with one set of pragmas, and another
9422 set of units with another set of pragmas. It is even possible
9423 to compile a spec with one set of pragmas, and then WITH the
9424 same spec with a different set of pragmas. Inconsistencies
9425 in the actual use of the restriction are checked at bind time.
9427 In order to achieve the guarantee of consistency for the
9428 Restriction_Set pragma, we consider that a use of the pragma
9429 that yields False is equivalent to a violation of the
9430 restriction.
9432 So for example if you write
9434 @smallexample @c ada
9435 if System'Restriction_Set (No_Floating_Point) then
9436    ...
9437 else
9438    ...
9439 end if;
9440 @end smallexample
9442 @noindent
9443 And the result is False, so that the else branch is executed,
9444 you can assume that this restriction is not set for any unit
9445 in the partition. This is checked by considering this use of
9446 the restriction pragma to be a violation of the restriction
9447 No_Floating_Point. This means that no other unit can attempt
9448 to set this restriction (if some unit does attempt to set it,
9449 the binder will refuse to bind the partition).
9451 Technical note: The restriction name and the unit name are
9452 intepreted entirely syntactically, as in the corresponding
9453 Restrictions pragma, they are not analyzed semantically,
9454 so they do not have a type.
9456 @node Attribute Result
9457 @unnumberedsec Attribute Result
9458 @findex Result
9459 @noindent
9460 @code{@var{function}'Result} can only be used with in a Postcondition pragma
9461 for a function. The prefix must be the name of the corresponding function. This
9462 is used to refer to the result of the function in the postcondition expression.
9463 For a further discussion of the use of this attribute and examples of its use,
9464 see the description of pragma Postcondition.
9466 @node Attribute Safe_Emax
9467 @unnumberedsec Attribute Safe_Emax
9468 @cindex Ada 83 attributes
9469 @findex Safe_Emax
9470 @noindent
9471 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
9472 the Ada 83 reference manual for an exact description of the semantics of
9473 this attribute.
9475 @node Attribute Safe_Large
9476 @unnumberedsec Attribute Safe_Large
9477 @cindex Ada 83 attributes
9478 @findex Safe_Large
9479 @noindent
9480 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
9481 the Ada 83 reference manual for an exact description of the semantics of
9482 this attribute.
9484 @node Attribute Safe_Small
9485 @unnumberedsec Attribute Safe_Small
9486 @cindex Ada 83 attributes
9487 @findex Safe_Small
9488 @noindent
9489 The @code{Safe_Small} attribute is provided for compatibility with Ada 83.  See
9490 the Ada 83 reference manual for an exact description of the semantics of
9491 this attribute.
9493 @node Attribute Scalar_Storage_Order
9494 @unnumberedsec Attribute Scalar_Storage_Order
9495 @cindex Endianness
9496 @cindex Scalar storage order
9497 @findex Scalar_Storage_Order
9498 @noindent
9499 For every array or record type @var{S}, the representation attribute
9500 @code{Scalar_Storage_Order} denotes the order in which storage elements
9501 that make up scalar components are ordered within S. The value given must
9502 be a static expression of type System.Bit_Order. The following is an example
9503 of the use of this feature:
9505 @smallexample @c ada
9506    --  Component type definitions
9508    subtype Yr_Type is Natural range 0 .. 127;
9509    subtype Mo_Type is Natural range 1 .. 12;
9510    subtype Da_Type is Natural range 1 .. 31;
9512    --  Record declaration
9514    type Date is record
9515       Years_Since_1980 : Yr_Type;
9516       Month            : Mo_Type;
9517       Day_Of_Month     : Da_Type;
9518    end record;
9520    --  Record representation clause
9522    for Date use record
9523       Years_Since_1980 at 0 range 0  ..  6;
9524       Month            at 0 range 7  .. 10;
9525       Day_Of_Month     at 0 range 11 .. 15;
9526    end record;
9528    --  Attribute definition clauses
9530    for Date'Bit_Order use System.High_Order_First;
9531    for Date'Scalar_Storage_Order use System.High_Order_First;
9532    --  If Scalar_Storage_Order is specified, it must be consistent with
9533    --  Bit_Order, so it's best to always define the latter explicitly if
9534    --  the former is used.
9535 @end smallexample
9537 @noindent
9538 Other properties are as for standard representation attribute @code{Bit_Order},
9539 as defined by Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
9541 For a record type @var{T}, if @code{@var{T}'Scalar_Storage_Order} is
9542 specified explicitly, it shall be equal to @code{@var{T}'Bit_Order}. Note:
9543 this means that if a @code{Scalar_Storage_Order} attribute definition
9544 clause is not confirming, then the type's @code{Bit_Order} shall be
9545 specified explicitly and set to the same value.
9547 Derived types inherit an explicitly set scalar storage order from their parent
9548 types. This may be overridden for the derived type by giving an explicit scalar
9549 storage order for the derived type. For a record extension, the derived type
9550 must have the same scalar storage order as the parent type.
9552 If a component of @var{T} is of a record or array type, then that type must
9553 also have a @code{Scalar_Storage_Order} attribute definition clause.
9555 A component of a record or array type that is a packed array, or that
9556 does not start on a byte boundary, must have the same scalar storage order
9557 as the enclosing record or array type.
9559 No component of a type that has an explicit @code{Scalar_Storage_Order}
9560 attribute definition may be aliased.
9562 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
9563 with a value equal to @code{System.Default_Bit_Order}) has no effect.
9565 If the opposite storage order is specified, then whenever the value of
9566 a scalar component of an object of type @var{S} is read, the storage
9567 elements of the enclosing machine scalar are first reversed (before
9568 retrieving the component value, possibly applying some shift and mask
9569 operatings on the enclosing machine scalar), and the opposite operation
9570 is done for writes.
9572 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
9573 are relaxed. Instead, the following rules apply:
9575 @itemize @bullet
9576 @item the underlying storage elements are those at positions
9577   @code{(position + first_bit / storage_element_size) ..
9578         (position + (last_bit + storage_element_size - 1) /
9579                     storage_element_size)}
9580 @item the sequence of underlying storage elements shall have
9581         a size no greater than the largest machine scalar
9582 @item the enclosing machine scalar is defined as the smallest machine
9583         scalar starting at a position no greater than
9584         @code{position + first_bit / storage_element_size} and covering
9585         storage elements at least up to @code{position + (last_bit +
9586         storage_element_size - 1) / storage_element_size}
9587 @item the position of the component is interpreted relative to that machine
9588  scalar.
9590 @end itemize
9592 If no scalar storage order is specified for a type (either directly, or by
9593 inheritance in the case of a derived type), then the default is normally
9594 the native ordering of the target, but this default can be overridden using
9595 pragma @code{Default_Scalar_Storage_Order}.
9597 @node Attribute Simple_Storage_Pool
9598 @unnumberedsec Attribute Simple_Storage_Pool
9599 @cindex Storage pool, simple
9600 @cindex Simple storage pool
9601 @findex Simple_Storage_Pool
9602 @noindent
9603 For every nonformal, nonderived access-to-object type @var{Acc}, the
9604 representation attribute @code{Simple_Storage_Pool} may be specified
9605 via an attribute_definition_clause (or by specifying the equivalent aspect):
9607 @smallexample @c ada
9609 My_Pool : My_Simple_Storage_Pool_Type;
9611 type Acc is access My_Data_Type;
9613 for Acc'Simple_Storage_Pool use My_Pool;
9615 @end smallexample
9617 @noindent
9618 The name given in an attribute_definition_clause for the
9619 @code{Simple_Storage_Pool} attribute shall denote a variable of
9620 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
9622 The use of this attribute is only allowed for a prefix denoting a type
9623 for which it has been specified. The type of the attribute is the type
9624 of the variable specified as the simple storage pool of the access type,
9625 and the attribute denotes that variable.
9627 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
9628 for the same access type.
9630 If the @code{Simple_Storage_Pool} attribute has been specified for an access
9631 type, then applying the @code{Storage_Pool} attribute to the type is flagged
9632 with a warning and its evaluation raises the exception @code{Program_Error}.
9634 If the Simple_Storage_Pool attribute has been specified for an access
9635 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
9636 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
9637 which is intended to indicate the number of storage elements reserved for
9638 the simple storage pool. If the Storage_Size function has not been defined
9639 for the simple storage pool type, then this attribute returns zero.
9641 If an access type @var{S} has a specified simple storage pool of type
9642 @var{SSP}, then the evaluation of an allocator for that access type calls
9643 the primitive @code{Allocate} procedure for type @var{SSP}, passing
9644 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
9645 semantics of such allocators is the same as those defined for allocators
9646 in section 13.11 of the Ada Reference Manual, with the term
9647 ``simple storage pool'' substituted for ``storage pool''.
9649 If an access type @var{S} has a specified simple storage pool of type
9650 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
9651 for that access type invokes the primitive @code{Deallocate} procedure
9652 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
9653 parameter. The detailed semantics of such unchecked deallocations is the same
9654 as defined in section 13.11.2 of the Ada Reference Manual, except that the
9655 term ``simple storage pool'' is substituted for ``storage pool''.
9657 @node Attribute Small
9658 @unnumberedsec Attribute Small
9659 @cindex Ada 83 attributes
9660 @findex Small
9661 @noindent
9662 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
9663 fixed-point types.
9664 GNAT also allows this attribute to be applied to floating-point types
9665 for compatibility with Ada 83.  See
9666 the Ada 83 reference manual for an exact description of the semantics of
9667 this attribute when applied to floating-point types.
9669 @node Attribute Storage_Unit
9670 @unnumberedsec Attribute Storage_Unit
9671 @findex Storage_Unit
9672 @noindent
9673 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
9674 prefix) provides the same value as @code{System.Storage_Unit}.
9676 @node Attribute Stub_Type
9677 @unnumberedsec Attribute Stub_Type
9678 @findex Stub_Type
9679 @noindent
9680 The GNAT implementation of remote access-to-classwide types is
9681 organized as described in AARM section E.4 (20.t): a value of an RACW type
9682 (designating a remote object) is represented as a normal access
9683 value, pointing to a "stub" object which in turn contains the
9684 necessary information to contact the designated remote object. A
9685 call on any dispatching operation of such a stub object does the
9686 remote call, if necessary, using the information in the stub object
9687 to locate the target partition, etc.
9689 For a prefix @code{T} that denotes a remote access-to-classwide type,
9690 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
9692 By construction, the layout of @code{T'Stub_Type} is identical to that of
9693 type @code{RACW_Stub_Type} declared in the internal implementation-defined
9694 unit @code{System.Partition_Interface}. Use of this attribute will create
9695 an implicit dependency on this unit.
9697 @node Attribute System_Allocator_Alignment
9698 @unnumberedsec Attribute System_Allocator_Alignment
9699 @cindex Alignment, allocator
9700 @findex System_Allocator_Alignment
9701 @noindent
9702 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
9703 permissible prefix) provides the observable guaranted to be honored by
9704 the system allocator (malloc). This is a static value that can be used
9705 in user storage pools based on malloc either to reject allocation
9706 with alignment too large or to enable a realignment circuitry if the
9707 alignment request is larger than this value.
9709 @node Attribute Target_Name
9710 @unnumberedsec Attribute Target_Name
9711 @findex Target_Name
9712 @noindent
9713 @code{Standard'Target_Name} (@code{Standard} is the only permissible
9714 prefix) provides a static string value that identifies the target
9715 for the current compilation. For GCC implementations, this is the
9716 standard gcc target name without the terminating slash (for
9717 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
9719 @node Attribute To_Address
9720 @unnumberedsec Attribute To_Address
9721 @findex To_Address
9722 @noindent
9723 The @code{System'To_Address}
9724 (@code{System} is the only permissible prefix)
9725 denotes a function identical to
9726 @code{System.Storage_Elements.To_Address} except that
9727 it is a static attribute.  This means that if its argument is
9728 a static expression, then the result of the attribute is a
9729 static expression.  This means that such an expression can be
9730 used in contexts (e.g.@: preelaborable packages) which require a
9731 static expression and where the function call could not be used
9732 (since the function call is always non-static, even if its
9733 argument is static). The argument must be in the range
9734 -(2**(m-1) .. 2**m-1, where m is the memory size
9735 (typically 32 or 64). Negative values are intepreted in a
9736 modular manner (e.g. -1 means the same as 16#FFFF_FFFF# on
9737 a 32 bits machine).
9739 @node Attribute To_Any
9740 @unnumberedsec Attribute To_Any
9741 @findex To_Any
9742 @noindent
9743 This internal attribute is used for the generation of remote subprogram
9744 stubs in the context of the Distributed Systems Annex.
9746 @node Attribute Type_Class
9747 @unnumberedsec Attribute Type_Class
9748 @findex Type_Class
9749 @noindent
9750 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
9751 the value of the type class for the full type of @var{type}.  If
9752 @var{type} is a generic formal type, the value is the value for the
9753 corresponding actual subtype.  The value of this attribute is of type
9754 @code{System.Aux_DEC.Type_Class}, which has the following definition:
9756 @smallexample @c ada
9757 type Type_Class is
9758   (Type_Class_Enumeration,
9759    Type_Class_Integer,
9760    Type_Class_Fixed_Point,
9761    Type_Class_Floating_Point,
9762    Type_Class_Array,
9763    Type_Class_Record,
9764    Type_Class_Access,
9765    Type_Class_Task,
9766    Type_Class_Address);
9767 @end smallexample
9769 @noindent
9770 Protected types yield the value @code{Type_Class_Task}, which thus
9771 applies to all concurrent types.  This attribute is designed to
9772 be compatible with the DEC Ada 83 attribute of the same name.
9774 @node Attribute Type_Key
9775 @unnumberedsec Attribute Type_Key
9776 @findex Type_Key
9777 @noindent
9778 The @code{Type_Key} attribute is applicable to a type or subtype and
9779 yields a value of type Standard.String containing encoded information
9780 about the type or subtype. This provides improved compatibility with
9781 other implementations that support this attribute.
9783 @node Attribute TypeCode
9784 @unnumberedsec Attribute TypeCode
9785 @findex TypeCode
9786 @noindent
9787 This internal attribute is used for the generation of remote subprogram
9788 stubs in the context of the Distributed Systems Annex.
9790 @node Attribute UET_Address
9791 @unnumberedsec Attribute UET_Address
9792 @findex UET_Address
9793 @noindent
9794 The @code{UET_Address} attribute can only be used for a prefix which
9795 denotes a library package.  It yields the address of the unit exception
9796 table when zero cost exception handling is used.  This attribute is
9797 intended only for use within the GNAT implementation.  See the unit
9798 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
9799 for details on how this attribute is used in the implementation.
9801 @node Attribute Unconstrained_Array
9802 @unnumberedsec Attribute Unconstrained_Array
9803 @findex Unconstrained_Array
9804 @noindent
9805 The @code{Unconstrained_Array} attribute can be used with a prefix that
9806 denotes any type or subtype. It is a static attribute that yields
9807 @code{True} if the prefix designates an unconstrained array,
9808 and @code{False} otherwise. In a generic instance, the result is
9809 still static, and yields the result of applying this test to the
9810 generic actual.
9812 @node Attribute Universal_Literal_String
9813 @unnumberedsec Attribute Universal_Literal_String
9814 @cindex Named numbers, representation of
9815 @findex Universal_Literal_String
9816 @noindent
9817 The prefix of @code{Universal_Literal_String} must be a named
9818 number.  The static result is the string consisting of the characters of
9819 the number as defined in the original source.  This allows the user
9820 program to access the actual text of named numbers without intermediate
9821 conversions and without the need to enclose the strings in quotes (which
9822 would preclude their use as numbers).
9824 For example, the following program prints the first 50 digits of pi:
9826 @smallexample @c ada
9827 with Text_IO; use Text_IO;
9828 with Ada.Numerics;
9829 procedure Pi is
9830 begin
9831    Put (Ada.Numerics.Pi'Universal_Literal_String);
9832 end;
9833 @end smallexample
9835 @node Attribute Unrestricted_Access
9836 @unnumberedsec Attribute Unrestricted_Access
9837 @cindex @code{Access}, unrestricted
9838 @findex Unrestricted_Access
9839 @noindent
9840 The @code{Unrestricted_Access} attribute is similar to @code{Access}
9841 except that all accessibility and aliased view checks are omitted.  This
9842 is a user-beware attribute.
9844 For objects, it is similar to @code{Address}, for which it is a
9845 desirable replacement where the value desired is an access type.
9846 In other words, its effect is similar to first applying the
9847 @code{Address} attribute and then doing an unchecked conversion to a
9848 desired access type.
9850 For subprograms, @code{P'Unrestricted_Access} may be used where
9851 @code{P'Access} would be illegal, to construct a value of a
9852 less-nested named access type that designates a more-nested
9853 subprogram. This value may be used in indirect calls, so long as the
9854 more-nested subprogram still exists; once the subprogram containing it
9855 has returned, such calls are erroneous. For example:
9857 @smallexample @c ada
9858 package body P is
9860    type Less_Nested is not null access procedure;
9861    Global : Less_Nested;
9863    procedure P1 is
9864    begin
9865       Global.all;
9866    end P1;
9868    procedure P2 is
9869       Local_Var : Integer;
9871       procedure More_Nested is
9872       begin
9873          ... Local_Var ...
9874       end More_Nested;
9875    begin
9876       Global := More_Nested'Unrestricted_Access;
9877       P1;
9878    end P2;
9880 end P;
9881 @end smallexample
9883 When P1 is called from P2, the call via Global is OK, but if P1 were
9884 called after P2 returns, it would be an erroneous use of a dangling
9885 pointer.
9887 For objects, it is possible to use @code{Unrestricted_Access} for any
9888 type, but care must be exercised if it is used to create pointers to
9889 unconstrained array objects.  In this case, the resulting pointer has
9890 the same scope as the context of the attribute, and may not be
9891 returned to some enclosing scope.  For instance, a function cannot use
9892 @code{Unrestricted_Access} to create a pointer to unconstrained and
9893 then return that value to the caller.  In addition, it is only valid
9894 to create pointers to unconstrained arrays using this attribute if the
9895 pointer has the normal default ``fat'' representation where a pointer
9896 has two components, one points to the array and one points to the
9897 bounds.  If a size clause is used to force ``thin'' representation for
9898 a pointer to unconstrained where there is only space for a single
9899 pointer, then the resulting pointer is not usable.
9901 In the simple case where a direct use of Unrestricted_Access attempts
9902 to make a thin pointer for a non-aliased object, the compiler will
9903 reject the use as illegal, as shown in the following example:
9905 @smallexample @c ada
9906 with System; use System;
9907 procedure SliceUA2 is
9908    type A is access all String;
9909    for A'Size use Standard'Address_Size;
9911    procedure P (Arg : A) is
9912    begin
9913       null;
9914    end P;
9916    X : String := "hello world!";
9917    X2 : aliased String := "hello world!";
9919    AV : A := X'Unrestricted_Access;    -- ERROR
9920              |
9921 >>> illegal use of Unrestricted_Access attribute
9922 >>> attempt to generate thin pointer to unaliased object
9924 begin
9925    P (X'Unrestricted_Access);          -- ERROR
9926       |
9927 >>> illegal use of Unrestricted_Access attribute
9928 >>> attempt to generate thin pointer to unaliased object
9930    P (X(7 .. 12)'Unrestricted_Access); -- ERROR
9931       |
9932 >>> illegal use of Unrestricted_Access attribute
9933 >>> attempt to generate thin pointer to unaliased object
9935    P (X2'Unrestricted_Access);         -- OK
9936 end;
9937 @end smallexample
9939 @noindent
9940 but other cases cannot be detected by the compiler, and are
9941 considered to be erroneous. Consider the following example:
9943 @smallexample @c ada
9944 with System; use System;
9945 with System; use System;
9946 procedure SliceUA is
9947    type AF is access all String;
9949    type A is access all String;
9950    for A'Size use Standard'Address_Size;
9952    procedure P (Arg : A) is
9953    begin
9954       if Arg'Length /= 6 then
9955          raise Program_Error;
9956       end if;
9957    end P;
9959    X : String := "hello world!";
9960    Y : AF := X (7 .. 12)'Unrestricted_Access;
9962 begin
9963    P (A (Y));
9964 end;
9965 @end smallexample
9967 @noindent
9968 A normal unconstrained array value
9969 or a constrained array object marked as aliased has the bounds in memory
9970 just before the array, so a thin pointer can retrieve both the data and
9971 the bounds.  But in this case, the non-aliased object @code{X} does not have the
9972 bounds before the string.  If the size clause for type @code{A}
9973 were not present, then the pointer
9974 would be a fat pointer, where one component is a pointer to the bounds,
9975 and all would be well.  But with the size clause present, the conversion from
9976 fat pointer to thin pointer in the call loses the bounds, and so this
9977 is erroneous, and the program likely raises a @code{Program_Error} exception.
9979 In general, it is advisable to completely
9980 avoid mixing the use of thin pointers and the use of
9981 @code{Unrestricted_Access} where the designated type is an
9982 unconstrained array.  The use of thin pointers should be restricted to
9983 cases of porting legacy code that implicitly assumes the size of pointers,
9984 and such code should not in any case be using this attribute.
9986 Another erroneous situation arises if the attribute is
9987 applied to a constant. The resulting pointer can be used to access the
9988 constant, but the effect of trying to modify a constant in this manner
9989 is not well-defined. Consider this example:
9991 @smallexample @c ada
9992 P : constant Integer := 4;
9993 type R is access all Integer;
9994 RV : R := P'Unrestricted_Access;
9996 RV.all := 3;
9997 @end smallexample
9999 @noindent
10000 Here we attempt to modify the constant P from 4 to 3, but the compiler may
10001 or may not notice this attempt, and subsequent references to P may yield
10002 either the value 3 or the value 4 or the assignment may blow up if the
10003 compiler decides to put P in read-only memory. One particular case where
10004 @code{Unrestricted_Access} can be used in this way is to modify the
10005 value of an @code{IN} parameter:
10007 @smallexample @c ada
10008 procedure K (S : in String) is
10009    type R is access all Character;
10010    RV : R := S (3)'Unrestricted_Access;
10011 begin
10012    RV.all := 'a';
10013 end;
10014 @end smallexample
10016 @noindent
10017 In general this is a risky approach. It may appear to "work" but such uses of
10018 @code{Unrestricted_Access} are potentially non-portable, even from one version
10019 of @code{GNAT} to another, so are best avoided if possible.
10021 @node Attribute Update
10022 @unnumberedsec Attribute Update
10023 @findex Update
10024 @noindent
10025 The @code{Update} attribute creates a copy of an array or record value
10026 with one or more modified components. The syntax is:
10028 @smallexample @c ada
10029 PREFIX'Update ( RECORD_COMPONENT_ASSOCIATION_LIST )
10030 PREFIX'Update ( ARRAY_COMPONENT_ASSOCIATION @{, ARRAY_COMPONENT_ASSOCIATION @} )
10031 PREFIX'Update ( MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION
10032                 @{, MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION @} )
10034 MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION ::= INDEX_EXPRESSION_LIST_LIST => EXPRESSION
10035 INDEX_EXPRESSION_LIST_LIST                   ::= INDEX_EXPRESSION_LIST @{| INDEX_EXPRESSION_LIST @}
10036 INDEX_EXPRESSION_LIST                        ::= ( EXPRESSION @{, EXPRESSION @} )
10037 @end smallexample
10039 @noindent
10040 where @code{PREFIX} is the name of an array or record object, and
10041 the association list in parentheses does not contain an @code{others}
10042 choice. The effect is to yield a copy of the array or record value which
10043 is unchanged apart from the components mentioned in the association list, which
10044 are changed to the indicated value. The original value of the array or
10045 record value is not affected. For example:
10047 @smallexample @c ada
10048 type Arr is Array (1 .. 5) of Integer;
10050 Avar1 : Arr := (1,2,3,4,5);
10051 Avar2 : Arr := Avar1'Update (2 => 10, 3 .. 4 => 20);
10052 @end smallexample
10054 @noindent
10055 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
10056 begin unmodified. Similarly:
10058 @smallexample @c ada
10059 type Rec is A, B, C : Integer;
10061 Rvar1 : Rec := (A => 1, B => 2, C => 3);
10062 Rvar2 : Rec := Rvar1'Update (B => 20);
10063 @end smallexample
10065 @noindent
10066 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
10067 with @code{Rvar1} being unmodifed.
10068 Note that the value of the attribute reference is computed
10069 completely before it is used. This means that if you write:
10071 @smallexample @c ada
10072 Avar1 := Avar1'Update (1 => 10, 2 => Function_Call);
10073 @end smallexample
10075 @noindent
10076 then the value of @code{Avar1} is not modified if @code{Function_Call}
10077 raises an exception, unlike the effect of a series of direct assignments
10078 to elements of @code{Avar1}. In general this requires that
10079 two extra complete copies of the object are required, which should be
10080 kept in mind when considering efficiency.
10082 The @code{Update} attribute cannot be applied to prefixes of a limited
10083 type, and cannot reference discriminants in the case of a record type.
10084 The accessibility level of an Update attribute result object is defined
10085 as for an aggregate.
10087 In the record case, no component can be mentioned more than once. In
10088 the array case, two overlapping ranges can appear in the association list,
10089 in which case the modifications are processed left to right.
10091 Multi-dimensional arrays can be modified, as shown by this example:
10093 @smallexample @c ada
10094 A : array (1 .. 10, 1 .. 10) of Integer;
10096 A := A'Update ((1, 2) => 20, (3, 4) => 30);
10097 @end smallexample
10099 @noindent
10100 which changes element (1,2) to 20 and (3,4) to 30.
10102 @node Attribute Valid_Scalars
10103 @unnumberedsec Attribute Valid_Scalars
10104 @findex Valid_Scalars
10105 @noindent
10106 The @code{'Valid_Scalars} attribute is intended to make it easier to
10107 check the validity of scalar subcomponents of composite objects. It
10108 is defined for any prefix @code{X} that denotes an object.
10109 The value of this attribute is of the predefined type Boolean.
10110 @code{X'Valid_Scalars} yields True if and only if evaluation of
10111 @code{P'Valid} yields True for every scalar part P of X or if X has
10112 no scalar parts. It is not specified in what order the scalar parts
10113 are checked, nor whether any more are checked after any one of them
10114 is determined to be invalid. If the prefix @code{X} is of a class-wide
10115 type @code{T'Class} (where @code{T} is the associated specific type),
10116 or if the prefix @code{X} is of a specific tagged type @code{T}, then
10117 only the scalar parts of components of @code{T} are traversed; in other
10118 words, components of extensions of @code{T} are not traversed even if
10119 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
10120 be determined at compile time that the prefix of the attribute has no
10121 scalar parts (e.g., if the prefix is of an access type, an interface type,
10122 an undiscriminated task type, or an undiscriminated protected type).
10124 For scalar types, @code{Valid_Scalars} is equivalent to @code{Valid}. The use
10125 of this attribute is not permitted for @code{Unchecked_Union} types for which
10126 in general it is not possible to determine the values of the discriminants.
10128 Note: @code{Valid_Scalars} can generate a lot of code, especially in the case
10129 of a large variant record. If the attribute is called in many places in the
10130 same program applied to objects of the same type, it can reduce program size
10131 to write a function with a single use of the attribute, and then call that
10132 function from multiple places.
10134 @node Attribute VADS_Size
10135 @unnumberedsec Attribute VADS_Size
10136 @cindex @code{Size}, VADS compatibility
10137 @findex VADS_Size
10138 @noindent
10139 The @code{'VADS_Size} attribute is intended to make it easier to port
10140 legacy code which relies on the semantics of @code{'Size} as implemented
10141 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
10142 same semantic interpretation.  In particular, @code{'VADS_Size} applied
10143 to a predefined or other primitive type with no Size clause yields the
10144 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
10145 typical machines).  In addition @code{'VADS_Size} applied to an object
10146 gives the result that would be obtained by applying the attribute to
10147 the corresponding type.
10149 @node Attribute Value_Size
10150 @unnumberedsec Attribute Value_Size
10151 @cindex @code{Size}, setting for not-first subtype
10152 @findex Value_Size
10153 @code{@var{type}'Value_Size} is the number of bits required to represent
10154 a value of the given subtype.  It is the same as @code{@var{type}'Size},
10155 but, unlike @code{Size}, may be set for non-first subtypes.
10157 @node Attribute Wchar_T_Size
10158 @unnumberedsec Attribute Wchar_T_Size
10159 @findex Wchar_T_Size
10160 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
10161 prefix) provides the size in bits of the C @code{wchar_t} type
10162 primarily for constructing the definition of this type in
10163 package @code{Interfaces.C}. The result is a static constant.
10165 @node Attribute Word_Size
10166 @unnumberedsec Attribute Word_Size
10167 @findex Word_Size
10168 @code{Standard'Word_Size} (@code{Standard} is the only permissible
10169 prefix) provides the value @code{System.Word_Size}. The result is
10170 a static constant.
10172 @node Standard and Implementation Defined Restrictions
10173 @chapter Standard and Implementation Defined Restrictions
10175 @noindent
10176 All RM defined Restriction identifiers are implemented:
10178 @itemize @bullet
10179 @item language-defined restrictions (see 13.12.1)
10180 @item tasking restrictions (see D.7)
10181 @item high integrity restrictions (see H.4)
10182 @end itemize
10184 @noindent
10185 GNAT implements additional restriction identifiers. All restrictions, whether
10186 language defined or GNAT-specific, are listed in the following.
10188 @menu
10189 * Partition-Wide Restrictions::
10190 * Program Unit Level Restrictions::
10191 @end menu
10193 @node Partition-Wide Restrictions
10194 @section Partition-Wide Restrictions
10196 There are two separate lists of restriction identifiers. The first
10197 set requires consistency throughout a partition (in other words, if the
10198 restriction identifier is used for any compilation unit in the partition,
10199 then all compilation units in the partition must obey the restriction).
10201 @menu
10202 * Immediate_Reclamation::
10203 * Max_Asynchronous_Select_Nesting::
10204 * Max_Entry_Queue_Length::
10205 * Max_Protected_Entries::
10206 * Max_Select_Alternatives::
10207 * Max_Storage_At_Blocking::
10208 * Max_Task_Entries::
10209 * Max_Tasks::
10210 * No_Abort_Statements::
10211 * No_Access_Parameter_Allocators::
10212 * No_Access_Subprograms::
10213 * No_Allocators::
10214 * No_Anonymous_Allocators::
10215 * No_Calendar::
10216 * No_Coextensions::
10217 * No_Default_Initialization::
10218 * No_Delay::
10219 * No_Dependence::
10220 * No_Direct_Boolean_Operators::
10221 * No_Dispatch::
10222 * No_Dispatching_Calls::
10223 * No_Dynamic_Attachment::
10224 * No_Dynamic_Priorities::
10225 * No_Entry_Calls_In_Elaboration_Code::
10226 * No_Enumeration_Maps::
10227 * No_Exception_Handlers::
10228 * No_Exception_Propagation::
10229 * No_Exception_Registration::
10230 * No_Exceptions::
10231 * No_Finalization::
10232 * No_Fixed_Point::
10233 * No_Floating_Point::
10234 * No_Implicit_Conditionals::
10235 * No_Implicit_Dynamic_Code::
10236 * No_Implicit_Heap_Allocations::
10237 * No_Implicit_Loops::
10238 * No_Initialize_Scalars::
10239 * No_IO::
10240 * No_Local_Allocators::
10241 * No_Local_Protected_Objects::
10242 * No_Local_Timing_Events::
10243 * No_Long_Long_Integers::
10244 * No_Multiple_Elaboration::
10245 * No_Nested_Finalization::
10246 * No_Protected_Type_Allocators::
10247 * No_Protected_Types::
10248 * No_Recursion::
10249 * No_Reentrancy::
10250 * No_Relative_Delay::
10251 * No_Requeue_Statements::
10252 * No_Secondary_Stack::
10253 * No_Select_Statements::
10254 * No_Specific_Termination_Handlers::
10255 * No_Specification_of_Aspect::
10256 * No_Standard_Allocators_After_Elaboration::
10257 * No_Standard_Storage_Pools::
10258 * No_Stream_Optimizations::
10259 * No_Streams::
10260 * No_Task_Allocators::
10261 * No_Task_Attributes_Package::
10262 * No_Task_Hierarchy::
10263 * No_Task_Termination::
10264 * No_Tasking::
10265 * No_Terminate_Alternatives::
10266 * No_Unchecked_Access::
10267 * Simple_Barriers::
10268 * Static_Priorities::
10269 * Static_Storage_Size::
10270 @end menu
10272 @node Immediate_Reclamation
10273 @unnumberedsubsec Immediate_Reclamation
10274 @findex Immediate_Reclamation
10275 [RM H.4] This restriction ensures that, except for storage occupied by
10276 objects created by allocators and not deallocated via unchecked
10277 deallocation, any storage reserved at run time for an object is
10278 immediately reclaimed when the object no longer exists.
10280 @node Max_Asynchronous_Select_Nesting
10281 @unnumberedsubsec Max_Asynchronous_Select_Nesting
10282 @findex Max_Asynchronous_Select_Nesting
10283 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
10284 selects. Violations of this restriction with a value of zero are
10285 detected at compile time. Violations of this restriction with values
10286 other than zero cause Storage_Error to be raised.
10288 @node Max_Entry_Queue_Length
10289 @unnumberedsubsec Max_Entry_Queue_Length
10290 @findex Max_Entry_Queue_Length
10291 [RM D.7] This restriction is a declaration that any protected entry compiled in
10292 the scope of the restriction has at most the specified number of
10293 tasks waiting on the entry at any one time, and so no queue is required.
10294 Note that this restriction is checked at run time. Violation of this
10295 restriction results in the raising of Program_Error exception at the point of
10296 the call.
10298 @findex Max_Entry_Queue_Depth
10299 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
10300 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
10301 compatibility purposes (and a warning will be generated for its use if
10302 warnings on obsolescent features are activated).
10304 @node Max_Protected_Entries
10305 @unnumberedsubsec Max_Protected_Entries
10306 @findex Max_Protected_Entries
10307 [RM D.7] Specifies the maximum number of entries per protected type. The
10308 bounds of every entry family of a protected unit shall be static, or shall be
10309 defined by a discriminant of a subtype whose corresponding bound is static.
10311 @node Max_Select_Alternatives
10312 @unnumberedsubsec Max_Select_Alternatives
10313 @findex Max_Select_Alternatives
10314 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
10316 @node Max_Storage_At_Blocking
10317 @unnumberedsubsec Max_Storage_At_Blocking
10318 @findex Max_Storage_At_Blocking
10319 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
10320 Storage_Size that can be retained by a blocked task. A violation of this
10321 restriction causes Storage_Error to be raised.
10323 @node Max_Task_Entries
10324 @unnumberedsubsec Max_Task_Entries
10325 @findex Max_Task_Entries
10326 [RM D.7] Specifies the maximum number of entries
10327 per task.  The bounds of every entry family
10328 of a task unit shall be static, or shall be
10329 defined by a discriminant of a subtype whose
10330 corresponding bound is static.
10332 @node Max_Tasks
10333 @unnumberedsubsec Max_Tasks
10334 @findex Max_Tasks
10335 [RM D.7] Specifies the maximum number of task that may be created, not
10336 counting the creation of the environment task.  Violations of this
10337 restriction with a value of zero are detected at compile
10338 time. Violations of this restriction with values other than zero cause
10339 Storage_Error to be raised.
10341 @node No_Abort_Statements
10342 @unnumberedsubsec No_Abort_Statements
10343 @findex No_Abort_Statements
10344 [RM D.7] There are no abort_statements, and there are
10345 no calls to Task_Identification.Abort_Task.
10347 @node No_Access_Parameter_Allocators
10348 @unnumberedsubsec No_Access_Parameter_Allocators
10349 @findex No_Access_Parameter_Allocators
10350 [RM H.4] This restriction ensures at compile time that there are no
10351 occurrences of an allocator as the actual parameter to an access
10352 parameter.
10354 @node No_Access_Subprograms
10355 @unnumberedsubsec No_Access_Subprograms
10356 @findex No_Access_Subprograms
10357 [RM H.4] This restriction ensures at compile time that there are no
10358 declarations of access-to-subprogram types.
10360 @node No_Allocators
10361 @unnumberedsubsec No_Allocators
10362 @findex No_Allocators
10363 [RM H.4] This restriction ensures at compile time that there are no
10364 occurrences of an allocator.
10366 @node No_Anonymous_Allocators
10367 @unnumberedsubsec No_Anonymous_Allocators
10368 @findex No_Anonymous_Allocators
10369 [RM H.4] This restriction ensures at compile time that there are no
10370 occurrences of an allocator of anonymous access type.
10372 @node No_Calendar
10373 @unnumberedsubsec No_Calendar
10374 @findex No_Calendar
10375 [GNAT] This restriction ensures at compile time that there is no implicit or
10376 explicit dependence on the package @code{Ada.Calendar}.
10378 @node No_Coextensions
10379 @unnumberedsubsec No_Coextensions
10380 @findex No_Coextensions
10381 [RM H.4] This restriction ensures at compile time that there are no
10382 coextensions. See 3.10.2.
10384 @node No_Default_Initialization
10385 @unnumberedsubsec No_Default_Initialization
10386 @findex No_Default_Initialization
10388 [GNAT] This restriction prohibits any instance of default initialization
10389 of variables.  The binder implements a consistency rule which prevents
10390 any unit compiled without the restriction from with'ing a unit with the
10391 restriction (this allows the generation of initialization procedures to
10392 be skipped, since you can be sure that no call is ever generated to an
10393 initialization procedure in a unit with the restriction active). If used
10394 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
10395 is to prohibit all cases of variables declared without a specific
10396 initializer (including the case of OUT scalar parameters).
10398 @node No_Delay
10399 @unnumberedsubsec No_Delay
10400 @findex No_Delay
10401 [RM H.4] This restriction ensures at compile time that there are no
10402 delay statements and no dependences on package Calendar.
10404 @node No_Dependence
10405 @unnumberedsubsec No_Dependence
10406 @findex No_Dependence
10407 [RM 13.12.1] This restriction checks at compile time that there are no
10408 dependence on a library unit.
10410 @node No_Direct_Boolean_Operators
10411 @unnumberedsubsec No_Direct_Boolean_Operators
10412 @findex No_Direct_Boolean_Operators
10413 [GNAT] This restriction ensures that no logical operators (and/or/xor)
10414 are used on operands of type Boolean (or any type derived from Boolean).
10415 This is intended for use in safety critical programs where the certification
10416 protocol requires the use of short-circuit (and then, or else) forms for all
10417 composite boolean operations.
10419 @node No_Dispatch
10420 @unnumberedsubsec No_Dispatch
10421 @findex No_Dispatch
10422 [RM H.4] This restriction ensures at compile time that there are no
10423 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
10425 @node No_Dispatching_Calls
10426 @unnumberedsubsec No_Dispatching_Calls
10427 @findex No_Dispatching_Calls
10428 [GNAT] This restriction ensures at compile time that the code generated by the
10429 compiler involves no dispatching calls. The use of this restriction allows the
10430 safe use of record extensions, classwide membership tests and other classwide
10431 features not involving implicit dispatching. This restriction ensures that
10432 the code contains no indirect calls through a dispatching mechanism. Note that
10433 this includes internally-generated calls created by the compiler, for example
10434 in the implementation of class-wide objects assignments. The
10435 membership test is allowed in the presence of this restriction, because its
10436 implementation requires no dispatching.
10437 This restriction is comparable to the official Ada restriction
10438 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
10439 all classwide constructs that do not imply dispatching.
10440 The following example indicates constructs that violate this restriction.
10442 @smallexample
10443 package Pkg is
10444   type T is tagged record
10445     Data : Natural;
10446   end record;
10447   procedure P (X : T);
10449   type DT is new T with record
10450     More_Data : Natural;
10451   end record;
10452   procedure Q (X : DT);
10453 end Pkg;
10455 with Pkg; use Pkg;
10456 procedure Example is
10457   procedure Test (O : T'Class) is
10458     N : Natural  := O'Size;--  Error: Dispatching call
10459     C : T'Class := O;      --  Error: implicit Dispatching Call
10460   begin
10461     if O in DT'Class then  --  OK   : Membership test
10462        Q (DT (O));         --  OK   : Type conversion plus direct call
10463     else
10464        P (O);              --  Error: Dispatching call
10465     end if;
10466   end Test;
10468   Obj : DT;
10469 begin
10470   P (Obj);                 --  OK   : Direct call
10471   P (T (Obj));             --  OK   : Type conversion plus direct call
10472   P (T'Class (Obj));       --  Error: Dispatching call
10474   Test (Obj);              --  OK   : Type conversion
10476   if Obj in T'Class then   --  OK   : Membership test
10477      null;
10478   end if;
10479 end Example;
10480 @end smallexample
10482 @node No_Dynamic_Attachment
10483 @unnumberedsubsec No_Dynamic_Attachment
10484 @findex No_Dynamic_Attachment
10485 [RM D.7] This restriction ensures that there is no call to any of the
10486 operations defined in package Ada.Interrupts
10487 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
10488 Detach_Handler, and Reference).
10490 @findex No_Dynamic_Interrupts
10491 The restriction @code{No_Dynamic_Interrupts} is recognized as a
10492 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
10493 compatibility purposes (and a warning will be generated for its use if
10494 warnings on obsolescent features are activated).
10496 @node No_Dynamic_Priorities
10497 @unnumberedsubsec No_Dynamic_Priorities
10498 @findex No_Dynamic_Priorities
10499 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
10501 @node No_Entry_Calls_In_Elaboration_Code
10502 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
10503 @findex No_Entry_Calls_In_Elaboration_Code
10504 [GNAT] This restriction ensures at compile time that no task or protected entry
10505 calls are made during elaboration code.  As a result of the use of this
10506 restriction, the compiler can assume that no code past an accept statement
10507 in a task can be executed at elaboration time.
10509 @node No_Enumeration_Maps
10510 @unnumberedsubsec No_Enumeration_Maps
10511 @findex No_Enumeration_Maps
10512 [GNAT] This restriction ensures at compile time that no operations requiring
10513 enumeration maps are used (that is Image and Value attributes applied
10514 to enumeration types).
10516 @node No_Exception_Handlers
10517 @unnumberedsubsec No_Exception_Handlers
10518 @findex No_Exception_Handlers
10519 [GNAT] This restriction ensures at compile time that there are no explicit
10520 exception handlers. It also indicates that no exception propagation will
10521 be provided. In this mode, exceptions may be raised but will result in
10522 an immediate call to the last chance handler, a routine that the user
10523 must define with the following profile:
10525 @smallexample @c ada
10526 procedure Last_Chance_Handler
10527   (Source_Location : System.Address; Line : Integer);
10528 pragma Export (C, Last_Chance_Handler,
10529                "__gnat_last_chance_handler");
10530 @end smallexample
10532 The parameter is a C null-terminated string representing a message to be
10533 associated with the exception (typically the source location of the raise
10534 statement generated by the compiler). The Line parameter when nonzero
10535 represents the line number in the source program where the raise occurs.
10537 @node No_Exception_Propagation
10538 @unnumberedsubsec No_Exception_Propagation
10539 @findex No_Exception_Propagation
10540 [GNAT] This restriction guarantees that exceptions are never propagated
10541 to an outer subprogram scope. The only case in which an exception may
10542 be raised is when the handler is statically in the same subprogram, so
10543 that the effect of a raise is essentially like a goto statement. Any
10544 other raise statement (implicit or explicit) will be considered
10545 unhandled. Exception handlers are allowed, but may not contain an
10546 exception occurrence identifier (exception choice). In addition, use of
10547 the package GNAT.Current_Exception is not permitted, and reraise
10548 statements (raise with no operand) are not permitted.
10550 @node No_Exception_Registration
10551 @unnumberedsubsec No_Exception_Registration
10552 @findex No_Exception_Registration
10553 [GNAT] This restriction ensures at compile time that no stream operations for
10554 types Exception_Id or Exception_Occurrence are used. This also makes it
10555 impossible to pass exceptions to or from a partition with this restriction
10556 in a distributed environment. If this restriction is active, the generated
10557 code is simplified by omitting the otherwise-required global registration
10558 of exceptions when they are declared.
10560 @node No_Exceptions
10561 @unnumberedsubsec No_Exceptions
10562 @findex No_Exceptions
10563 [RM H.4] This restriction ensures at compile time that there are no
10564 raise statements and no exception handlers.
10566 @node No_Finalization
10567 @unnumberedsubsec No_Finalization
10568 @findex No_Finalization
10569 [GNAT] This restriction disables the language features described in
10570 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
10571 performed by the compiler to support these features. The following types
10572 are no longer considered controlled when this restriction is in effect:
10573 @itemize @bullet
10574 @item
10575 @code{Ada.Finalization.Controlled}
10576 @item
10577 @code{Ada.Finalization.Limited_Controlled}
10578 @item
10579 Derivations from @code{Controlled} or @code{Limited_Controlled}
10580 @item
10581 Class-wide types
10582 @item
10583 Protected types
10584 @item
10585 Task types
10586 @item
10587 Array and record types with controlled components
10588 @end itemize
10589 The compiler no longer generates code to initialize, finalize or adjust an
10590 object or a nested component, either declared on the stack or on the heap. The
10591 deallocation of a controlled object no longer finalizes its contents.
10593 @node No_Fixed_Point
10594 @unnumberedsubsec No_Fixed_Point
10595 @findex No_Fixed_Point
10596 [RM H.4] This restriction ensures at compile time that there are no
10597 occurrences of fixed point types and operations.
10599 @node No_Floating_Point
10600 @unnumberedsubsec No_Floating_Point
10601 @findex No_Floating_Point
10602 [RM H.4] This restriction ensures at compile time that there are no
10603 occurrences of floating point types and operations.
10605 @node No_Implicit_Conditionals
10606 @unnumberedsubsec No_Implicit_Conditionals
10607 @findex No_Implicit_Conditionals
10608 [GNAT] This restriction ensures that the generated code does not contain any
10609 implicit conditionals, either by modifying the generated code where possible,
10610 or by rejecting any construct that would otherwise generate an implicit
10611 conditional. Note that this check does not include run time constraint
10612 checks, which on some targets may generate implicit conditionals as
10613 well. To control the latter, constraint checks can be suppressed in the
10614 normal manner. Constructs generating implicit conditionals include comparisons
10615 of composite objects and the Max/Min attributes.
10617 @node No_Implicit_Dynamic_Code
10618 @unnumberedsubsec No_Implicit_Dynamic_Code
10619 @findex No_Implicit_Dynamic_Code
10620 @cindex trampoline
10621 [GNAT] This restriction prevents the compiler from building ``trampolines''.
10622 This is a structure that is built on the stack and contains dynamic
10623 code to be executed at run time. On some targets, a trampoline is
10624 built for the following features: @code{Access},
10625 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
10626 nested task bodies; primitive operations of nested tagged types.
10627 Trampolines do not work on machines that prevent execution of stack
10628 data. For example, on windows systems, enabling DEP (data execution
10629 protection) will cause trampolines to raise an exception.
10630 Trampolines are also quite slow at run time.
10632 On many targets, trampolines have been largely eliminated. Look at the
10633 version of system.ads for your target --- if it has
10634 Always_Compatible_Rep equal to False, then trampolines are largely
10635 eliminated. In particular, a trampoline is built for the following
10636 features: @code{Address} of a nested subprogram;
10637 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
10638 but only if pragma Favor_Top_Level applies, or the access type has a
10639 foreign-language convention; primitive operations of nested tagged
10640 types.
10642 @node No_Implicit_Heap_Allocations
10643 @unnumberedsubsec No_Implicit_Heap_Allocations
10644 @findex No_Implicit_Heap_Allocations
10645 [RM D.7] No constructs are allowed to cause implicit heap allocation.
10647 @node No_Implicit_Loops
10648 @unnumberedsubsec No_Implicit_Loops
10649 @findex No_Implicit_Loops
10650 [GNAT] This restriction ensures that the generated code does not contain any
10651 implicit @code{for} loops, either by modifying
10652 the generated code where possible,
10653 or by rejecting any construct that would otherwise generate an implicit
10654 @code{for} loop. If this restriction is active, it is possible to build
10655 large array aggregates with all static components without generating an
10656 intermediate temporary, and without generating a loop to initialize individual
10657 components. Otherwise, a loop is created for arrays larger than about 5000
10658 scalar components.
10660 @node No_Initialize_Scalars
10661 @unnumberedsubsec No_Initialize_Scalars
10662 @findex No_Initialize_Scalars
10663 [GNAT] This restriction ensures that no unit in the partition is compiled with
10664 pragma Initialize_Scalars. This allows the generation of more efficient
10665 code, and in particular eliminates dummy null initialization routines that
10666 are otherwise generated for some record and array types.
10668 @node No_IO
10669 @unnumberedsubsec No_IO
10670 @findex No_IO
10671 [RM H.4] This restriction ensures at compile time that there are no
10672 dependences on any of the library units Sequential_IO, Direct_IO,
10673 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
10675 @node No_Local_Allocators
10676 @unnumberedsubsec No_Local_Allocators
10677 @findex No_Local_Allocators
10678 [RM H.4] This restriction ensures at compile time that there are no
10679 occurrences of an allocator in subprograms, generic subprograms, tasks,
10680 and entry bodies.
10682 @node No_Local_Protected_Objects
10683 @unnumberedsubsec No_Local_Protected_Objects
10684 @findex No_Local_Protected_Objects
10685 [RM D.7] This restriction ensures at compile time that protected objects are
10686 only declared at the library level.
10688 @node No_Local_Timing_Events
10689 @unnumberedsubsec No_Local_Timing_Events
10690 @findex No_Local_Timing_Events
10691 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
10692 declared at the library level.
10694 @node No_Long_Long_Integers
10695 @unnumberedsubsec No_Long_Long_Integers
10696 @findex No_Long_Long_Integers
10697 [GNAT] This partition-wide restriction forbids any explicit reference to
10698 type Standard.Long_Long_Integer, and also forbids declaring range types whose
10699 implicit base type is Long_Long_Integer, and modular types whose size exceeds
10700 Long_Integer'Size.
10702 @node No_Multiple_Elaboration
10703 @unnumberedsubsec No_Multiple_Elaboration
10704 @findex No_Multiple_Elaboration
10705 [GNAT] Normally each package contains a 16-bit counter used to check for access
10706 before elaboration, and to control multiple elaboration attempts.
10707 This counter is eliminated for units compiled with the static model
10708 of elaboration if restriction @code{No_Elaboration_Code}
10709 is active but because of
10710 the need to check for multiple elaboration in the general case, these
10711 counters cannot be eliminated if elaboration code may be present. The
10712 restriction @code{No_Multiple_Elaboration}
10713 allows suppression of these counters
10714 in static elaboration units even if they do have elaboration code. If this
10715 restriction is used, then the situations in which multiple elaboration is
10716 possible, including non-Ada main programs, and Stand Alone libraries, are not
10717 permitted, and will be diagnosed by the binder.
10719 @node No_Nested_Finalization
10720 @unnumberedsubsec No_Nested_Finalization
10721 @findex No_Nested_Finalization
10722 [RM D.7] All objects requiring finalization are declared at the library level.
10724 @node No_Protected_Type_Allocators
10725 @unnumberedsubsec No_Protected_Type_Allocators
10726 @findex No_Protected_Type_Allocators
10727 [RM D.7] This restriction ensures at compile time that there are no allocator
10728 expressions that attempt to allocate protected objects.
10730 @node No_Protected_Types
10731 @unnumberedsubsec No_Protected_Types
10732 @findex No_Protected_Types
10733 [RM H.4] This restriction ensures at compile time that there are no
10734 declarations of protected types or protected objects.
10736 @node No_Recursion
10737 @unnumberedsubsec No_Recursion
10738 @findex No_Recursion
10739 [RM H.4] A program execution is erroneous if a subprogram is invoked as
10740 part of its execution.
10742 @node No_Reentrancy
10743 @unnumberedsubsec No_Reentrancy
10744 @findex No_Reentrancy
10745 [RM H.4] A program execution is erroneous if a subprogram is executed by
10746 two tasks at the same time.
10748 @node No_Relative_Delay
10749 @unnumberedsubsec No_Relative_Delay
10750 @findex No_Relative_Delay
10751 [RM D.7] This restriction ensures at compile time that there are no delay
10752 relative statements and prevents expressions such as @code{delay 1.23;} from
10753 appearing in source code.
10755 @node No_Requeue_Statements
10756 @unnumberedsubsec No_Requeue_Statements
10757 @findex No_Requeue_Statements
10758 [RM D.7] This restriction ensures at compile time that no requeue statements
10759 are permitted and prevents keyword @code{requeue} from being used in source
10760 code.
10762 @findex No_Requeue
10763 The restriction @code{No_Requeue} is recognized as a
10764 synonym for @code{No_Requeue_Statements}. This is retained for historical
10765 compatibility purposes (and a warning will be generated for its use if
10766 warnings on oNobsolescent features are activated).
10768 @node No_Secondary_Stack
10769 @unnumberedsubsec No_Secondary_Stack
10770 @findex No_Secondary_Stack
10771 [GNAT] This restriction ensures at compile time that the generated code
10772 does not contain any reference to the secondary stack.  The secondary
10773 stack is used to implement functions returning unconstrained objects
10774 (arrays or records) on some targets.
10776 @node No_Select_Statements
10777 @unnumberedsubsec No_Select_Statements
10778 @findex No_Select_Statements
10779 [RM D.7] This restriction ensures at compile time no select statements of any
10780 kind are permitted, that is the keyword @code{select} may not appear.
10782 @node No_Specific_Termination_Handlers
10783 @unnumberedsubsec No_Specific_Termination_Handlers
10784 @findex No_Specific_Termination_Handlers
10785 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
10786 or to Ada.Task_Termination.Specific_Handler.
10788 @node No_Specification_of_Aspect
10789 @unnumberedsubsec No_Specification_of_Aspect
10790 @findex No_Specification_of_Aspect
10791 [RM 13.12.1] This restriction checks at compile time that no aspect
10792 specification, attribute definition clause, or pragma is given for a
10793 given aspect.
10795 @node No_Standard_Allocators_After_Elaboration
10796 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
10797 @findex No_Standard_Allocators_After_Elaboration
10798 [RM D.7] Specifies that an allocator using a standard storage pool
10799 should never be evaluated at run time after the elaboration of the
10800 library items of the partition has completed. Otherwise, Storage_Error
10801 is raised.
10803 @node No_Standard_Storage_Pools
10804 @unnumberedsubsec No_Standard_Storage_Pools
10805 @findex No_Standard_Storage_Pools
10806 [GNAT] This restriction ensures at compile time that no access types
10807 use the standard default storage pool.  Any access type declared must
10808 have an explicit Storage_Pool attribute defined specifying a
10809 user-defined storage pool.
10811 @node No_Stream_Optimizations
10812 @unnumberedsubsec No_Stream_Optimizations
10813 @findex No_Stream_Optimizations
10814 [GNAT] This restriction affects the performance of stream operations on types
10815 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
10816 compiler uses block reads and writes when manipulating @code{String} objects
10817 due to their supperior performance. When this restriction is in effect, the
10818 compiler performs all IO operations on a per-character basis.
10820 @node No_Streams
10821 @unnumberedsubsec No_Streams
10822 @findex No_Streams
10823 [GNAT] This restriction ensures at compile/bind time that there are no
10824 stream objects created and no use of stream attributes.
10825 This restriction does not forbid dependences on the package
10826 @code{Ada.Streams}. So it is permissible to with
10827 @code{Ada.Streams} (or another package that does so itself)
10828 as long as no actual stream objects are created and no
10829 stream attributes are used.
10831 Note that the use of restriction allows optimization of tagged types,
10832 since they do not need to worry about dispatching stream operations.
10833 To take maximum advantage of this space-saving optimization, any
10834 unit declaring a tagged type should be compiled with the restriction,
10835 though this is not required.
10837 @node No_Task_Allocators
10838 @unnumberedsubsec No_Task_Allocators
10839 @findex No_Task_Allocators
10840 [RM D.7] There are no allocators for task types
10841 or types containing task subcomponents.
10843 @node No_Task_Attributes_Package
10844 @unnumberedsubsec No_Task_Attributes_Package
10845 @findex No_Task_Attributes_Package
10846 [GNAT] This restriction ensures at compile time that there are no implicit or
10847 explicit dependencies on the package @code{Ada.Task_Attributes}.
10849 @findex No_Task_Attributes
10850 The restriction @code{No_Task_Attributes} is recognized as a synonym
10851 for @code{No_Task_Attributes_Package}. This is retained for historical
10852 compatibility purposes (and a warning will be generated for its use if
10853 warnings on obsolescent features are activated).
10855 @node No_Task_Hierarchy
10856 @unnumberedsubsec No_Task_Hierarchy
10857 @findex No_Task_Hierarchy
10858 [RM D.7] All (non-environment) tasks depend
10859 directly on the environment task of the partition.
10861 @node No_Task_Termination
10862 @unnumberedsubsec No_Task_Termination
10863 @findex No_Task_Termination
10864 [RM D.7] Tasks which terminate are erroneous.
10866 @node No_Tasking
10867 @unnumberedsubsec No_Tasking
10868 @findex No_Tasking
10869 [GNAT] This restriction prevents the declaration of tasks or task types
10870 throughout the partition.  It is similar in effect to the use of
10871 @code{Max_Tasks => 0} except that violations are caught at compile time
10872 and cause an error message to be output either by the compiler or
10873 binder.
10875 @node No_Terminate_Alternatives
10876 @unnumberedsubsec No_Terminate_Alternatives
10877 @findex No_Terminate_Alternatives
10878 [RM D.7] There are no selective accepts with terminate alternatives.
10880 @node No_Unchecked_Access
10881 @unnumberedsubsec No_Unchecked_Access
10882 @findex No_Unchecked_Access
10883 [RM H.4] This restriction ensures at compile time that there are no
10884 occurrences of the Unchecked_Access attribute.
10886 @node Simple_Barriers
10887 @unnumberedsubsec Simple_Barriers
10888 @findex Simple_Barriers
10889 [RM D.7] This restriction ensures at compile time that barriers in entry
10890 declarations for protected types are restricted to either static boolean
10891 expressions or references to simple boolean variables defined in the private
10892 part of the protected type.  No other form of entry barriers is permitted.
10894 @findex Boolean_Entry_Barriers
10895 The restriction @code{Boolean_Entry_Barriers} is recognized as a
10896 synonym for @code{Simple_Barriers}. This is retained for historical
10897 compatibility purposes (and a warning will be generated for its use if
10898 warnings on obsolescent features are activated).
10900 @node Static_Priorities
10901 @unnumberedsubsec Static_Priorities
10902 @findex Static_Priorities
10903 [GNAT] This restriction ensures at compile time that all priority expressions
10904 are static, and that there are no dependences on the package
10905 @code{Ada.Dynamic_Priorities}.
10907 @node Static_Storage_Size
10908 @unnumberedsubsec Static_Storage_Size
10909 @findex Static_Storage_Size
10910 [GNAT] This restriction ensures at compile time that any expression appearing
10911 in a Storage_Size pragma or attribute definition clause is static.
10913 @node Program Unit Level Restrictions
10914 @section Program Unit Level Restrictions
10916 @noindent
10917 The second set of restriction identifiers
10918 does not require partition-wide consistency.
10919 The restriction may be enforced for a single
10920 compilation unit without any effect on any of the
10921 other compilation units in the partition.
10923 @menu
10924 * No_Elaboration_Code::
10925 * No_Entry_Queue::
10926 * No_Implementation_Aspect_Specifications::
10927 * No_Implementation_Attributes::
10928 * No_Implementation_Identifiers::
10929 * No_Implementation_Pragmas::
10930 * No_Implementation_Restrictions::
10931 * No_Implementation_Units::
10932 * No_Implicit_Aliasing::
10933 * No_Obsolescent_Features::
10934 * No_Wide_Characters::
10935 * SPARK_05::
10936 @end menu
10938 @node No_Elaboration_Code
10939 @unnumberedsubsec No_Elaboration_Code
10940 @findex No_Elaboration_Code
10941 [GNAT] This restriction ensures at compile time that no elaboration code is
10942 generated.  Note that this is not the same condition as is enforced
10943 by pragma @code{Preelaborate}.  There are cases in which pragma
10944 @code{Preelaborate} still permits code to be generated (e.g.@: code
10945 to initialize a large array to all zeroes), and there are cases of units
10946 which do not meet the requirements for pragma @code{Preelaborate},
10947 but for which no elaboration code is generated.  Generally, it is
10948 the case that preelaborable units will meet the restrictions, with
10949 the exception of large aggregates initialized with an others_clause,
10950 and exception declarations (which generate calls to a run-time
10951 registry procedure).  This restriction is enforced on
10952 a unit by unit basis, it need not be obeyed consistently
10953 throughout a partition.
10955 In the case of aggregates with others, if the aggregate has a dynamic
10956 size, there is no way to eliminate the elaboration code (such dynamic
10957 bounds would be incompatible with @code{Preelaborate} in any case). If
10958 the bounds are static, then use of this restriction actually modifies
10959 the code choice of the compiler to avoid generating a loop, and instead
10960 generate the aggregate statically if possible, no matter how many times
10961 the data for the others clause must be repeatedly generated.
10963 It is not possible to precisely document
10964 the constructs which are compatible with this restriction, since,
10965 unlike most other restrictions, this is not a restriction on the
10966 source code, but a restriction on the generated object code. For
10967 example, if the source contains a declaration:
10969 @smallexample
10970    Val : constant Integer := X;
10971 @end smallexample
10973 @noindent
10974 where X is not a static constant, it may be possible, depending
10975 on complex optimization circuitry, for the compiler to figure
10976 out the value of X at compile time, in which case this initialization
10977 can be done by the loader, and requires no initialization code. It
10978 is not possible to document the precise conditions under which the
10979 optimizer can figure this out.
10981 Note that this the implementation of this restriction requires full
10982 code generation. If it is used in conjunction with "semantics only"
10983 checking, then some cases of violations may be missed.
10985 @node No_Entry_Queue
10986 @unnumberedsubsec No_Entry_Queue
10987 @findex No_Entry_Queue
10988 [GNAT] This restriction is a declaration that any protected entry compiled in
10989 the scope of the restriction has at most one task waiting on the entry
10990 at any one time, and so no queue is required.  This restriction is not
10991 checked at compile time.  A program execution is erroneous if an attempt
10992 is made to queue a second task on such an entry.
10994 @node No_Implementation_Aspect_Specifications
10995 @unnumberedsubsec No_Implementation_Aspect_Specifications
10996 @findex No_Implementation_Aspect_Specifications
10997 [RM 13.12.1] This restriction checks at compile time that no
10998 GNAT-defined aspects are present.  With this restriction, the only
10999 aspects that can be used are those defined in the Ada Reference Manual.
11001 @node No_Implementation_Attributes
11002 @unnumberedsubsec No_Implementation_Attributes
11003 @findex No_Implementation_Attributes
11004 [RM 13.12.1] This restriction checks at compile time that no
11005 GNAT-defined attributes are present.  With this restriction, the only
11006 attributes that can be used are those defined in the Ada Reference
11007 Manual.
11009 @node No_Implementation_Identifiers
11010 @unnumberedsubsec No_Implementation_Identifiers
11011 @findex No_Implementation_Identifiers
11012 [RM 13.12.1] This restriction checks at compile time that no
11013 implementation-defined identifiers (marked with pragma Implementation_Defined)
11014 occur within language-defined packages.
11016 @node No_Implementation_Pragmas
11017 @unnumberedsubsec No_Implementation_Pragmas
11018 @findex No_Implementation_Pragmas
11019 [RM 13.12.1] This restriction checks at compile time that no
11020 GNAT-defined pragmas are present.  With this restriction, the only
11021 pragmas that can be used are those defined in the Ada Reference Manual.
11023 @node No_Implementation_Restrictions
11024 @unnumberedsubsec No_Implementation_Restrictions
11025 @findex No_Implementation_Restrictions
11026 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
11027 identifiers (other than @code{No_Implementation_Restrictions} itself)
11028 are present.  With this restriction, the only other restriction identifiers
11029 that can be used are those defined in the Ada Reference Manual.
11031 @node No_Implementation_Units
11032 @unnumberedsubsec No_Implementation_Units
11033 @findex No_Implementation_Units
11034 [RM 13.12.1] This restriction checks at compile time that there is no
11035 mention in the context clause of any implementation-defined descendants
11036 of packages Ada, Interfaces, or System.
11038 @node No_Implicit_Aliasing
11039 @unnumberedsubsec No_Implicit_Aliasing
11040 @findex No_Implicit_Aliasing
11041 [GNAT] This restriction, which is not required to be partition-wide consistent,
11042 requires an explicit aliased keyword for an object to which 'Access,
11043 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
11044 the 'Unrestricted_Access attribute for objects. Note: the reason that
11045 Unrestricted_Access is forbidden is that it would require the prefix
11046 to be aliased, and in such cases, it can always be replaced by
11047 the standard attribute Unchecked_Access which is preferable.
11049 @node No_Obsolescent_Features
11050 @unnumberedsubsec No_Obsolescent_Features
11051 @findex No_Obsolescent_Features
11052 [RM 13.12.1] This restriction checks at compile time that no obsolescent
11053 features are used, as defined in Annex J of the Ada Reference Manual.
11055 @node No_Wide_Characters
11056 @unnumberedsubsec No_Wide_Characters
11057 @findex No_Wide_Characters
11058 [GNAT] This restriction ensures at compile time that no uses of the types
11059 @code{Wide_Character} or @code{Wide_String} or corresponding wide
11060 wide types
11061 appear, and that no wide or wide wide string or character literals
11062 appear in the program (that is literals representing characters not in
11063 type @code{Character}).
11065 @node SPARK_05
11066 @unnumberedsubsec SPARK_05
11067 @findex SPARK_05
11068 [GNAT] This restriction checks at compile time that some constructs
11069 forbidden in SPARK 2005 are not present. Error messages related to
11070 SPARK restriction have the form:
11072 @smallexample
11073 violation of restriction "SPARK_05" at <source-location>
11074  <error message>
11075 @end smallexample
11077 @findex SPARK
11078 The restriction @code{SPARK} is recognized as a
11079 synonym for @code{SPARK_05}. This is retained for historical
11080 compatibility purposes (and an unconditional warning will be generated
11081 for its use, advising replacement by @code{SPARK}).
11083 This is not a replacement for the semantic checks performed by the
11084 SPARK Examiner tool, as the compiler currently only deals with code,
11085 not SPARK 2005 annotations, and does not guarantee catching all
11086 cases of constructs forbidden by SPARK 2005.
11088 Thus it may well be the case that code which passes the compiler with
11089 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
11090 the different visibility rules of the Examiner based on SPARK 2005
11091 @code{inherit} annotations.
11093 This restriction can be useful in providing an initial filter for code
11094 developed using SPARK 2005, or in examining legacy code to see how far
11095 it is from meeting SPARK restrictions.
11097 The list below summarizes the checks that are performed when this
11098 restriction is in force:
11099 @itemize @bullet
11100 @item No block statements
11101 @item No case statements with only an others clause
11102 @item Exit statements in loops must respect the SPARK 2005 language restrictions
11103 @item No goto statements
11104 @item Return can only appear as last statement in function
11105 @item Function must have return statement
11106 @item Loop parameter specification must include subtype mark
11107 @item Prefix of expanded name cannot be a loop statement
11108 @item Abstract subprogram not allowed
11109 @item User-defined operators not allowed
11110 @item Access type parameters not allowed
11111 @item Default expressions for parameters not allowed
11112 @item Default expressions for record fields not allowed
11113 @item No tasking constructs allowed
11114 @item Label needed at end of subprograms and packages
11115 @item No mixing of positional and named parameter association
11116 @item No access types as result type
11117 @item No unconstrained arrays as result types
11118 @item No null procedures
11119 @item Initial and later declarations must be in correct order (declaration can't come after body)
11120 @item No attributes on private types if full declaration not visible
11121 @item No package declaration within package specification
11122 @item No controlled types
11123 @item No discriminant types
11124 @item No overloading
11125 @item Selector name cannot be operator symbol (i.e. operator symbol cannot be prefixed)
11126 @item Access attribute not allowed
11127 @item Allocator not allowed
11128 @item Result of catenation must be String
11129 @item Operands of catenation must be string literal, static char or another catenation
11130 @item No conditional expressions
11131 @item No explicit dereference
11132 @item Quantified expression not allowed
11133 @item Slicing not allowed
11134 @item No exception renaming
11135 @item No generic renaming
11136 @item No object renaming
11137 @item No use clause
11138 @item Aggregates must be qualified
11139 @item Non-static choice in array aggregates not allowed
11140 @item The only view conversions which are allowed as in-out parameters are conversions of a tagged type to an ancestor type
11141 @item No mixing of positional and named association in aggregate, no multi choice
11142 @item AND, OR and XOR for arrays only allowed when operands have same static bounds
11143 @item Fixed point operands to * or / must be qualified or converted
11144 @item Comparison operators not allowed for Booleans or arrays (except strings)
11145 @item Equality not allowed for arrays with non-matching static bounds (except strings)
11146 @item Conversion / qualification not allowed for arrays with non-matching static bounds
11147 @item Subprogram declaration only allowed in package spec (unless followed by import)
11148 @item Access types not allowed
11149 @item Incomplete type declaration not allowed
11150 @item Object and subtype declarations must respect SPARK restrictions
11151 @item Digits or delta constraint not allowed
11152 @item Decimal fixed point type not allowed
11153 @item Aliasing of objects not allowed
11154 @item Modular type modulus must be power of 2
11155 @item Base not allowed on subtype mark
11156 @item Unary operators not allowed on modular types (except not)
11157 @item Untagged record cannot be null
11158 @item No class-wide operations
11159 @item Initialization expressions must respect SPARK restrictions
11160 @item Non-static ranges not allowed except in iteration schemes
11161 @item String subtypes must have lower bound of 1
11162 @item Subtype of Boolean cannot have constraint
11163 @item At most one tagged type or extension per package
11164 @item Interface is not allowed
11165 @item Character literal cannot be prefixed (selector name cannot be character literal)
11166 @item Record aggregate cannot contain 'others'
11167 @item Component association in record aggregate must contain a single choice
11168 @item Ancestor part cannot be a type mark
11169 @item Attributes 'Image, 'Width and 'Value not allowed
11170 @item Functions may not update globals
11171 @item Subprograms may not contain direct calls to themselves (prevents recursion within unit)
11172 @item Call to subprogram not allowed in same unit before body has been seen (prevents recursion within unit)
11173 @end itemize
11175 The following restrictions are enforced, but note that they are actually more
11176 strict that the latest SPARK 2005 language definition:
11178 @itemize @bullet
11179 @item No derived types other than tagged type extensions
11180 @item Subtype of unconstrained array must have constraint
11181 @end itemize
11183 This list summarises the main SPARK 2005 language rules that are not
11184 currently checked by the SPARK_05 restriction:
11186 @itemize @bullet
11187 @item SPARK annotations are treated as comments so are not checked at all
11188 @item Based real literals not allowed
11189 @item Objects cannot be initialized at declaration by calls to user-defined functions
11190 @item Objects cannot be initialized at declaration by assignments from variables
11191 @item Objects cannot be initialized at declaration by assignments from indexed/selected components
11192 @item Ranges shall not be null
11193 @item A fixed point delta expression must be a simple expression
11194 @item Restrictions on where renaming declarations may be placed
11195 @item Externals of mode 'out' cannot be referenced
11196 @item Externals of mode 'in' cannot be updated
11197 @item Loop with no iteration scheme or exits only allowed as last statement in main program or task
11198 @item Subprogram cannot have parent unit name
11199 @item SPARK 2005 inherited subprogram must be prefixed with overriding
11200 @item External variables (or functions that reference them) may not be passed as actual parameters
11201 @item Globals must be explicitly mentioned in contract
11202 @item Deferred constants cannot be completed by pragma Import
11203 @item Package initialization cannot read/write variables from other packages
11204 @item Prefix not allowed for entities that are directly visible
11205 @item Identifier declaration can't override inherited package name
11206 @item Cannot use Standard or other predefined packages as identifiers
11207 @item After renaming, cannot use the original name
11208 @item Subprograms can only be renamed to remove package prefix
11209 @item Pragma import must be immediately after entity it names
11210 @item No mutual recursion between multiple units (this can be checked with gnatcheck)
11211 @end itemize
11213 Note that if a unit is compiled in Ada 95 mode with the SPARK restriction,
11214 violations will be reported for constructs forbidden in SPARK 95,
11215 instead of SPARK 2005.
11217 @c ------------------------
11218 @node Implementation Advice
11219 @chapter Implementation Advice
11220 @noindent
11221 The main text of the Ada Reference Manual describes the required
11222 behavior of all Ada compilers, and the GNAT compiler conforms to
11223 these requirements.
11225 In addition, there are sections throughout the Ada Reference Manual headed
11226 by the phrase ``Implementation advice''.  These sections are not normative,
11227 i.e., they do not specify requirements that all compilers must
11228 follow.  Rather they provide advice on generally desirable behavior.  You
11229 may wonder why they are not requirements.  The most typical answer is
11230 that they describe behavior that seems generally desirable, but cannot
11231 be provided on all systems, or which may be undesirable on some systems.
11233 As far as practical, GNAT follows the implementation advice sections in
11234 the Ada Reference Manual.  This chapter contains a table giving the
11235 reference manual section number, paragraph number and several keywords
11236 for each advice.  Each entry consists of the text of the advice followed
11237 by the GNAT interpretation of this advice.  Most often, this simply says
11238 ``followed'', which means that GNAT follows the advice.  However, in a
11239 number of cases, GNAT deliberately deviates from this advice, in which
11240 case the text describes what GNAT does and why.
11242 @cindex Error detection
11243 @unnumberedsec 1.1.3(20): Error Detection
11244 @sp 1
11245 @cartouche
11246 If an implementation detects the use of an unsupported Specialized Needs
11247 Annex feature at run time, it should raise @code{Program_Error} if
11248 feasible.
11249 @end cartouche
11250 Not relevant.  All specialized needs annex features are either supported,
11251 or diagnosed at compile time.
11253 @cindex Child Units
11254 @unnumberedsec 1.1.3(31): Child Units
11255 @sp 1
11256 @cartouche
11257 If an implementation wishes to provide implementation-defined
11258 extensions to the functionality of a language-defined library unit, it
11259 should normally do so by adding children to the library unit.
11260 @end cartouche
11261 Followed.
11263 @cindex Bounded errors
11264 @unnumberedsec 1.1.5(12): Bounded Errors
11265 @sp 1
11266 @cartouche
11267 If an implementation detects a bounded error or erroneous
11268 execution, it should raise @code{Program_Error}.
11269 @end cartouche
11270 Followed in all cases in which the implementation detects a bounded
11271 error or erroneous execution.  Not all such situations are detected at
11272 runtime.
11274 @cindex Pragmas
11275 @unnumberedsec 2.8(16): Pragmas
11276 @sp 1
11277 @cartouche
11278 Normally, implementation-defined pragmas should have no semantic effect
11279 for error-free programs; that is, if the implementation-defined pragmas
11280 are removed from a working program, the program should still be legal,
11281 and should still have the same semantics.
11282 @end cartouche
11283 The following implementation defined pragmas are exceptions to this
11284 rule:
11286 @table @code
11287 @item Abort_Defer
11288 Affects semantics
11289 @item Ada_83
11290 Affects legality
11291 @item Assert
11292 Affects semantics
11293 @item CPP_Class
11294 Affects semantics
11295 @item CPP_Constructor
11296 Affects semantics
11297 @item Debug
11298 Affects semantics
11299 @item Interface_Name
11300 Affects semantics
11301 @item Machine_Attribute
11302 Affects semantics
11303 @item Unimplemented_Unit
11304 Affects legality
11305 @item Unchecked_Union
11306 Affects semantics
11307 @end table
11309 @noindent
11310 In each of the above cases, it is essential to the purpose of the pragma
11311 that this advice not be followed.  For details see the separate section
11312 on implementation defined pragmas.
11314 @unnumberedsec 2.8(17-19): Pragmas
11315 @sp 1
11316 @cartouche
11317 Normally, an implementation should not define pragmas that can
11318 make an illegal program legal, except as follows:
11319 @end cartouche
11320 @sp 1
11321 @cartouche
11322 A pragma used to complete a declaration, such as a pragma @code{Import};
11323 @end cartouche
11324 @sp 1
11325 @cartouche
11326 A pragma used to configure the environment by adding, removing, or
11327 replacing @code{library_items}.
11328 @end cartouche
11329 See response to paragraph 16 of this same section.
11331 @cindex Character Sets
11332 @cindex Alternative Character Sets
11333 @unnumberedsec 3.5.2(5): Alternative Character Sets
11334 @sp 1
11335 @cartouche
11336 If an implementation supports a mode with alternative interpretations
11337 for @code{Character} and @code{Wide_Character}, the set of graphic
11338 characters of @code{Character} should nevertheless remain a proper
11339 subset of the set of graphic characters of @code{Wide_Character}.  Any
11340 character set ``localizations'' should be reflected in the results of
11341 the subprograms defined in the language-defined package
11342 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
11343 an alternative interpretation of @code{Character}, the implementation should
11344 also support a corresponding change in what is a legal
11345 @code{identifier_letter}.
11346 @end cartouche
11347 Not all wide character modes follow this advice, in particular the JIS
11348 and IEC modes reflect standard usage in Japan, and in these encoding,
11349 the upper half of the Latin-1 set is not part of the wide-character
11350 subset, since the most significant bit is used for wide character
11351 encoding.  However, this only applies to the external forms.  Internally
11352 there is no such restriction.
11354 @cindex Integer types
11355 @unnumberedsec 3.5.4(28): Integer Types
11357 @sp 1
11358 @cartouche
11359 An implementation should support @code{Long_Integer} in addition to
11360 @code{Integer} if the target machine supports 32-bit (or longer)
11361 arithmetic.  No other named integer subtypes are recommended for package
11362 @code{Standard}.  Instead, appropriate named integer subtypes should be
11363 provided in the library package @code{Interfaces} (see B.2).
11364 @end cartouche
11365 @code{Long_Integer} is supported.  Other standard integer types are supported
11366 so this advice is not fully followed.  These types
11367 are supported for convenient interface to C, and so that all hardware
11368 types of the machine are easily available.
11369 @unnumberedsec 3.5.4(29): Integer Types
11371 @sp 1
11372 @cartouche
11373 An implementation for a two's complement machine should support
11374 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
11375 implementation should support a non-binary modules up to @code{Integer'Last}.
11376 @end cartouche
11377 Followed.
11379 @cindex Enumeration values
11380 @unnumberedsec 3.5.5(8): Enumeration Values
11381 @sp 1
11382 @cartouche
11383 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
11384 subtype, if the value of the operand does not correspond to the internal
11385 code for any enumeration literal of its type (perhaps due to an
11386 un-initialized variable), then the implementation should raise
11387 @code{Program_Error}.  This is particularly important for enumeration
11388 types with noncontiguous internal codes specified by an
11389 enumeration_representation_clause.
11390 @end cartouche
11391 Followed.
11393 @cindex Float types
11394 @unnumberedsec 3.5.7(17): Float Types
11395 @sp 1
11396 @cartouche
11397 An implementation should support @code{Long_Float} in addition to
11398 @code{Float} if the target machine supports 11 or more digits of
11399 precision.  No other named floating point subtypes are recommended for
11400 package @code{Standard}.  Instead, appropriate named floating point subtypes
11401 should be provided in the library package @code{Interfaces} (see B.2).
11402 @end cartouche
11403 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
11404 former provides improved compatibility with other implementations
11405 supporting this type.  The latter corresponds to the highest precision
11406 floating-point type supported by the hardware.  On most machines, this
11407 will be the same as @code{Long_Float}, but on some machines, it will
11408 correspond to the IEEE extended form.  The notable case is all ia32
11409 (x86) implementations, where @code{Long_Long_Float} corresponds to
11410 the 80-bit extended precision format supported in hardware on this
11411 processor.  Note that the 128-bit format on SPARC is not supported,
11412 since this is a software rather than a hardware format.
11414 @cindex Multidimensional arrays
11415 @cindex Arrays, multidimensional
11416 @unnumberedsec 3.6.2(11): Multidimensional Arrays
11417 @sp 1
11418 @cartouche
11419 An implementation should normally represent multidimensional arrays in
11420 row-major order, consistent with the notation used for multidimensional
11421 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
11422 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
11423 column-major order should be used instead (see B.5, ``Interfacing with
11424 Fortran'').
11425 @end cartouche
11426 Followed.
11428 @findex Duration'Small
11429 @unnumberedsec 9.6(30-31): Duration'Small
11430 @sp 1
11431 @cartouche
11432 Whenever possible in an implementation, the value of @code{Duration'Small}
11433 should be no greater than 100 microseconds.
11434 @end cartouche
11435 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
11437 @sp 1
11438 @cartouche
11439 The time base for @code{delay_relative_statements} should be monotonic;
11440 it need not be the same time base as used for @code{Calendar.Clock}.
11441 @end cartouche
11442 Followed.
11444 @unnumberedsec 10.2.1(12): Consistent Representation
11445 @sp 1
11446 @cartouche
11447 In an implementation, a type declared in a pre-elaborated package should
11448 have the same representation in every elaboration of a given version of
11449 the package, whether the elaborations occur in distinct executions of
11450 the same program, or in executions of distinct programs or partitions
11451 that include the given version.
11452 @end cartouche
11453 Followed, except in the case of tagged types.  Tagged types involve
11454 implicit pointers to a local copy of a dispatch table, and these pointers
11455 have representations which thus depend on a particular elaboration of the
11456 package.  It is not easy to see how it would be possible to follow this
11457 advice without severely impacting efficiency of execution.
11459 @cindex Exception information
11460 @unnumberedsec 11.4.1(19): Exception Information
11461 @sp 1
11462 @cartouche
11463 @code{Exception_Message} by default and @code{Exception_Information}
11464 should produce information useful for
11465 debugging.  @code{Exception_Message} should be short, about one
11466 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
11467 should not include the
11468 @code{Exception_Name}.  @code{Exception_Information} should include both
11469 the @code{Exception_Name} and the @code{Exception_Message}.
11470 @end cartouche
11471 Followed.  For each exception that doesn't have a specified
11472 @code{Exception_Message}, the compiler generates one containing the location
11473 of the raise statement.  This location has the form ``file:line'', where
11474 file is the short file name (without path information) and line is the line
11475 number in the file.  Note that in the case of the Zero Cost Exception
11476 mechanism, these messages become redundant with the Exception_Information that
11477 contains a full backtrace of the calling sequence, so they are disabled.
11478 To disable explicitly the generation of the source location message, use the
11479 Pragma @code{Discard_Names}.
11481 @cindex Suppression of checks
11482 @cindex Checks, suppression of
11483 @unnumberedsec 11.5(28): Suppression of Checks
11484 @sp 1
11485 @cartouche
11486 The implementation should minimize the code executed for checks that
11487 have been suppressed.
11488 @end cartouche
11489 Followed.
11491 @cindex Representation clauses
11492 @unnumberedsec 13.1 (21-24): Representation Clauses
11493 @sp 1
11494 @cartouche
11495 The recommended level of support for all representation items is
11496 qualified as follows:
11497 @end cartouche
11498 @sp 1
11499 @cartouche
11500 An implementation need not support representation items containing
11501 non-static expressions, except that an implementation should support a
11502 representation item for a given entity if each non-static expression in
11503 the representation item is a name that statically denotes a constant
11504 declared before the entity.
11505 @end cartouche
11506 Followed.  In fact, GNAT goes beyond the recommended level of support
11507 by allowing nonstatic expressions in some representation clauses even
11508 without the need to declare constants initialized with the values of
11509 such expressions.
11510 For example:
11512 @smallexample @c ada
11513   X : Integer;
11514   Y : Float;
11515   for Y'Address use X'Address;>>
11516 @end smallexample
11518 @sp 1
11519 @cartouche
11520 An implementation need not support a specification for the @code{Size}
11521 for a given composite subtype, nor the size or storage place for an
11522 object (including a component) of a given composite subtype, unless the
11523 constraints on the subtype and its composite subcomponents (if any) are
11524 all static constraints.
11525 @end cartouche
11526 Followed.  Size Clauses are not permitted on non-static components, as
11527 described above.
11529 @sp 1
11530 @cartouche
11531 An aliased component, or a component whose type is by-reference, should
11532 always be allocated at an addressable location.
11533 @end cartouche
11534 Followed.
11536 @cindex Packed types
11537 @unnumberedsec 13.2(6-8): Packed Types
11538 @sp 1
11539 @cartouche
11540 If a type is packed, then the implementation should try to minimize
11541 storage allocated to objects of the type, possibly at the expense of
11542 speed of accessing components, subject to reasonable complexity in
11543 addressing calculations.
11544 @end cartouche
11545 @sp 1
11546 @cartouche
11547 The recommended level of support pragma @code{Pack} is:
11549 For a packed record type, the components should be packed as tightly as
11550 possible subject to the Sizes of the component subtypes, and subject to
11551 any @code{record_representation_clause} that applies to the type; the
11552 implementation may, but need not, reorder components or cross aligned
11553 word boundaries to improve the packing.  A component whose @code{Size} is
11554 greater than the word size may be allocated an integral number of words.
11555 @end cartouche
11556 Followed.  Tight packing of arrays is supported for all component sizes
11557 up to 64-bits. If the array component size is 1 (that is to say, if
11558 the component is a boolean type or an enumeration type with two values)
11559 then values of the type are implicitly initialized to zero. This
11560 happens both for objects of the packed type, and for objects that have a
11561 subcomponent of the packed type.
11563 @sp 1
11564 @cartouche
11565 An implementation should support Address clauses for imported
11566 subprograms.
11567 @end cartouche
11568 Followed.
11569 @cindex @code{Address} clauses
11570 @unnumberedsec 13.3(14-19): Address Clauses
11572 @sp 1
11573 @cartouche
11574 For an array @var{X}, @code{@var{X}'Address} should point at the first
11575 component of the array, and not at the array bounds.
11576 @end cartouche
11577 Followed.
11579 @sp 1
11580 @cartouche
11581 The recommended level of support for the @code{Address} attribute is:
11583 @code{@var{X}'Address} should produce a useful result if @var{X} is an
11584 object that is aliased or of a by-reference type, or is an entity whose
11585 @code{Address} has been specified.
11586 @end cartouche
11587 Followed.  A valid address will be produced even if none of those
11588 conditions have been met.  If necessary, the object is forced into
11589 memory to ensure the address is valid.
11591 @sp 1
11592 @cartouche
11593 An implementation should support @code{Address} clauses for imported
11594 subprograms.
11595 @end cartouche
11596 Followed.
11598 @sp 1
11599 @cartouche
11600 Objects (including subcomponents) that are aliased or of a by-reference
11601 type should be allocated on storage element boundaries.
11602 @end cartouche
11603 Followed.
11605 @sp 1
11606 @cartouche
11607 If the @code{Address} of an object is specified, or it is imported or exported,
11608 then the implementation should not perform optimizations based on
11609 assumptions of no aliases.
11610 @end cartouche
11611 Followed.
11613 @cindex @code{Alignment} clauses
11614 @unnumberedsec 13.3(29-35): Alignment Clauses
11615 @sp 1
11616 @cartouche
11617 The recommended level of support for the @code{Alignment} attribute for
11618 subtypes is:
11620 An implementation should support specified Alignments that are factors
11621 and multiples of the number of storage elements per word, subject to the
11622 following:
11623 @end cartouche
11624 Followed.
11626 @sp 1
11627 @cartouche
11628 An implementation need not support specified @code{Alignment}s for
11629 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
11630 loaded and stored by available machine instructions.
11631 @end cartouche
11632 Followed.
11634 @sp 1
11635 @cartouche
11636 An implementation need not support specified @code{Alignment}s that are
11637 greater than the maximum @code{Alignment} the implementation ever returns by
11638 default.
11639 @end cartouche
11640 Followed.
11642 @sp 1
11643 @cartouche
11644 The recommended level of support for the @code{Alignment} attribute for
11645 objects is:
11647 Same as above, for subtypes, but in addition:
11648 @end cartouche
11649 Followed.
11651 @sp 1
11652 @cartouche
11653 For stand-alone library-level objects of statically constrained
11654 subtypes, the implementation should support all @code{Alignment}s
11655 supported by the target linker.  For example, page alignment is likely to
11656 be supported for such objects, but not for subtypes.
11657 @end cartouche
11658 Followed.
11660 @cindex @code{Size} clauses
11661 @unnumberedsec 13.3(42-43): Size Clauses
11662 @sp 1
11663 @cartouche
11664 The recommended level of support for the @code{Size} attribute of
11665 objects is:
11667 A @code{Size} clause should be supported for an object if the specified
11668 @code{Size} is at least as large as its subtype's @code{Size}, and
11669 corresponds to a size in storage elements that is a multiple of the
11670 object's @code{Alignment} (if the @code{Alignment} is nonzero).
11671 @end cartouche
11672 Followed.
11674 @unnumberedsec 13.3(50-56): Size Clauses
11675 @sp 1
11676 @cartouche
11677 If the @code{Size} of a subtype is specified, and allows for efficient
11678 independent addressability (see 9.10) on the target architecture, then
11679 the @code{Size} of the following objects of the subtype should equal the
11680 @code{Size} of the subtype:
11682 Aliased objects (including components).
11683 @end cartouche
11684 Followed.
11686 @sp 1
11687 @cartouche
11688 @code{Size} clause on a composite subtype should not affect the
11689 internal layout of components.
11690 @end cartouche
11691 Followed. But note that this can be overridden by use of the implementation
11692 pragma Implicit_Packing in the case of packed arrays.
11694 @sp 1
11695 @cartouche
11696 The recommended level of support for the @code{Size} attribute of subtypes is:
11697 @end cartouche
11698 @sp 1
11699 @cartouche
11700 The @code{Size} (if not specified) of a static discrete or fixed point
11701 subtype should be the number of bits needed to represent each value
11702 belonging to the subtype using an unbiased representation, leaving space
11703 for a sign bit only if the subtype contains negative values.  If such a
11704 subtype is a first subtype, then an implementation should support a
11705 specified @code{Size} for it that reflects this representation.
11706 @end cartouche
11707 Followed.
11709 @sp 1
11710 @cartouche
11711 For a subtype implemented with levels of indirection, the @code{Size}
11712 should include the size of the pointers, but not the size of what they
11713 point at.
11714 @end cartouche
11715 Followed.
11717 @cindex @code{Component_Size} clauses
11718 @unnumberedsec 13.3(71-73): Component Size Clauses
11719 @sp 1
11720 @cartouche
11721 The recommended level of support for the @code{Component_Size}
11722 attribute is:
11723 @end cartouche
11724 @sp 1
11725 @cartouche
11726 An implementation need not support specified @code{Component_Sizes} that are
11727 less than the @code{Size} of the component subtype.
11728 @end cartouche
11729 Followed.
11731 @sp 1
11732 @cartouche
11733 An implementation should support specified @code{Component_Size}s that
11734 are factors and multiples of the word size.  For such
11735 @code{Component_Size}s, the array should contain no gaps between
11736 components.  For other @code{Component_Size}s (if supported), the array
11737 should contain no gaps between components when packing is also
11738 specified; the implementation should forbid this combination in cases
11739 where it cannot support a no-gaps representation.
11740 @end cartouche
11741 Followed.
11743 @cindex Enumeration representation clauses
11744 @cindex Representation clauses, enumeration
11745 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
11746 @sp 1
11747 @cartouche
11748 The recommended level of support for enumeration representation clauses
11751 An implementation need not support enumeration representation clauses
11752 for boolean types, but should at minimum support the internal codes in
11753 the range @code{System.Min_Int.System.Max_Int}.
11754 @end cartouche
11755 Followed.
11757 @cindex Record representation clauses
11758 @cindex Representation clauses, records
11759 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
11760 @sp 1
11761 @cartouche
11762 The recommended level of support for
11763 @*@code{record_representation_clauses} is:
11765 An implementation should support storage places that can be extracted
11766 with a load, mask, shift sequence of machine code, and set with a load,
11767 shift, mask, store sequence, given the available machine instructions
11768 and run-time model.
11769 @end cartouche
11770 Followed.
11772 @sp 1
11773 @cartouche
11774 A storage place should be supported if its size is equal to the
11775 @code{Size} of the component subtype, and it starts and ends on a
11776 boundary that obeys the @code{Alignment} of the component subtype.
11777 @end cartouche
11778 Followed.
11780 @sp 1
11781 @cartouche
11782 If the default bit ordering applies to the declaration of a given type,
11783 then for a component whose subtype's @code{Size} is less than the word
11784 size, any storage place that does not cross an aligned word boundary
11785 should be supported.
11786 @end cartouche
11787 Followed.
11789 @sp 1
11790 @cartouche
11791 An implementation may reserve a storage place for the tag field of a
11792 tagged type, and disallow other components from overlapping that place.
11793 @end cartouche
11794 Followed.  The storage place for the tag field is the beginning of the tagged
11795 record, and its size is Address'Size.  GNAT will reject an explicit component
11796 clause for the tag field.
11798 @sp 1
11799 @cartouche
11800 An implementation need not support a @code{component_clause} for a
11801 component of an extension part if the storage place is not after the
11802 storage places of all components of the parent type, whether or not
11803 those storage places had been specified.
11804 @end cartouche
11805 Followed.  The above advice on record representation clauses is followed,
11806 and all mentioned features are implemented.
11808 @cindex Storage place attributes
11809 @unnumberedsec 13.5.2(5): Storage Place Attributes
11810 @sp 1
11811 @cartouche
11812 If a component is represented using some form of pointer (such as an
11813 offset) to the actual data of the component, and this data is contiguous
11814 with the rest of the object, then the storage place attributes should
11815 reflect the place of the actual data, not the pointer.  If a component is
11816 allocated discontinuously from the rest of the object, then a warning
11817 should be generated upon reference to one of its storage place
11818 attributes.
11819 @end cartouche
11820 Followed.  There are no such components in GNAT@.
11822 @cindex Bit ordering
11823 @unnumberedsec 13.5.3(7-8): Bit Ordering
11824 @sp 1
11825 @cartouche
11826 The recommended level of support for the non-default bit ordering is:
11827 @end cartouche
11828 @sp 1
11829 @cartouche
11830 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
11831 should support the non-default bit ordering in addition to the default
11832 bit ordering.
11833 @end cartouche
11834 Followed.  Word size does not equal storage size in this implementation.
11835 Thus non-default bit ordering is not supported.
11837 @cindex @code{Address}, as private type
11838 @unnumberedsec 13.7(37): Address as Private
11839 @sp 1
11840 @cartouche
11841 @code{Address} should be of a private type.
11842 @end cartouche
11843 Followed.
11845 @cindex Operations, on @code{Address}
11846 @cindex @code{Address}, operations of
11847 @unnumberedsec 13.7.1(16): Address Operations
11848 @sp 1
11849 @cartouche
11850 Operations in @code{System} and its children should reflect the target
11851 environment semantics as closely as is reasonable.  For example, on most
11852 machines, it makes sense for address arithmetic to ``wrap around''.
11853 Operations that do not make sense should raise @code{Program_Error}.
11854 @end cartouche
11855 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
11856 operation raises @code{Program_Error}, since all operations make sense.
11858 @cindex Unchecked conversion
11859 @unnumberedsec 13.9(14-17): Unchecked Conversion
11860 @sp 1
11861 @cartouche
11862 The @code{Size} of an array object should not include its bounds; hence,
11863 the bounds should not be part of the converted data.
11864 @end cartouche
11865 Followed.
11867 @sp 1
11868 @cartouche
11869 The implementation should not generate unnecessary run-time checks to
11870 ensure that the representation of @var{S} is a representation of the
11871 target type.  It should take advantage of the permission to return by
11872 reference when possible.  Restrictions on unchecked conversions should be
11873 avoided unless required by the target environment.
11874 @end cartouche
11875 Followed.  There are no restrictions on unchecked conversion.  A warning is
11876 generated if the source and target types do not have the same size since
11877 the semantics in this case may be target dependent.
11879 @sp 1
11880 @cartouche
11881 The recommended level of support for unchecked conversions is:
11882 @end cartouche
11883 @sp 1
11884 @cartouche
11885 Unchecked conversions should be supported and should be reversible in
11886 the cases where this clause defines the result.  To enable meaningful use
11887 of unchecked conversion, a contiguous representation should be used for
11888 elementary subtypes, for statically constrained array subtypes whose
11889 component subtype is one of the subtypes described in this paragraph,
11890 and for record subtypes without discriminants whose component subtypes
11891 are described in this paragraph.
11892 @end cartouche
11893 Followed.
11895 @cindex Heap usage, implicit
11896 @unnumberedsec 13.11(23-25): Implicit Heap Usage
11897 @sp 1
11898 @cartouche
11899 An implementation should document any cases in which it dynamically
11900 allocates heap storage for a purpose other than the evaluation of an
11901 allocator.
11902 @end cartouche
11903 Followed, the only other points at which heap storage is dynamically
11904 allocated are as follows:
11906 @itemize @bullet
11907 @item
11908 At initial elaboration time, to allocate dynamically sized global
11909 objects.
11911 @item
11912 To allocate space for a task when a task is created.
11914 @item
11915 To extend the secondary stack dynamically when needed.  The secondary
11916 stack is used for returning variable length results.
11917 @end itemize
11919 @sp 1
11920 @cartouche
11921 A default (implementation-provided) storage pool for an
11922 access-to-constant type should not have overhead to support deallocation of
11923 individual objects.
11924 @end cartouche
11925 Followed.
11927 @sp 1
11928 @cartouche
11929 A storage pool for an anonymous access type should be created at the
11930 point of an allocator for the type, and be reclaimed when the designated
11931 object becomes inaccessible.
11932 @end cartouche
11933 Followed.
11935 @cindex Unchecked deallocation
11936 @unnumberedsec 13.11.2(17): Unchecked De-allocation
11937 @sp 1
11938 @cartouche
11939 For a standard storage pool, @code{Free} should actually reclaim the
11940 storage.
11941 @end cartouche
11942 Followed.
11944 @cindex Stream oriented attributes
11945 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
11946 @sp 1
11947 @cartouche
11948 If a stream element is the same size as a storage element, then the
11949 normal in-memory representation should be used by @code{Read} and
11950 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
11951 should use the smallest number of stream elements needed to represent
11952 all values in the base range of the scalar type.
11953 @end cartouche
11955 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
11956 which specifies using the size of the first subtype.
11957 However, such an implementation is based on direct binary
11958 representations and is therefore target- and endianness-dependent.
11959 To address this issue, GNAT also supplies an alternate implementation
11960 of the stream attributes @code{Read} and @code{Write},
11961 which uses the target-independent XDR standard representation
11962 for scalar types.
11963 @cindex XDR representation
11964 @cindex @code{Read} attribute
11965 @cindex @code{Write} attribute
11966 @cindex Stream oriented attributes
11967 The XDR implementation is provided as an alternative body of the
11968 @code{System.Stream_Attributes} package, in the file
11969 @file{s-stratt-xdr.adb} in the GNAT library.
11970 There is no @file{s-stratt-xdr.ads} file.
11971 In order to install the XDR implementation, do the following:
11972 @enumerate
11973 @item Replace the default implementation of the
11974 @code{System.Stream_Attributes} package with the XDR implementation.
11975 For example on a Unix platform issue the commands:
11976 @smallexample
11977 $ mv s-stratt.adb s-stratt-default.adb
11978 $ mv s-stratt-xdr.adb s-stratt.adb
11979 @end smallexample
11981 @item
11982 Rebuild the GNAT run-time library as documented in
11983 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
11984 @end enumerate
11986 @unnumberedsec A.1(52): Names of Predefined Numeric Types
11987 @sp 1
11988 @cartouche
11989 If an implementation provides additional named predefined integer types,
11990 then the names should end with @samp{Integer} as in
11991 @samp{Long_Integer}.  If an implementation provides additional named
11992 predefined floating point types, then the names should end with
11993 @samp{Float} as in @samp{Long_Float}.
11994 @end cartouche
11995 Followed.
11997 @findex Ada.Characters.Handling
11998 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
11999 @sp 1
12000 @cartouche
12001 If an implementation provides a localized definition of @code{Character}
12002 or @code{Wide_Character}, then the effects of the subprograms in
12003 @code{Characters.Handling} should reflect the localizations.  See also
12004 3.5.2.
12005 @end cartouche
12006 Followed.  GNAT provides no such localized definitions.
12008 @cindex Bounded-length strings
12009 @unnumberedsec A.4.4(106): Bounded-Length String Handling
12010 @sp 1
12011 @cartouche
12012 Bounded string objects should not be implemented by implicit pointers
12013 and dynamic allocation.
12014 @end cartouche
12015 Followed.  No implicit pointers or dynamic allocation are used.
12017 @cindex Random number generation
12018 @unnumberedsec A.5.2(46-47): Random Number Generation
12019 @sp 1
12020 @cartouche
12021 Any storage associated with an object of type @code{Generator} should be
12022 reclaimed on exit from the scope of the object.
12023 @end cartouche
12024 Followed.
12026 @sp 1
12027 @cartouche
12028 If the generator period is sufficiently long in relation to the number
12029 of distinct initiator values, then each possible value of
12030 @code{Initiator} passed to @code{Reset} should initiate a sequence of
12031 random numbers that does not, in a practical sense, overlap the sequence
12032 initiated by any other value.  If this is not possible, then the mapping
12033 between initiator values and generator states should be a rapidly
12034 varying function of the initiator value.
12035 @end cartouche
12036 Followed.  The generator period is sufficiently long for the first
12037 condition here to hold true.
12039 @findex Get_Immediate
12040 @unnumberedsec A.10.7(23): @code{Get_Immediate}
12041 @sp 1
12042 @cartouche
12043 The @code{Get_Immediate} procedures should be implemented with
12044 unbuffered input.  For a device such as a keyboard, input should be
12045 @dfn{available} if a key has already been typed, whereas for a disk
12046 file, input should always be available except at end of file.  For a file
12047 associated with a keyboard-like device, any line-editing features of the
12048 underlying operating system should be disabled during the execution of
12049 @code{Get_Immediate}.
12050 @end cartouche
12051 Followed on all targets except VxWorks. For VxWorks, there is no way to
12052 provide this functionality that does not result in the input buffer being
12053 flushed before the @code{Get_Immediate} call. A special unit
12054 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
12055 this functionality.
12057 @findex Export
12058 @unnumberedsec B.1(39-41): Pragma @code{Export}
12059 @sp 1
12060 @cartouche
12061 If an implementation supports pragma @code{Export} to a given language,
12062 then it should also allow the main subprogram to be written in that
12063 language.  It should support some mechanism for invoking the elaboration
12064 of the Ada library units included in the system, and for invoking the
12065 finalization of the environment task.  On typical systems, the
12066 recommended mechanism is to provide two subprograms whose link names are
12067 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
12068 elaboration code for library units.  @code{adafinal} should contain the
12069 finalization code.  These subprograms should have no effect the second
12070 and subsequent time they are called.
12071 @end cartouche
12072 Followed.
12074 @sp 1
12075 @cartouche
12076 Automatic elaboration of pre-elaborated packages should be
12077 provided when pragma @code{Export} is supported.
12078 @end cartouche
12079 Followed when the main program is in Ada.  If the main program is in a
12080 foreign language, then
12081 @code{adainit} must be called to elaborate pre-elaborated
12082 packages.
12084 @sp 1
12085 @cartouche
12086 For each supported convention @var{L} other than @code{Intrinsic}, an
12087 implementation should support @code{Import} and @code{Export} pragmas
12088 for objects of @var{L}-compatible types and for subprograms, and pragma
12089 @code{Convention} for @var{L}-eligible types and for subprograms,
12090 presuming the other language has corresponding features.  Pragma
12091 @code{Convention} need not be supported for scalar types.
12092 @end cartouche
12093 Followed.
12095 @cindex Package @code{Interfaces}
12096 @findex Interfaces
12097 @unnumberedsec B.2(12-13): Package @code{Interfaces}
12098 @sp 1
12099 @cartouche
12100 For each implementation-defined convention identifier, there should be a
12101 child package of package Interfaces with the corresponding name.  This
12102 package should contain any declarations that would be useful for
12103 interfacing to the language (implementation) represented by the
12104 convention.  Any declarations useful for interfacing to any language on
12105 the given hardware architecture should be provided directly in
12106 @code{Interfaces}.
12107 @end cartouche
12108 Followed.
12110 @sp 1
12111 @cartouche
12112 An implementation supporting an interface to C, COBOL, or Fortran should
12113 provide the corresponding package or packages described in the following
12114 clauses.
12115 @end cartouche
12116 Followed.  GNAT provides all the packages described in this section.
12118 @cindex C, interfacing with
12119 @unnumberedsec B.3(63-71): Interfacing with C
12120 @sp 1
12121 @cartouche
12122 An implementation should support the following interface correspondences
12123 between Ada and C@.
12124 @end cartouche
12125 Followed.
12127 @sp 1
12128 @cartouche
12129 An Ada procedure corresponds to a void-returning C function.
12130 @end cartouche
12131 Followed.
12133 @sp 1
12134 @cartouche
12135 An Ada function corresponds to a non-void C function.
12136 @end cartouche
12137 Followed.
12139 @sp 1
12140 @cartouche
12141 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
12142 function.
12143 @end cartouche
12144 Followed.
12146 @sp 1
12147 @cartouche
12148 An Ada @code{in} parameter of an access-to-object type with designated
12149 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
12150 where @var{t} is the C type corresponding to the Ada type @var{T}.
12151 @end cartouche
12152 Followed.
12154 @sp 1
12155 @cartouche
12156 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
12157 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
12158 argument to a C function, where @var{t} is the C type corresponding to
12159 the Ada type @var{T}.  In the case of an elementary @code{out} or
12160 @code{in out} parameter, a pointer to a temporary copy is used to
12161 preserve by-copy semantics.
12162 @end cartouche
12163 Followed.
12165 @sp 1
12166 @cartouche
12167 An Ada parameter of a record type @var{T}, of any mode, is passed as a
12168 @code{@var{t}*} argument to a C function, where @var{t} is the C
12169 structure corresponding to the Ada type @var{T}.
12170 @end cartouche
12171 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
12172 pragma, or Convention, or by explicitly specifying the mechanism for a given
12173 call using an extended import or export pragma.
12175 @sp 1
12176 @cartouche
12177 An Ada parameter of an array type with component type @var{T}, of any
12178 mode, is passed as a @code{@var{t}*} argument to a C function, where
12179 @var{t} is the C type corresponding to the Ada type @var{T}.
12180 @end cartouche
12181 Followed.
12183 @sp 1
12184 @cartouche
12185 An Ada parameter of an access-to-subprogram type is passed as a pointer
12186 to a C function whose prototype corresponds to the designated
12187 subprogram's specification.
12188 @end cartouche
12189 Followed.
12191 @cindex COBOL, interfacing with
12192 @unnumberedsec B.4(95-98): Interfacing with COBOL
12193 @sp 1
12194 @cartouche
12195 An Ada implementation should support the following interface
12196 correspondences between Ada and COBOL@.
12197 @end cartouche
12198 Followed.
12200 @sp 1
12201 @cartouche
12202 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
12203 the COBOL type corresponding to @var{T}.
12204 @end cartouche
12205 Followed.
12207 @sp 1
12208 @cartouche
12209 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
12210 the corresponding COBOL type.
12211 @end cartouche
12212 Followed.
12214 @sp 1
12215 @cartouche
12216 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
12217 COBOL type corresponding to the Ada parameter type; for scalars, a local
12218 copy is used if necessary to ensure by-copy semantics.
12219 @end cartouche
12220 Followed.
12222 @cindex Fortran, interfacing with
12223 @unnumberedsec B.5(22-26): Interfacing with Fortran
12224 @sp 1
12225 @cartouche
12226 An Ada implementation should support the following interface
12227 correspondences between Ada and Fortran:
12228 @end cartouche
12229 Followed.
12231 @sp 1
12232 @cartouche
12233 An Ada procedure corresponds to a Fortran subroutine.
12234 @end cartouche
12235 Followed.
12237 @sp 1
12238 @cartouche
12239 An Ada function corresponds to a Fortran function.
12240 @end cartouche
12241 Followed.
12243 @sp 1
12244 @cartouche
12245 An Ada parameter of an elementary, array, or record type @var{T} is
12246 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
12247 the Fortran type corresponding to the Ada type @var{T}, and where the
12248 INTENT attribute of the corresponding dummy argument matches the Ada
12249 formal parameter mode; the Fortran implementation's parameter passing
12250 conventions are used.  For elementary types, a local copy is used if
12251 necessary to ensure by-copy semantics.
12252 @end cartouche
12253 Followed.
12255 @sp 1
12256 @cartouche
12257 An Ada parameter of an access-to-subprogram type is passed as a
12258 reference to a Fortran procedure whose interface corresponds to the
12259 designated subprogram's specification.
12260 @end cartouche
12261 Followed.
12263 @cindex Machine operations
12264 @unnumberedsec C.1(3-5): Access to Machine Operations
12265 @sp 1
12266 @cartouche
12267 The machine code or intrinsic support should allow access to all
12268 operations normally available to assembly language programmers for the
12269 target environment, including privileged instructions, if any.
12270 @end cartouche
12271 Followed.
12273 @sp 1
12274 @cartouche
12275 The interfacing pragmas (see Annex B) should support interface to
12276 assembler; the default assembler should be associated with the
12277 convention identifier @code{Assembler}.
12278 @end cartouche
12279 Followed.
12281 @sp 1
12282 @cartouche
12283 If an entity is exported to assembly language, then the implementation
12284 should allocate it at an addressable location, and should ensure that it
12285 is retained by the linking process, even if not otherwise referenced
12286 from the Ada code.  The implementation should assume that any call to a
12287 machine code or assembler subprogram is allowed to read or update every
12288 object that is specified as exported.
12289 @end cartouche
12290 Followed.
12292 @unnumberedsec C.1(10-16): Access to Machine Operations
12293 @sp 1
12294 @cartouche
12295 The implementation should ensure that little or no overhead is
12296 associated with calling intrinsic and machine-code subprograms.
12297 @end cartouche
12298 Followed for both intrinsics and machine-code subprograms.
12300 @sp 1
12301 @cartouche
12302 It is recommended that intrinsic subprograms be provided for convenient
12303 access to any machine operations that provide special capabilities or
12304 efficiency and that are not otherwise available through the language
12305 constructs.
12306 @end cartouche
12307 Followed.  A full set of machine operation intrinsic subprograms is provided.
12309 @sp 1
12310 @cartouche
12311 Atomic read-modify-write operations---e.g.@:, test and set, compare and
12312 swap, decrement and test, enqueue/dequeue.
12313 @end cartouche
12314 Followed on any target supporting such operations.
12316 @sp 1
12317 @cartouche
12318 Standard numeric functions---e.g.@:, sin, log.
12319 @end cartouche
12320 Followed on any target supporting such operations.
12322 @sp 1
12323 @cartouche
12324 String manipulation operations---e.g.@:, translate and test.
12325 @end cartouche
12326 Followed on any target supporting such operations.
12328 @sp 1
12329 @cartouche
12330 Vector operations---e.g.@:, compare vector against thresholds.
12331 @end cartouche
12332 Followed on any target supporting such operations.
12334 @sp 1
12335 @cartouche
12336 Direct operations on I/O ports.
12337 @end cartouche
12338 Followed on any target supporting such operations.
12340 @cindex Interrupt support
12341 @unnumberedsec C.3(28): Interrupt Support
12342 @sp 1
12343 @cartouche
12344 If the @code{Ceiling_Locking} policy is not in effect, the
12345 implementation should provide means for the application to specify which
12346 interrupts are to be blocked during protected actions, if the underlying
12347 system allows for a finer-grain control of interrupt blocking.
12348 @end cartouche
12349 Followed.  The underlying system does not allow for finer-grain control
12350 of interrupt blocking.
12352 @cindex Protected procedure handlers
12353 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
12354 @sp 1
12355 @cartouche
12356 Whenever possible, the implementation should allow interrupt handlers to
12357 be called directly by the hardware.
12358 @end cartouche
12359 Followed on any target where the underlying operating system permits
12360 such direct calls.
12362 @sp 1
12363 @cartouche
12364 Whenever practical, violations of any
12365 implementation-defined restrictions should be detected before run time.
12366 @end cartouche
12367 Followed.  Compile time warnings are given when possible.
12369 @cindex Package @code{Interrupts}
12370 @findex Interrupts
12371 @unnumberedsec C.3.2(25): Package @code{Interrupts}
12373 @sp 1
12374 @cartouche
12375 If implementation-defined forms of interrupt handler procedures are
12376 supported, such as protected procedures with parameters, then for each
12377 such form of a handler, a type analogous to @code{Parameterless_Handler}
12378 should be specified in a child package of @code{Interrupts}, with the
12379 same operations as in the predefined package Interrupts.
12380 @end cartouche
12381 Followed.
12383 @cindex Pre-elaboration requirements
12384 @unnumberedsec C.4(14): Pre-elaboration Requirements
12385 @sp 1
12386 @cartouche
12387 It is recommended that pre-elaborated packages be implemented in such a
12388 way that there should be little or no code executed at run time for the
12389 elaboration of entities not already covered by the Implementation
12390 Requirements.
12391 @end cartouche
12392 Followed.  Executable code is generated in some cases, e.g.@: loops
12393 to initialize large arrays.
12395 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
12396 @sp 1
12397 @cartouche
12398 If the pragma applies to an entity, then the implementation should
12399 reduce the amount of storage used for storing names associated with that
12400 entity.
12401 @end cartouche
12402 Followed.
12404 @cindex Package @code{Task_Attributes}
12405 @findex Task_Attributes
12406 @unnumberedsec C.7.2(30): The Package Task_Attributes
12407 @sp 1
12408 @cartouche
12409 Some implementations are targeted to domains in which memory use at run
12410 time must be completely deterministic.  For such implementations, it is
12411 recommended that the storage for task attributes will be pre-allocated
12412 statically and not from the heap.  This can be accomplished by either
12413 placing restrictions on the number and the size of the task's
12414 attributes, or by using the pre-allocated storage for the first @var{N}
12415 attribute objects, and the heap for the others.  In the latter case,
12416 @var{N} should be documented.
12417 @end cartouche
12418 Not followed.  This implementation is not targeted to such a domain.
12420 @cindex Locking Policies
12421 @unnumberedsec D.3(17): Locking Policies
12423 @sp 1
12424 @cartouche
12425 The implementation should use names that end with @samp{_Locking} for
12426 locking policies defined by the implementation.
12427 @end cartouche
12428 Followed.  Two implementation-defined locking policies are defined,
12429 whose names (@code{Inheritance_Locking} and
12430 @code{Concurrent_Readers_Locking}) follow this suggestion.
12432 @cindex Entry queuing policies
12433 @unnumberedsec D.4(16): Entry Queuing Policies
12434 @sp 1
12435 @cartouche
12436 Names that end with @samp{_Queuing} should be used
12437 for all implementation-defined queuing policies.
12438 @end cartouche
12439 Followed.  No such implementation-defined queuing policies exist.
12441 @cindex Preemptive abort
12442 @unnumberedsec D.6(9-10): Preemptive Abort
12443 @sp 1
12444 @cartouche
12445 Even though the @code{abort_statement} is included in the list of
12446 potentially blocking operations (see 9.5.1), it is recommended that this
12447 statement be implemented in a way that never requires the task executing
12448 the @code{abort_statement} to block.
12449 @end cartouche
12450 Followed.
12452 @sp 1
12453 @cartouche
12454 On a multi-processor, the delay associated with aborting a task on
12455 another processor should be bounded; the implementation should use
12456 periodic polling, if necessary, to achieve this.
12457 @end cartouche
12458 Followed.
12460 @cindex Tasking restrictions
12461 @unnumberedsec D.7(21): Tasking Restrictions
12462 @sp 1
12463 @cartouche
12464 When feasible, the implementation should take advantage of the specified
12465 restrictions to produce a more efficient implementation.
12466 @end cartouche
12467 GNAT currently takes advantage of these restrictions by providing an optimized
12468 run time when the Ravenscar profile and the GNAT restricted run time set
12469 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
12470 pragma @code{Profile (Restricted)} for more details.
12472 @cindex Time, monotonic
12473 @unnumberedsec D.8(47-49): Monotonic Time
12474 @sp 1
12475 @cartouche
12476 When appropriate, implementations should provide configuration
12477 mechanisms to change the value of @code{Tick}.
12478 @end cartouche
12479 Such configuration mechanisms are not appropriate to this implementation
12480 and are thus not supported.
12482 @sp 1
12483 @cartouche
12484 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
12485 be implemented as transformations of the same time base.
12486 @end cartouche
12487 Followed.
12489 @sp 1
12490 @cartouche
12491 It is recommended that the @dfn{best} time base which exists in
12492 the underlying system be available to the application through
12493 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
12494 @end cartouche
12495 Followed.
12497 @cindex Partition communication subsystem
12498 @cindex PCS
12499 @unnumberedsec E.5(28-29): Partition Communication Subsystem
12500 @sp 1
12501 @cartouche
12502 Whenever possible, the PCS on the called partition should allow for
12503 multiple tasks to call the RPC-receiver with different messages and
12504 should allow them to block until the corresponding subprogram body
12505 returns.
12506 @end cartouche
12507 Followed by GLADE, a separately supplied PCS that can be used with
12508 GNAT.
12510 @sp 1
12511 @cartouche
12512 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
12513 should raise @code{Storage_Error} if it runs out of space trying to
12514 write the @code{Item} into the stream.
12515 @end cartouche
12516 Followed by GLADE, a separately supplied PCS that can be used with
12517 GNAT@.
12519 @cindex COBOL support
12520 @unnumberedsec F(7): COBOL Support
12521 @sp 1
12522 @cartouche
12523 If COBOL (respectively, C) is widely supported in the target
12524 environment, implementations supporting the Information Systems Annex
12525 should provide the child package @code{Interfaces.COBOL} (respectively,
12526 @code{Interfaces.C}) specified in Annex B and should support a
12527 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
12528 pragmas (see Annex B), thus allowing Ada programs to interface with
12529 programs written in that language.
12530 @end cartouche
12531 Followed.
12533 @cindex Decimal radix support
12534 @unnumberedsec F.1(2): Decimal Radix Support
12535 @sp 1
12536 @cartouche
12537 Packed decimal should be used as the internal representation for objects
12538 of subtype @var{S} when @var{S}'Machine_Radix = 10.
12539 @end cartouche
12540 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
12541 representations.
12543 @cindex Numerics
12544 @unnumberedsec G: Numerics
12545 @sp 2
12546 @cartouche
12547 If Fortran (respectively, C) is widely supported in the target
12548 environment, implementations supporting the Numerics Annex
12549 should provide the child package @code{Interfaces.Fortran} (respectively,
12550 @code{Interfaces.C}) specified in Annex B and should support a
12551 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
12552 pragmas (see Annex B), thus allowing Ada programs to interface with
12553 programs written in that language.
12554 @end cartouche
12555 Followed.
12557 @cindex Complex types
12558 @unnumberedsec G.1.1(56-58): Complex Types
12559 @sp 2
12560 @cartouche
12561 Because the usual mathematical meaning of multiplication of a complex
12562 operand and a real operand is that of the scaling of both components of
12563 the former by the latter, an implementation should not perform this
12564 operation by first promoting the real operand to complex type and then
12565 performing a full complex multiplication.  In systems that, in the
12566 future, support an Ada binding to IEC 559:1989, the latter technique
12567 will not generate the required result when one of the components of the
12568 complex operand is infinite.  (Explicit multiplication of the infinite
12569 component by the zero component obtained during promotion yields a NaN
12570 that propagates into the final result.) Analogous advice applies in the
12571 case of multiplication of a complex operand and a pure-imaginary
12572 operand, and in the case of division of a complex operand by a real or
12573 pure-imaginary operand.
12574 @end cartouche
12575 Not followed.
12577 @sp 1
12578 @cartouche
12579 Similarly, because the usual mathematical meaning of addition of a
12580 complex operand and a real operand is that the imaginary operand remains
12581 unchanged, an implementation should not perform this operation by first
12582 promoting the real operand to complex type and then performing a full
12583 complex addition.  In implementations in which the @code{Signed_Zeros}
12584 attribute of the component type is @code{True} (and which therefore
12585 conform to IEC 559:1989 in regard to the handling of the sign of zero in
12586 predefined arithmetic operations), the latter technique will not
12587 generate the required result when the imaginary component of the complex
12588 operand is a negatively signed zero.  (Explicit addition of the negative
12589 zero to the zero obtained during promotion yields a positive zero.)
12590 Analogous advice applies in the case of addition of a complex operand
12591 and a pure-imaginary operand, and in the case of subtraction of a
12592 complex operand and a real or pure-imaginary operand.
12593 @end cartouche
12594 Not followed.
12596 @sp 1
12597 @cartouche
12598 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
12599 attempt to provide a rational treatment of the signs of zero results and
12600 result components.  As one example, the result of the @code{Argument}
12601 function should have the sign of the imaginary component of the
12602 parameter @code{X} when the point represented by that parameter lies on
12603 the positive real axis; as another, the sign of the imaginary component
12604 of the @code{Compose_From_Polar} function should be the same as
12605 (respectively, the opposite of) that of the @code{Argument} parameter when that
12606 parameter has a value of zero and the @code{Modulus} parameter has a
12607 nonnegative (respectively, negative) value.
12608 @end cartouche
12609 Followed.
12611 @cindex Complex elementary functions
12612 @unnumberedsec G.1.2(49): Complex Elementary Functions
12613 @sp 1
12614 @cartouche
12615 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
12616 @code{True} should attempt to provide a rational treatment of the signs
12617 of zero results and result components.  For example, many of the complex
12618 elementary functions have components that are odd functions of one of
12619 the parameter components; in these cases, the result component should
12620 have the sign of the parameter component at the origin.  Other complex
12621 elementary functions have zero components whose sign is opposite that of
12622 a parameter component at the origin, or is always positive or always
12623 negative.
12624 @end cartouche
12625 Followed.
12627 @cindex Accuracy requirements
12628 @unnumberedsec G.2.4(19): Accuracy Requirements
12629 @sp 1
12630 @cartouche
12631 The versions of the forward trigonometric functions without a
12632 @code{Cycle} parameter should not be implemented by calling the
12633 corresponding version with a @code{Cycle} parameter of
12634 @code{2.0*Numerics.Pi}, since this will not provide the required
12635 accuracy in some portions of the domain.  For the same reason, the
12636 version of @code{Log} without a @code{Base} parameter should not be
12637 implemented by calling the corresponding version with a @code{Base}
12638 parameter of @code{Numerics.e}.
12639 @end cartouche
12640 Followed.
12642 @cindex Complex arithmetic accuracy
12643 @cindex Accuracy, complex arithmetic
12644 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
12646 @sp 1
12647 @cartouche
12648 The version of the @code{Compose_From_Polar} function without a
12649 @code{Cycle} parameter should not be implemented by calling the
12650 corresponding version with a @code{Cycle} parameter of
12651 @code{2.0*Numerics.Pi}, since this will not provide the required
12652 accuracy in some portions of the domain.
12653 @end cartouche
12654 Followed.
12656 @cindex Sequential elaboration policy
12657 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
12659 @sp 1
12660 @cartouche
12661 If the partition elaboration policy is @code{Sequential} and the
12662 Environment task becomes permanently blocked during elaboration then the
12663 partition is deadlocked and it is recommended that the partition be
12664 immediately terminated.
12665 @end cartouche
12666 Not followed.
12668 @c -----------------------------------------
12669 @node Implementation Defined Characteristics
12670 @chapter Implementation Defined Characteristics
12672 @noindent
12673 In addition to the implementation dependent pragmas and attributes, and the
12674 implementation advice, there are a number of other Ada features that are
12675 potentially implementation dependent and are designated as
12676 implementation-defined. These are mentioned throughout the Ada Reference
12677 Manual, and are summarized in Annex M@.
12679 A requirement for conforming Ada compilers is that they provide
12680 documentation describing how the implementation deals with each of these
12681 issues.  In this chapter you will find each point in Annex M listed,
12682 followed by a description of how GNAT
12683 handles the implementation dependence.
12685 You can use this chapter as a guide to minimizing implementation
12686 dependent features in your programs if portability to other compilers
12687 and other operating systems is an important consideration.  The numbers
12688 in each entry below correspond to the paragraph numbers in the Ada
12689 Reference Manual.
12692 @itemize @bullet
12693 @sp 1
12694 @item
12695 @cartouche
12696 @noindent
12697 Whether or not each recommendation given in Implementation
12698 Advice is followed.  See 1.1.2(37).
12699 @end cartouche
12700 @noindent
12701 @xref{Implementation Advice}.
12704 @sp 1
12705 @item
12706 @cartouche
12707 @noindent
12708 Capacity limitations of the implementation.  See 1.1.3(3).
12709 @end cartouche
12710 @noindent
12711 The complexity of programs that can be processed is limited only by the
12712 total amount of available virtual memory, and disk space for the
12713 generated object files.
12716 @sp 1
12717 @item
12718 @cartouche
12719 @noindent
12720 Variations from the standard that are impractical to avoid
12721 given the implementation's execution environment.  See 1.1.3(6).
12722 @end cartouche
12723 @noindent
12724 There are no variations from the standard.
12727 @sp 1
12728 @item
12729 @cartouche
12730 @noindent
12731 Which @code{code_statement}s cause external
12732 interactions.  See 1.1.3(10).
12733 @end cartouche
12734 @noindent
12735 Any @code{code_statement} can potentially cause external interactions.
12737 @sp 1
12738 @item
12739 @cartouche
12740 @noindent
12741 The coded representation for the text of an Ada
12742 program.  See 2.1(4).
12743 @end cartouche
12744 @noindent
12745 See separate section on source representation.
12748 @sp 1
12749 @item
12750 @cartouche
12751 @noindent
12752 The control functions allowed in comments.  See 2.1(14).
12753 @end cartouche
12754 @noindent
12755 See separate section on source representation.
12757 @sp 1
12758 @item
12759 @cartouche
12760 @noindent
12761 The representation for an end of line.  See 2.2(2).
12762 @end cartouche
12763 @noindent
12764 See separate section on source representation.
12766 @sp 1
12767 @item
12768 @cartouche
12769 @noindent
12770 Maximum supported line length and lexical element
12771 length.  See 2.2(15).
12772 @end cartouche
12773 @noindent
12774 The maximum line length is 255 characters and the maximum length of
12775 a lexical element is also 255 characters. This is the default setting
12776 if not overridden by the use of compiler switch @option{-gnaty} (which
12777 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
12778 line length to be specified to be any value up to 32767. The maximum
12779 length of a lexical element is the same as the maximum line length.
12781 @sp 1
12782 @item
12783 @cartouche
12784 @noindent
12785 Implementation defined pragmas.  See 2.8(14).
12786 @end cartouche
12787 @noindent
12789 @xref{Implementation Defined Pragmas}.
12791 @sp 1
12792 @item
12793 @cartouche
12794 @noindent
12795 Effect of pragma @code{Optimize}.  See 2.8(27).
12796 @end cartouche
12797 @noindent
12798 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
12799 parameter, checks that the optimization flag is set, and aborts if it is
12800 not.
12802 @sp 1
12803 @item
12804 @cartouche
12805 @noindent
12806 The sequence of characters of the value returned by
12807 @code{@var{S}'Image} when some of the graphic characters of
12808 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
12809 3.5(37).
12810 @end cartouche
12811 @noindent
12812 The sequence of characters is as defined by the wide character encoding
12813 method used for the source.  See section on source representation for
12814 further details.
12816 @sp 1
12817 @item
12818 @cartouche
12819 @noindent
12820 The predefined integer types declared in
12821 @code{Standard}.  See 3.5.4(25).
12822 @end cartouche
12823 @noindent
12824 @table @code
12825 @item Short_Short_Integer
12826 8 bit signed
12827 @item Short_Integer
12828 (Short) 16 bit signed
12829 @item Integer
12830 32 bit signed
12831 @item Long_Integer
12832 64 bit signed (on most 64 bit targets, depending on the C definition of long).
12833 32 bit signed (all other targets)
12834 @item Long_Long_Integer
12835 64 bit signed
12836 @end table
12838 @sp 1
12839 @item
12840 @cartouche
12841 @noindent
12842 Any nonstandard integer types and the operators defined
12843 for them.  See 3.5.4(26).
12844 @end cartouche
12845 @noindent
12846 There are no nonstandard integer types.
12848 @sp 1
12849 @item
12850 @cartouche
12851 @noindent
12852 Any nonstandard real types and the operators defined for
12853 them.  See 3.5.6(8).
12854 @end cartouche
12855 @noindent
12856 There are no nonstandard real types.
12858 @sp 1
12859 @item
12860 @cartouche
12861 @noindent
12862 What combinations of requested decimal precision and range
12863 are supported for floating point types.  See 3.5.7(7).
12864 @end cartouche
12865 @noindent
12866 The precision and range is as defined by the IEEE standard.
12868 @sp 1
12869 @item
12870 @cartouche
12871 @noindent
12872 The predefined floating point types declared in
12873 @code{Standard}.  See 3.5.7(16).
12874 @end cartouche
12875 @noindent
12876 @table @code
12877 @item Short_Float
12878 32 bit IEEE short
12879 @item Float
12880 (Short) 32 bit IEEE short
12881 @item Long_Float
12882 64 bit IEEE long
12883 @item Long_Long_Float
12884 64 bit IEEE long (80 bit IEEE long on x86 processors)
12885 @end table
12887 @sp 1
12888 @item
12889 @cartouche
12890 @noindent
12891 The small of an ordinary fixed point type.  See 3.5.9(8).
12892 @end cartouche
12893 @noindent
12894 @code{Fine_Delta} is 2**(@minus{}63)
12896 @sp 1
12897 @item
12898 @cartouche
12899 @noindent
12900 What combinations of small, range, and digits are
12901 supported for fixed point types.  See 3.5.9(10).
12902 @end cartouche
12903 @noindent
12904 Any combinations are permitted that do not result in a small less than
12905 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
12906 If the mantissa is larger than 53 bits on machines where Long_Long_Float
12907 is 64 bits (true of all architectures except ia32), then the output from
12908 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
12909 is because floating-point conversions are used to convert fixed point.
12911 @sp 1
12912 @item
12913 @cartouche
12914 @noindent
12915 The result of @code{Tags.Expanded_Name} for types declared
12916 within an unnamed @code{block_statement}.  See 3.9(10).
12917 @end cartouche
12918 @noindent
12919 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
12920 decimal integer are allocated.
12922 @sp 1
12923 @item
12924 @cartouche
12925 @noindent
12926 Implementation-defined attributes.  See 4.1.4(12).
12927 @end cartouche
12928 @noindent
12929 @xref{Implementation Defined Attributes}.
12931 @sp 1
12932 @item
12933 @cartouche
12934 @noindent
12935 Any implementation-defined time types.  See 9.6(6).
12936 @end cartouche
12937 @noindent
12938 There are no implementation-defined time types.
12940 @sp 1
12941 @item
12942 @cartouche
12943 @noindent
12944 The time base associated with relative delays.
12945 @end cartouche
12946 @noindent
12947 See 9.6(20).  The time base used is that provided by the C library
12948 function @code{gettimeofday}.
12950 @sp 1
12951 @item
12952 @cartouche
12953 @noindent
12954 The time base of the type @code{Calendar.Time}.  See
12955 9.6(23).
12956 @end cartouche
12957 @noindent
12958 The time base used is that provided by the C library function
12959 @code{gettimeofday}.
12961 @sp 1
12962 @item
12963 @cartouche
12964 @noindent
12965 The time zone used for package @code{Calendar}
12966 operations.  See 9.6(24).
12967 @end cartouche
12968 @noindent
12969 The time zone used by package @code{Calendar} is the current system time zone
12970 setting for local time, as accessed by the C library function
12971 @code{localtime}.
12973 @sp 1
12974 @item
12975 @cartouche
12976 @noindent
12977 Any limit on @code{delay_until_statements} of
12978 @code{select_statements}.  See 9.6(29).
12979 @end cartouche
12980 @noindent
12981 There are no such limits.
12983 @sp 1
12984 @item
12985 @cartouche
12986 @noindent
12987 Whether or not two non-overlapping parts of a composite
12988 object are independently addressable, in the case where packing, record
12989 layout, or @code{Component_Size} is specified for the object.  See
12990 9.10(1).
12991 @end cartouche
12992 @noindent
12993 Separate components are independently addressable if they do not share
12994 overlapping storage units.
12996 @sp 1
12997 @item
12998 @cartouche
12999 @noindent
13000 The representation for a compilation.  See 10.1(2).
13001 @end cartouche
13002 @noindent
13003 A compilation is represented by a sequence of files presented to the
13004 compiler in a single invocation of the @command{gcc} command.
13006 @sp 1
13007 @item
13008 @cartouche
13009 @noindent
13010 Any restrictions on compilations that contain multiple
13011 compilation_units.  See 10.1(4).
13012 @end cartouche
13013 @noindent
13014 No single file can contain more than one compilation unit, but any
13015 sequence of files can be presented to the compiler as a single
13016 compilation.
13018 @sp 1
13019 @item
13020 @cartouche
13021 @noindent
13022 The mechanisms for creating an environment and for adding
13023 and replacing compilation units.  See 10.1.4(3).
13024 @end cartouche
13025 @noindent
13026 See separate section on compilation model.
13028 @sp 1
13029 @item
13030 @cartouche
13031 @noindent
13032 The manner of explicitly assigning library units to a
13033 partition.  See 10.2(2).
13034 @end cartouche
13035 @noindent
13036 If a unit contains an Ada main program, then the Ada units for the partition
13037 are determined by recursive application of the rules in the Ada Reference
13038 Manual section 10.2(2-6).  In other words, the Ada units will be those that
13039 are needed by the main program, and then this definition of need is applied
13040 recursively to those units, and the partition contains the transitive
13041 closure determined by this relationship.  In short, all the necessary units
13042 are included, with no need to explicitly specify the list.  If additional
13043 units are required, e.g.@: by foreign language units, then all units must be
13044 mentioned in the context clause of one of the needed Ada units.
13046 If the partition contains no main program, or if the main program is in
13047 a language other than Ada, then GNAT
13048 provides the binder options @option{-z} and @option{-n} respectively, and in
13049 this case a list of units can be explicitly supplied to the binder for
13050 inclusion in the partition (all units needed by these units will also
13051 be included automatically).  For full details on the use of these
13052 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
13053 @value{EDITION} User's Guide}.
13055 @sp 1
13056 @item
13057 @cartouche
13058 @noindent
13059 The implementation-defined means, if any, of specifying
13060 which compilation units are needed by a given compilation unit.  See
13061 10.2(2).
13062 @end cartouche
13063 @noindent
13064 The units needed by a given compilation unit are as defined in
13065 the Ada Reference Manual section 10.2(2-6).  There are no
13066 implementation-defined pragmas or other implementation-defined
13067 means for specifying needed units.
13069 @sp 1
13070 @item
13071 @cartouche
13072 @noindent
13073 The manner of designating the main subprogram of a
13074 partition.  See 10.2(7).
13075 @end cartouche
13076 @noindent
13077 The main program is designated by providing the name of the
13078 corresponding @file{ALI} file as the input parameter to the binder.
13080 @sp 1
13081 @item
13082 @cartouche
13083 @noindent
13084 The order of elaboration of @code{library_items}.  See
13085 10.2(18).
13086 @end cartouche
13087 @noindent
13088 The first constraint on ordering is that it meets the requirements of
13089 Chapter 10 of the Ada Reference Manual.  This still leaves some
13090 implementation dependent choices, which are resolved by first
13091 elaborating bodies as early as possible (i.e., in preference to specs
13092 where there is a choice), and second by evaluating the immediate with
13093 clauses of a unit to determine the probably best choice, and
13094 third by elaborating in alphabetical order of unit names
13095 where a choice still remains.
13097 @sp 1
13098 @item
13099 @cartouche
13100 @noindent
13101 Parameter passing and function return for the main
13102 subprogram.  See 10.2(21).
13103 @end cartouche
13104 @noindent
13105 The main program has no parameters.  It may be a procedure, or a function
13106 returning an integer type.  In the latter case, the returned integer
13107 value is the return code of the program (overriding any value that
13108 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
13110 @sp 1
13111 @item
13112 @cartouche
13113 @noindent
13114 The mechanisms for building and running partitions.  See
13115 10.2(24).
13116 @end cartouche
13117 @noindent
13118 GNAT itself supports programs with only a single partition.  The GNATDIST
13119 tool provided with the GLADE package (which also includes an implementation
13120 of the PCS) provides a completely flexible method for building and running
13121 programs consisting of multiple partitions.  See the separate GLADE manual
13122 for details.
13124 @sp 1
13125 @item
13126 @cartouche
13127 @noindent
13128 The details of program execution, including program
13129 termination.  See 10.2(25).
13130 @end cartouche
13131 @noindent
13132 See separate section on compilation model.
13134 @sp 1
13135 @item
13136 @cartouche
13137 @noindent
13138 The semantics of any non-active partitions supported by the
13139 implementation.  See 10.2(28).
13140 @end cartouche
13141 @noindent
13142 Passive partitions are supported on targets where shared memory is
13143 provided by the operating system.  See the GLADE reference manual for
13144 further details.
13146 @sp 1
13147 @item
13148 @cartouche
13149 @noindent
13150 The information returned by @code{Exception_Message}.  See
13151 11.4.1(10).
13152 @end cartouche
13153 @noindent
13154 Exception message returns the null string unless a specific message has
13155 been passed by the program.
13157 @sp 1
13158 @item
13159 @cartouche
13160 @noindent
13161 The result of @code{Exceptions.Exception_Name} for types
13162 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
13163 @end cartouche
13164 @noindent
13165 Blocks have implementation defined names of the form @code{B@var{nnn}}
13166 where @var{nnn} is an integer.
13168 @sp 1
13169 @item
13170 @cartouche
13171 @noindent
13172 The information returned by
13173 @code{Exception_Information}.  See 11.4.1(13).
13174 @end cartouche
13175 @noindent
13176 @code{Exception_Information} returns a string in the following format:
13178 @smallexample
13179 @emph{Exception_Name:} nnnnn
13180 @emph{Message:} mmmmm
13181 @emph{PID:} ppp
13182 @emph{Load address:} 0xhhhh
13183 @emph{Call stack traceback locations:}
13184 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
13185 @end smallexample
13187 @noindent
13188 where
13190 @itemize @bullet
13191 @item
13192 @code{nnnn} is the fully qualified name of the exception in all upper
13193 case letters. This line is always present.
13195 @item
13196 @code{mmmm} is the message (this line present only if message is non-null)
13198 @item
13199 @code{ppp} is the Process Id value as a decimal integer (this line is
13200 present only if the Process Id is nonzero). Currently we are
13201 not making use of this field.
13203 @item
13204 The Load address line, the Call stack traceback locations line and the
13205 following values are present only if at least one traceback location was
13206 recorded. The Load address indicates the address at which the main executable
13207 was loaded; this line may not be present if operating system hasn't relocated
13208 the main executable. The values are given in C style format, with lower case
13209 letters for a-f, and only as many digits present as are necessary.
13210 @end itemize
13212 @noindent
13213 The line terminator sequence at the end of each line, including
13214 the last line is a single @code{LF} character (@code{16#0A#}).
13216 @sp 1
13217 @item
13218 @cartouche
13219 @noindent
13220 Implementation-defined check names.  See 11.5(27).
13221 @end cartouche
13222 @noindent
13223 The implementation defined check name Alignment_Check controls checking of
13224 address clause values for proper alignment (that is, the address supplied
13225 must be consistent with the alignment of the type).
13227 The implementation defined check name Predicate_Check controls whether
13228 predicate checks are generated.
13230 The implementation defined check name Validity_Check controls whether
13231 validity checks are generated.
13233 In addition, a user program can add implementation-defined check names
13234 by means of the pragma Check_Name.
13236 @sp 1
13237 @item
13238 @cartouche
13239 @noindent
13240 The interpretation of each aspect of representation.  See
13241 13.1(20).
13242 @end cartouche
13243 @noindent
13244 See separate section on data representations.
13246 @sp 1
13247 @item
13248 @cartouche
13249 @noindent
13250 Any restrictions placed upon representation items.  See
13251 13.1(20).
13252 @end cartouche
13253 @noindent
13254 See separate section on data representations.
13256 @sp 1
13257 @item
13258 @cartouche
13259 @noindent
13260 The meaning of @code{Size} for indefinite subtypes.  See
13261 13.3(48).
13262 @end cartouche
13263 @noindent
13264 Size for an indefinite subtype is the maximum possible size, except that
13265 for the case of a subprogram parameter, the size of the parameter object
13266 is the actual size.
13268 @sp 1
13269 @item
13270 @cartouche
13271 @noindent
13272 The default external representation for a type tag.  See
13273 13.3(75).
13274 @end cartouche
13275 @noindent
13276 The default external representation for a type tag is the fully expanded
13277 name of the type in upper case letters.
13279 @sp 1
13280 @item
13281 @cartouche
13282 @noindent
13283 What determines whether a compilation unit is the same in
13284 two different partitions.  See 13.3(76).
13285 @end cartouche
13286 @noindent
13287 A compilation unit is the same in two different partitions if and only
13288 if it derives from the same source file.
13290 @sp 1
13291 @item
13292 @cartouche
13293 @noindent
13294 Implementation-defined components.  See 13.5.1(15).
13295 @end cartouche
13296 @noindent
13297 The only implementation defined component is the tag for a tagged type,
13298 which contains a pointer to the dispatching table.
13300 @sp 1
13301 @item
13302 @cartouche
13303 @noindent
13304 If @code{Word_Size} = @code{Storage_Unit}, the default bit
13305 ordering.  See 13.5.3(5).
13306 @end cartouche
13307 @noindent
13308 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
13309 implementation, so no non-default bit ordering is supported.  The default
13310 bit ordering corresponds to the natural endianness of the target architecture.
13312 @sp 1
13313 @item
13314 @cartouche
13315 @noindent
13316 The contents of the visible part of package @code{System}
13317 and its language-defined children.  See 13.7(2).
13318 @end cartouche
13319 @noindent
13320 See the definition of these packages in files @file{system.ads} and
13321 @file{s-stoele.ads}. Note that two declarations are added to package
13322 System.
13324 @smallexample @c ada
13325    Max_Priority           : constant Positive :=
13326      Priority'Last;
13327    Max_Interrupt_Priority : constant Positive :=
13328      Interrupt_Priority'Last;
13329 @end smallexample
13331 @sp 1
13332 @item
13333 @cartouche
13334 @noindent
13335 The contents of the visible part of package
13336 @code{System.Machine_Code}, and the meaning of
13337 @code{code_statements}.  See 13.8(7).
13338 @end cartouche
13339 @noindent
13340 See the definition and documentation in file @file{s-maccod.ads}.
13342 @sp 1
13343 @item
13344 @cartouche
13345 @noindent
13346 The effect of unchecked conversion.  See 13.9(11).
13347 @end cartouche
13348 @noindent
13349 Unchecked conversion between types of the same size
13350 results in an uninterpreted transmission of the bits from one type
13351 to the other.  If the types are of unequal sizes, then in the case of
13352 discrete types, a shorter source is first zero or sign extended as
13353 necessary, and a shorter target is simply truncated on the left.
13354 For all non-discrete types, the source is first copied if necessary
13355 to ensure that the alignment requirements of the target are met, then
13356 a pointer is constructed to the source value, and the result is obtained
13357 by dereferencing this pointer after converting it to be a pointer to the
13358 target type. Unchecked conversions where the target subtype is an
13359 unconstrained array are not permitted. If the target alignment is
13360 greater than the source alignment, then a copy of the result is
13361 made with appropriate alignment
13363 @sp 1
13364 @item
13365 @cartouche
13366 @noindent
13367 The semantics of operations on invalid representations.
13368 See 13.9.2(10-11).
13369 @end cartouche
13370 @noindent
13371 For assignments and other operations where the use of invalid values cannot
13372 result in erroneous behavior, the compiler ignores the possibility of invalid
13373 values. An exception is raised at the point where an invalid value would
13374 result in erroneous behavior. For example executing:
13376 @smallexample @c ada
13377 procedure invalidvals is
13378    X : Integer := -1;
13379    Y : Natural range 1 .. 10;
13380    for Y'Address use X'Address;
13381    Z : Natural range 1 .. 10;
13382    A : array (Natural range 1 .. 10) of Integer;
13383 begin
13384    Z := Y;     -- no exception
13385    A (Z) := 3; -- exception raised;
13386 end;
13387 @end smallexample
13389 @noindent
13390 As indicated, an exception is raised on the array assignment, but not
13391 on the simple assignment of the invalid negative value from Y to Z.
13393 @sp 1
13394 @item
13395 @cartouche
13396 @noindent
13397 The manner of choosing a storage pool for an access type
13398 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
13399 @end cartouche
13400 @noindent
13401 There are 3 different standard pools used by the compiler when
13402 @code{Storage_Pool} is not specified depending whether the type is local
13403 to a subprogram or defined at the library level and whether
13404 @code{Storage_Size}is specified or not.  See documentation in the runtime
13405 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
13406 @code{System.Pool_Local} in files @file{s-poosiz.ads},
13407 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
13408 default pools used.
13410 @sp 1
13411 @item
13412 @cartouche
13413 @noindent
13414 Whether or not the implementation provides user-accessible
13415 names for the standard pool type(s).  See 13.11(17).
13416 @end cartouche
13417 @noindent
13419 See documentation in the sources of the run time mentioned in the previous
13420 paragraph.  All these pools are accessible by means of @code{with}'ing
13421 these units.
13423 @sp 1
13424 @item
13425 @cartouche
13426 @noindent
13427 The meaning of @code{Storage_Size}.  See 13.11(18).
13428 @end cartouche
13429 @noindent
13430 @code{Storage_Size} is measured in storage units, and refers to the
13431 total space available for an access type collection, or to the primary
13432 stack space for a task.
13434 @sp 1
13435 @item
13436 @cartouche
13437 @noindent
13438 Implementation-defined aspects of storage pools.  See
13439 13.11(22).
13440 @end cartouche
13441 @noindent
13442 See documentation in the sources of the run time mentioned in the
13443 paragraph about standard storage pools above
13444 for details on GNAT-defined aspects of storage pools.
13446 @sp 1
13447 @item
13448 @cartouche
13449 @noindent
13450 The set of restrictions allowed in a pragma
13451 @code{Restrictions}.  See 13.12(7).
13452 @end cartouche
13453 @noindent
13454 @xref{Standard and Implementation Defined Restrictions}.
13456 @sp 1
13457 @item
13458 @cartouche
13459 @noindent
13460 The consequences of violating limitations on
13461 @code{Restrictions} pragmas.  See 13.12(9).
13462 @end cartouche
13463 @noindent
13464 Restrictions that can be checked at compile time result in illegalities
13465 if violated.  Currently there are no other consequences of violating
13466 restrictions.
13468 @sp 1
13469 @item
13470 @cartouche
13471 @noindent
13472 The representation used by the @code{Read} and
13473 @code{Write} attributes of elementary types in terms of stream
13474 elements.  See 13.13.2(9).
13475 @end cartouche
13476 @noindent
13477 The representation is the in-memory representation of the base type of
13478 the type, using the number of bits corresponding to the
13479 @code{@var{type}'Size} value, and the natural ordering of the machine.
13481 @sp 1
13482 @item
13483 @cartouche
13484 @noindent
13485 The names and characteristics of the numeric subtypes
13486 declared in the visible part of package @code{Standard}.  See A.1(3).
13487 @end cartouche
13488 @noindent
13489 See items describing the integer and floating-point types supported.
13491 @sp 1
13492 @item
13493 @cartouche
13494 @noindent
13495 The string returned by @code{Character_Set_Version}.
13496 See A.3.5(3).
13497 @end cartouche
13498 @noindent
13499 @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns
13500 the string "Unicode 4.0", referring to version 4.0 of the
13501 Unicode specification.
13503 @sp 1
13504 @item
13505 @cartouche
13506 @noindent
13507 The accuracy actually achieved by the elementary
13508 functions.  See A.5.1(1).
13509 @end cartouche
13510 @noindent
13511 The elementary functions correspond to the functions available in the C
13512 library.  Only fast math mode is implemented.
13514 @sp 1
13515 @item
13516 @cartouche
13517 @noindent
13518 The sign of a zero result from some of the operators or
13519 functions in @code{Numerics.Generic_Elementary_Functions}, when
13520 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
13521 @end cartouche
13522 @noindent
13523 The sign of zeroes follows the requirements of the IEEE 754 standard on
13524 floating-point.
13526 @sp 1
13527 @item
13528 @cartouche
13529 @noindent
13530 The value of
13531 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
13532 @end cartouche
13533 @noindent
13534 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13536 @sp 1
13537 @item
13538 @cartouche
13539 @noindent
13540 The value of
13541 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
13542 @end cartouche
13543 @noindent
13544 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13546 @sp 1
13547 @item
13548 @cartouche
13549 @noindent
13550 The algorithms for random number generation.  See
13551 A.5.2(32).
13552 @end cartouche
13553 @noindent
13554 The algorithm is the Mersenne Twister, as documented in the source file
13555 @file{s-rannum.adb}. This version of the algorithm has a period of
13556 2**19937-1.
13558 @sp 1
13559 @item
13560 @cartouche
13561 @noindent
13562 The string representation of a random number generator's
13563 state.  See A.5.2(38).
13564 @end cartouche
13565 @noindent
13566 The value returned by the Image function is the concatenation of
13567 the fixed-width decimal representations of the 624 32-bit integers
13568 of the state vector.
13570 @sp 1
13571 @item
13572 @cartouche
13573 @noindent
13574 The minimum time interval between calls to the
13575 time-dependent Reset procedure that are guaranteed to initiate different
13576 random number sequences.  See A.5.2(45).
13577 @end cartouche
13578 @noindent
13579 The minimum period between reset calls to guarantee distinct series of
13580 random numbers is one microsecond.
13582 @sp 1
13583 @item
13584 @cartouche
13585 @noindent
13586 The values of the @code{Model_Mantissa},
13587 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
13588 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
13589 Annex is not supported.  See A.5.3(72).
13590 @end cartouche
13591 @noindent
13592 Run the compiler with @option{-gnatS} to produce a listing of package
13593 @code{Standard}, has the values of all numeric attributes.
13595 @sp 1
13596 @item
13597 @cartouche
13598 @noindent
13599 Any implementation-defined characteristics of the
13600 input-output packages.  See A.7(14).
13601 @end cartouche
13602 @noindent
13603 There are no special implementation defined characteristics for these
13604 packages.
13606 @sp 1
13607 @item
13608 @cartouche
13609 @noindent
13610 The value of @code{Buffer_Size} in @code{Storage_IO}.  See
13611 A.9(10).
13612 @end cartouche
13613 @noindent
13614 All type representations are contiguous, and the @code{Buffer_Size} is
13615 the value of @code{@var{type}'Size} rounded up to the next storage unit
13616 boundary.
13618 @sp 1
13619 @item
13620 @cartouche
13621 @noindent
13622 External files for standard input, standard output, and
13623 standard error See A.10(5).
13624 @end cartouche
13625 @noindent
13626 These files are mapped onto the files provided by the C streams
13627 libraries.  See source file @file{i-cstrea.ads} for further details.
13629 @sp 1
13630 @item
13631 @cartouche
13632 @noindent
13633 The accuracy of the value produced by @code{Put}.  See
13634 A.10.9(36).
13635 @end cartouche
13636 @noindent
13637 If more digits are requested in the output than are represented by the
13638 precision of the value, zeroes are output in the corresponding least
13639 significant digit positions.
13641 @sp 1
13642 @item
13643 @cartouche
13644 @noindent
13645 The meaning of @code{Argument_Count}, @code{Argument}, and
13646 @code{Command_Name}.  See A.15(1).
13647 @end cartouche
13648 @noindent
13649 These are mapped onto the @code{argv} and @code{argc} parameters of the
13650 main program in the natural manner.
13652 @sp 1
13653 @item
13654 @cartouche
13655 @noindent
13656 The interpretation of the @code{Form} parameter in procedure
13657 @code{Create_Directory}.  See A.16(56).
13658 @end cartouche
13659 @noindent
13660 The @code{Form} parameter is not used.
13662 @sp 1
13663 @item
13664 @cartouche
13665 @noindent
13666 The interpretation of the @code{Form} parameter in procedure
13667 @code{Create_Path}.  See A.16(60).
13668 @end cartouche
13669 @noindent
13670 The @code{Form} parameter is not used.
13672 @sp 1
13673 @item
13674 @cartouche
13675 @noindent
13676 The interpretation of the @code{Form} parameter in procedure
13677 @code{Copy_File}.  See A.16(68).
13678 @end cartouche
13679 @noindent
13680 The @code{Form} parameter is case-insensitive.
13682 Two fields are recognized in the @code{Form} parameter:
13684 @table @code
13686 @item preserve=<value>
13688 @item mode=<value>
13690 @end table
13692 @noindent
13693 <value> starts immediately after the character '=' and ends with the
13694 character immediately preceding the next comma (',') or with the last
13695 character of the parameter.
13697 The only possible values for preserve= are:
13699 @table @code
13701 @item no_attributes
13702 Do not try to preserve any file attributes. This is the default if no
13703 preserve= is found in Form.
13705 @item all_attributes
13706 Try to preserve all file attributes (timestamps, access rights).
13708 @item timestamps
13709 Preserve the timestamp of the copied file, but not the other file attributes.
13711 @end table
13713 @noindent
13714 The only possible values for mode= are:
13716 @table @code
13718 @item copy
13719 Only do the copy if the destination file does not already exist. If it already
13720 exists, Copy_File fails.
13722 @item overwrite
13723 Copy the file in all cases. Overwrite an already existing destination file.
13725 @item append
13726 Append the original file to the destination file. If the destination file does
13727 not exist, the destination file is a copy of the source file. When mode=append,
13728 the field preserve=, if it exists, is not taken into account.
13730 @end table
13732 @noindent
13733 If the Form parameter includes one or both of the fields and the value or
13734 values are incorrect, Copy_file fails with Use_Error.
13736 Examples of correct Forms:
13738 @smallexample
13739 Form => "preserve=no_attributes,mode=overwrite" (the default)
13740 Form => "mode=append"
13741 Form => "mode=copy, preserve=all_attributes"
13742 @end smallexample
13744 @noindent
13745 Examples of incorrect Forms
13747 @smallexample
13748 Form => "preserve=junk"
13749 Form => "mode=internal, preserve=timestamps"
13750 @end smallexample
13752 @sp 1
13753 @item
13754 @cartouche
13755 @noindent
13756 The interpretation of the @code{Pattern} parameter, when not the null string,
13757 in the @code{Start_Search} and @code{Search} procedures.
13758 See A.16(104) and A.16(112).
13759 @end cartouche
13760 @noindent
13761 When the @code{Pattern} parameter is not the null string, it is interpreted
13762 according to the syntax of regular expressions as defined in the
13763 @code{GNAT.Regexp} package.
13764 @xref{GNAT.Regexp (g-regexp.ads)}.
13766 @sp 1
13767 @item
13768 @cartouche
13769 @noindent
13770 Implementation-defined convention names.  See B.1(11).
13771 @end cartouche
13772 @noindent
13773 The following convention names are supported
13775 @table @code
13776 @item  Ada
13778 @item Ada_Pass_By_Copy
13779 Allowed for any types except by-reference types such as limited
13780 records. Compatible with convention Ada, but causes any parameters
13781 with this convention to be passed by copy.
13782 @item Ada_Pass_By_Reference
13783 Allowed for any types except by-copy types such as scalars.
13784 Compatible with convention Ada, but causes any parameters
13785 with this convention to be passed by reference.
13786 @item Assembler
13787 Assembly language
13788 @item Asm
13789 Synonym for Assembler
13790 @item Assembly
13791 Synonym for Assembler
13792 @item C
13794 @item C_Pass_By_Copy
13795 Allowed only for record types, like C, but also notes that record
13796 is to be passed by copy rather than reference.
13797 @item COBOL
13798 COBOL
13799 @item C_Plus_Plus (or CPP)
13801 @item Default
13802 Treated the same as C
13803 @item External
13804 Treated the same as C
13805 @item Fortran
13806 Fortran
13807 @item Intrinsic
13808 For support of pragma @code{Import} with convention Intrinsic, see
13809 separate section on Intrinsic Subprograms.
13810 @item Stdcall
13811 Stdcall (used for Windows implementations only).  This convention correspond
13812 to the WINAPI (previously called Pascal convention) C/C++ convention under
13813 Windows.  A routine with this convention cleans the stack before
13814 exit. This pragma cannot be applied to a dispatching call.
13815 @item DLL
13816 Synonym for Stdcall
13817 @item Win32
13818 Synonym for Stdcall
13819 @item Stubbed
13820 Stubbed is a special convention used to indicate that the body of the
13821 subprogram will be entirely ignored.  Any call to the subprogram
13822 is converted into a raise of the @code{Program_Error} exception.  If a
13823 pragma @code{Import} specifies convention @code{stubbed} then no body need
13824 be present at all.  This convention is useful during development for the
13825 inclusion of subprograms whose body has not yet been written.
13827 @end table
13828 @noindent
13829 In addition, all otherwise unrecognized convention names are also
13830 treated as being synonymous with convention C@.  In all implementations
13831 except for VMS, use of such other names results in a warning.  In VMS
13832 implementations, these names are accepted silently.
13834 @sp 1
13835 @item
13836 @cartouche
13837 @noindent
13838 The meaning of link names.  See B.1(36).
13839 @end cartouche
13840 @noindent
13841 Link names are the actual names used by the linker.
13843 @sp 1
13844 @item
13845 @cartouche
13846 @noindent
13847 The manner of choosing link names when neither the link
13848 name nor the address of an imported or exported entity is specified.  See
13849 B.1(36).
13850 @end cartouche
13851 @noindent
13852 The default linker name is that which would be assigned by the relevant
13853 external language, interpreting the Ada name as being in all lower case
13854 letters.
13856 @sp 1
13857 @item
13858 @cartouche
13859 @noindent
13860 The effect of pragma @code{Linker_Options}.  See B.1(37).
13861 @end cartouche
13862 @noindent
13863 The string passed to @code{Linker_Options} is presented uninterpreted as
13864 an argument to the link command, unless it contains ASCII.NUL characters.
13865 NUL characters if they appear act as argument separators, so for example
13867 @smallexample @c ada
13868 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
13869 @end smallexample
13871 @noindent
13872 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
13873 linker. The order of linker options is preserved for a given unit. The final
13874 list of options passed to the linker is in reverse order of the elaboration
13875 order. For example, linker options for a body always appear before the options
13876 from the corresponding package spec.
13878 @sp 1
13879 @item
13880 @cartouche
13881 @noindent
13882 The contents of the visible part of package
13883 @code{Interfaces} and its language-defined descendants.  See B.2(1).
13884 @end cartouche
13885 @noindent
13886 See files with prefix @file{i-} in the distributed library.
13888 @sp 1
13889 @item
13890 @cartouche
13891 @noindent
13892 Implementation-defined children of package
13893 @code{Interfaces}.  The contents of the visible part of package
13894 @code{Interfaces}.  See B.2(11).
13895 @end cartouche
13896 @noindent
13897 See files with prefix @file{i-} in the distributed library.
13899 @sp 1
13900 @item
13901 @cartouche
13902 @noindent
13903 The types @code{Floating}, @code{Long_Floating},
13904 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
13905 @code{COBOL_Character}; and the initialization of the variables
13906 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
13907 @code{Interfaces.COBOL}.  See B.4(50).
13908 @end cartouche
13909 @noindent
13910 @table @code
13911 @item Floating
13912 Float
13913 @item Long_Floating
13914 (Floating) Long_Float
13915 @item Binary
13916 Integer
13917 @item Long_Binary
13918 Long_Long_Integer
13919 @item Decimal_Element
13920 Character
13921 @item COBOL_Character
13922 Character
13923 @end table
13925 @noindent
13926 For initialization, see the file @file{i-cobol.ads} in the distributed library.
13928 @sp 1
13929 @item
13930 @cartouche
13931 @noindent
13932 Support for access to machine instructions.  See C.1(1).
13933 @end cartouche
13934 @noindent
13935 See documentation in file @file{s-maccod.ads} in the distributed library.
13937 @sp 1
13938 @item
13939 @cartouche
13940 @noindent
13941 Implementation-defined aspects of access to machine
13942 operations.  See C.1(9).
13943 @end cartouche
13944 @noindent
13945 See documentation in file @file{s-maccod.ads} in the distributed library.
13947 @sp 1
13948 @item
13949 @cartouche
13950 @noindent
13951 Implementation-defined aspects of interrupts.  See C.3(2).
13952 @end cartouche
13953 @noindent
13954 Interrupts are mapped to signals or conditions as appropriate.  See
13955 definition of unit
13956 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
13957 on the interrupts supported on a particular target.
13959 @sp 1
13960 @item
13961 @cartouche
13962 @noindent
13963 Implementation-defined aspects of pre-elaboration.  See
13964 C.4(13).
13965 @end cartouche
13966 @noindent
13967 GNAT does not permit a partition to be restarted without reloading,
13968 except under control of the debugger.
13970 @sp 1
13971 @item
13972 @cartouche
13973 @noindent
13974 The semantics of pragma @code{Discard_Names}.  See C.5(7).
13975 @end cartouche
13976 @noindent
13977 Pragma @code{Discard_Names} causes names of enumeration literals to
13978 be suppressed.  In the presence of this pragma, the Image attribute
13979 provides the image of the Pos of the literal, and Value accepts
13980 Pos values.
13982 @sp 1
13983 @item
13984 @cartouche
13985 @noindent
13986 The result of the @code{Task_Identification.Image}
13987 attribute.  See C.7.1(7).
13988 @end cartouche
13989 @noindent
13990 The result of this attribute is a string that identifies
13991 the object or component that denotes a given task. If a variable @code{Var}
13992 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
13993 where the suffix
13994 is the hexadecimal representation of the virtual address of the corresponding
13995 task control block. If the variable is an array of tasks, the image of each
13996 task will have the form of an indexed component indicating the position of a
13997 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
13998 component of a record, the image of the task will have the form of a selected
13999 component. These rules are fully recursive, so that the image of a task that
14000 is a subcomponent of a composite object corresponds to the expression that
14001 designates this task.
14002 @noindent
14003 If a task is created by an allocator, its image depends on the context. If the
14004 allocator is part of an object declaration, the rules described above are used
14005 to construct its image, and this image is not affected by subsequent
14006 assignments. If the allocator appears within an expression, the image
14007 includes only the name of the task type.
14008 @noindent
14009 If the configuration pragma Discard_Names is present, or if the restriction
14010 No_Implicit_Heap_Allocation is in effect,  the image reduces to
14011 the numeric suffix, that is to say the hexadecimal representation of the
14012 virtual address of the control block of the task.
14013 @sp 1
14014 @item
14015 @cartouche
14016 @noindent
14017 The value of @code{Current_Task} when in a protected entry
14018 or interrupt handler.  See C.7.1(17).
14019 @end cartouche
14020 @noindent
14021 Protected entries or interrupt handlers can be executed by any
14022 convenient thread, so the value of @code{Current_Task} is undefined.
14024 @sp 1
14025 @item
14026 @cartouche
14027 @noindent
14028 The effect of calling @code{Current_Task} from an entry
14029 body or interrupt handler.  See C.7.1(19).
14030 @end cartouche
14031 @noindent
14032 The effect of calling @code{Current_Task} from an entry body or
14033 interrupt handler is to return the identification of the task currently
14034 executing the code.
14036 @sp 1
14037 @item
14038 @cartouche
14039 @noindent
14040 Implementation-defined aspects of
14041 @code{Task_Attributes}.  See C.7.2(19).
14042 @end cartouche
14043 @noindent
14044 There are no implementation-defined aspects of @code{Task_Attributes}.
14046 @sp 1
14047 @item
14048 @cartouche
14049 @noindent
14050 Values of all @code{Metrics}.  See D(2).
14051 @end cartouche
14052 @noindent
14053 The metrics information for GNAT depends on the performance of the
14054 underlying operating system.  The sources of the run-time for tasking
14055 implementation, together with the output from @option{-gnatG} can be
14056 used to determine the exact sequence of operating systems calls made
14057 to implement various tasking constructs.  Together with appropriate
14058 information on the performance of the underlying operating system,
14059 on the exact target in use, this information can be used to determine
14060 the required metrics.
14062 @sp 1
14063 @item
14064 @cartouche
14065 @noindent
14066 The declarations of @code{Any_Priority} and
14067 @code{Priority}.  See D.1(11).
14068 @end cartouche
14069 @noindent
14070 See declarations in file @file{system.ads}.
14072 @sp 1
14073 @item
14074 @cartouche
14075 @noindent
14076 Implementation-defined execution resources.  See D.1(15).
14077 @end cartouche
14078 @noindent
14079 There are no implementation-defined execution resources.
14081 @sp 1
14082 @item
14083 @cartouche
14084 @noindent
14085 Whether, on a multiprocessor, a task that is waiting for
14086 access to a protected object keeps its processor busy.  See D.2.1(3).
14087 @end cartouche
14088 @noindent
14089 On a multi-processor, a task that is waiting for access to a protected
14090 object does not keep its processor busy.
14092 @sp 1
14093 @item
14094 @cartouche
14095 @noindent
14096 The affect of implementation defined execution resources
14097 on task dispatching.  See D.2.1(9).
14098 @end cartouche
14099 @noindent
14100 Tasks map to threads in the threads package used by GNAT@.  Where possible
14101 and appropriate, these threads correspond to native threads of the
14102 underlying operating system.
14104 @sp 1
14105 @item
14106 @cartouche
14107 @noindent
14108 Implementation-defined @code{policy_identifiers} allowed
14109 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
14110 @end cartouche
14111 @noindent
14112 There are no implementation-defined policy-identifiers allowed in this
14113 pragma.
14115 @sp 1
14116 @item
14117 @cartouche
14118 @noindent
14119 Implementation-defined aspects of priority inversion.  See
14120 D.2.2(16).
14121 @end cartouche
14122 @noindent
14123 Execution of a task cannot be preempted by the implementation processing
14124 of delay expirations for lower priority tasks.
14126 @sp 1
14127 @item
14128 @cartouche
14129 @noindent
14130 Implementation-defined task dispatching.  See D.2.2(18).
14131 @end cartouche
14132 @noindent
14133 The policy is the same as that of the underlying threads implementation.
14135 @sp 1
14136 @item
14137 @cartouche
14138 @noindent
14139 Implementation-defined @code{policy_identifiers} allowed
14140 in a pragma @code{Locking_Policy}.  See D.3(4).
14141 @end cartouche
14142 @noindent
14143 The two implementation defined policies permitted in GNAT are
14144 @code{Inheritance_Locking} and  @code{Conccurent_Readers_Locking}.  On
14145 targets that support the @code{Inheritance_Locking} policy, locking is
14146 implemented by inheritance, i.e.@: the task owning the lock operates
14147 at a priority equal to the highest priority of any task currently
14148 requesting the lock.  On targets that support the
14149 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
14150 read/write lock allowing multiple propected object functions to enter
14151 concurrently.
14153 @sp 1
14154 @item
14155 @cartouche
14156 @noindent
14157 Default ceiling priorities.  See D.3(10).
14158 @end cartouche
14159 @noindent
14160 The ceiling priority of protected objects of the type
14161 @code{System.Interrupt_Priority'Last} as described in the Ada
14162 Reference Manual D.3(10),
14164 @sp 1
14165 @item
14166 @cartouche
14167 @noindent
14168 The ceiling of any protected object used internally by
14169 the implementation.  See D.3(16).
14170 @end cartouche
14171 @noindent
14172 The ceiling priority of internal protected objects is
14173 @code{System.Priority'Last}.
14175 @sp 1
14176 @item
14177 @cartouche
14178 @noindent
14179 Implementation-defined queuing policies.  See D.4(1).
14180 @end cartouche
14181 @noindent
14182 There are no implementation-defined queuing policies.
14184 @sp 1
14185 @item
14186 @cartouche
14187 @noindent
14188 On a multiprocessor, any conditions that cause the
14189 completion of an aborted construct to be delayed later than what is
14190 specified for a single processor.  See D.6(3).
14191 @end cartouche
14192 @noindent
14193 The semantics for abort on a multi-processor is the same as on a single
14194 processor, there are no further delays.
14196 @sp 1
14197 @item
14198 @cartouche
14199 @noindent
14200 Any operations that implicitly require heap storage
14201 allocation.  See D.7(8).
14202 @end cartouche
14203 @noindent
14204 The only operation that implicitly requires heap storage allocation is
14205 task creation.
14207 @sp 1
14208 @item
14209 @cartouche
14210 @noindent
14211 Implementation-defined aspects of pragma
14212 @code{Restrictions}.  See D.7(20).
14213 @end cartouche
14214 @noindent
14215 There are no such implementation-defined aspects.
14217 @sp 1
14218 @item
14219 @cartouche
14220 @noindent
14221 Implementation-defined aspects of package
14222 @code{Real_Time}.  See D.8(17).
14223 @end cartouche
14224 @noindent
14225 There are no implementation defined aspects of package @code{Real_Time}.
14227 @sp 1
14228 @item
14229 @cartouche
14230 @noindent
14231 Implementation-defined aspects of
14232 @code{delay_statements}.  See D.9(8).
14233 @end cartouche
14234 @noindent
14235 Any difference greater than one microsecond will cause the task to be
14236 delayed (see D.9(7)).
14238 @sp 1
14239 @item
14240 @cartouche
14241 @noindent
14242 The upper bound on the duration of interrupt blocking
14243 caused by the implementation.  See D.12(5).
14244 @end cartouche
14245 @noindent
14246 The upper bound is determined by the underlying operating system.  In
14247 no cases is it more than 10 milliseconds.
14249 @sp 1
14250 @item
14251 @cartouche
14252 @noindent
14253 The means for creating and executing distributed
14254 programs.  See E(5).
14255 @end cartouche
14256 @noindent
14257 The GLADE package provides a utility GNATDIST for creating and executing
14258 distributed programs.  See the GLADE reference manual for further details.
14260 @sp 1
14261 @item
14262 @cartouche
14263 @noindent
14264 Any events that can result in a partition becoming
14265 inaccessible.  See E.1(7).
14266 @end cartouche
14267 @noindent
14268 See the GLADE reference manual for full details on such events.
14270 @sp 1
14271 @item
14272 @cartouche
14273 @noindent
14274 The scheduling policies, treatment of priorities, and
14275 management of shared resources between partitions in certain cases.  See
14276 E.1(11).
14277 @end cartouche
14278 @noindent
14279 See the GLADE reference manual for full details on these aspects of
14280 multi-partition execution.
14282 @sp 1
14283 @item
14284 @cartouche
14285 @noindent
14286 Events that cause the version of a compilation unit to
14287 change.  See E.3(5).
14288 @end cartouche
14289 @noindent
14290 Editing the source file of a compilation unit, or the source files of
14291 any units on which it is dependent in a significant way cause the version
14292 to change.  No other actions cause the version number to change.  All changes
14293 are significant except those which affect only layout, capitalization or
14294 comments.
14296 @sp 1
14297 @item
14298 @cartouche
14299 @noindent
14300 Whether the execution of the remote subprogram is
14301 immediately aborted as a result of cancellation.  See E.4(13).
14302 @end cartouche
14303 @noindent
14304 See the GLADE reference manual for details on the effect of abort in
14305 a distributed application.
14307 @sp 1
14308 @item
14309 @cartouche
14310 @noindent
14311 Implementation-defined aspects of the PCS@.  See E.5(25).
14312 @end cartouche
14313 @noindent
14314 See the GLADE reference manual for a full description of all implementation
14315 defined aspects of the PCS@.
14317 @sp 1
14318 @item
14319 @cartouche
14320 @noindent
14321 Implementation-defined interfaces in the PCS@.  See
14322 E.5(26).
14323 @end cartouche
14324 @noindent
14325 See the GLADE reference manual for a full description of all
14326 implementation defined interfaces.
14328 @sp 1
14329 @item
14330 @cartouche
14331 @noindent
14332 The values of named numbers in the package
14333 @code{Decimal}.  See F.2(7).
14334 @end cartouche
14335 @noindent
14336 @table @code
14337 @item Max_Scale
14339 @item Min_Scale
14341 @item Min_Delta
14342 1.0E-18
14343 @item Max_Delta
14344 1.0E+18
14345 @item Max_Decimal_Digits
14347 @end table
14349 @sp 1
14350 @item
14351 @cartouche
14352 @noindent
14353 The value of @code{Max_Picture_Length} in the package
14354 @code{Text_IO.Editing}.  See F.3.3(16).
14355 @end cartouche
14356 @noindent
14359 @sp 1
14360 @item
14361 @cartouche
14362 @noindent
14363 The value of @code{Max_Picture_Length} in the package
14364 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
14365 @end cartouche
14366 @noindent
14369 @sp 1
14370 @item
14371 @cartouche
14372 @noindent
14373 The accuracy actually achieved by the complex elementary
14374 functions and by other complex arithmetic operations.  See G.1(1).
14375 @end cartouche
14376 @noindent
14377 Standard library functions are used for the complex arithmetic
14378 operations.  Only fast math mode is currently supported.
14380 @sp 1
14381 @item
14382 @cartouche
14383 @noindent
14384 The sign of a zero result (or a component thereof) from
14385 any operator or function in @code{Numerics.Generic_Complex_Types}, when
14386 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
14387 @end cartouche
14388 @noindent
14389 The signs of zero values are as recommended by the relevant
14390 implementation advice.
14392 @sp 1
14393 @item
14394 @cartouche
14395 @noindent
14396 The sign of a zero result (or a component thereof) from
14397 any operator or function in
14398 @code{Numerics.Generic_Complex_Elementary_Functions}, when
14399 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
14400 @end cartouche
14401 @noindent
14402 The signs of zero values are as recommended by the relevant
14403 implementation advice.
14405 @sp 1
14406 @item
14407 @cartouche
14408 @noindent
14409 Whether the strict mode or the relaxed mode is the
14410 default.  See G.2(2).
14411 @end cartouche
14412 @noindent
14413 The strict mode is the default.  There is no separate relaxed mode.  GNAT
14414 provides a highly efficient implementation of strict mode.
14416 @sp 1
14417 @item
14418 @cartouche
14419 @noindent
14420 The result interval in certain cases of fixed-to-float
14421 conversion.  See G.2.1(10).
14422 @end cartouche
14423 @noindent
14424 For cases where the result interval is implementation dependent, the
14425 accuracy is that provided by performing all operations in 64-bit IEEE
14426 floating-point format.
14428 @sp 1
14429 @item
14430 @cartouche
14431 @noindent
14432 The result of a floating point arithmetic operation in
14433 overflow situations, when the @code{Machine_Overflows} attribute of the
14434 result type is @code{False}.  See G.2.1(13).
14435 @end cartouche
14436 @noindent
14437 Infinite and NaN values are produced as dictated by the IEEE
14438 floating-point standard.
14440 Note that on machines that are not fully compliant with the IEEE
14441 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
14442 must be used for achieving IEEE conforming behavior (although at the cost
14443 of a significant performance penalty), so infinite and NaN values are
14444 properly generated.
14446 @sp 1
14447 @item
14448 @cartouche
14449 @noindent
14450 The result interval for division (or exponentiation by a
14451 negative exponent), when the floating point hardware implements division
14452 as multiplication by a reciprocal.  See G.2.1(16).
14453 @end cartouche
14454 @noindent
14455 Not relevant, division is IEEE exact.
14457 @sp 1
14458 @item
14459 @cartouche
14460 @noindent
14461 The definition of close result set, which determines the
14462 accuracy of certain fixed point multiplications and divisions.  See
14463 G.2.3(5).
14464 @end cartouche
14465 @noindent
14466 Operations in the close result set are performed using IEEE long format
14467 floating-point arithmetic.  The input operands are converted to
14468 floating-point, the operation is done in floating-point, and the result
14469 is converted to the target type.
14471 @sp 1
14472 @item
14473 @cartouche
14474 @noindent
14475 Conditions on a @code{universal_real} operand of a fixed
14476 point multiplication or division for which the result shall be in the
14477 perfect result set.  See G.2.3(22).
14478 @end cartouche
14479 @noindent
14480 The result is only defined to be in the perfect result set if the result
14481 can be computed by a single scaling operation involving a scale factor
14482 representable in 64-bits.
14484 @sp 1
14485 @item
14486 @cartouche
14487 @noindent
14488 The result of a fixed point arithmetic operation in
14489 overflow situations, when the @code{Machine_Overflows} attribute of the
14490 result type is @code{False}.  See G.2.3(27).
14491 @end cartouche
14492 @noindent
14493 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
14494 types.
14496 @sp 1
14497 @item
14498 @cartouche
14499 @noindent
14500 The result of an elementary function reference in
14501 overflow situations, when the @code{Machine_Overflows} attribute of the
14502 result type is @code{False}.  See G.2.4(4).
14503 @end cartouche
14504 @noindent
14505 IEEE infinite and Nan values are produced as appropriate.
14507 @sp 1
14508 @item
14509 @cartouche
14510 @noindent
14511 The value of the angle threshold, within which certain
14512 elementary functions, complex arithmetic operations, and complex
14513 elementary functions yield results conforming to a maximum relative
14514 error bound.  See G.2.4(10).
14515 @end cartouche
14516 @noindent
14517 Information on this subject is not yet available.
14519 @sp 1
14520 @item
14521 @cartouche
14522 @noindent
14523 The accuracy of certain elementary functions for
14524 parameters beyond the angle threshold.  See G.2.4(10).
14525 @end cartouche
14526 @noindent
14527 Information on this subject is not yet available.
14529 @sp 1
14530 @item
14531 @cartouche
14532 @noindent
14533 The result of a complex arithmetic operation or complex
14534 elementary function reference in overflow situations, when the
14535 @code{Machine_Overflows} attribute of the corresponding real type is
14536 @code{False}.  See G.2.6(5).
14537 @end cartouche
14538 @noindent
14539 IEEE infinite and Nan values are produced as appropriate.
14541 @sp 1
14542 @item
14543 @cartouche
14544 @noindent
14545 The accuracy of certain complex arithmetic operations and
14546 certain complex elementary functions for parameters (or components
14547 thereof) beyond the angle threshold.  See G.2.6(8).
14548 @end cartouche
14549 @noindent
14550 Information on those subjects is not yet available.
14552 @sp 1
14553 @item
14554 @cartouche
14555 @noindent
14556 Information regarding bounded errors and erroneous
14557 execution.  See H.2(1).
14558 @end cartouche
14559 @noindent
14560 Information on this subject is not yet available.
14562 @sp 1
14563 @item
14564 @cartouche
14565 @noindent
14566 Implementation-defined aspects of pragma
14567 @code{Inspection_Point}.  See H.3.2(8).
14568 @end cartouche
14569 @noindent
14570 Pragma @code{Inspection_Point} ensures that the variable is live and can
14571 be examined by the debugger at the inspection point.
14573 @sp 1
14574 @item
14575 @cartouche
14576 @noindent
14577 Implementation-defined aspects of pragma
14578 @code{Restrictions}.  See H.4(25).
14579 @end cartouche
14580 @noindent
14581 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
14582 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
14583 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
14585 @sp 1
14586 @item
14587 @cartouche
14588 @noindent
14589 Any restrictions on pragma @code{Restrictions}.  See
14590 H.4(27).
14591 @end cartouche
14592 @noindent
14593 There are no restrictions on pragma @code{Restrictions}.
14595 @end itemize
14598 @c =======================
14599 @node Intrinsic Subprograms
14600 @chapter Intrinsic Subprograms
14601 @cindex Intrinsic Subprograms
14603 @menu
14604 * Intrinsic Operators::
14605 * Compilation_Date::
14606 * Compilation_Time::
14607 * Enclosing_Entity::
14608 * Exception_Information::
14609 * Exception_Message::
14610 * Exception_Name::
14611 * File::
14612 * Line::
14613 * Shifts and Rotates::
14614 * Source_Location::
14615 @end menu
14617 @noindent
14618 GNAT allows a user application program to write the declaration:
14620 @smallexample @c ada
14621    pragma Import (Intrinsic, name);
14622 @end smallexample
14624 @noindent
14625 providing that the name corresponds to one of the implemented intrinsic
14626 subprograms in GNAT, and that the parameter profile of the referenced
14627 subprogram meets the requirements.  This chapter describes the set of
14628 implemented intrinsic subprograms, and the requirements on parameter profiles.
14629 Note that no body is supplied; as with other uses of pragma Import, the
14630 body is supplied elsewhere (in this case by the compiler itself).  Note
14631 that any use of this feature is potentially non-portable, since the
14632 Ada standard does not require Ada compilers to implement this feature.
14634 @node Intrinsic Operators
14635 @section Intrinsic Operators
14636 @cindex Intrinsic operator
14638 @noindent
14639 All the predefined numeric operators in package Standard
14640 in @code{pragma Import (Intrinsic,..)}
14641 declarations.  In the binary operator case, the operands must have the same
14642 size.  The operand or operands must also be appropriate for
14643 the operator.  For example, for addition, the operands must
14644 both be floating-point or both be fixed-point, and the
14645 right operand for @code{"**"} must have a root type of
14646 @code{Standard.Integer'Base}.
14647 You can use an intrinsic operator declaration as in the following example:
14649 @smallexample @c ada
14650    type Int1 is new Integer;
14651    type Int2 is new Integer;
14653    function "+" (X1 : Int1; X2 : Int2) return Int1;
14654    function "+" (X1 : Int1; X2 : Int2) return Int2;
14655    pragma Import (Intrinsic, "+");
14656 @end smallexample
14658 @noindent
14659 This declaration would permit ``mixed mode'' arithmetic on items
14660 of the differing types @code{Int1} and @code{Int2}.
14661 It is also possible to specify such operators for private types, if the
14662 full views are appropriate arithmetic types.
14664 @node Compilation_Date
14665 @section Compilation_Date
14666 @cindex Compilation_Date
14667 @noindent
14668 This intrinsic subprogram is used in the implementation of the
14669 library package @code{GNAT.Source_Info}.  The only useful use of the
14670 intrinsic import in this case is the one in this unit, so an
14671 application program should simply call the function
14672 @code{GNAT.Source_Info.Compilation_Date} to obtain the date of
14673 the current compilation (in local time format MMM DD YYYY).
14675 @node Compilation_Time
14676 @section Compilation_Time
14677 @cindex Compilation_Time
14678 @noindent
14679 This intrinsic subprogram is used in the implementation of the
14680 library package @code{GNAT.Source_Info}.  The only useful use of the
14681 intrinsic import in this case is the one in this unit, so an
14682 application program should simply call the function
14683 @code{GNAT.Source_Info.Compilation_Time} to obtain the time of
14684 the current compilation (in local time format HH:MM:SS).
14686 @node Enclosing_Entity
14687 @section Enclosing_Entity
14688 @cindex Enclosing_Entity
14689 @noindent
14690 This intrinsic subprogram is used in the implementation of the
14691 library package @code{GNAT.Source_Info}.  The only useful use of the
14692 intrinsic import in this case is the one in this unit, so an
14693 application program should simply call the function
14694 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
14695 the current subprogram, package, task, entry, or protected subprogram.
14697 @node Exception_Information
14698 @section Exception_Information
14699 @cindex Exception_Information'
14700 @noindent
14701 This intrinsic subprogram is used in the implementation of the
14702 library package @code{GNAT.Current_Exception}.  The only useful
14703 use of the intrinsic import in this case is the one in this unit,
14704 so an application program should simply call the function
14705 @code{GNAT.Current_Exception.Exception_Information} to obtain
14706 the exception information associated with the current exception.
14708 @node Exception_Message
14709 @section Exception_Message
14710 @cindex Exception_Message
14711 @noindent
14712 This intrinsic subprogram is used in the implementation of the
14713 library package @code{GNAT.Current_Exception}.  The only useful
14714 use of the intrinsic import in this case is the one in this unit,
14715 so an application program should simply call the function
14716 @code{GNAT.Current_Exception.Exception_Message} to obtain
14717 the message associated with the current exception.
14719 @node Exception_Name
14720 @section Exception_Name
14721 @cindex Exception_Name
14722 @noindent
14723 This intrinsic subprogram is used in the implementation of the
14724 library package @code{GNAT.Current_Exception}.  The only useful
14725 use of the intrinsic import in this case is the one in this unit,
14726 so an application program should simply call the function
14727 @code{GNAT.Current_Exception.Exception_Name} to obtain
14728 the name of the current exception.
14730 @node File
14731 @section File
14732 @cindex File
14733 @noindent
14734 This intrinsic subprogram is used in the implementation of the
14735 library package @code{GNAT.Source_Info}.  The only useful use of the
14736 intrinsic import in this case is the one in this unit, so an
14737 application program should simply call the function
14738 @code{GNAT.Source_Info.File} to obtain the name of the current
14739 file.
14741 @node Line
14742 @section Line
14743 @cindex Line
14744 @noindent
14745 This intrinsic subprogram is used in the implementation of the
14746 library package @code{GNAT.Source_Info}.  The only useful use of the
14747 intrinsic import in this case is the one in this unit, so an
14748 application program should simply call the function
14749 @code{GNAT.Source_Info.Line} to obtain the number of the current
14750 source line.
14752 @node Shifts and Rotates
14753 @section Shifts and Rotates
14754 @cindex Shift_Left
14755 @cindex Shift_Right
14756 @cindex Shift_Right_Arithmetic
14757 @cindex Rotate_Left
14758 @cindex Rotate_Right
14759 @noindent
14760 In standard Ada, the shift and rotate functions are available only
14761 for the predefined modular types in package @code{Interfaces}.  However, in
14762 GNAT it is possible to define these functions for any integer
14763 type (signed or modular), as in this example:
14765 @smallexample @c ada
14766    function Shift_Left
14767      (Value  : T;
14768       Amount : Natural) return T;
14769 @end smallexample
14771 @noindent
14772 The function name must be one of
14773 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
14774 Rotate_Right. T must be an integer type. T'Size must be
14775 8, 16, 32 or 64 bits; if T is modular, the modulus
14776 must be 2**8, 2**16, 2**32 or 2**64.
14777 The result type must be the same as the type of @code{Value}.
14778 The shift amount must be Natural.
14779 The formal parameter names can be anything.
14781 A more convenient way of providing these shift operators is to use
14782 the Provide_Shift_Operators pragma, which provides the function declarations
14783 and corresponding pragma Import's for all five shift functions.
14785 @node Source_Location
14786 @section Source_Location
14787 @cindex Source_Location
14788 @noindent
14789 This intrinsic subprogram is used in the implementation of the
14790 library routine @code{GNAT.Source_Info}.  The only useful use of the
14791 intrinsic import in this case is the one in this unit, so an
14792 application program should simply call the function
14793 @code{GNAT.Source_Info.Source_Location} to obtain the current
14794 source file location.
14796 @node Representation Clauses and Pragmas
14797 @chapter Representation Clauses and Pragmas
14798 @cindex Representation Clauses
14800 @menu
14801 * Alignment Clauses::
14802 * Size Clauses::
14803 * Storage_Size Clauses::
14804 * Size of Variant Record Objects::
14805 * Biased Representation ::
14806 * Value_Size and Object_Size Clauses::
14807 * Component_Size Clauses::
14808 * Bit_Order Clauses::
14809 * Effect of Bit_Order on Byte Ordering::
14810 * Pragma Pack for Arrays::
14811 * Pragma Pack for Records::
14812 * Record Representation Clauses::
14813 * Handling of Records with Holes::
14814 * Enumeration Clauses::
14815 * Address Clauses::
14816 * Use of Address Clauses for Memory-Mapped I/O::
14817 * Effect of Convention on Representation::
14818 * Conventions and Anonymous Access Types::
14819 * Determining the Representations chosen by GNAT::
14820 @end menu
14822 @noindent
14823 @cindex Representation Clause
14824 @cindex Representation Pragma
14825 @cindex Pragma, representation
14826 This section describes the representation clauses accepted by GNAT, and
14827 their effect on the representation of corresponding data objects.
14829 GNAT fully implements Annex C (Systems Programming).  This means that all
14830 the implementation advice sections in chapter 13 are fully implemented.
14831 However, these sections only require a minimal level of support for
14832 representation clauses.  GNAT provides much more extensive capabilities,
14833 and this section describes the additional capabilities provided.
14835 @node Alignment Clauses
14836 @section Alignment Clauses
14837 @cindex Alignment Clause
14839 @noindent
14840 GNAT requires that all alignment clauses specify a power of 2, and all
14841 default alignments are always a power of 2.  The default alignment
14842 values are as follows:
14844 @itemize @bullet
14845 @item @emph{Primitive Types}.
14846 For primitive types, the alignment is the minimum of the actual size of
14847 objects of the type divided by @code{Storage_Unit},
14848 and the maximum alignment supported by the target.
14849 (This maximum alignment is given by the GNAT-specific attribute
14850 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
14851 @cindex @code{Maximum_Alignment} attribute
14852 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
14853 default alignment will be 8 on any target that supports alignments
14854 this large, but on some targets, the maximum alignment may be smaller
14855 than 8, in which case objects of type @code{Long_Float} will be maximally
14856 aligned.
14858 @item @emph{Arrays}.
14859 For arrays, the alignment is equal to the alignment of the component type
14860 for the normal case where no packing or component size is given.  If the
14861 array is packed, and the packing is effective (see separate section on
14862 packed arrays), then the alignment will be one for long packed arrays,
14863 or arrays whose length is not known at compile time.  For short packed
14864 arrays, which are handled internally as modular types, the alignment
14865 will be as described for primitive types, e.g.@: a packed array of length
14866 31 bits will have an object size of four bytes, and an alignment of 4.
14868 @item @emph{Records}.
14869 For the normal non-packed case, the alignment of a record is equal to
14870 the maximum alignment of any of its components.  For tagged records, this
14871 includes the implicit access type used for the tag.  If a pragma @code{Pack}
14872 is used and all components are packable (see separate section on pragma
14873 @code{Pack}), then the resulting alignment is 1, unless the layout of the
14874 record makes it profitable to increase it.
14876 A special case is when:
14877 @itemize @bullet
14878 @item
14879 the size of the record is given explicitly, or a
14880 full record representation clause is given, and
14881 @item
14882 the size of the record is 2, 4, or 8 bytes.
14883 @end itemize
14884 @noindent
14885 In this case, an alignment is chosen to match the
14886 size of the record. For example, if we have:
14888 @smallexample @c ada
14889    type Small is record
14890       A, B : Character;
14891    end record;
14892    for Small'Size use 16;
14893 @end smallexample
14895 @noindent
14896 then the default alignment of the record type @code{Small} is 2, not 1. This
14897 leads to more efficient code when the record is treated as a unit, and also
14898 allows the type to specified as @code{Atomic} on architectures requiring
14899 strict alignment.
14901 @end itemize
14903 @noindent
14904 An alignment clause may specify a larger alignment than the default value
14905 up to some maximum value dependent on the target (obtainable by using the
14906 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
14907 a smaller alignment than the default value for enumeration, integer and
14908 fixed point types, as well as for record types, for example
14910 @smallexample @c ada
14911   type V is record
14912      A : Integer;
14913   end record;
14915   for V'alignment use 1;
14916 @end smallexample
14918 @noindent
14919 @cindex Alignment, default
14920 The default alignment for the type @code{V} is 4, as a result of the
14921 Integer field in the record, but it is permissible, as shown, to
14922 override the default alignment of the record with a smaller value.
14924 @cindex Alignment, subtypes
14925 Note that according to the Ada standard, an alignment clause applies only
14926 to the first named subtype. If additional subtypes are declared, then the
14927 compiler is allowed to choose any alignment it likes, and there is no way
14928 to control this choice. Consider:
14930 @smallexample @c ada
14931    type R is range 1 .. 10_000;
14932    for R'Alignment use 1;
14933    subtype RS is R range 1 .. 1000;
14934 @end smallexample
14936 @noindent
14937 The alignment clause specifies an alignment of 1 for the first named subtype
14938 @code{R} but this does not necessarily apply to @code{RS}. When writing
14939 portable Ada code, you should avoid writing code that explicitly or
14940 implicitly relies on the alignment of such subtypes.
14942 For the GNAT compiler, if an explicit alignment clause is given, this
14943 value is also used for any subsequent subtypes. So for GNAT, in the
14944 above example, you can count on the alignment of @code{RS} being 1. But this
14945 assumption is non-portable, and other compilers may choose different
14946 alignments for the subtype @code{RS}.
14948 @node Size Clauses
14949 @section Size Clauses
14950 @cindex Size Clause
14952 @noindent
14953 The default size for a type @code{T} is obtainable through the
14954 language-defined attribute @code{T'Size} and also through the
14955 equivalent GNAT-defined attribute @code{T'Value_Size}.
14956 For objects of type @code{T}, GNAT will generally increase the type size
14957 so that the object size (obtainable through the GNAT-defined attribute
14958 @code{T'Object_Size})
14959 is a multiple of @code{T'Alignment * Storage_Unit}.
14960 For example
14962 @smallexample @c ada
14963    type Smallint is range 1 .. 6;
14965    type Rec is record
14966       Y1 : integer;
14967       Y2 : boolean;
14968    end record;
14969 @end smallexample
14971 @noindent
14972 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
14973 as specified by the RM rules,
14974 but objects of this type will have a size of 8
14975 (@code{Smallint'Object_Size} = 8),
14976 since objects by default occupy an integral number
14977 of storage units.  On some targets, notably older
14978 versions of the Digital Alpha, the size of stand
14979 alone objects of this type may be 32, reflecting
14980 the inability of the hardware to do byte load/stores.
14982 Similarly, the size of type @code{Rec} is 40 bits
14983 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
14984 the alignment is 4, so objects of this type will have
14985 their size increased to 64 bits so that it is a multiple
14986 of the alignment (in bits).  This decision is
14987 in accordance with the specific Implementation Advice in RM 13.3(43):
14989 @quotation
14990 A @code{Size} clause should be supported for an object if the specified
14991 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
14992 to a size in storage elements that is a multiple of the object's
14993 @code{Alignment} (if the @code{Alignment} is nonzero).
14994 @end quotation
14996 @noindent
14997 An explicit size clause may be used to override the default size by
14998 increasing it.  For example, if we have:
15000 @smallexample @c ada
15001    type My_Boolean is new Boolean;
15002    for My_Boolean'Size use 32;
15003 @end smallexample
15005 @noindent
15006 then values of this type will always be 32 bits long.  In the case of
15007 discrete types, the size can be increased up to 64 bits, with the effect
15008 that the entire specified field is used to hold the value, sign- or
15009 zero-extended as appropriate.  If more than 64 bits is specified, then
15010 padding space is allocated after the value, and a warning is issued that
15011 there are unused bits.
15013 Similarly the size of records and arrays may be increased, and the effect
15014 is to add padding bits after the value.  This also causes a warning message
15015 to be generated.
15017 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
15018 Size in bits, this corresponds to an object of size 256 megabytes (minus
15019 one).  This limitation is true on all targets.  The reason for this
15020 limitation is that it improves the quality of the code in many cases
15021 if it is known that a Size value can be accommodated in an object of
15022 type Integer.
15024 @node Storage_Size Clauses
15025 @section Storage_Size Clauses
15026 @cindex Storage_Size Clause
15028 @noindent
15029 For tasks, the @code{Storage_Size} clause specifies the amount of space
15030 to be allocated for the task stack.  This cannot be extended, and if the
15031 stack is exhausted, then @code{Storage_Error} will be raised (if stack
15032 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
15033 or a @code{Storage_Size} pragma in the task definition to set the
15034 appropriate required size.  A useful technique is to include in every
15035 task definition a pragma of the form:
15037 @smallexample @c ada
15038    pragma Storage_Size (Default_Stack_Size);
15039 @end smallexample
15041 @noindent
15042 Then @code{Default_Stack_Size} can be defined in a global package, and
15043 modified as required. Any tasks requiring stack sizes different from the
15044 default can have an appropriate alternative reference in the pragma.
15046 You can also use the @option{-d} binder switch to modify the default stack
15047 size.
15049 For access types, the @code{Storage_Size} clause specifies the maximum
15050 space available for allocation of objects of the type.  If this space is
15051 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
15052 In the case where the access type is declared local to a subprogram, the
15053 use of a @code{Storage_Size} clause triggers automatic use of a special
15054 predefined storage pool (@code{System.Pool_Size}) that ensures that all
15055 space for the pool is automatically reclaimed on exit from the scope in
15056 which the type is declared.
15058 A special case recognized by the compiler is the specification of a
15059 @code{Storage_Size} of zero for an access type.  This means that no
15060 items can be allocated from the pool, and this is recognized at compile
15061 time, and all the overhead normally associated with maintaining a fixed
15062 size storage pool is eliminated.  Consider the following example:
15064 @smallexample @c ada
15065    procedure p is
15066       type R is array (Natural) of Character;
15067       type P is access all R;
15068       for P'Storage_Size use 0;
15069       --  Above access type intended only for interfacing purposes
15071       y : P;
15073       procedure g (m : P);
15074       pragma Import (C, g);
15076       --  @dots{}
15078    begin
15079       --  @dots{}
15080       y := new R;
15081    end;
15082 @end smallexample
15084 @noindent
15085 As indicated in this example, these dummy storage pools are often useful in
15086 connection with interfacing where no object will ever be allocated.  If you
15087 compile the above example, you get the warning:
15089 @smallexample
15090    p.adb:16:09: warning: allocation from empty storage pool
15091    p.adb:16:09: warning: Storage_Error will be raised at run time
15092 @end smallexample
15094 @noindent
15095 Of course in practice, there will not be any explicit allocators in the
15096 case of such an access declaration.
15098 @node Size of Variant Record Objects
15099 @section Size of Variant Record Objects
15100 @cindex Size, variant record objects
15101 @cindex Variant record objects, size
15103 @noindent
15104 In the case of variant record objects, there is a question whether Size gives
15105 information about a particular variant, or the maximum size required
15106 for any variant.  Consider the following program
15108 @smallexample @c ada
15109 with Text_IO; use Text_IO;
15110 procedure q is
15111    type R1 (A : Boolean := False) is record
15112      case A is
15113        when True  => X : Character;
15114        when False => null;
15115      end case;
15116    end record;
15118    V1 : R1 (False);
15119    V2 : R1;
15121 begin
15122    Put_Line (Integer'Image (V1'Size));
15123    Put_Line (Integer'Image (V2'Size));
15124 end q;
15125 @end smallexample
15127 @noindent
15128 Here we are dealing with a variant record, where the True variant
15129 requires 16 bits, and the False variant requires 8 bits.
15130 In the above example, both V1 and V2 contain the False variant,
15131 which is only 8 bits long.  However, the result of running the
15132 program is:
15134 @smallexample
15137 @end smallexample
15139 @noindent
15140 The reason for the difference here is that the discriminant value of
15141 V1 is fixed, and will always be False.  It is not possible to assign
15142 a True variant value to V1, therefore 8 bits is sufficient.  On the
15143 other hand, in the case of V2, the initial discriminant value is
15144 False (from the default), but it is possible to assign a True
15145 variant value to V2, therefore 16 bits must be allocated for V2
15146 in the general case, even fewer bits may be needed at any particular
15147 point during the program execution.
15149 As can be seen from the output of this program, the @code{'Size}
15150 attribute applied to such an object in GNAT gives the actual allocated
15151 size of the variable, which is the largest size of any of the variants.
15152 The Ada Reference Manual is not completely clear on what choice should
15153 be made here, but the GNAT behavior seems most consistent with the
15154 language in the RM@.
15156 In some cases, it may be desirable to obtain the size of the current
15157 variant, rather than the size of the largest variant.  This can be
15158 achieved in GNAT by making use of the fact that in the case of a
15159 subprogram parameter, GNAT does indeed return the size of the current
15160 variant (because a subprogram has no way of knowing how much space
15161 is actually allocated for the actual).
15163 Consider the following modified version of the above program:
15165 @smallexample @c ada
15166 with Text_IO; use Text_IO;
15167 procedure q is
15168    type R1 (A : Boolean := False) is record
15169      case A is
15170        when True  => X : Character;
15171        when False => null;
15172      end case;
15173    end record;
15175    V2 : R1;
15177    function Size (V : R1) return Integer is
15178    begin
15179       return V'Size;
15180    end Size;
15182 begin
15183    Put_Line (Integer'Image (V2'Size));
15184    Put_Line (Integer'IMage (Size (V2)));
15185    V2 := (True, 'x');
15186    Put_Line (Integer'Image (V2'Size));
15187    Put_Line (Integer'IMage (Size (V2)));
15188 end q;
15189 @end smallexample
15191 @noindent
15192 The output from this program is
15194 @smallexample
15199 @end smallexample
15201 @noindent
15202 Here we see that while the @code{'Size} attribute always returns
15203 the maximum size, regardless of the current variant value, the
15204 @code{Size} function does indeed return the size of the current
15205 variant value.
15207 @node Biased Representation
15208 @section Biased Representation
15209 @cindex Size for biased representation
15210 @cindex Biased representation
15212 @noindent
15213 In the case of scalars with a range starting at other than zero, it is
15214 possible in some cases to specify a size smaller than the default minimum
15215 value, and in such cases, GNAT uses an unsigned biased representation,
15216 in which zero is used to represent the lower bound, and successive values
15217 represent successive values of the type.
15219 For example, suppose we have the declaration:
15221 @smallexample @c ada
15222    type Small is range -7 .. -4;
15223    for Small'Size use 2;
15224 @end smallexample
15226 @noindent
15227 Although the default size of type @code{Small} is 4, the @code{Size}
15228 clause is accepted by GNAT and results in the following representation
15229 scheme:
15231 @smallexample
15232   -7 is represented as 2#00#
15233   -6 is represented as 2#01#
15234   -5 is represented as 2#10#
15235   -4 is represented as 2#11#
15236 @end smallexample
15238 @noindent
15239 Biased representation is only used if the specified @code{Size} clause
15240 cannot be accepted in any other manner.  These reduced sizes that force
15241 biased representation can be used for all discrete types except for
15242 enumeration types for which a representation clause is given.
15244 @node Value_Size and Object_Size Clauses
15245 @section Value_Size and Object_Size Clauses
15246 @findex Value_Size
15247 @findex Object_Size
15248 @cindex Size, of objects
15250 @noindent
15251 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
15252 number of bits required to hold values of type @code{T}.
15253 Although this interpretation was allowed in Ada 83, it was not required,
15254 and this requirement in practice can cause some significant difficulties.
15255 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
15256 However, in Ada 95 and Ada 2005,
15257 @code{Natural'Size} is
15258 typically 31.  This means that code may change in behavior when moving
15259 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
15261 @smallexample @c ada
15262    type Rec is record;
15263       A : Natural;
15264       B : Natural;
15265    end record;
15267    for Rec use record
15268       at 0  range 0 .. Natural'Size - 1;
15269       at 0  range Natural'Size .. 2 * Natural'Size - 1;
15270    end record;
15271 @end smallexample
15273 @noindent
15274 In the above code, since the typical size of @code{Natural} objects
15275 is 32 bits and @code{Natural'Size} is 31, the above code can cause
15276 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
15277 there are cases where the fact that the object size can exceed the
15278 size of the type causes surprises.
15280 To help get around this problem GNAT provides two implementation
15281 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
15282 applied to a type, these attributes yield the size of the type
15283 (corresponding to the RM defined size attribute), and the size of
15284 objects of the type respectively.
15286 The @code{Object_Size} is used for determining the default size of
15287 objects and components.  This size value can be referred to using the
15288 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
15289 the basis of the determination of the size.  The backend is free to
15290 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
15291 character might be stored in 32 bits on a machine with no efficient
15292 byte access instructions such as the Alpha.
15294 The default rules for the value of @code{Object_Size} for
15295 discrete types are as follows:
15297 @itemize @bullet
15298 @item
15299 The @code{Object_Size} for base subtypes reflect the natural hardware
15300 size in bits (run the compiler with @option{-gnatS} to find those values
15301 for numeric types). Enumeration types and fixed-point base subtypes have
15302 8, 16, 32 or 64 bits for this size, depending on the range of values
15303 to be stored.
15305 @item
15306 The @code{Object_Size} of a subtype is the same as the
15307 @code{Object_Size} of
15308 the type from which it is obtained.
15310 @item
15311 The @code{Object_Size} of a derived base type is copied from the parent
15312 base type, and the @code{Object_Size} of a derived first subtype is copied
15313 from the parent first subtype.
15314 @end itemize
15316 @noindent
15317 The @code{Value_Size} attribute
15318 is the (minimum) number of bits required to store a value
15319 of the type.
15320 This value is used to determine how tightly to pack
15321 records or arrays with components of this type, and also affects
15322 the semantics of unchecked conversion (unchecked conversions where
15323 the @code{Value_Size} values differ generate a warning, and are potentially
15324 target dependent).
15326 The default rules for the value of @code{Value_Size} are as follows:
15328 @itemize @bullet
15329 @item
15330 The @code{Value_Size} for a base subtype is the minimum number of bits
15331 required to store all values of the type (including the sign bit
15332 only if negative values are possible).
15334 @item
15335 If a subtype statically matches the first subtype of a given type, then it has
15336 by default the same @code{Value_Size} as the first subtype.  This is a
15337 consequence of RM 13.1(14) (``if two subtypes statically match,
15338 then their subtype-specific aspects are the same''.)
15340 @item
15341 All other subtypes have a @code{Value_Size} corresponding to the minimum
15342 number of bits required to store all values of the subtype.  For
15343 dynamic bounds, it is assumed that the value can range down or up
15344 to the corresponding bound of the ancestor
15345 @end itemize
15347 @noindent
15348 The RM defined attribute @code{Size} corresponds to the
15349 @code{Value_Size} attribute.
15351 The @code{Size} attribute may be defined for a first-named subtype.  This sets
15352 the @code{Value_Size} of
15353 the first-named subtype to the given value, and the
15354 @code{Object_Size} of this first-named subtype to the given value padded up
15355 to an appropriate boundary.  It is a consequence of the default rules
15356 above that this @code{Object_Size} will apply to all further subtypes.  On the
15357 other hand, @code{Value_Size} is affected only for the first subtype, any
15358 dynamic subtypes obtained from it directly, and any statically matching
15359 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
15361 @code{Value_Size} and
15362 @code{Object_Size} may be explicitly set for any subtype using
15363 an attribute definition clause.  Note that the use of these attributes
15364 can cause the RM 13.1(14) rule to be violated.  If two access types
15365 reference aliased objects whose subtypes have differing @code{Object_Size}
15366 values as a result of explicit attribute definition clauses, then it
15367 is illegal to convert from one access subtype to the other. For a more
15368 complete description of this additional legality rule, see the
15369 description of the @code{Object_Size} attribute.
15371 At the implementation level, Esize stores the Object_Size and the
15372 RM_Size field stores the @code{Value_Size} (and hence the value of the
15373 @code{Size} attribute,
15374 which, as noted above, is equivalent to @code{Value_Size}).
15376 To get a feel for the difference, consider the following examples (note
15377 that in each case the base is @code{Short_Short_Integer} with a size of 8):
15379 @smallexample
15380                                        Object_Size     Value_Size
15382 type x1 is range 0 .. 5;                    8               3
15384 type x2 is range 0 .. 5;
15385 for x2'size use 12;                        16              12
15387 subtype x3 is x2 range 0 .. 3;             16               2
15389 subtype x4 is x2'base range 0 .. 10;        8               4
15391 subtype x5 is x2 range 0 .. dynamic;       16               3*
15393 subtype x6 is x2'base range 0 .. dynamic;   8               3*
15395 @end smallexample
15397 @noindent
15398 Note: the entries marked ``3*'' are not actually specified by the Ada
15399 Reference Manual, but it seems in the spirit of the RM rules to allocate
15400 the minimum number of bits (here 3, given the range for @code{x2})
15401 known to be large enough to hold the given range of values.
15403 So far, so good, but GNAT has to obey the RM rules, so the question is
15404 under what conditions must the RM @code{Size} be used.
15405 The following is a list
15406 of the occasions on which the RM @code{Size} must be used:
15408 @itemize @bullet
15409 @item
15410 Component size for packed arrays or records
15412 @item
15413 Value of the attribute @code{Size} for a type
15415 @item
15416 Warning about sizes not matching for unchecked conversion
15417 @end itemize
15419 @noindent
15420 For record types, the @code{Object_Size} is always a multiple of the
15421 alignment of the type (this is true for all types). In some cases the
15422 @code{Value_Size} can be smaller. Consider:
15424 @smallexample
15425    type R is record
15426      X : Integer;
15427      Y : Character;
15428    end record;
15429 @end smallexample
15431 @noindent
15432 On a typical 32-bit architecture, the X component will be four bytes, and
15433 require four-byte alignment, and the Y component will be one byte. In this
15434 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
15435 required to store a value of this type, and for example, it is permissible
15436 to have a component of type R in an outer array whose component size is
15437 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
15438 since it must be rounded up so that this value is a multiple of the
15439 alignment (4 bytes = 32 bits).
15441 @noindent
15442 For all other types, the @code{Object_Size}
15443 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
15444 Only @code{Size} may be specified for such types.
15446 Note that @code{Value_Size} can be used to force biased representation
15447 for a particular subtype. Consider this example:
15449 @smallexample
15450    type R is (A, B, C, D, E, F);
15451    subtype RAB is R range A .. B;
15452    subtype REF is R range E .. F;
15453 @end smallexample
15455 @noindent
15456 By default, @code{RAB}
15457 has a size of 1 (sufficient to accommodate the representation
15458 of @code{A} and @code{B}, 0 and 1), and @code{REF}
15459 has a size of 3 (sufficient to accommodate the representation
15460 of @code{E} and @code{F}, 4 and 5). But if we add the
15461 following @code{Value_Size} attribute definition clause:
15463 @smallexample
15464    for REF'Value_Size use 1;
15465 @end smallexample
15467 @noindent
15468 then biased representation is forced for @code{REF},
15469 and 0 will represent @code{E} and 1 will represent @code{F}.
15470 A warning is issued when a @code{Value_Size} attribute
15471 definition clause forces biased representation. This
15472 warning can be turned off using @code{-gnatw.B}.
15474 @node Component_Size Clauses
15475 @section Component_Size Clauses
15476 @cindex Component_Size Clause
15478 @noindent
15479 Normally, the value specified in a component size clause must be consistent
15480 with the subtype of the array component with regard to size and alignment.
15481 In other words, the value specified must be at least equal to the size
15482 of this subtype, and must be a multiple of the alignment value.
15484 In addition, component size clauses are allowed which cause the array
15485 to be packed, by specifying a smaller value.  A first case is for
15486 component size values in the range 1 through 63.  The value specified
15487 must not be smaller than the Size of the subtype.  GNAT will accurately
15488 honor all packing requests in this range.  For example, if we have:
15490 @smallexample @c ada
15491 type r is array (1 .. 8) of Natural;
15492 for r'Component_Size use 31;
15493 @end smallexample
15495 @noindent
15496 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
15497 Of course access to the components of such an array is considerably
15498 less efficient than if the natural component size of 32 is used.
15499 A second case is when the subtype of the component is a record type
15500 padded because of its default alignment.  For example, if we have:
15502 @smallexample @c ada
15503 type r is record
15504   i : Integer;
15505   j : Integer;
15506   b : Boolean;
15507 end record;
15509 type a is array (1 .. 8) of r;
15510 for a'Component_Size use 72;
15511 @end smallexample
15513 @noindent
15514 then the resulting array has a length of 72 bytes, instead of 96 bytes
15515 if the alignment of the record (4) was obeyed.
15517 Note that there is no point in giving both a component size clause
15518 and a pragma Pack for the same array type. if such duplicate
15519 clauses are given, the pragma Pack will be ignored.
15521 @node Bit_Order Clauses
15522 @section Bit_Order Clauses
15523 @cindex Bit_Order Clause
15524 @cindex bit ordering
15525 @cindex ordering, of bits
15527 @noindent
15528 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
15529 attribute.  The specification may either correspond to the default bit
15530 order for the target, in which case the specification has no effect and
15531 places no additional restrictions, or it may be for the non-standard
15532 setting (that is the opposite of the default).
15534 In the case where the non-standard value is specified, the effect is
15535 to renumber bits within each byte, but the ordering of bytes is not
15536 affected.  There are certain
15537 restrictions placed on component clauses as follows:
15539 @itemize @bullet
15541 @item Components fitting within a single storage unit.
15542 @noindent
15543 These are unrestricted, and the effect is merely to renumber bits.  For
15544 example if we are on a little-endian machine with @code{Low_Order_First}
15545 being the default, then the following two declarations have exactly
15546 the same effect:
15548 @smallexample @c ada
15549    type R1 is record
15550       A : Boolean;
15551       B : Integer range 1 .. 120;
15552    end record;
15554    for R1 use record
15555       A at 0 range 0 .. 0;
15556       B at 0 range 1 .. 7;
15557    end record;
15559    type R2 is record
15560       A : Boolean;
15561       B : Integer range 1 .. 120;
15562    end record;
15564    for R2'Bit_Order use High_Order_First;
15566    for R2 use record
15567       A at 0 range 7 .. 7;
15568       B at 0 range 0 .. 6;
15569    end record;
15570 @end smallexample
15572 @noindent
15573 The useful application here is to write the second declaration with the
15574 @code{Bit_Order} attribute definition clause, and know that it will be treated
15575 the same, regardless of whether the target is little-endian or big-endian.
15577 @item Components occupying an integral number of bytes.
15578 @noindent
15579 These are components that exactly fit in two or more bytes.  Such component
15580 declarations are allowed, but have no effect, since it is important to realize
15581 that the @code{Bit_Order} specification does not affect the ordering of bytes.
15582 In particular, the following attempt at getting an endian-independent integer
15583 does not work:
15585 @smallexample @c ada
15586    type R2 is record
15587       A : Integer;
15588    end record;
15590    for R2'Bit_Order use High_Order_First;
15592    for R2 use record
15593       A at 0 range 0 .. 31;
15594    end record;
15595 @end smallexample
15597 @noindent
15598 This declaration will result in a little-endian integer on a
15599 little-endian machine, and a big-endian integer on a big-endian machine.
15600 If byte flipping is required for interoperability between big- and
15601 little-endian machines, this must be explicitly programmed.  This capability
15602 is not provided by @code{Bit_Order}.
15604 @item Components that are positioned across byte boundaries
15605 @noindent
15606 but do not occupy an integral number of bytes.  Given that bytes are not
15607 reordered, such fields would occupy a non-contiguous sequence of bits
15608 in memory, requiring non-trivial code to reassemble.  They are for this
15609 reason not permitted, and any component clause specifying such a layout
15610 will be flagged as illegal by GNAT@.
15612 @end itemize
15614 @noindent
15615 Since the misconception that Bit_Order automatically deals with all
15616 endian-related incompatibilities is a common one, the specification of
15617 a component field that is an integral number of bytes will always
15618 generate a warning.  This warning may be suppressed using @code{pragma
15619 Warnings (Off)} if desired.  The following section contains additional
15620 details regarding the issue of byte ordering.
15622 @node Effect of Bit_Order on Byte Ordering
15623 @section Effect of Bit_Order on Byte Ordering
15624 @cindex byte ordering
15625 @cindex ordering, of bytes
15627 @noindent
15628 In this section we will review the effect of the @code{Bit_Order} attribute
15629 definition clause on byte ordering.  Briefly, it has no effect at all, but
15630 a detailed example will be helpful.  Before giving this
15631 example, let us review the precise
15632 definition of the effect of defining @code{Bit_Order}.  The effect of a
15633 non-standard bit order is described in section 15.5.3 of the Ada
15634 Reference Manual:
15636 @quotation
15637 2   A bit ordering is a method of interpreting the meaning of
15638 the storage place attributes.
15639 @end quotation
15641 @noindent
15642 To understand the precise definition of storage place attributes in
15643 this context, we visit section 13.5.1 of the manual:
15645 @quotation
15646 13   A record_representation_clause (without the mod_clause)
15647 specifies the layout.  The storage place attributes (see 13.5.2)
15648 are taken from the values of the position, first_bit, and last_bit
15649 expressions after normalizing those values so that first_bit is
15650 less than Storage_Unit.
15651 @end quotation
15653 @noindent
15654 The critical point here is that storage places are taken from
15655 the values after normalization, not before.  So the @code{Bit_Order}
15656 interpretation applies to normalized values.  The interpretation
15657 is described in the later part of the 15.5.3 paragraph:
15659 @quotation
15660 2   A bit ordering is a method of interpreting the meaning of
15661 the storage place attributes.  High_Order_First (known in the
15662 vernacular as ``big endian'') means that the first bit of a
15663 storage element (bit 0) is the most significant bit (interpreting
15664 the sequence of bits that represent a component as an unsigned
15665 integer value).  Low_Order_First (known in the vernacular as
15666 ``little endian'') means the opposite: the first bit is the
15667 least significant.
15668 @end quotation
15670 @noindent
15671 Note that the numbering is with respect to the bits of a storage
15672 unit.  In other words, the specification affects only the numbering
15673 of bits within a single storage unit.
15675 We can make the effect clearer by giving an example.
15677 Suppose that we have an external device which presents two bytes, the first
15678 byte presented, which is the first (low addressed byte) of the two byte
15679 record is called Master, and the second byte is called Slave.
15681 The left most (most significant bit is called Control for each byte, and
15682 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
15683 (least significant) bit.
15685 On a big-endian machine, we can write the following representation clause
15687 @smallexample @c ada
15688    type Data is record
15689       Master_Control : Bit;
15690       Master_V1      : Bit;
15691       Master_V2      : Bit;
15692       Master_V3      : Bit;
15693       Master_V4      : Bit;
15694       Master_V5      : Bit;
15695       Master_V6      : Bit;
15696       Master_V7      : Bit;
15697       Slave_Control  : Bit;
15698       Slave_V1       : Bit;
15699       Slave_V2       : Bit;
15700       Slave_V3       : Bit;
15701       Slave_V4       : Bit;
15702       Slave_V5       : Bit;
15703       Slave_V6       : Bit;
15704       Slave_V7       : Bit;
15705    end record;
15707    for Data use record
15708       Master_Control at 0 range 0 .. 0;
15709       Master_V1      at 0 range 1 .. 1;
15710       Master_V2      at 0 range 2 .. 2;
15711       Master_V3      at 0 range 3 .. 3;
15712       Master_V4      at 0 range 4 .. 4;
15713       Master_V5      at 0 range 5 .. 5;
15714       Master_V6      at 0 range 6 .. 6;
15715       Master_V7      at 0 range 7 .. 7;
15716       Slave_Control  at 1 range 0 .. 0;
15717       Slave_V1       at 1 range 1 .. 1;
15718       Slave_V2       at 1 range 2 .. 2;
15719       Slave_V3       at 1 range 3 .. 3;
15720       Slave_V4       at 1 range 4 .. 4;
15721       Slave_V5       at 1 range 5 .. 5;
15722       Slave_V6       at 1 range 6 .. 6;
15723       Slave_V7       at 1 range 7 .. 7;
15724    end record;
15725 @end smallexample
15727 @noindent
15728 Now if we move this to a little endian machine, then the bit ordering within
15729 the byte is backwards, so we have to rewrite the record rep clause as:
15731 @smallexample @c ada
15732    for Data use record
15733       Master_Control at 0 range 7 .. 7;
15734       Master_V1      at 0 range 6 .. 6;
15735       Master_V2      at 0 range 5 .. 5;
15736       Master_V3      at 0 range 4 .. 4;
15737       Master_V4      at 0 range 3 .. 3;
15738       Master_V5      at 0 range 2 .. 2;
15739       Master_V6      at 0 range 1 .. 1;
15740       Master_V7      at 0 range 0 .. 0;
15741       Slave_Control  at 1 range 7 .. 7;
15742       Slave_V1       at 1 range 6 .. 6;
15743       Slave_V2       at 1 range 5 .. 5;
15744       Slave_V3       at 1 range 4 .. 4;
15745       Slave_V4       at 1 range 3 .. 3;
15746       Slave_V5       at 1 range 2 .. 2;
15747       Slave_V6       at 1 range 1 .. 1;
15748       Slave_V7       at 1 range 0 .. 0;
15749    end record;
15750 @end smallexample
15752 @noindent
15753 It is a nuisance to have to rewrite the clause, especially if
15754 the code has to be maintained on both machines.  However,
15755 this is a case that we can handle with the
15756 @code{Bit_Order} attribute if it is implemented.
15757 Note that the implementation is not required on byte addressed
15758 machines, but it is indeed implemented in GNAT.
15759 This means that we can simply use the
15760 first record clause, together with the declaration
15762 @smallexample @c ada
15763    for Data'Bit_Order use High_Order_First;
15764 @end smallexample
15766 @noindent
15767 and the effect is what is desired, namely the layout is exactly the same,
15768 independent of whether the code is compiled on a big-endian or little-endian
15769 machine.
15771 The important point to understand is that byte ordering is not affected.
15772 A @code{Bit_Order} attribute definition never affects which byte a field
15773 ends up in, only where it ends up in that byte.
15774 To make this clear, let us rewrite the record rep clause of the previous
15775 example as:
15777 @smallexample @c ada
15778    for Data'Bit_Order use High_Order_First;
15779    for Data use record
15780       Master_Control at 0 range  0 .. 0;
15781       Master_V1      at 0 range  1 .. 1;
15782       Master_V2      at 0 range  2 .. 2;
15783       Master_V3      at 0 range  3 .. 3;
15784       Master_V4      at 0 range  4 .. 4;
15785       Master_V5      at 0 range  5 .. 5;
15786       Master_V6      at 0 range  6 .. 6;
15787       Master_V7      at 0 range  7 .. 7;
15788       Slave_Control  at 0 range  8 .. 8;
15789       Slave_V1       at 0 range  9 .. 9;
15790       Slave_V2       at 0 range 10 .. 10;
15791       Slave_V3       at 0 range 11 .. 11;
15792       Slave_V4       at 0 range 12 .. 12;
15793       Slave_V5       at 0 range 13 .. 13;
15794       Slave_V6       at 0 range 14 .. 14;
15795       Slave_V7       at 0 range 15 .. 15;
15796    end record;
15797 @end smallexample
15799 @noindent
15800 This is exactly equivalent to saying (a repeat of the first example):
15802 @smallexample @c ada
15803    for Data'Bit_Order use High_Order_First;
15804    for Data use record
15805       Master_Control at 0 range 0 .. 0;
15806       Master_V1      at 0 range 1 .. 1;
15807       Master_V2      at 0 range 2 .. 2;
15808       Master_V3      at 0 range 3 .. 3;
15809       Master_V4      at 0 range 4 .. 4;
15810       Master_V5      at 0 range 5 .. 5;
15811       Master_V6      at 0 range 6 .. 6;
15812       Master_V7      at 0 range 7 .. 7;
15813       Slave_Control  at 1 range 0 .. 0;
15814       Slave_V1       at 1 range 1 .. 1;
15815       Slave_V2       at 1 range 2 .. 2;
15816       Slave_V3       at 1 range 3 .. 3;
15817       Slave_V4       at 1 range 4 .. 4;
15818       Slave_V5       at 1 range 5 .. 5;
15819       Slave_V6       at 1 range 6 .. 6;
15820       Slave_V7       at 1 range 7 .. 7;
15821    end record;
15822 @end smallexample
15824 @noindent
15825 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
15826 field.  The storage place attributes are obtained by normalizing the
15827 values given so that the @code{First_Bit} value is less than 8.  After
15828 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
15829 we specified in the other case.
15831 Now one might expect that the @code{Bit_Order} attribute might affect
15832 bit numbering within the entire record component (two bytes in this
15833 case, thus affecting which byte fields end up in), but that is not
15834 the way this feature is defined, it only affects numbering of bits,
15835 not which byte they end up in.
15837 Consequently it never makes sense to specify a starting bit number
15838 greater than 7 (for a byte addressable field) if an attribute
15839 definition for @code{Bit_Order} has been given, and indeed it
15840 may be actively confusing to specify such a value, so the compiler
15841 generates a warning for such usage.
15843 If you do need to control byte ordering then appropriate conditional
15844 values must be used.  If in our example, the slave byte came first on
15845 some machines we might write:
15847 @smallexample @c ada
15848    Master_Byte_First constant Boolean := @dots{};
15850    Master_Byte : constant Natural :=
15851                    1 - Boolean'Pos (Master_Byte_First);
15852    Slave_Byte  : constant Natural :=
15853                    Boolean'Pos (Master_Byte_First);
15855    for Data'Bit_Order use High_Order_First;
15856    for Data use record
15857       Master_Control at Master_Byte range 0 .. 0;
15858       Master_V1      at Master_Byte range 1 .. 1;
15859       Master_V2      at Master_Byte range 2 .. 2;
15860       Master_V3      at Master_Byte range 3 .. 3;
15861       Master_V4      at Master_Byte range 4 .. 4;
15862       Master_V5      at Master_Byte range 5 .. 5;
15863       Master_V6      at Master_Byte range 6 .. 6;
15864       Master_V7      at Master_Byte range 7 .. 7;
15865       Slave_Control  at Slave_Byte  range 0 .. 0;
15866       Slave_V1       at Slave_Byte  range 1 .. 1;
15867       Slave_V2       at Slave_Byte  range 2 .. 2;
15868       Slave_V3       at Slave_Byte  range 3 .. 3;
15869       Slave_V4       at Slave_Byte  range 4 .. 4;
15870       Slave_V5       at Slave_Byte  range 5 .. 5;
15871       Slave_V6       at Slave_Byte  range 6 .. 6;
15872       Slave_V7       at Slave_Byte  range 7 .. 7;
15873    end record;
15874 @end smallexample
15876 @noindent
15877 Now to switch between machines, all that is necessary is
15878 to set the boolean constant @code{Master_Byte_First} in
15879 an appropriate manner.
15881 @node Pragma Pack for Arrays
15882 @section Pragma Pack for Arrays
15883 @cindex Pragma Pack (for arrays)
15885 @noindent
15886 Pragma @code{Pack} applied to an array has no effect unless the component type
15887 is packable.  For a component type to be packable, it must be one of the
15888 following cases:
15890 @itemize @bullet
15891 @item
15892 Any scalar type
15893 @item
15894 Any type whose size is specified with a size clause
15895 @item
15896 Any packed array type with a static size
15897 @item
15898 Any record type padded because of its default alignment
15899 @end itemize
15901 @noindent
15902 For all these cases, if the component subtype size is in the range
15903 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
15904 component size were specified giving the component subtype size.
15905 For example if we have:
15907 @smallexample @c ada
15908    type r is range 0 .. 17;
15910    type ar is array (1 .. 8) of r;
15911    pragma Pack (ar);
15912 @end smallexample
15914 @noindent
15915 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
15916 and the size of the array @code{ar} will be exactly 40 bits.
15918 Note that in some cases this rather fierce approach to packing can produce
15919 unexpected effects.  For example, in Ada 95 and Ada 2005,
15920 subtype @code{Natural} typically has a size of 31, meaning that if you
15921 pack an array of @code{Natural}, you get 31-bit
15922 close packing, which saves a few bits, but results in far less efficient
15923 access.  Since many other Ada compilers will ignore such a packing request,
15924 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
15925 might not be what is intended.  You can easily remove this warning by
15926 using an explicit @code{Component_Size} setting instead, which never generates
15927 a warning, since the intention of the programmer is clear in this case.
15929 GNAT treats packed arrays in one of two ways.  If the size of the array is
15930 known at compile time and is less than 64 bits, then internally the array
15931 is represented as a single modular type, of exactly the appropriate number
15932 of bits.  If the length is greater than 63 bits, or is not known at compile
15933 time, then the packed array is represented as an array of bytes, and the
15934 length is always a multiple of 8 bits.
15936 Note that to represent a packed array as a modular type, the alignment must
15937 be suitable for the modular type involved. For example, on typical machines
15938 a 32-bit packed array will be represented by a 32-bit modular integer with
15939 an alignment of four bytes. If you explicitly override the default alignment
15940 with an alignment clause that is too small, the modular representation
15941 cannot be used. For example, consider the following set of declarations:
15943 @smallexample @c ada
15944    type R is range 1 .. 3;
15945    type S is array (1 .. 31) of R;
15946    for S'Component_Size use 2;
15947    for S'Size use 62;
15948    for S'Alignment use 1;
15949 @end smallexample
15951 @noindent
15952 If the alignment clause were not present, then a 62-bit modular
15953 representation would be chosen (typically with an alignment of 4 or 8
15954 bytes depending on the target). But the default alignment is overridden
15955 with the explicit alignment clause. This means that the modular
15956 representation cannot be used, and instead the array of bytes
15957 representation must be used, meaning that the length must be a multiple
15958 of 8. Thus the above set of declarations will result in a diagnostic
15959 rejecting the size clause and noting that the minimum size allowed is 64.
15961 @cindex Pragma Pack (for type Natural)
15962 @cindex Pragma Pack warning
15964 One special case that is worth noting occurs when the base type of the
15965 component size is 8/16/32 and the subtype is one bit less. Notably this
15966 occurs with subtype @code{Natural}. Consider:
15968 @smallexample @c ada
15969    type Arr is array (1 .. 32) of Natural;
15970    pragma Pack (Arr);
15971 @end smallexample
15973 @noindent
15974 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
15975 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
15976 Ada 83 compilers did not attempt 31 bit packing.
15978 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
15979 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
15980 substantial unintended performance penalty when porting legacy Ada 83 code.
15981 To help prevent this, GNAT generates a warning in such cases. If you really
15982 want 31 bit packing in a case like this, you can set the component size
15983 explicitly:
15985 @smallexample @c ada
15986    type Arr is array (1 .. 32) of Natural;
15987    for Arr'Component_Size use 31;
15988 @end smallexample
15990 @noindent
15991 Here 31-bit packing is achieved as required, and no warning is generated,
15992 since in this case the programmer intention is clear.
15994 @node Pragma Pack for Records
15995 @section Pragma Pack for Records
15996 @cindex Pragma Pack (for records)
15998 @noindent
15999 Pragma @code{Pack} applied to a record will pack the components to reduce
16000 wasted space from alignment gaps and by reducing the amount of space
16001 taken by components.  We distinguish between @emph{packable} components and
16002 @emph{non-packable} components.
16003 Components of the following types are considered packable:
16004 @itemize @bullet
16005 @item
16006 Components of a primitive type are packable unless they are aliased
16007 or of an atomic type.
16009 @item
16010 Small packed arrays, whose size does not exceed 64 bits, and where the
16011 size is statically known at compile time, are represented internally
16012 as modular integers, and so they are also packable.
16014 @end itemize
16016 @noindent
16017 All packable components occupy the exact number of bits corresponding to
16018 their @code{Size} value, and are packed with no padding bits, i.e.@: they
16019 can start on an arbitrary bit boundary.
16021 All other types are non-packable, they occupy an integral number of
16022 storage units, and
16023 are placed at a boundary corresponding to their alignment requirements.
16025 For example, consider the record
16027 @smallexample @c ada
16028    type Rb1 is array (1 .. 13) of Boolean;
16029    pragma Pack (Rb1);
16031    type Rb2 is array (1 .. 65) of Boolean;
16032    pragma Pack (Rb2);
16034    type AF is new Float with Atomic;
16036    type X2 is record
16037       L1 : Boolean;
16038       L2 : Duration;
16039       L3 : AF;
16040       L4 : Boolean;
16041       L5 : Rb1;
16042       L6 : Rb2;
16043    end record;
16044    pragma Pack (X2);
16045 @end smallexample
16047 @noindent
16048 The representation for the record X2 is as follows:
16050 @smallexample @c ada
16051 for X2'Size use 224;
16052 for X2 use record
16053    L1 at  0 range  0 .. 0;
16054    L2 at  0 range  1 .. 64;
16055    L3 at 12 range  0 .. 31;
16056    L4 at 16 range  0 .. 0;
16057    L5 at 16 range  1 .. 13;
16058    L6 at 18 range  0 .. 71;
16059 end record;
16060 @end smallexample
16062 @noindent
16063 Studying this example, we see that the packable fields @code{L1}
16064 and @code{L2} are
16065 of length equal to their sizes, and placed at specific bit boundaries (and
16066 not byte boundaries) to
16067 eliminate padding.  But @code{L3} is of a non-packable float type (because
16068 it is aliased), so it is on the next appropriate alignment boundary.
16070 The next two fields are fully packable, so @code{L4} and @code{L5} are
16071 minimally packed with no gaps.  However, type @code{Rb2} is a packed
16072 array that is longer than 64 bits, so it is itself non-packable.  Thus
16073 the @code{L6} field is aligned to the next byte boundary, and takes an
16074 integral number of bytes, i.e.@: 72 bits.
16076 @node Record Representation Clauses
16077 @section Record Representation Clauses
16078 @cindex Record Representation Clause
16080 @noindent
16081 Record representation clauses may be given for all record types, including
16082 types obtained by record extension.  Component clauses are allowed for any
16083 static component.  The restrictions on component clauses depend on the type
16084 of the component.
16086 @cindex Component Clause
16087 For all components of an elementary type, the only restriction on component
16088 clauses is that the size must be at least the 'Size value of the type
16089 (actually the Value_Size).  There are no restrictions due to alignment,
16090 and such components may freely cross storage boundaries.
16092 Packed arrays with a size up to and including 64 bits are represented
16093 internally using a modular type with the appropriate number of bits, and
16094 thus the same lack of restriction applies.  For example, if you declare:
16096 @smallexample @c ada
16097    type R is array (1 .. 49) of Boolean;
16098    pragma Pack (R);
16099    for R'Size use 49;
16100 @end smallexample
16102 @noindent
16103 then a component clause for a component of type R may start on any
16104 specified bit boundary, and may specify a value of 49 bits or greater.
16106 For packed bit arrays that are longer than 64 bits, there are two
16107 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
16108 including the important case of single bits or boolean values, then
16109 there are no limitations on placement of such components, and they
16110 may start and end at arbitrary bit boundaries.
16112 If the component size is not a power of 2 (e.g.@: 3 or 5), then
16113 an array of this type longer than 64 bits must always be placed on
16114 on a storage unit (byte) boundary and occupy an integral number
16115 of storage units (bytes). Any component clause that does not
16116 meet this requirement will be rejected.
16118 Any aliased component, or component of an aliased type, must
16119 have its normal alignment and size. A component clause that
16120 does not meet this requirement will be rejected.
16122 The tag field of a tagged type always occupies an address sized field at
16123 the start of the record.  No component clause may attempt to overlay this
16124 tag. When a tagged type appears as a component, the tag field must have
16125 proper alignment
16127 In the case of a record extension T1, of a type T, no component clause applied
16128 to the type T1 can specify a storage location that would overlap the first
16129 T'Size bytes of the record.
16131 For all other component types, including non-bit-packed arrays,
16132 the component can be placed at an arbitrary bit boundary,
16133 so for example, the following is permitted:
16135 @smallexample @c ada
16136    type R is array (1 .. 10) of Boolean;
16137    for R'Size use 80;
16139    type Q is record
16140       G, H : Boolean;
16141       L, M : R;
16142    end record;
16144    for Q use record
16145       G at 0 range  0 ..   0;
16146       H at 0 range  1 ..   1;
16147       L at 0 range  2 ..  81;
16148       R at 0 range 82 .. 161;
16149    end record;
16150 @end smallexample
16152 @noindent
16153 Note: the above rules apply to recent releases of GNAT 5.
16154 In GNAT 3, there are more severe restrictions on larger components.
16155 For non-primitive types, including packed arrays with a size greater than
16156 64 bits, component clauses must respect the alignment requirement of the
16157 type, in particular, always starting on a byte boundary, and the length
16158 must be a multiple of the storage unit.
16160 @node Handling of Records with Holes
16161 @section Handling of Records with Holes
16162 @cindex Handling of Records with Holes
16164 As a result of alignment considerations, records may contain "holes"
16165 or gaps
16166 which do not correspond to the data bits of any of the components.
16167 Record representation clauses can also result in holes in records.
16169 GNAT does not attempt to clear these holes, so in record objects,
16170 they should be considered to hold undefined rubbish. The generated
16171 equality routine just tests components so does not access these
16172 undefined bits, and assignment and copy operations may or may not
16173 preserve the contents of these holes (for assignments, the holes
16174 in the target will in practice contain either the bits that are
16175 present in the holes in the source, or the bits that were present
16176 in the target before the assignment).
16178 If it is necessary to ensure that holes in records have all zero
16179 bits, then record objects for which this initialization is desired
16180 should be explicitly set to all zero values using Unchecked_Conversion
16181 or address overlays. For example
16183 @smallexample @c ada
16184 type HRec is record
16185    C : Character;
16186    I : Integer;
16187 end record;
16188 @end smallexample
16190 @noindent
16191 On typical machines, integers need to be aligned on a four-byte
16192 boundary, resulting in three bytes of undefined rubbish following
16193 the 8-bit field for C. To ensure that the hole in a variable of
16194 type HRec is set to all zero bits,
16195 you could for example do:
16197 @smallexample @c ada
16198 type Base is record
16199    Dummy1, Dummy2 : Integer := 0;
16200 end record;
16202 BaseVar : Base;
16203 RealVar : Hrec;
16204 for RealVar'Address use BaseVar'Address;
16205 @end smallexample
16207 @noindent
16208 Now the 8-bytes of the value of RealVar start out containing all zero
16209 bits. A safer approach is to just define dummy fields, avoiding the
16210 holes, as in:
16212 @smallexample @c ada
16213 type HRec is record
16214    C      : Character;
16215    Dummy1 : Short_Short_Integer := 0;
16216    Dummy2 : Short_Short_Integer := 0;
16217    Dummy3 : Short_Short_Integer := 0;
16218    I      : Integer;
16219 end record;
16220 @end smallexample
16222 @noindent
16223 And to make absolutely sure that the intent of this is followed, you
16224 can use representation clauses:
16226 @smallexample @c ada
16227 for Hrec use record
16228    C      at 0 range 0 .. 7;
16229    Dummy1 at 1 range 0 .. 7;
16230    Dummy2 at 2 range 0 .. 7;
16231    Dummy3 at 3 range 0 .. 7;
16232    I      at 4 range 0 .. 31;
16233 end record;
16234 for Hrec'Size use 64;
16235 @end smallexample
16237 @node Enumeration Clauses
16238 @section Enumeration Clauses
16240 The only restriction on enumeration clauses is that the range of values
16241 must be representable.  For the signed case, if one or more of the
16242 representation values are negative, all values must be in the range:
16244 @smallexample @c ada
16245    System.Min_Int .. System.Max_Int
16246 @end smallexample
16248 @noindent
16249 For the unsigned case, where all values are nonnegative, the values must
16250 be in the range:
16252 @smallexample @c ada
16253    0 .. System.Max_Binary_Modulus;
16254 @end smallexample
16256 @noindent
16257 A @emph{confirming} representation clause is one in which the values range
16258 from 0 in sequence, i.e.@: a clause that confirms the default representation
16259 for an enumeration type.
16260 Such a confirming representation
16261 is permitted by these rules, and is specially recognized by the compiler so
16262 that no extra overhead results from the use of such a clause.
16264 If an array has an index type which is an enumeration type to which an
16265 enumeration clause has been applied, then the array is stored in a compact
16266 manner.  Consider the declarations:
16268 @smallexample @c ada
16269    type r is (A, B, C);
16270    for r use (A => 1, B => 5, C => 10);
16271    type t is array (r) of Character;
16272 @end smallexample
16274 @noindent
16275 The array type t corresponds to a vector with exactly three elements and
16276 has a default size equal to @code{3*Character'Size}.  This ensures efficient
16277 use of space, but means that accesses to elements of the array will incur
16278 the overhead of converting representation values to the corresponding
16279 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
16281 @node Address Clauses
16282 @section Address Clauses
16283 @cindex Address Clause
16285 The reference manual allows a general restriction on representation clauses,
16286 as found in RM 13.1(22):
16288 @quotation
16289 An implementation need not support representation
16290 items containing nonstatic expressions, except that
16291 an implementation should support a representation item
16292 for a given entity if each nonstatic expression in the
16293 representation item is a name that statically denotes
16294 a constant declared before the entity.
16295 @end quotation
16297 @noindent
16298 In practice this is applicable only to address clauses, since this is the
16299 only case in which a non-static expression is permitted by the syntax.  As
16300 the AARM notes in sections 13.1 (22.a-22.h):
16302 @display
16303   22.a   Reason: This is to avoid the following sort of thing:
16305   22.b        X : Integer := F(@dots{});
16306               Y : Address := G(@dots{});
16307               for X'Address use Y;
16309   22.c   In the above, we have to evaluate the
16310          initialization expression for X before we
16311          know where to put the result.  This seems
16312          like an unreasonable implementation burden.
16314   22.d   The above code should instead be written
16315          like this:
16317   22.e        Y : constant Address := G(@dots{});
16318               X : Integer := F(@dots{});
16319               for X'Address use Y;
16321   22.f   This allows the expression ``Y'' to be safely
16322          evaluated before X is created.
16324   22.g   The constant could be a formal parameter of mode in.
16326   22.h   An implementation can support other nonstatic
16327          expressions if it wants to.  Expressions of type
16328          Address are hardly ever static, but their value
16329          might be known at compile time anyway in many
16330          cases.
16331 @end display
16333 @noindent
16334 GNAT does indeed permit many additional cases of non-static expressions.  In
16335 particular, if the type involved is elementary there are no restrictions
16336 (since in this case, holding a temporary copy of the initialization value,
16337 if one is present, is inexpensive).  In addition, if there is no implicit or
16338 explicit initialization, then there are no restrictions.  GNAT will reject
16339 only the case where all three of these conditions hold:
16341 @itemize @bullet
16343 @item
16344 The type of the item is non-elementary (e.g.@: a record or array).
16346 @item
16347 There is explicit or implicit initialization required for the object.
16348 Note that access values are always implicitly initialized.
16350 @item
16351 The address value is non-static.  Here GNAT is more permissive than the
16352 RM, and allows the address value to be the address of a previously declared
16353 stand-alone variable, as long as it does not itself have an address clause.
16355 @smallexample @c ada
16356            Anchor  : Some_Initialized_Type;
16357            Overlay : Some_Initialized_Type;
16358            for Overlay'Address use Anchor'Address;
16359 @end smallexample
16361 @noindent
16362 However, the prefix of the address clause cannot be an array component, or
16363 a component of a discriminated record.
16365 @end itemize
16367 @noindent
16368 As noted above in section 22.h, address values are typically non-static.  In
16369 particular the To_Address function, even if applied to a literal value, is
16370 a non-static function call.  To avoid this minor annoyance, GNAT provides
16371 the implementation defined attribute 'To_Address.  The following two
16372 expressions have identical values:
16374 @findex Attribute
16375 @findex To_Address
16376 @smallexample @c ada
16377    To_Address (16#1234_0000#)
16378    System'To_Address (16#1234_0000#);
16379 @end smallexample
16381 @noindent
16382 except that the second form is considered to be a static expression, and
16383 thus when used as an address clause value is always permitted.
16385 @noindent
16386 Additionally, GNAT treats as static an address clause that is an
16387 unchecked_conversion of a static integer value.  This simplifies the porting
16388 of legacy code, and provides a portable equivalent to the GNAT attribute
16389 @code{To_Address}.
16391 Another issue with address clauses is the interaction with alignment
16392 requirements.  When an address clause is given for an object, the address
16393 value must be consistent with the alignment of the object (which is usually
16394 the same as the alignment of the type of the object).  If an address clause
16395 is given that specifies an inappropriately aligned address value, then the
16396 program execution is erroneous.
16398 Since this source of erroneous behavior can have unfortunate effects, GNAT
16399 checks (at compile time if possible, generating a warning, or at execution
16400 time with a run-time check) that the alignment is appropriate.  If the
16401 run-time check fails, then @code{Program_Error} is raised.  This run-time
16402 check is suppressed if range checks are suppressed, or if the special GNAT
16403 check Alignment_Check is suppressed, or if
16404 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
16406 Finally, GNAT does not permit overlaying of objects of controlled types or
16407 composite types containing a controlled component. In most cases, the compiler
16408 can detect an attempt at such overlays and will generate a warning at compile
16409 time and a Program_Error exception at run time.
16411 @findex Export
16412 An address clause cannot be given for an exported object.  More
16413 understandably the real restriction is that objects with an address
16414 clause cannot be exported.  This is because such variables are not
16415 defined by the Ada program, so there is no external object to export.
16417 @findex Import
16418 It is permissible to give an address clause and a pragma Import for the
16419 same object.  In this case, the variable is not really defined by the
16420 Ada program, so there is no external symbol to be linked.  The link name
16421 and the external name are ignored in this case.  The reason that we allow this
16422 combination is that it provides a useful idiom to avoid unwanted
16423 initializations on objects with address clauses.
16425 When an address clause is given for an object that has implicit or
16426 explicit initialization, then by default initialization takes place.  This
16427 means that the effect of the object declaration is to overwrite the
16428 memory at the specified address.  This is almost always not what the
16429 programmer wants, so GNAT will output a warning:
16431 @smallexample
16432   with System;
16433   package G is
16434      type R is record
16435         M : Integer := 0;
16436      end record;
16438      Ext : R;
16439      for Ext'Address use System'To_Address (16#1234_1234#);
16440          |
16441   >>> warning: implicit initialization of "Ext" may
16442       modify overlaid storage
16443   >>> warning: use pragma Import for "Ext" to suppress
16444       initialization (RM B(24))
16446   end G;
16447 @end smallexample
16449 @noindent
16450 As indicated by the warning message, the solution is to use a (dummy) pragma
16451 Import to suppress this initialization.  The pragma tell the compiler that the
16452 object is declared and initialized elsewhere.  The following package compiles
16453 without warnings (and the initialization is suppressed):
16455 @smallexample @c ada
16456    with System;
16457    package G is
16458       type R is record
16459          M : Integer := 0;
16460       end record;
16462       Ext : R;
16463       for Ext'Address use System'To_Address (16#1234_1234#);
16464       pragma Import (Ada, Ext);
16465    end G;
16466 @end smallexample
16468 @noindent
16469 A final issue with address clauses involves their use for overlaying
16470 variables, as in the following example:
16471 @cindex Overlaying of objects
16473 @smallexample @c ada
16474   A : Integer;
16475   B : Integer;
16476   for B'Address use A'Address;
16477 @end smallexample
16479 @noindent
16480 or alternatively, using the form recommended by the RM:
16482 @smallexample @c ada
16483   A    : Integer;
16484   Addr : constant Address := A'Address;
16485   B    : Integer;
16486   for B'Address use Addr;
16487 @end smallexample
16489 @noindent
16490 In both of these cases, @code{A}
16491 and @code{B} become aliased to one another via the
16492 address clause. This use of address clauses to overlay
16493 variables, achieving an effect similar to unchecked
16494 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
16495 the effect is implementation defined. Furthermore, the
16496 Ada RM specifically recommends that in a situation
16497 like this, @code{B} should be subject to the following
16498 implementation advice (RM 13.3(19)):
16500 @quotation
16501 19  If the Address of an object is specified, or it is imported
16502     or exported, then the implementation should not perform
16503     optimizations based on assumptions of no aliases.
16504 @end quotation
16506 @noindent
16507 GNAT follows this recommendation, and goes further by also applying
16508 this recommendation to the overlaid variable (@code{A}
16509 in the above example) in this case. This means that the overlay
16510 works "as expected", in that a modification to one of the variables
16511 will affect the value of the other.
16513 Note that when address clause overlays are used in this way, there is an
16514 issue of unintentional initialization, as shown by this example:
16516 @smallexample @c ada
16517 package Overwrite_Record is
16518    type R is record
16519       A : Character := 'C';
16520       B : Character := 'A';
16521    end record;
16522    X : Short_Integer := 3;
16523    Y : R;
16524    for Y'Address use X'Address;
16525        |
16526 >>> warning: default initialization of "Y" may
16527     modify "X", use pragma Import for "Y" to
16528     suppress initialization (RM B.1(24))
16530 end Overwrite_Record;
16531 @end smallexample
16533 @noindent
16534 Here the default initialization of @code{Y} will clobber the value
16535 of @code{X}, which justifies the warning. The warning notes that
16536 this effect can be eliminated by adding a @code{pragma Import}
16537 which suppresses the initialization:
16539 @smallexample @c ada
16540 package Overwrite_Record is
16541    type R is record
16542       A : Character := 'C';
16543       B : Character := 'A';
16544    end record;
16545    X : Short_Integer := 3;
16546    Y : R;
16547    for Y'Address use X'Address;
16548    pragma Import (Ada, Y);
16549 end Overwrite_Record;
16550 @end smallexample
16552 @noindent
16553 Note that the use of @code{pragma Initialize_Scalars} may cause variables to
16554 be initialized when they would not otherwise have been in the absence
16555 of the use of this pragma. This may cause an overlay to have this
16556 unintended clobbering effect. The compiler avoids this for scalar
16557 types, but not for composite objects (where in general the effect
16558 of @code{Initialize_Scalars} is part of the initialization routine
16559 for the composite object:
16561 @smallexample @c ada
16562 pragma Initialize_Scalars;
16563 with Ada.Text_IO;  use Ada.Text_IO;
16564 procedure Overwrite_Array is
16565    type Arr is array (1 .. 5) of Integer;
16566    X : Arr := (others => 1);
16567    A : Arr;
16568    for A'Address use X'Address;
16569        |
16570 >>> warning: default initialization of "A" may
16571     modify "X", use pragma Import for "A" to
16572     suppress initialization (RM B.1(24))
16574 begin
16575    if X /= Arr'(others => 1) then
16576       Put_Line ("X was clobbered");
16577    else
16578       Put_Line ("X was not clobbered");
16579    end if;
16580 end Overwrite_Array;
16581 @end smallexample
16583 @noindent
16584 The above program generates the warning as shown, and at execution
16585 time, prints @code{X was clobbered}. If the @code{pragma Import} is
16586 added as suggested:
16588 @smallexample @c ada
16589 pragma Initialize_Scalars;
16590 with Ada.Text_IO;  use Ada.Text_IO;
16591 procedure Overwrite_Array is
16592    type Arr is array (1 .. 5) of Integer;
16593    X : Arr := (others => 1);
16594    A : Arr;
16595    for A'Address use X'Address;
16596    pragma Import (Ada, A);
16597 begin
16598    if X /= Arr'(others => 1) then
16599       Put_Line ("X was clobbered");
16600    else
16601       Put_Line ("X was not clobbered");
16602    end if;
16603 end Overwrite_Array;
16604 @end smallexample
16606 @noindent
16607 then the program compiles without the warning and when run will generate
16608 the output @code{X was not clobbered}.
16610 @node Use of Address Clauses for Memory-Mapped I/O
16611 @section Use of Address Clauses for Memory-Mapped I/O
16612 @cindex Memory-mapped I/O
16614 A common pattern is to use an address clause to map an atomic variable to
16615 a location in memory that corresponds to a memory-mapped I/O operation or
16616 operations, for example:
16618 @smallexample @c ada
16619     type Mem_Word is record
16620        A,B,C,D : Byte;
16621     end record;
16622     pragma Atomic (Mem_Word);
16623     for Mem_Word_Size use 32;
16625     Mem : Mem_Word;
16626     for Mem'Address use some-address;
16627     ...
16628     Temp := Mem;
16629     Temp.A := 32;
16630     Mem := Temp;
16631 @end smallexample
16633 @noindent
16634 For a full access (reference or modification) of the variable (Mem) in
16635 this case, as in the above examples, GNAT guarantees that the entire atomic
16636 word will be accessed. It is not clear whether the RM requires this. For
16637 example in the above, can the compiler reference only the Mem.A field as
16638 an optimization? Whatever the answer to this question is, GNAT makes the
16639 guarantee that for such a reference, the entire word is read or written.
16641 A problem arises with a component access such as:
16643 @smallexample @c ada
16644     Mem.A := 32;
16645 @end smallexample
16647 @noindent
16648 Note that the component A is not declared as atomic. This means that it is
16649 not clear what this assignment means. It could correspond to full word read
16650 and write as given in the first example, or on architectures that supported
16651 such an operation it might be a single byte store instruction. The RM does
16652 not have anything to say in this situation, and GNAT does not make any
16653 guarantee. The code generated may vary from target to target. GNAT will issue
16654 a warning in such a case:
16656 @smallexample @c ada
16657     Mem.A := 32;
16658     |
16659     >>> warning: access to non-atomic component of atomic array,
16660         may cause unexpected accesses to atomic object
16661 @end smallexample
16663 @noindent
16664 It is best to be explicit in this situation, by either declaring the
16665 components to be atomic if you want the byte store, or explicitly writing
16666 the full word access sequence if that is what the hardware requires.
16668 @node Effect of Convention on Representation
16669 @section Effect of Convention on Representation
16670 @cindex Convention, effect on representation
16672 @noindent
16673 Normally the specification of a foreign language convention for a type or
16674 an object has no effect on the chosen representation.  In particular, the
16675 representation chosen for data in GNAT generally meets the standard system
16676 conventions, and for example records are laid out in a manner that is
16677 consistent with C@.  This means that specifying convention C (for example)
16678 has no effect.
16680 There are four exceptions to this general rule:
16682 @itemize @bullet
16684 @item Convention Fortran and array subtypes
16685 If pragma Convention Fortran is specified for an array subtype, then in
16686 accordance with the implementation advice in section 3.6.2(11) of the
16687 Ada Reference Manual, the array will be stored in a Fortran-compatible
16688 column-major manner, instead of the normal default row-major order.
16690 @item Convention C and enumeration types
16691 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
16692 to accommodate all values of the type.  For example, for the enumeration
16693 type declared by:
16695 @smallexample @c ada
16696    type Color is (Red, Green, Blue);
16697 @end smallexample
16699 @noindent
16700 8 bits is sufficient to store all values of the type, so by default, objects
16701 of type @code{Color} will be represented using 8 bits.  However, normal C
16702 convention is to use 32 bits for all enum values in C, since enum values
16703 are essentially of type int.  If pragma @code{Convention C} is specified for an
16704 Ada enumeration type, then the size is modified as necessary (usually to
16705 32 bits) to be consistent with the C convention for enum values.
16707 Note that this treatment applies only to types. If Convention C is given for
16708 an enumeration object, where the enumeration type is not Convention C, then
16709 Object_Size bits are allocated. For example, for a normal enumeration type,
16710 with less than 256 elements, only 8 bits will be allocated for the object.
16711 Since this may be a surprise in terms of what C expects, GNAT will issue a
16712 warning in this situation. The warning can be suppressed by giving an explicit
16713 size clause specifying the desired size.
16715 @item Convention C/Fortran and Boolean types
16716 In C, the usual convention for boolean values, that is values used for
16717 conditions, is that zero represents false, and nonzero values represent
16718 true.  In Ada, the normal convention is that two specific values, typically
16719 0/1, are used to represent false/true respectively.
16721 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
16722 value represents true).
16724 To accommodate the Fortran and C conventions, if a pragma Convention specifies
16725 C or Fortran convention for a derived Boolean, as in the following example:
16727 @smallexample @c ada
16728    type C_Switch is new Boolean;
16729    pragma Convention (C, C_Switch);
16730 @end smallexample
16732 @noindent
16733 then the GNAT generated code will treat any nonzero value as true.  For truth
16734 values generated by GNAT, the conventional value 1 will be used for True, but
16735 when one of these values is read, any nonzero value is treated as True.
16737 @item Access types on OpenVMS
16738 For 64-bit OpenVMS systems, access types (other than those for unconstrained
16739 arrays) are 64-bits long. An exception to this rule is for the case of
16740 C-convention access types where there is no explicit size clause present (or
16741 inherited for derived types). In this case, GNAT chooses to make these
16742 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
16743 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
16745 @end itemize
16747 @node Conventions and Anonymous Access Types
16748 @section Conventions and Anonymous Access Types
16749 @cindex Anonymous access types
16750 @cindex Convention for anonymous access types
16752 The RM is not entirely clear on convention handling in a number of cases,
16753 and in particular, it is not clear on the convention to be given to
16754 anonymous access types in general, and in particular what is to be
16755 done for the case of anonymous access-to-subprogram.
16757 In GNAT, we decide that if an explicit Convention is applied
16758 to an object or component, and its type is such an anonymous type,
16759 then the convention will apply to this anonymous type as well. This
16760 seems to make sense since it is anomolous in any case to have a
16761 different convention for an object and its type, and there is clearly
16762 no way to explicitly specify a convention for an anonymous type, since
16763 it doesn't have a name to specify!
16765 Furthermore, we decide that if a convention is applied to a record type,
16766 then this convention is inherited by any of its components that are of an
16767 anonymous access type which do not have an explicitly specified convention.
16769 The following program shows these conventions in action:
16771 @smallexample @c ada
16772 package ConvComp is
16773    type Foo is range 1 .. 10;
16774    type T1 is record
16775       A : access function (X : Foo) return Integer;
16776       B : Integer;
16777    end record;
16778    pragma Convention (C, T1);
16780    type T2 is record
16781       A : access function (X : Foo) return Integer;
16782       pragma Convention  (C, A);
16783       B : Integer;
16784    end record;
16785    pragma Convention (COBOL, T2);
16787    type T3 is record
16788       A : access function (X : Foo) return Integer;
16789       pragma Convention  (COBOL, A);
16790       B : Integer;
16791    end record;
16792    pragma Convention (C, T3);
16794    type T4 is record
16795       A : access function (X : Foo) return Integer;
16796       B : Integer;
16797    end record;
16798    pragma Convention (COBOL, T4);
16800    function F (X : Foo) return Integer;
16801    pragma Convention (C, F);
16803    function F (X : Foo) return Integer is (13);
16805    TV1 : T1 := (F'Access, 12);  -- OK
16806    TV2 : T2 := (F'Access, 13);  -- OK
16808    TV3 : T3 := (F'Access, 13);  -- ERROR
16809                 |
16810 >>> subprogram "F" has wrong convention
16811 >>> does not match access to subprogram declared at line 17
16812      38.    TV4 : T4 := (F'Access, 13);  -- ERROR
16813                 |
16814 >>> subprogram "F" has wrong convention
16815 >>> does not match access to subprogram declared at line 24
16816      39. end ConvComp;
16817 @end smallexample
16819 @node Determining the Representations chosen by GNAT
16820 @section Determining the Representations chosen by GNAT
16821 @cindex Representation, determination of
16822 @cindex @option{-gnatR} switch
16824 @noindent
16825 Although the descriptions in this section are intended to be complete, it is
16826 often easier to simply experiment to see what GNAT accepts and what the
16827 effect is on the layout of types and objects.
16829 As required by the Ada RM, if a representation clause is not accepted, then
16830 it must be rejected as illegal by the compiler.  However, when a
16831 representation clause or pragma is accepted, there can still be questions
16832 of what the compiler actually does.  For example, if a partial record
16833 representation clause specifies the location of some components and not
16834 others, then where are the non-specified components placed? Or if pragma
16835 @code{Pack} is used on a record, then exactly where are the resulting
16836 fields placed? The section on pragma @code{Pack} in this chapter can be
16837 used to answer the second question, but it is often easier to just see
16838 what the compiler does.
16840 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
16841 with this option, then the compiler will output information on the actual
16842 representations chosen, in a format similar to source representation
16843 clauses.  For example, if we compile the package:
16845 @smallexample @c ada
16846 package q is
16847    type r (x : boolean) is tagged record
16848       case x is
16849          when True => S : String (1 .. 100);
16850          when False => null;
16851       end case;
16852    end record;
16854    type r2 is new r (false) with record
16855       y2 : integer;
16856    end record;
16858    for r2 use record
16859       y2 at 16 range 0 .. 31;
16860    end record;
16862    type x is record
16863       y : character;
16864    end record;
16866    type x1 is array (1 .. 10) of x;
16867    for x1'component_size use 11;
16869    type ia is access integer;
16871    type Rb1 is array (1 .. 13) of Boolean;
16872    pragma Pack (rb1);
16874    type Rb2 is array (1 .. 65) of Boolean;
16875    pragma Pack (rb2);
16877    type x2 is record
16878       l1 : Boolean;
16879       l2 : Duration;
16880       l3 : Float;
16881       l4 : Boolean;
16882       l5 : Rb1;
16883       l6 : Rb2;
16884    end record;
16885    pragma Pack (x2);
16886 end q;
16887 @end smallexample
16889 @noindent
16890 using the switch @option{-gnatR} we obtain the following output:
16892 @smallexample
16893 Representation information for unit q
16894 -------------------------------------
16896 for r'Size use ??;
16897 for r'Alignment use 4;
16898 for r use record
16899    x    at 4 range  0 .. 7;
16900    _tag at 0 range  0 .. 31;
16901    s    at 5 range  0 .. 799;
16902 end record;
16904 for r2'Size use 160;
16905 for r2'Alignment use 4;
16906 for r2 use record
16907    x       at  4 range  0 .. 7;
16908    _tag    at  0 range  0 .. 31;
16909    _parent at  0 range  0 .. 63;
16910    y2      at 16 range  0 .. 31;
16911 end record;
16913 for x'Size use 8;
16914 for x'Alignment use 1;
16915 for x use record
16916    y at 0 range  0 .. 7;
16917 end record;
16919 for x1'Size use 112;
16920 for x1'Alignment use 1;
16921 for x1'Component_Size use 11;
16923 for rb1'Size use 13;
16924 for rb1'Alignment use 2;
16925 for rb1'Component_Size use 1;
16927 for rb2'Size use 72;
16928 for rb2'Alignment use 1;
16929 for rb2'Component_Size use 1;
16931 for x2'Size use 224;
16932 for x2'Alignment use 4;
16933 for x2 use record
16934    l1 at  0 range  0 .. 0;
16935    l2 at  0 range  1 .. 64;
16936    l3 at 12 range  0 .. 31;
16937    l4 at 16 range  0 .. 0;
16938    l5 at 16 range  1 .. 13;
16939    l6 at 18 range  0 .. 71;
16940 end record;
16941 @end smallexample
16943 @noindent
16944 The Size values are actually the Object_Size, i.e.@: the default size that
16945 will be allocated for objects of the type.
16946 The ?? size for type r indicates that we have a variant record, and the
16947 actual size of objects will depend on the discriminant value.
16949 The Alignment values show the actual alignment chosen by the compiler
16950 for each record or array type.
16952 The record representation clause for type r shows where all fields
16953 are placed, including the compiler generated tag field (whose location
16954 cannot be controlled by the programmer).
16956 The record representation clause for the type extension r2 shows all the
16957 fields present, including the parent field, which is a copy of the fields
16958 of the parent type of r2, i.e.@: r1.
16960 The component size and size clauses for types rb1 and rb2 show
16961 the exact effect of pragma @code{Pack} on these arrays, and the record
16962 representation clause for type x2 shows how pragma @code{Pack} affects
16963 this record type.
16965 In some cases, it may be useful to cut and paste the representation clauses
16966 generated by the compiler into the original source to fix and guarantee
16967 the actual representation to be used.
16969 @node Standard Library Routines
16970 @chapter Standard Library Routines
16972 @noindent
16973 The Ada Reference Manual contains in Annex A a full description of an
16974 extensive set of standard library routines that can be used in any Ada
16975 program, and which must be provided by all Ada compilers.  They are
16976 analogous to the standard C library used by C programs.
16978 GNAT implements all of the facilities described in annex A, and for most
16979 purposes the description in the Ada Reference Manual, or appropriate Ada
16980 text book, will be sufficient for making use of these facilities.
16982 In the case of the input-output facilities,
16983 @xref{The Implementation of Standard I/O},
16984 gives details on exactly how GNAT interfaces to the
16985 file system.  For the remaining packages, the Ada Reference Manual
16986 should be sufficient.  The following is a list of the packages included,
16987 together with a brief description of the functionality that is provided.
16989 For completeness, references are included to other predefined library
16990 routines defined in other sections of the Ada Reference Manual (these are
16991 cross-indexed from Annex A). For further details see the relevant
16992 package declarations in the run-time library. In particular, a few units
16993 are not implemented, as marked by the presence of pragma Unimplemented_Unit,
16994 and in this case the package declaration contains comments explaining why
16995 the unit is not implemented.
16997 @table @code
16998 @item Ada (A.2)
16999 This is a parent package for all the standard library packages.  It is
17000 usually included implicitly in your program, and itself contains no
17001 useful data or routines.
17003 @item Ada.Assertions (11.4.2)
17004 @code{Assertions} provides the @code{Assert} subprograms, and also
17005 the declaration of the @code{Assertion_Error} exception.
17007 @item Ada.Asynchronous_Task_Control (D.11)
17008 @code{Asynchronous_Task_Control} provides low level facilities for task
17009 synchronization. It is typically not implemented. See package spec for details.
17011 @item Ada.Calendar (9.6)
17012 @code{Calendar} provides time of day access, and routines for
17013 manipulating times and durations.
17015 @item Ada.Calendar.Arithmetic (9.6.1)
17016 This package provides additional arithmetic
17017 operations for @code{Calendar}.
17019 @item Ada.Calendar.Formatting (9.6.1)
17020 This package provides formatting operations for @code{Calendar}.
17022 @item Ada.Calendar.Time_Zones (9.6.1)
17023 This package provides additional @code{Calendar} facilities
17024 for handling time zones.
17026 @item Ada.Characters (A.3.1)
17027 This is a dummy parent package that contains no useful entities
17029 @item Ada.Characters.Conversions (A.3.2)
17030 This package provides character conversion functions.
17032 @item Ada.Characters.Handling (A.3.2)
17033 This package provides some basic character handling capabilities,
17034 including classification functions for classes of characters (e.g.@: test
17035 for letters, or digits).
17037 @item Ada.Characters.Latin_1 (A.3.3)
17038 This package includes a complete set of definitions of the characters
17039 that appear in type CHARACTER@.  It is useful for writing programs that
17040 will run in international environments.  For example, if you want an
17041 upper case E with an acute accent in a string, it is often better to use
17042 the definition of @code{UC_E_Acute} in this package.  Then your program
17043 will print in an understandable manner even if your environment does not
17044 support these extended characters.
17046 @item Ada.Command_Line (A.15)
17047 This package provides access to the command line parameters and the name
17048 of the current program (analogous to the use of @code{argc} and @code{argv}
17049 in C), and also allows the exit status for the program to be set in a
17050 system-independent manner.
17052 @item Ada.Complex_Text_IO (G.1.3)
17053 This package provides text input and output of complex numbers.
17055 @item Ada.Containers (A.18.1)
17056 A top level package providing a few basic definitions used by all the
17057 following specific child packages that provide specific kinds of
17058 containers.
17060 @item Ada.Containers.Bounded_Priority_Queues (A.18.31)
17062 @item Ada.Containers.Bounded_Synchronized_Queues (A.18.29)
17064 @item Ada.Containers.Doubly_Linked_Lists (A.18.3)
17066 @item Ada.Containers.Generic_Array_Sort (A.18.26)
17068 @item Ada.Containers.Generic_Constrained_Array_Sort (A.18.26)
17070 @item Ada.Containers.Generic_Sort (A.18.26)
17072 @item Ada.Containers.Hashed_Maps (A.18.5)
17074 @item Ada.Containers.Hashed_Sets (A.18.8)
17076 @item Ada.Containers.Indefinite_Doubly_Linked_Lists (A.18.12)
17078 @item Ada.Containers.Indefinite_Hashed_Maps (A.18.13)
17080 @item Ada.Containers.Indefinite_Hashed_Sets (A.18.15)
17082 @item Ada.Containers.Indefinite_Holders (A.18.18)
17084 @item Ada.Containers.Indefinite_Multiway_Trees (A.18.17)
17086 @item Ada.Containers.Indefinite_Ordered_Maps (A.18.14)
17088 @item Ada.Containers.Indefinite_Ordered_Sets (A.18.16)
17090 @item Ada.Containers.Indefinite_Vectors (A.18.11)
17092 @item Ada.Containers.Multiway_Trees (A.18.10)
17094 @item Ada.Containers.Ordered_Maps (A.18.6)
17096 @item Ada.Containers.Ordered_Sets (A.18.9)
17098 @item Ada.Containers.Synchronized_Queue_Interfaces (A.18.27)
17100 @item Ada.Containers.Unbounded_Priority_Queues (A.18.30)
17102 @item Ada.Containers.Unbounded_Synchronized_Queues (A.18.28)
17104 @item Ada.Containers.Vectors (A.18.2)
17106 @item Ada.Directories (A.16)
17107 This package provides operations on directories.
17109 @item Ada.Directories.Hierarchical_File_Names (A.16.1)
17110 This package provides additional directory operations handling
17111 hiearchical file names.
17113 @item Ada.Directories.Information (A.16)
17114 This is an implementation defined package for additional directory
17115 operations, which is not implemented in GNAT.
17117 @item Ada.Decimal (F.2)
17118 This package provides constants describing the range of decimal numbers
17119 implemented, and also a decimal divide routine (analogous to the COBOL
17120 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
17122 @item Ada.Direct_IO (A.8.4)
17123 This package provides input-output using a model of a set of records of
17124 fixed-length, containing an arbitrary definite Ada type, indexed by an
17125 integer record number.
17127 @item Ada.Dispatching (D.2.1)
17128 A parent package containing definitions for task dispatching operations.
17130 @item Ada.Dispatching.EDF (D.2.6)
17131 Not implemented in GNAT.
17133 @item Ada.Dispatching.Non_Preemptive (D.2.4)
17134 Not implemented in GNAT.
17136 @item Ada.Dispatching.Round_Robin (D.2.5)
17137 Not implemented in GNAT.
17139 @item Ada.Dynamic_Priorities (D.5)
17140 This package allows the priorities of a task to be adjusted dynamically
17141 as the task is running.
17143 @item Ada.Environment_Variables (A.17)
17144 This package provides facilities for accessing environment variables.
17146 @item Ada.Exceptions (11.4.1)
17147 This package provides additional information on exceptions, and also
17148 contains facilities for treating exceptions as data objects, and raising
17149 exceptions with associated messages.
17151 @item Ada.Execution_Time (D.14)
17152 Not implemented in GNAT.
17154 @item Ada.Execution_Time.Group_Budgets (D.14.2)
17155 Not implemented in GNAT.
17157 @item Ada.Execution_Time.Timers (D.14.1)'
17158 Not implemented in GNAT.
17160 @item Ada.Finalization (7.6)
17161 This package contains the declarations and subprograms to support the
17162 use of controlled types, providing for automatic initialization and
17163 finalization (analogous to the constructors and destructors of C++).
17165 @item Ada.Float_Text_IO (A.10.9)
17166 A library level instantiation of Text_IO.Float_IO for type Float.
17168 @item Ada.Float_Wide_Text_IO (A.10.9)
17169 A library level instantiation of Wide_Text_IO.Float_IO for type Float.
17171 @item Ada.Float_Wide_Wide_Text_IO (A.10.9)
17172 A library level instantiation of Wide_Wide_Text_IO.Float_IO for type Float.
17174 @item Ada.Integer_Text_IO (A.10.9)
17175 A library level instantiation of Text_IO.Integer_IO for type Integer.
17177 @item Ada.Integer_Wide_Text_IO (A.10.9)
17178 A library level instantiation of Wide_Text_IO.Integer_IO for type Integer.
17180 @item Ada.Integer_Wide_Wide_Text_IO (A.10.9)
17181 A library level instantiation of Wide_Wide_Text_IO.Integer_IO for type Integer.
17183 @item Ada.Interrupts (C.3.2)
17184 This package provides facilities for interfacing to interrupts, which
17185 includes the set of signals or conditions that can be raised and
17186 recognized as interrupts.
17188 @item Ada.Interrupts.Names (C.3.2)
17189 This package provides the set of interrupt names (actually signal
17190 or condition names) that can be handled by GNAT@.
17192 @item Ada.IO_Exceptions (A.13)
17193 This package defines the set of exceptions that can be raised by use of
17194 the standard IO packages.
17196 @item Ada.Iterator_Interfaces (5.5.1)
17197 This package provides a generic interface to generalized iterators.
17199 @item Ada.Locales (A.19)
17200 This package provides declarations providing information (Language
17201 and Country) about the current locale.
17203 @item Ada.Numerics
17204 This package contains some standard constants and exceptions used
17205 throughout the numerics packages.  Note that the constants pi and e are
17206 defined here, and it is better to use these definitions than rolling
17207 your own.
17209 @item Ada.Numerics.Complex_Arrays (G.3.2)
17210 Provides operations on arrays of complex numbers.
17212 @item Ada.Numerics.Complex_Elementary_Functions
17213 Provides the implementation of standard elementary functions (such as
17214 log and trigonometric functions) operating on complex numbers using the
17215 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
17216 created by the package @code{Numerics.Complex_Types}.
17218 @item Ada.Numerics.Complex_Types
17219 This is a predefined instantiation of
17220 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
17221 build the type @code{Complex} and @code{Imaginary}.
17223 @item Ada.Numerics.Discrete_Random
17224 This generic package provides a random number generator suitable for generating
17225 uniformly distributed values of a specified discrete subtype.
17227 @item Ada.Numerics.Float_Random
17228 This package provides a random number generator suitable for generating
17229 uniformly distributed floating point values in the unit interval.
17231 @item Ada.Numerics.Generic_Complex_Elementary_Functions
17232 This is a generic version of the package that provides the
17233 implementation of standard elementary functions (such as log and
17234 trigonometric functions) for an arbitrary complex type.
17236 The following predefined instantiations of this package are provided:
17238 @table @code
17239 @item Short_Float
17240 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
17241 @item Float
17242 @code{Ada.Numerics.Complex_Elementary_Functions}
17243 @item Long_Float
17244 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
17245 @end table
17247 @item Ada.Numerics.Generic_Complex_Types
17248 This is a generic package that allows the creation of complex types,
17249 with associated complex arithmetic operations.
17251 The following predefined instantiations of this package exist
17252 @table @code
17253 @item Short_Float
17254 @code{Ada.Numerics.Short_Complex_Complex_Types}
17255 @item Float
17256 @code{Ada.Numerics.Complex_Complex_Types}
17257 @item Long_Float
17258 @code{Ada.Numerics.Long_Complex_Complex_Types}
17259 @end table
17261 @item Ada.Numerics.Generic_Elementary_Functions
17262 This is a generic package that provides the implementation of standard
17263 elementary functions (such as log an trigonometric functions) for an
17264 arbitrary float type.
17266 The following predefined instantiations of this package exist
17268 @table @code
17269 @item Short_Float
17270 @code{Ada.Numerics.Short_Elementary_Functions}
17271 @item Float
17272 @code{Ada.Numerics.Elementary_Functions}
17273 @item Long_Float
17274 @code{Ada.Numerics.Long_Elementary_Functions}
17275 @end table
17277 @item Ada.Numerics.Generic_Real_Arrays (G.3.1)
17278 Generic operations on arrays of reals
17280 @item Ada.Numerics.Real_Arrays (G.3.1)
17281 Preinstantiation of Ada.Numerics.Generic_Real_Arrays (Float).
17283 @item Ada.Real_Time (D.8)
17284 This package provides facilities similar to those of @code{Calendar}, but
17285 operating with a finer clock suitable for real time control. Note that
17286 annex D requires that there be no backward clock jumps, and GNAT generally
17287 guarantees this behavior, but of course if the external clock on which
17288 the GNAT runtime depends is deliberately reset by some external event,
17289 then such a backward jump may occur.
17291 @item Ada.Real_Time.Timing_Events (D.15)
17292 Not implemented in GNAT.
17294 @item Ada.Sequential_IO (A.8.1)
17295 This package provides input-output facilities for sequential files,
17296 which can contain a sequence of values of a single type, which can be
17297 any Ada type, including indefinite (unconstrained) types.
17299 @item Ada.Storage_IO (A.9)
17300 This package provides a facility for mapping arbitrary Ada types to and
17301 from a storage buffer.  It is primarily intended for the creation of new
17302 IO packages.
17304 @item Ada.Streams (13.13.1)
17305 This is a generic package that provides the basic support for the
17306 concept of streams as used by the stream attributes (@code{Input},
17307 @code{Output}, @code{Read} and @code{Write}).
17309 @item Ada.Streams.Stream_IO (A.12.1)
17310 This package is a specialization of the type @code{Streams} defined in
17311 package @code{Streams} together with a set of operations providing
17312 Stream_IO capability.  The Stream_IO model permits both random and
17313 sequential access to a file which can contain an arbitrary set of values
17314 of one or more Ada types.
17316 @item Ada.Strings (A.4.1)
17317 This package provides some basic constants used by the string handling
17318 packages.
17320 @item Ada.Strings.Bounded (A.4.4)
17321 This package provides facilities for handling variable length
17322 strings.  The bounded model requires a maximum length.  It is thus
17323 somewhat more limited than the unbounded model, but avoids the use of
17324 dynamic allocation or finalization.
17326 @item Ada.Strings.Bounded.Equal_Case_Insensitive (A.4.10)
17327 Provides case-insensitive comparisons of bounded strings
17329 @item Ada.Strings.Bounded.Hash (A.4.9)
17330 This package provides a generic hash function for bounded strings
17332 @item Ada.Strings.Bounded.Hash_Case_Insensitive (A.4.9)
17333 This package provides a generic hash function for bounded strings that
17334 converts the string to be hashed to lower case.
17336 @item Ada.Strings.Bounded.Less_Case_Insensitive (A.4.10)
17337 This package provides a comparison function for bounded strings that works
17338 in a case insensitive manner by converting to lower case before the comparison.
17340 @item Ada.Strings.Fixed (A.4.3)
17341 This package provides facilities for handling fixed length strings.
17343 @item Ada.Strings.Fixed.Equal_Case_Insensitive (A.4.10)
17344 This package provides an equality function for fixed strings that compares
17345 the strings after converting both to lower case.
17347 @item Ada.Strings.Fixed.Hash_Case_Insensitive (A.4.9)
17348 This package provides a case insensitive hash function for fixed strings that
17349 converts the string to lower case before computing the hash.
17351 @item Ada.Strings.Fixed.Less_Case_Insensitive (A.4.10)
17352 This package provides a comparison function for fixed strings that works
17353 in a case insensitive manner by converting to lower case before the comparison.
17355 Ada.Strings.Hash (A.4.9)
17356 This package provides a hash function for strings.
17358 Ada.Strings.Hash_Case_Insensitive (A.4.9)
17359 This package provides a hash function for strings that is case insensitive.
17360 The string is converted to lower case before computing the hash.
17362 @item Ada.Strings.Less_Case_Insensitive (A.4.10)
17363 This package provides a comparison function for\strings that works
17364 in a case insensitive manner by converting to lower case before the comparison.
17366 @item Ada.Strings.Maps (A.4.2)
17367 This package provides facilities for handling character mappings and
17368 arbitrarily defined subsets of characters.  For instance it is useful in
17369 defining specialized translation tables.
17371 @item Ada.Strings.Maps.Constants (A.4.6)
17372 This package provides a standard set of predefined mappings and
17373 predefined character sets.  For example, the standard upper to lower case
17374 conversion table is found in this package.  Note that upper to lower case
17375 conversion is non-trivial if you want to take the entire set of
17376 characters, including extended characters like E with an acute accent,
17377 into account.  You should use the mappings in this package (rather than
17378 adding 32 yourself) to do case mappings.
17380 @item Ada.Strings.Unbounded (A.4.5)
17381 This package provides facilities for handling variable length
17382 strings.  The unbounded model allows arbitrary length strings, but
17383 requires the use of dynamic allocation and finalization.
17385 @item Ada.Strings.Unbounded.Equal_Case_Insensitive (A.4.10)
17386 Provides case-insensitive comparisons of unbounded strings
17388 @item Ada.Strings.Unbounded.Hash (A.4.9)
17389 This package provides a generic hash function for unbounded strings
17391 @item Ada.Strings.Unbounded.Hash_Case_Insensitive (A.4.9)
17392 This package provides a generic hash function for unbounded strings that
17393 converts the string to be hashed to lower case.
17395 @item Ada.Strings.Unbounded.Less_Case_Insensitive (A.4.10)
17396 This package provides a comparison function for unbounded strings that works
17397 in a case insensitive manner by converting to lower case before the comparison.
17399 @item Ada.Strings.UTF_Encoding (A.4.11)
17400 This package provides basic definitions for dealing with UTF-encoded strings.
17402 @item Ada.Strings.UTF_Encoding.Conversions (A.4.11)
17403 This package provides conversion functions for UTF-encoded strings.
17405 @item Ada.Strings.UTF_Encoding.Strings (A.4.11)
17406 @itemx Ada.Strings.UTF_Encoding.Wide_Strings (A.4.11)
17407 @itemx Ada.Strings.UTF_Encoding.Wide_Wide_Strings (A.4.11)
17408 These packages provide facilities for handling UTF encodings for
17409 Strings, Wide_Strings and Wide_Wide_Strings.
17411 @item Ada.Strings.Wide_Bounded (A.4.7)
17412 @itemx Ada.Strings.Wide_Fixed (A.4.7)
17413 @itemx Ada.Strings.Wide_Maps (A.4.7)
17414 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
17415 These packages provide analogous capabilities to the corresponding
17416 packages without @samp{Wide_} in the name, but operate with the types
17417 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
17418 and @code{Character}. Versions of all the child packages are available.
17420 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
17421 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
17422 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
17423 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
17424 These packages provide analogous capabilities to the corresponding
17425 packages without @samp{Wide_} in the name, but operate with the types
17426 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
17427 of @code{String} and @code{Character}.
17429 @item Ada.Synchronous_Barriers (D.10.1)
17430 This package provides facilities for synchronizing tasks at a low level
17431 with barriers.
17433 @item Ada.Synchronous_Task_Control (D.10)
17434 This package provides some standard facilities for controlling task
17435 communication in a synchronous manner.
17437 @item Ada.Synchronous_Task_Control.EDF (D.10)
17438 Not implemented in GNAT.
17440 @item Ada.Tags
17441 This package contains definitions for manipulation of the tags of tagged
17442 values.
17444 @item Ada.Tags.Generic_Dispatching_Constructor (3.9)
17445 This package provides a way of constructing tagged class-wide values given
17446 only the tag value.
17448 @item Ada.Task_Attributes (C.7.2)
17449 This package provides the capability of associating arbitrary
17450 task-specific data with separate tasks.
17452 @item Ada.Task_Identifification (C.7.1)
17453 This package provides capabilities for task identification.
17455 @item Ada.Task_Termination (C.7.3)
17456 This package provides control over task termination.
17458 @item Ada.Text_IO
17459 This package provides basic text input-output capabilities for
17460 character, string and numeric data.  The subpackages of this
17461 package are listed next. Note that although these are defined
17462 as subpackages in the RM, they are actually transparently
17463 implemented as child packages in GNAT, meaning that they
17464 are only loaded if needed.
17466 @item Ada.Text_IO.Decimal_IO
17467 Provides input-output facilities for decimal fixed-point types
17469 @item Ada.Text_IO.Enumeration_IO
17470 Provides input-output facilities for enumeration types.
17472 @item Ada.Text_IO.Fixed_IO
17473 Provides input-output facilities for ordinary fixed-point types.
17475 @item Ada.Text_IO.Float_IO
17476 Provides input-output facilities for float types.  The following
17477 predefined instantiations of this generic package are available:
17479 @table @code
17480 @item Short_Float
17481 @code{Short_Float_Text_IO}
17482 @item Float
17483 @code{Float_Text_IO}
17484 @item Long_Float
17485 @code{Long_Float_Text_IO}
17486 @end table
17488 @item Ada.Text_IO.Integer_IO
17489 Provides input-output facilities for integer types.  The following
17490 predefined instantiations of this generic package are available:
17492 @table @code
17493 @item Short_Short_Integer
17494 @code{Ada.Short_Short_Integer_Text_IO}
17495 @item Short_Integer
17496 @code{Ada.Short_Integer_Text_IO}
17497 @item Integer
17498 @code{Ada.Integer_Text_IO}
17499 @item Long_Integer
17500 @code{Ada.Long_Integer_Text_IO}
17501 @item Long_Long_Integer
17502 @code{Ada.Long_Long_Integer_Text_IO}
17503 @end table
17505 @item Ada.Text_IO.Modular_IO
17506 Provides input-output facilities for modular (unsigned) types.
17508 @item Ada.Text_IO.Bounded_IO (A.10.11)
17509 Provides input-output facilities for bounded strings.
17511 @item Ada.Text_IO.Complex_IO (G.1.3)
17512 This package provides basic text input-output capabilities for complex
17513 data.
17515 @item Ada.Text_IO.Editing (F.3.3)
17516 This package contains routines for edited output, analogous to the use
17517 of pictures in COBOL@.  The picture formats used by this package are a
17518 close copy of the facility in COBOL@.
17520 @item Ada.Text_IO.Text_Streams (A.12.2)
17521 This package provides a facility that allows Text_IO files to be treated
17522 as streams, so that the stream attributes can be used for writing
17523 arbitrary data, including binary data, to Text_IO files.
17525 @item Ada.Text_IO.Unbounded_IO (A.10.12)
17526 This package provides input-output facilities for unbounded strings.
17528 @item Ada.Unchecked_Conversion (13.9)
17529 This generic package allows arbitrary conversion from one type to
17530 another of the same size, providing for breaking the type safety in
17531 special circumstances.
17533 If the types have the same Size (more accurately the same Value_Size),
17534 then the effect is simply to transfer the bits from the source to the
17535 target type without any modification.  This usage is well defined, and
17536 for simple types whose representation is typically the same across
17537 all implementations, gives a portable method of performing such
17538 conversions.
17540 If the types do not have the same size, then the result is implementation
17541 defined, and thus may be non-portable.  The following describes how GNAT
17542 handles such unchecked conversion cases.
17544 If the types are of different sizes, and are both discrete types, then
17545 the effect is of a normal type conversion without any constraint checking.
17546 In particular if the result type has a larger size, the result will be
17547 zero or sign extended.  If the result type has a smaller size, the result
17548 will be truncated by ignoring high order bits.
17550 If the types are of different sizes, and are not both discrete types,
17551 then the conversion works as though pointers were created to the source
17552 and target, and the pointer value is converted.  The effect is that bits
17553 are copied from successive low order storage units and bits of the source
17554 up to the length of the target type.
17556 A warning is issued if the lengths differ, since the effect in this
17557 case is implementation dependent, and the above behavior may not match
17558 that of some other compiler.
17560 A pointer to one type may be converted to a pointer to another type using
17561 unchecked conversion.  The only case in which the effect is undefined is
17562 when one or both pointers are pointers to unconstrained array types.  In
17563 this case, the bounds information may get incorrectly transferred, and in
17564 particular, GNAT uses double size pointers for such types, and it is
17565 meaningless to convert between such pointer types.  GNAT will issue a
17566 warning if the alignment of the target designated type is more strict
17567 than the alignment of the source designated type (since the result may
17568 be unaligned in this case).
17570 A pointer other than a pointer to an unconstrained array type may be
17571 converted to and from System.Address.  Such usage is common in Ada 83
17572 programs, but note that Ada.Address_To_Access_Conversions is the
17573 preferred method of performing such conversions in Ada 95 and Ada 2005.
17574 Neither
17575 unchecked conversion nor Ada.Address_To_Access_Conversions should be
17576 used in conjunction with pointers to unconstrained objects, since
17577 the bounds information cannot be handled correctly in this case.
17579 @item Ada.Unchecked_Deallocation (13.11.2)
17580 This generic package allows explicit freeing of storage previously
17581 allocated by use of an allocator.
17583 @item Ada.Wide_Text_IO (A.11)
17584 This package is similar to @code{Ada.Text_IO}, except that the external
17585 file supports wide character representations, and the internal types are
17586 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17587 and @code{String}. The corresponding set of nested packages and child
17588 packages are defined.
17590 @item Ada.Wide_Wide_Text_IO (A.11)
17591 This package is similar to @code{Ada.Text_IO}, except that the external
17592 file supports wide character representations, and the internal types are
17593 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17594 and @code{String}. The corresponding set of nested packages and child
17595 packages are defined.
17597 @end table
17599 For packages in Interfaces and System, all the RM defined packages are
17600 available in GNAT, see the Ada 2012 RM for full details.
17602 @node The Implementation of Standard I/O
17603 @chapter The Implementation of Standard I/O
17605 @noindent
17606 GNAT implements all the required input-output facilities described in
17607 A.6 through A.14.  These sections of the Ada Reference Manual describe the
17608 required behavior of these packages from the Ada point of view, and if
17609 you are writing a portable Ada program that does not need to know the
17610 exact manner in which Ada maps to the outside world when it comes to
17611 reading or writing external files, then you do not need to read this
17612 chapter.  As long as your files are all regular files (not pipes or
17613 devices), and as long as you write and read the files only from Ada, the
17614 description in the Ada Reference Manual is sufficient.
17616 However, if you want to do input-output to pipes or other devices, such
17617 as the keyboard or screen, or if the files you are dealing with are
17618 either generated by some other language, or to be read by some other
17619 language, then you need to know more about the details of how the GNAT
17620 implementation of these input-output facilities behaves.
17622 In this chapter we give a detailed description of exactly how GNAT
17623 interfaces to the file system.  As always, the sources of the system are
17624 available to you for answering questions at an even more detailed level,
17625 but for most purposes the information in this chapter will suffice.
17627 Another reason that you may need to know more about how input-output is
17628 implemented arises when you have a program written in mixed languages
17629 where, for example, files are shared between the C and Ada sections of
17630 the same program.  GNAT provides some additional facilities, in the form
17631 of additional child library packages, that facilitate this sharing, and
17632 these additional facilities are also described in this chapter.
17634 @menu
17635 * Standard I/O Packages::
17636 * FORM Strings::
17637 * Direct_IO::
17638 * Sequential_IO::
17639 * Text_IO::
17640 * Wide_Text_IO::
17641 * Wide_Wide_Text_IO::
17642 * Stream_IO::
17643 * Text Translation::
17644 * Shared Files::
17645 * Filenames encoding::
17646 * File content encoding::
17647 * Open Modes::
17648 * Operations on C Streams::
17649 * Interfacing to C Streams::
17650 @end menu
17652 @node Standard I/O Packages
17653 @section Standard I/O Packages
17655 @noindent
17656 The Standard I/O packages described in Annex A for
17658 @itemize @bullet
17659 @item
17660 Ada.Text_IO
17661 @item
17662 Ada.Text_IO.Complex_IO
17663 @item
17664 Ada.Text_IO.Text_Streams
17665 @item
17666 Ada.Wide_Text_IO
17667 @item
17668 Ada.Wide_Text_IO.Complex_IO
17669 @item
17670 Ada.Wide_Text_IO.Text_Streams
17671 @item
17672 Ada.Wide_Wide_Text_IO
17673 @item
17674 Ada.Wide_Wide_Text_IO.Complex_IO
17675 @item
17676 Ada.Wide_Wide_Text_IO.Text_Streams
17677 @item
17678 Ada.Stream_IO
17679 @item
17680 Ada.Sequential_IO
17681 @item
17682 Ada.Direct_IO
17683 @end itemize
17685 @noindent
17686 are implemented using the C
17687 library streams facility; where
17689 @itemize @bullet
17690 @item
17691 All files are opened using @code{fopen}.
17692 @item
17693 All input/output operations use @code{fread}/@code{fwrite}.
17694 @end itemize
17696 @noindent
17697 There is no internal buffering of any kind at the Ada library level. The only
17698 buffering is that provided at the system level in the implementation of the
17699 library routines that support streams. This facilitates shared use of these
17700 streams by mixed language programs. Note though that system level buffering is
17701 explicitly enabled at elaboration of the standard I/O packages and that can
17702 have an impact on mixed language programs, in particular those using I/O before
17703 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
17704 the Ada elaboration routine before performing any I/O or when impractical,
17705 flush the common I/O streams and in particular Standard_Output before
17706 elaborating the Ada code.
17708 @node FORM Strings
17709 @section FORM Strings
17711 @noindent
17712 The format of a FORM string in GNAT is:
17714 @smallexample
17715 "keyword=value,keyword=value,@dots{},keyword=value"
17716 @end smallexample
17718 @noindent
17719 where letters may be in upper or lower case, and there are no spaces
17720 between values.  The order of the entries is not important.  Currently
17721 the following keywords defined.
17723 @smallexample
17724 TEXT_TRANSLATION=[YES|NO|TEXT|BINARY|U8TEXT|WTEXT|U16TEXT]
17725 SHARED=[YES|NO]
17726 WCEM=[n|h|u|s|e|8|b]
17727 ENCODING=[UTF8|8BITS]
17728 @end smallexample
17730 @noindent
17731 The use of these parameters is described later in this section. If an
17732 unrecognized keyword appears in a form string, it is silently ignored
17733 and not considered invalid.
17735 @noindent
17736 For OpenVMS additional FORM string keywords are available for use with
17737 RMS services.  The syntax is:
17739 @smallexample
17740 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
17741 @end smallexample
17743 @noindent
17744 The following RMS keywords and values are currently defined:
17746 @smallexample
17747 Context=Force_Stream_Mode|Force_Record_Mode
17748 @end smallexample
17750 @noindent
17751 VMS RMS keys are silently ignored on non-VMS systems.  On OpenVMS
17752 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
17754 @node Direct_IO
17755 @section Direct_IO
17757 @noindent
17758 Direct_IO can only be instantiated for definite types.  This is a
17759 restriction of the Ada language, which means that the records are fixed
17760 length (the length being determined by @code{@var{type}'Size}, rounded
17761 up to the next storage unit boundary if necessary).
17763 The records of a Direct_IO file are simply written to the file in index
17764 sequence, with the first record starting at offset zero, and subsequent
17765 records following.  There is no control information of any kind.  For
17766 example, if 32-bit integers are being written, each record takes
17767 4-bytes, so the record at index @var{K} starts at offset
17768 (@var{K}@minus{}1)*4.
17770 There is no limit on the size of Direct_IO files, they are expanded as
17771 necessary to accommodate whatever records are written to the file.
17773 @node Sequential_IO
17774 @section Sequential_IO
17776 @noindent
17777 Sequential_IO may be instantiated with either a definite (constrained)
17778 or indefinite (unconstrained) type.
17780 For the definite type case, the elements written to the file are simply
17781 the memory images of the data values with no control information of any
17782 kind.  The resulting file should be read using the same type, no validity
17783 checking is performed on input.
17785 For the indefinite type case, the elements written consist of two
17786 parts.  First is the size of the data item, written as the memory image
17787 of a @code{Interfaces.C.size_t} value, followed by the memory image of
17788 the data value.  The resulting file can only be read using the same
17789 (unconstrained) type.  Normal assignment checks are performed on these
17790 read operations, and if these checks fail, @code{Data_Error} is
17791 raised.  In particular, in the array case, the lengths must match, and in
17792 the variant record case, if the variable for a particular read operation
17793 is constrained, the discriminants must match.
17795 Note that it is not possible to use Sequential_IO to write variable
17796 length array items, and then read the data back into different length
17797 arrays.  For example, the following will raise @code{Data_Error}:
17799 @smallexample @c ada
17800  package IO is new Sequential_IO (String);
17801  F : IO.File_Type;
17802  S : String (1..4);
17803  @dots{}
17804  IO.Create (F)
17805  IO.Write (F, "hello!")
17806  IO.Reset (F, Mode=>In_File);
17807  IO.Read (F, S);
17808  Put_Line (S);
17810 @end smallexample
17812 @noindent
17813 On some Ada implementations, this will print @code{hell}, but the program is
17814 clearly incorrect, since there is only one element in the file, and that
17815 element is the string @code{hello!}.
17817 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
17818 using Stream_IO, and this is the preferred mechanism.  In particular, the
17819 above program fragment rewritten to use Stream_IO will work correctly.
17821 @node Text_IO
17822 @section Text_IO
17824 @noindent
17825 Text_IO files consist of a stream of characters containing the following
17826 special control characters:
17828 @smallexample
17829 LF (line feed, 16#0A#) Line Mark
17830 FF (form feed, 16#0C#) Page Mark
17831 @end smallexample
17833 @noindent
17834 A canonical Text_IO file is defined as one in which the following
17835 conditions are met:
17837 @itemize @bullet
17838 @item
17839 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
17840 of the line.
17842 @item
17843 The character @code{FF} is used only as a page mark, i.e.@: to mark the
17844 end of a page and consequently can appear only immediately following a
17845 @code{LF} (line mark) character.
17847 @item
17848 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
17849 (line mark, page mark).  In the former case, the page mark is implicitly
17850 assumed to be present.
17851 @end itemize
17853 @noindent
17854 A file written using Text_IO will be in canonical form provided that no
17855 explicit @code{LF} or @code{FF} characters are written using @code{Put}
17856 or @code{Put_Line}.  There will be no @code{FF} character at the end of
17857 the file unless an explicit @code{New_Page} operation was performed
17858 before closing the file.
17860 A canonical Text_IO file that is a regular file (i.e., not a device or a
17861 pipe) can be read using any of the routines in Text_IO@.  The
17862 semantics in this case will be exactly as defined in the Ada Reference
17863 Manual, and all the routines in Text_IO are fully implemented.
17865 A text file that does not meet the requirements for a canonical Text_IO
17866 file has one of the following:
17868 @itemize @bullet
17869 @item
17870 The file contains @code{FF} characters not immediately following a
17871 @code{LF} character.
17873 @item
17874 The file contains @code{LF} or @code{FF} characters written by
17875 @code{Put} or @code{Put_Line}, which are not logically considered to be
17876 line marks or page marks.
17878 @item
17879 The file ends in a character other than @code{LF} or @code{FF},
17880 i.e.@: there is no explicit line mark or page mark at the end of the file.
17881 @end itemize
17883 @noindent
17884 Text_IO can be used to read such non-standard text files but subprograms
17885 to do with line or page numbers do not have defined meanings.  In
17886 particular, a @code{FF} character that does not follow a @code{LF}
17887 character may or may not be treated as a page mark from the point of
17888 view of page and line numbering.  Every @code{LF} character is considered
17889 to end a line, and there is an implied @code{LF} character at the end of
17890 the file.
17892 @menu
17893 * Text_IO Stream Pointer Positioning::
17894 * Text_IO Reading and Writing Non-Regular Files::
17895 * Get_Immediate::
17896 * Treating Text_IO Files as Streams::
17897 * Text_IO Extensions::
17898 * Text_IO Facilities for Unbounded Strings::
17899 @end menu
17901 @node Text_IO Stream Pointer Positioning
17902 @subsection Stream Pointer Positioning
17904 @noindent
17905 @code{Ada.Text_IO} has a definition of current position for a file that
17906 is being read.  No internal buffering occurs in Text_IO, and usually the
17907 physical position in the stream used to implement the file corresponds
17908 to this logical position defined by Text_IO@.  There are two exceptions:
17910 @itemize @bullet
17911 @item
17912 After a call to @code{End_Of_Page} that returns @code{True}, the stream
17913 is positioned past the @code{LF} (line mark) that precedes the page
17914 mark.  Text_IO maintains an internal flag so that subsequent read
17915 operations properly handle the logical position which is unchanged by
17916 the @code{End_Of_Page} call.
17918 @item
17919 After a call to @code{End_Of_File} that returns @code{True}, if the
17920 Text_IO file was positioned before the line mark at the end of file
17921 before the call, then the logical position is unchanged, but the stream
17922 is physically positioned right at the end of file (past the line mark,
17923 and past a possible page mark following the line mark.  Again Text_IO
17924 maintains internal flags so that subsequent read operations properly
17925 handle the logical position.
17926 @end itemize
17928 @noindent
17929 These discrepancies have no effect on the observable behavior of
17930 Text_IO, but if a single Ada stream is shared between a C program and
17931 Ada program, or shared (using @samp{shared=yes} in the form string)
17932 between two Ada files, then the difference may be observable in some
17933 situations.
17935 @node Text_IO Reading and Writing Non-Regular Files
17936 @subsection Reading and Writing Non-Regular Files
17938 @noindent
17939 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
17940 can be used for reading and writing.  Writing is not affected and the
17941 sequence of characters output is identical to the normal file case, but
17942 for reading, the behavior of Text_IO is modified to avoid undesirable
17943 look-ahead as follows:
17945 An input file that is not a regular file is considered to have no page
17946 marks.  Any @code{Ascii.FF} characters (the character normally used for a
17947 page mark) appearing in the file are considered to be data
17948 characters.  In particular:
17950 @itemize @bullet
17951 @item
17952 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
17953 following a line mark.  If a page mark appears, it will be treated as a
17954 data character.
17956 @item
17957 This avoids the need to wait for an extra character to be typed or
17958 entered from the pipe to complete one of these operations.
17960 @item
17961 @code{End_Of_Page} always returns @code{False}
17963 @item
17964 @code{End_Of_File} will return @code{False} if there is a page mark at
17965 the end of the file.
17966 @end itemize
17968 @noindent
17969 Output to non-regular files is the same as for regular files.  Page marks
17970 may be written to non-regular files using @code{New_Page}, but as noted
17971 above they will not be treated as page marks on input if the output is
17972 piped to another Ada program.
17974 Another important discrepancy when reading non-regular files is that the end
17975 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
17976 pressing the @key{EOT} key,
17977 then end of file
17978 is signaled once (i.e.@: the test @code{End_Of_File}
17979 will yield @code{True}, or a read will
17980 raise @code{End_Error}), but then reading can resume
17981 to read data past that end of
17982 file indication, until another end of file indication is entered.
17984 @node Get_Immediate
17985 @subsection Get_Immediate
17986 @cindex Get_Immediate
17988 @noindent
17989 Get_Immediate returns the next character (including control characters)
17990 from the input file.  In particular, Get_Immediate will return LF or FF
17991 characters used as line marks or page marks.  Such operations leave the
17992 file positioned past the control character, and it is thus not treated
17993 as having its normal function.  This means that page, line and column
17994 counts after this kind of Get_Immediate call are set as though the mark
17995 did not occur.  In the case where a Get_Immediate leaves the file
17996 positioned between the line mark and page mark (which is not normally
17997 possible), it is undefined whether the FF character will be treated as a
17998 page mark.
18000 @node Treating Text_IO Files as Streams
18001 @subsection Treating Text_IO Files as Streams
18002 @cindex Stream files
18004 @noindent
18005 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
18006 as a stream.  Data written to a Text_IO file in this stream mode is
18007 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
18008 16#0C# (@code{FF}), the resulting file may have non-standard
18009 format.  Similarly if read operations are used to read from a Text_IO
18010 file treated as a stream, then @code{LF} and @code{FF} characters may be
18011 skipped and the effect is similar to that described above for
18012 @code{Get_Immediate}.
18014 @node Text_IO Extensions
18015 @subsection Text_IO Extensions
18016 @cindex Text_IO extensions
18018 @noindent
18019 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
18020 to the standard @code{Text_IO} package:
18022 @itemize @bullet
18023 @item function File_Exists (Name : String) return Boolean;
18024 Determines if a file of the given name exists.
18026 @item function Get_Line return String;
18027 Reads a string from the standard input file.  The value returned is exactly
18028 the length of the line that was read.
18030 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
18031 Similar, except that the parameter File specifies the file from which
18032 the string is to be read.
18034 @end itemize
18036 @node Text_IO Facilities for Unbounded Strings
18037 @subsection Text_IO Facilities for Unbounded Strings
18038 @cindex Text_IO for unbounded strings
18039 @cindex Unbounded_String, Text_IO operations
18041 @noindent
18042 The package @code{Ada.Strings.Unbounded.Text_IO}
18043 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
18044 subprograms useful for Text_IO operations on unbounded strings:
18046 @itemize @bullet
18048 @item function Get_Line (File : File_Type) return Unbounded_String;
18049 Reads a line from the specified file
18050 and returns the result as an unbounded string.
18052 @item procedure Put (File : File_Type; U : Unbounded_String);
18053 Writes the value of the given unbounded string to the specified file
18054 Similar to the effect of
18055 @code{Put (To_String (U))} except that an extra copy is avoided.
18057 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
18058 Writes the value of the given unbounded string to the specified file,
18059 followed by a @code{New_Line}.
18060 Similar to the effect of @code{Put_Line (To_String (U))} except
18061 that an extra copy is avoided.
18062 @end itemize
18064 @noindent
18065 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
18066 and is optional.  If the parameter is omitted, then the standard input or
18067 output file is referenced as appropriate.
18069 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
18070 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
18071 @code{Wide_Text_IO} functionality for unbounded wide strings.
18073 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
18074 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
18075 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
18077 @node Wide_Text_IO
18078 @section Wide_Text_IO
18080 @noindent
18081 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
18082 both input and output files may contain special sequences that represent
18083 wide character values.  The encoding scheme for a given file may be
18084 specified using a FORM parameter:
18086 @smallexample
18087 WCEM=@var{x}
18088 @end smallexample
18090 @noindent
18091 as part of the FORM string (WCEM = wide character encoding method),
18092 where @var{x} is one of the following characters
18094 @table @samp
18095 @item h
18096 Hex ESC encoding
18097 @item u
18098 Upper half encoding
18099 @item s
18100 Shift-JIS encoding
18101 @item e
18102 EUC Encoding
18103 @item 8
18104 UTF-8 encoding
18105 @item b
18106 Brackets encoding
18107 @end table
18109 @noindent
18110 The encoding methods match those that
18111 can be used in a source
18112 program, but there is no requirement that the encoding method used for
18113 the source program be the same as the encoding method used for files,
18114 and different files may use different encoding methods.
18116 The default encoding method for the standard files, and for opened files
18117 for which no WCEM parameter is given in the FORM string matches the
18118 wide character encoding specified for the main program (the default
18119 being brackets encoding if no coding method was specified with -gnatW).
18121 @table @asis
18122 @item Hex Coding
18123 In this encoding, a wide character is represented by a five character
18124 sequence:
18126 @smallexample
18127 ESC a b c d
18128 @end smallexample
18130 @noindent
18131 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
18132 characters (using upper case letters) of the wide character code.  For
18133 example, ESC A345 is used to represent the wide character with code
18134 16#A345#.  This scheme is compatible with use of the full
18135 @code{Wide_Character} set.
18137 @item Upper Half Coding
18138 The wide character with encoding 16#abcd#, where the upper bit is on
18139 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
18140 16#cd#.  The second byte may never be a format control character, but is
18141 not required to be in the upper half.  This method can be also used for
18142 shift-JIS or EUC where the internal coding matches the external coding.
18144 @item Shift JIS Coding
18145 A wide character is represented by a two character sequence 16#ab# and
18146 16#cd#, with the restrictions described for upper half encoding as
18147 described above.  The internal character code is the corresponding JIS
18148 character according to the standard algorithm for Shift-JIS
18149 conversion.  Only characters defined in the JIS code set table can be
18150 used with this encoding method.
18152 @item EUC Coding
18153 A wide character is represented by a two character sequence 16#ab# and
18154 16#cd#, with both characters being in the upper half.  The internal
18155 character code is the corresponding JIS character according to the EUC
18156 encoding algorithm.  Only characters defined in the JIS code set table
18157 can be used with this encoding method.
18159 @item UTF-8 Coding
18160 A wide character is represented using
18161 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
18162 10646-1/Am.2.  Depending on the character value, the representation
18163 is a one, two, or three byte sequence:
18165 @smallexample
18166 16#0000#-16#007f#: 2#0xxxxxxx#
18167 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
18168 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
18169 @end smallexample
18171 @noindent
18172 where the @var{xxx} bits correspond to the left-padded bits of the
18173 16-bit character value.  Note that all lower half ASCII characters
18174 are represented as ASCII bytes and all upper half characters and
18175 other wide characters are represented as sequences of upper-half
18176 (The full UTF-8 scheme allows for encoding 31-bit characters as
18177 6-byte sequences, but in this implementation, all UTF-8 sequences
18178 of four or more bytes length will raise a Constraint_Error, as
18179 will all invalid UTF-8 sequences.)
18181 @item Brackets Coding
18182 In this encoding, a wide character is represented by the following eight
18183 character sequence:
18185 @smallexample
18186 [ " a b c d " ]
18187 @end smallexample
18189 @noindent
18190 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
18191 characters (using uppercase letters) of the wide character code.  For
18192 example, @code{["A345"]} is used to represent the wide character with code
18193 @code{16#A345#}.
18194 This scheme is compatible with use of the full Wide_Character set.
18195 On input, brackets coding can also be used for upper half characters,
18196 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
18197 is only used for wide characters with a code greater than @code{16#FF#}.
18199 Note that brackets coding is not normally used in the context of
18200 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
18201 a portable way of encoding source files. In the context of Wide_Text_IO
18202 or Wide_Wide_Text_IO, it can only be used if the file does not contain
18203 any instance of the left bracket character other than to encode wide
18204 character values using the brackets encoding method. In practice it is
18205 expected that some standard wide character encoding method such
18206 as UTF-8 will be used for text input output.
18208 If brackets notation is used, then any occurrence of a left bracket
18209 in the input file which is not the start of a valid wide character
18210 sequence will cause Constraint_Error to be raised. It is possible to
18211 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
18212 input will interpret this as a left bracket.
18214 However, when a left bracket is output, it will be output as a left bracket
18215 and not as ["5B"]. We make this decision because for normal use of
18216 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
18217 brackets. For example, if we write:
18219 @smallexample
18220    Put_Line ("Start of output [first run]");
18221 @end smallexample
18223 @noindent
18224 we really do not want to have the left bracket in this message clobbered so
18225 that the output reads:
18227 @smallexample
18228    Start of output ["5B"]first run]
18229 @end smallexample
18231 @noindent
18232 In practice brackets encoding is reasonably useful for normal Put_Line use
18233 since we won't get confused between left brackets and wide character
18234 sequences in the output. But for input, or when files are written out
18235 and read back in, it really makes better sense to use one of the standard
18236 encoding methods such as UTF-8.
18238 @end table
18240 @noindent
18241 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
18242 not all wide character
18243 values can be represented.  An attempt to output a character that cannot
18244 be represented using the encoding scheme for the file causes
18245 Constraint_Error to be raised.  An invalid wide character sequence on
18246 input also causes Constraint_Error to be raised.
18248 @menu
18249 * Wide_Text_IO Stream Pointer Positioning::
18250 * Wide_Text_IO Reading and Writing Non-Regular Files::
18251 @end menu
18253 @node Wide_Text_IO Stream Pointer Positioning
18254 @subsection Stream Pointer Positioning
18256 @noindent
18257 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
18258 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
18259 case:
18261 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
18262 normal lower ASCII set (i.e.@: a character in the range:
18264 @smallexample @c ada
18265 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
18266 @end smallexample
18268 @noindent
18269 then although the logical position of the file pointer is unchanged by
18270 the @code{Look_Ahead} call, the stream is physically positioned past the
18271 wide character sequence.  Again this is to avoid the need for buffering
18272 or backup, and all @code{Wide_Text_IO} routines check the internal
18273 indication that this situation has occurred so that this is not visible
18274 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
18275 can be observed if the wide text file shares a stream with another file.
18277 @node Wide_Text_IO Reading and Writing Non-Regular Files
18278 @subsection Reading and Writing Non-Regular Files
18280 @noindent
18281 As in the case of Text_IO, when a non-regular file is read, it is
18282 assumed that the file contains no page marks (any form characters are
18283 treated as data characters), and @code{End_Of_Page} always returns
18284 @code{False}.  Similarly, the end of file indication is not sticky, so
18285 it is possible to read beyond an end of file.
18287 @node Wide_Wide_Text_IO
18288 @section Wide_Wide_Text_IO
18290 @noindent
18291 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
18292 both input and output files may contain special sequences that represent
18293 wide wide character values.  The encoding scheme for a given file may be
18294 specified using a FORM parameter:
18296 @smallexample
18297 WCEM=@var{x}
18298 @end smallexample
18300 @noindent
18301 as part of the FORM string (WCEM = wide character encoding method),
18302 where @var{x} is one of the following characters
18304 @table @samp
18305 @item h
18306 Hex ESC encoding
18307 @item u
18308 Upper half encoding
18309 @item s
18310 Shift-JIS encoding
18311 @item e
18312 EUC Encoding
18313 @item 8
18314 UTF-8 encoding
18315 @item b
18316 Brackets encoding
18317 @end table
18319 @noindent
18320 The encoding methods match those that
18321 can be used in a source
18322 program, but there is no requirement that the encoding method used for
18323 the source program be the same as the encoding method used for files,
18324 and different files may use different encoding methods.
18326 The default encoding method for the standard files, and for opened files
18327 for which no WCEM parameter is given in the FORM string matches the
18328 wide character encoding specified for the main program (the default
18329 being brackets encoding if no coding method was specified with -gnatW).
18331 @table @asis
18333 @item UTF-8 Coding
18334 A wide character is represented using
18335 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
18336 10646-1/Am.2.  Depending on the character value, the representation
18337 is a one, two, three, or four byte sequence:
18339 @smallexample
18340 16#000000#-16#00007f#: 2#0xxxxxxx#
18341 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
18342 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
18343 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
18344 @end smallexample
18346 @noindent
18347 where the @var{xxx} bits correspond to the left-padded bits of the
18348 21-bit character value.  Note that all lower half ASCII characters
18349 are represented as ASCII bytes and all upper half characters and
18350 other wide characters are represented as sequences of upper-half
18351 characters.
18353 @item Brackets Coding
18354 In this encoding, a wide wide character is represented by the following eight
18355 character sequence if is in wide character range
18357 @smallexample
18358 [ " a b c d " ]
18359 @end smallexample
18361 and by the following ten character sequence if not
18363 @smallexample
18364 [ " a b c d e f " ]
18365 @end smallexample
18367 @noindent
18368 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
18369 are the four or six hexadecimal
18370 characters (using uppercase letters) of the wide wide character code.  For
18371 example, @code{["01A345"]} is used to represent the wide wide character
18372 with code @code{16#01A345#}.
18374 This scheme is compatible with use of the full Wide_Wide_Character set.
18375 On input, brackets coding can also be used for upper half characters,
18376 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
18377 is only used for wide characters with a code greater than @code{16#FF#}.
18379 @end table
18381 @noindent
18382 If is also possible to use the other Wide_Character encoding methods,
18383 such as Shift-JIS, but the other schemes cannot support the full range
18384 of wide wide characters.
18385 An attempt to output a character that cannot
18386 be represented using the encoding scheme for the file causes
18387 Constraint_Error to be raised.  An invalid wide character sequence on
18388 input also causes Constraint_Error to be raised.
18390 @menu
18391 * Wide_Wide_Text_IO Stream Pointer Positioning::
18392 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
18393 @end menu
18395 @node Wide_Wide_Text_IO Stream Pointer Positioning
18396 @subsection Stream Pointer Positioning
18398 @noindent
18399 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
18400 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
18401 case:
18403 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
18404 normal lower ASCII set (i.e.@: a character in the range:
18406 @smallexample @c ada
18407 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
18408 @end smallexample
18410 @noindent
18411 then although the logical position of the file pointer is unchanged by
18412 the @code{Look_Ahead} call, the stream is physically positioned past the
18413 wide character sequence.  Again this is to avoid the need for buffering
18414 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
18415 indication that this situation has occurred so that this is not visible
18416 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
18417 can be observed if the wide text file shares a stream with another file.
18419 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
18420 @subsection Reading and Writing Non-Regular Files
18422 @noindent
18423 As in the case of Text_IO, when a non-regular file is read, it is
18424 assumed that the file contains no page marks (any form characters are
18425 treated as data characters), and @code{End_Of_Page} always returns
18426 @code{False}.  Similarly, the end of file indication is not sticky, so
18427 it is possible to read beyond an end of file.
18429 @node Stream_IO
18430 @section Stream_IO
18432 @noindent
18433 A stream file is a sequence of bytes, where individual elements are
18434 written to the file as described in the Ada Reference Manual.  The type
18435 @code{Stream_Element} is simply a byte.  There are two ways to read or
18436 write a stream file.
18438 @itemize @bullet
18439 @item
18440 The operations @code{Read} and @code{Write} directly read or write a
18441 sequence of stream elements with no control information.
18443 @item
18444 The stream attributes applied to a stream file transfer data in the
18445 manner described for stream attributes.
18446 @end itemize
18448 @node Text Translation
18449 @section Text Translation
18451 @noindent
18452 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
18453 passed to Text_IO.Create and Text_IO.Open. @samp{Text_Translation=@var{xxx}}
18454 has no effect on Unix systems. Possible values are:
18456 @itemize @bullet
18458 @item
18459 @samp{@var{Yes} or @var{Text}} is the default, which means to
18460 translate LF to/from CR/LF on Windows systems.
18462 @samp{@var{No}} disables this translation; i.e. it
18463 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
18464 may be used to create Unix-style files on
18465 Windows.
18467 @item
18468 @samp{@var{wtext}} translation enabled in Unicode mode.
18469 (corresponds to _O_WTEXT).
18471 @item
18472 @samp{@var{u8text}} translation enabled in Unicode UTF-8 mode.
18473 (corresponds to O_U8TEXT).
18475 @item
18476 @samp{@var{u16text}} translation enabled in Unicode UTF-16
18477 mode. (corresponds to_O_U16TEXT).
18479 @end itemize
18483 @node Shared Files
18484 @section Shared Files
18486 @noindent
18487 Section A.14 of the Ada Reference Manual allows implementations to
18488 provide a wide variety of behavior if an attempt is made to access the
18489 same external file with two or more internal files.
18491 To provide a full range of functionality, while at the same time
18492 minimizing the problems of portability caused by this implementation
18493 dependence, GNAT handles file sharing as follows:
18495 @itemize @bullet
18496 @item
18497 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
18498 to open two or more files with the same full name is considered an error
18499 and is not supported.  The exception @code{Use_Error} will be
18500 raised.  Note that a file that is not explicitly closed by the program
18501 remains open until the program terminates.
18503 @item
18504 If the form parameter @samp{shared=no} appears in the form string, the
18505 file can be opened or created with its own separate stream identifier,
18506 regardless of whether other files sharing the same external file are
18507 opened.  The exact effect depends on how the C stream routines handle
18508 multiple accesses to the same external files using separate streams.
18510 @item
18511 If the form parameter @samp{shared=yes} appears in the form string for
18512 each of two or more files opened using the same full name, the same
18513 stream is shared between these files, and the semantics are as described
18514 in Ada Reference Manual, Section A.14.
18515 @end itemize
18517 @noindent
18518 When a program that opens multiple files with the same name is ported
18519 from another Ada compiler to GNAT, the effect will be that
18520 @code{Use_Error} is raised.
18522 The documentation of the original compiler and the documentation of the
18523 program should then be examined to determine if file sharing was
18524 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
18525 and @code{Create} calls as required.
18527 When a program is ported from GNAT to some other Ada compiler, no
18528 special attention is required unless the @samp{shared=@var{xxx}} form
18529 parameter is used in the program.  In this case, you must examine the
18530 documentation of the new compiler to see if it supports the required
18531 file sharing semantics, and form strings modified appropriately.  Of
18532 course it may be the case that the program cannot be ported if the
18533 target compiler does not support the required functionality.  The best
18534 approach in writing portable code is to avoid file sharing (and hence
18535 the use of the @samp{shared=@var{xxx}} parameter in the form string)
18536 completely.
18538 One common use of file sharing in Ada 83 is the use of instantiations of
18539 Sequential_IO on the same file with different types, to achieve
18540 heterogeneous input-output.  Although this approach will work in GNAT if
18541 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
18542 for this purpose (using the stream attributes)
18544 @node Filenames encoding
18545 @section Filenames encoding
18547 @noindent
18548 An encoding form parameter can be used to specify the filename
18549 encoding @samp{encoding=@var{xxx}}.
18551 @itemize @bullet
18552 @item
18553 If the form parameter @samp{encoding=utf8} appears in the form string, the
18554 filename must be encoded in UTF-8.
18556 @item
18557 If the form parameter @samp{encoding=8bits} appears in the form
18558 string, the filename must be a standard 8bits string.
18559 @end itemize
18561 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
18562 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
18563 variable. And if not set @samp{utf8} is assumed.
18565 @table @samp
18566 @item CP_ACP
18567 The current system Windows ANSI code page.
18568 @item CP_UTF8
18569 UTF-8 encoding
18570 @end table
18572 This encoding form parameter is only supported on the Windows
18573 platform. On the other Operating Systems the run-time is supporting
18574 UTF-8 natively.
18576 @node File content encoding
18577 @section File content encoding
18579 @noindent
18580 For text files it is possible to specify the encoding to use. This is
18581 controlled by the by the @samp{GNAT_CCS_ENCODING} environment
18582 variable. And if not set @samp{TEXT} is assumed.
18584 The possible values are those supported on Windows:
18586 @table @samp
18587 @item TEXT
18588 Translated text mode
18589 @item WTEXT
18590 Translated unicode encoding
18591 @item U16TEXT
18592 Unicode 16-bit encoding
18593 @item U8TEXT
18594 Unicode 8-bit encoding
18595 @end table
18597 This encoding is only supported on the Windows platform.
18599 @node Open Modes
18600 @section Open Modes
18602 @noindent
18603 @code{Open} and @code{Create} calls result in a call to @code{fopen}
18604 using the mode shown in the following table:
18606 @sp 2
18607 @center @code{Open} and @code{Create} Call Modes
18608 @smallexample
18609                                @b{OPEN }           @b{CREATE}
18610 Append_File                    "r+"             "w+"
18611 In_File                        "r"              "w+"
18612 Out_File (Direct_IO)           "r+"             "w"
18613 Out_File (all other cases)     "w"              "w"
18614 Inout_File                     "r+"             "w+"
18615 @end smallexample
18617 @noindent
18618 If text file translation is required, then either @samp{b} or @samp{t}
18619 is added to the mode, depending on the setting of Text.  Text file
18620 translation refers to the mapping of CR/LF sequences in an external file
18621 to LF characters internally.  This mapping only occurs in DOS and
18622 DOS-like systems, and is not relevant to other systems.
18624 A special case occurs with Stream_IO@.  As shown in the above table, the
18625 file is initially opened in @samp{r} or @samp{w} mode for the
18626 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
18627 subsequently requires switching from reading to writing or vice-versa,
18628 then the file is reopened in @samp{r+} mode to permit the required operation.
18630 @node Operations on C Streams
18631 @section Operations on C Streams
18632 The package @code{Interfaces.C_Streams} provides an Ada program with direct
18633 access to the C library functions for operations on C streams:
18635 @smallexample @c adanocomment
18636 package Interfaces.C_Streams is
18637   -- Note: the reason we do not use the types that are in
18638   -- Interfaces.C is that we want to avoid dragging in the
18639   -- code in this unit if possible.
18640   subtype chars is System.Address;
18641   -- Pointer to null-terminated array of characters
18642   subtype FILEs is System.Address;
18643   -- Corresponds to the C type FILE*
18644   subtype voids is System.Address;
18645   -- Corresponds to the C type void*
18646   subtype int is Integer;
18647   subtype long is Long_Integer;
18648   -- Note: the above types are subtypes deliberately, and it
18649   -- is part of this spec that the above correspondences are
18650   -- guaranteed.  This means that it is legitimate to, for
18651   -- example, use Integer instead of int.  We provide these
18652   -- synonyms for clarity, but in some cases it may be
18653   -- convenient to use the underlying types (for example to
18654   -- avoid an unnecessary dependency of a spec on the spec
18655   -- of this unit).
18656   type size_t is mod 2 ** Standard'Address_Size;
18657   NULL_Stream : constant FILEs;
18658   -- Value returned (NULL in C) to indicate an
18659   -- fdopen/fopen/tmpfile error
18660   ----------------------------------
18661   -- Constants Defined in stdio.h --
18662   ----------------------------------
18663   EOF : constant int;
18664   -- Used by a number of routines to indicate error or
18665   -- end of file
18666   IOFBF : constant int;
18667   IOLBF : constant int;
18668   IONBF : constant int;
18669   -- Used to indicate buffering mode for setvbuf call
18670   SEEK_CUR : constant int;
18671   SEEK_END : constant int;
18672   SEEK_SET : constant int;
18673   -- Used to indicate origin for fseek call
18674   function stdin return FILEs;
18675   function stdout return FILEs;
18676   function stderr return FILEs;
18677   -- Streams associated with standard files
18678   --------------------------
18679   -- Standard C functions --
18680   --------------------------
18681   -- The functions selected below are ones that are
18682   -- available in UNIX (but not necessarily in ANSI C).
18683   -- These are very thin interfaces
18684   -- which copy exactly the C headers.  For more
18685   -- documentation on these functions, see the Microsoft C
18686   -- "Run-Time Library Reference" (Microsoft Press, 1990,
18687   -- ISBN 1-55615-225-6), which includes useful information
18688   -- on system compatibility.
18689   procedure clearerr (stream : FILEs);
18690   function fclose (stream : FILEs) return int;
18691   function fdopen (handle : int; mode : chars) return FILEs;
18692   function feof (stream : FILEs) return int;
18693   function ferror (stream : FILEs) return int;
18694   function fflush (stream : FILEs) return int;
18695   function fgetc (stream : FILEs) return int;
18696   function fgets (strng : chars; n : int; stream : FILEs)
18697       return chars;
18698   function fileno (stream : FILEs) return int;
18699   function fopen (filename : chars; Mode : chars)
18700       return FILEs;
18701   -- Note: to maintain target independence, use
18702   -- text_translation_required, a boolean variable defined in
18703   -- a-sysdep.c to deal with the target dependent text
18704   -- translation requirement.  If this variable is set,
18705   -- then  b/t should be appended to the standard mode
18706   -- argument to set the text translation mode off or on
18707   -- as required.
18708   function fputc (C : int; stream : FILEs) return int;
18709   function fputs (Strng : chars; Stream : FILEs) return int;
18710   function fread
18711      (buffer : voids;
18712       size : size_t;
18713       count : size_t;
18714       stream : FILEs)
18715       return size_t;
18716   function freopen
18717      (filename : chars;
18718       mode : chars;
18719       stream : FILEs)
18720       return FILEs;
18721   function fseek
18722      (stream : FILEs;
18723       offset : long;
18724       origin : int)
18725       return int;
18726   function ftell (stream : FILEs) return long;
18727   function fwrite
18728      (buffer : voids;
18729       size : size_t;
18730       count : size_t;
18731       stream : FILEs)
18732       return size_t;
18733   function isatty (handle : int) return int;
18734   procedure mktemp (template : chars);
18735   -- The return value (which is just a pointer to template)
18736   -- is discarded
18737   procedure rewind (stream : FILEs);
18738   function rmtmp return int;
18739   function setvbuf
18740      (stream : FILEs;
18741       buffer : chars;
18742       mode : int;
18743       size : size_t)
18744       return int;
18746   function tmpfile return FILEs;
18747   function ungetc (c : int; stream : FILEs) return int;
18748   function unlink (filename : chars) return int;
18749   ---------------------
18750   -- Extra functions --
18751   ---------------------
18752   -- These functions supply slightly thicker bindings than
18753   -- those above.  They are derived from functions in the
18754   -- C Run-Time Library, but may do a bit more work than
18755   -- just directly calling one of the Library functions.
18756   function is_regular_file (handle : int) return int;
18757   -- Tests if given handle is for a regular file (result 1)
18758   -- or for a non-regular file (pipe or device, result 0).
18759   ---------------------------------
18760   -- Control of Text/Binary Mode --
18761   ---------------------------------
18762   -- If text_translation_required is true, then the following
18763   -- functions may be used to dynamically switch a file from
18764   -- binary to text mode or vice versa.  These functions have
18765   -- no effect if text_translation_required is false (i.e.@: in
18766   -- normal UNIX mode).  Use fileno to get a stream handle.
18767   procedure set_binary_mode (handle : int);
18768   procedure set_text_mode (handle : int);
18769   ----------------------------
18770   -- Full Path Name support --
18771   ----------------------------
18772   procedure full_name (nam : chars; buffer : chars);
18773   -- Given a NUL terminated string representing a file
18774   -- name, returns in buffer a NUL terminated string
18775   -- representing the full path name for the file name.
18776   -- On systems where it is relevant the   drive is also
18777   -- part of the full path name.  It is the responsibility
18778   -- of the caller to pass an actual parameter for buffer
18779   -- that is big enough for any full path name.  Use
18780   -- max_path_len given below as the size of buffer.
18781   max_path_len : integer;
18782   -- Maximum length of an allowable full path name on the
18783   -- system, including a terminating NUL character.
18784 end Interfaces.C_Streams;
18785 @end smallexample
18787 @node Interfacing to C Streams
18788 @section Interfacing to C Streams
18790 @noindent
18791 The packages in this section permit interfacing Ada files to C Stream
18792 operations.
18794 @smallexample @c ada
18795  with Interfaces.C_Streams;
18796  package Ada.Sequential_IO.C_Streams is
18797     function C_Stream (F : File_Type)
18798        return Interfaces.C_Streams.FILEs;
18799     procedure Open
18800       (File : in out File_Type;
18801        Mode : in File_Mode;
18802        C_Stream : in Interfaces.C_Streams.FILEs;
18803        Form : in String := "");
18804  end Ada.Sequential_IO.C_Streams;
18806   with Interfaces.C_Streams;
18807   package Ada.Direct_IO.C_Streams is
18808      function C_Stream (F : File_Type)
18809         return Interfaces.C_Streams.FILEs;
18810      procedure Open
18811        (File : in out File_Type;
18812         Mode : in File_Mode;
18813         C_Stream : in Interfaces.C_Streams.FILEs;
18814         Form : in String := "");
18815   end Ada.Direct_IO.C_Streams;
18817   with Interfaces.C_Streams;
18818   package Ada.Text_IO.C_Streams is
18819      function C_Stream (F : File_Type)
18820         return Interfaces.C_Streams.FILEs;
18821      procedure Open
18822        (File : in out File_Type;
18823         Mode : in File_Mode;
18824         C_Stream : in Interfaces.C_Streams.FILEs;
18825         Form : in String := "");
18826   end Ada.Text_IO.C_Streams;
18828   with Interfaces.C_Streams;
18829   package Ada.Wide_Text_IO.C_Streams is
18830      function C_Stream (F : File_Type)
18831         return Interfaces.C_Streams.FILEs;
18832      procedure Open
18833        (File : in out File_Type;
18834         Mode : in File_Mode;
18835         C_Stream : in Interfaces.C_Streams.FILEs;
18836         Form : in String := "");
18837  end Ada.Wide_Text_IO.C_Streams;
18839   with Interfaces.C_Streams;
18840   package Ada.Wide_Wide_Text_IO.C_Streams is
18841      function C_Stream (F : File_Type)
18842         return Interfaces.C_Streams.FILEs;
18843      procedure Open
18844        (File : in out File_Type;
18845         Mode : in File_Mode;
18846         C_Stream : in Interfaces.C_Streams.FILEs;
18847         Form : in String := "");
18848  end Ada.Wide_Wide_Text_IO.C_Streams;
18850  with Interfaces.C_Streams;
18851  package Ada.Stream_IO.C_Streams is
18852     function C_Stream (F : File_Type)
18853        return Interfaces.C_Streams.FILEs;
18854     procedure Open
18855       (File : in out File_Type;
18856        Mode : in File_Mode;
18857        C_Stream : in Interfaces.C_Streams.FILEs;
18858        Form : in String := "");
18859  end Ada.Stream_IO.C_Streams;
18860 @end smallexample
18862 @noindent
18863 In each of these six packages, the @code{C_Stream} function obtains the
18864 @code{FILE} pointer from a currently opened Ada file.  It is then
18865 possible to use the @code{Interfaces.C_Streams} package to operate on
18866 this stream, or the stream can be passed to a C program which can
18867 operate on it directly.  Of course the program is responsible for
18868 ensuring that only appropriate sequences of operations are executed.
18870 One particular use of relevance to an Ada program is that the
18871 @code{setvbuf} function can be used to control the buffering of the
18872 stream used by an Ada file.  In the absence of such a call the standard
18873 default buffering is used.
18875 The @code{Open} procedures in these packages open a file giving an
18876 existing C Stream instead of a file name.  Typically this stream is
18877 imported from a C program, allowing an Ada file to operate on an
18878 existing C file.
18880 @node The GNAT Library
18881 @chapter The GNAT Library
18883 @noindent
18884 The GNAT library contains a number of general and special purpose packages.
18885 It represents functionality that the GNAT developers have found useful, and
18886 which is made available to GNAT users.  The packages described here are fully
18887 supported, and upwards compatibility will be maintained in future releases,
18888 so you can use these facilities with the confidence that the same functionality
18889 will be available in future releases.
18891 The chapter here simply gives a brief summary of the facilities available.
18892 The full documentation is found in the spec file for the package.  The full
18893 sources of these library packages, including both spec and body, are provided
18894 with all GNAT releases.  For example, to find out the full specifications of
18895 the SPITBOL pattern matching capability, including a full tutorial and
18896 extensive examples, look in the @file{g-spipat.ads} file in the library.
18898 For each entry here, the package name (as it would appear in a @code{with}
18899 clause) is given, followed by the name of the corresponding spec file in
18900 parentheses.  The packages are children in four hierarchies, @code{Ada},
18901 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
18902 GNAT-specific hierarchy.
18904 Note that an application program should only use packages in one of these
18905 four hierarchies if the package is defined in the Ada Reference Manual,
18906 or is listed in this section of the GNAT Programmers Reference Manual.
18907 All other units should be considered internal implementation units and
18908 should not be directly @code{with}'ed by application code.  The use of
18909 a @code{with} statement that references one of these internal implementation
18910 units makes an application potentially dependent on changes in versions
18911 of GNAT, and will generate a warning message.
18913 @menu
18914 * Ada.Characters.Latin_9 (a-chlat9.ads)::
18915 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
18916 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
18917 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
18918 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
18919 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
18920 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
18921 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
18922 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
18923 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
18924 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
18925 * Ada.Command_Line.Environment (a-colien.ads)::
18926 * Ada.Command_Line.Remove (a-colire.ads)::
18927 * Ada.Command_Line.Response_File (a-clrefi.ads)::
18928 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
18929 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
18930 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
18931 * Ada.Exceptions.Traceback (a-exctra.ads)::
18932 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
18933 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
18934 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
18935 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
18936 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
18937 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
18938 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
18939 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
18940 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
18941 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
18942 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
18943 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
18944 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
18945 * GNAT.Altivec (g-altive.ads)::
18946 * GNAT.Altivec.Conversions (g-altcon.ads)::
18947 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
18948 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
18949 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
18950 * GNAT.Array_Split (g-arrspl.ads)::
18951 * GNAT.AWK (g-awk.ads)::
18952 * GNAT.Bounded_Buffers (g-boubuf.ads)::
18953 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
18954 * GNAT.Bubble_Sort (g-bubsor.ads)::
18955 * GNAT.Bubble_Sort_A (g-busora.ads)::
18956 * GNAT.Bubble_Sort_G (g-busorg.ads)::
18957 * GNAT.Byte_Order_Mark (g-byorma.ads)::
18958 * GNAT.Byte_Swapping (g-bytswa.ads)::
18959 * GNAT.Calendar (g-calend.ads)::
18960 * GNAT.Calendar.Time_IO (g-catiio.ads)::
18961 * GNAT.Case_Util (g-casuti.ads)::
18962 * GNAT.CGI (g-cgi.ads)::
18963 * GNAT.CGI.Cookie (g-cgicoo.ads)::
18964 * GNAT.CGI.Debug (g-cgideb.ads)::
18965 * GNAT.Command_Line (g-comlin.ads)::
18966 * GNAT.Compiler_Version (g-comver.ads)::
18967 * GNAT.Ctrl_C (g-ctrl_c.ads)::
18968 * GNAT.CRC32 (g-crc32.ads)::
18969 * GNAT.Current_Exception (g-curexc.ads)::
18970 * GNAT.Debug_Pools (g-debpoo.ads)::
18971 * GNAT.Debug_Utilities (g-debuti.ads)::
18972 * GNAT.Decode_String (g-decstr.ads)::
18973 * GNAT.Decode_UTF8_String (g-deutst.ads)::
18974 * GNAT.Directory_Operations (g-dirope.ads)::
18975 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
18976 * GNAT.Dynamic_HTables (g-dynhta.ads)::
18977 * GNAT.Dynamic_Tables (g-dyntab.ads)::
18978 * GNAT.Encode_String (g-encstr.ads)::
18979 * GNAT.Encode_UTF8_String (g-enutst.ads)::
18980 * GNAT.Exception_Actions (g-excact.ads)::
18981 * GNAT.Exception_Traces (g-exctra.ads)::
18982 * GNAT.Exceptions (g-except.ads)::
18983 * GNAT.Expect (g-expect.ads)::
18984 * GNAT.Expect.TTY (g-exptty.ads)::
18985 * GNAT.Float_Control (g-flocon.ads)::
18986 * GNAT.Formatted_String (g-forstr.ads)::
18987 * GNAT.Heap_Sort (g-heasor.ads)::
18988 * GNAT.Heap_Sort_A (g-hesora.ads)::
18989 * GNAT.Heap_Sort_G (g-hesorg.ads)::
18990 * GNAT.HTable (g-htable.ads)::
18991 * GNAT.IO (g-io.ads)::
18992 * GNAT.IO_Aux (g-io_aux.ads)::
18993 * GNAT.Lock_Files (g-locfil.ads)::
18994 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
18995 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
18996 * GNAT.MD5 (g-md5.ads)::
18997 * GNAT.Memory_Dump (g-memdum.ads)::
18998 * GNAT.Most_Recent_Exception (g-moreex.ads)::
18999 * GNAT.OS_Lib (g-os_lib.ads)::
19000 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
19001 * GNAT.Random_Numbers (g-rannum.ads)::
19002 * GNAT.Regexp (g-regexp.ads)::
19003 * GNAT.Registry (g-regist.ads)::
19004 * GNAT.Regpat (g-regpat.ads)::
19005 * GNAT.Rewrite_Data (g-rewdat.ads)::
19006 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
19007 * GNAT.Semaphores (g-semaph.ads)::
19008 * GNAT.Serial_Communications (g-sercom.ads)::
19009 * GNAT.SHA1 (g-sha1.ads)::
19010 * GNAT.SHA224 (g-sha224.ads)::
19011 * GNAT.SHA256 (g-sha256.ads)::
19012 * GNAT.SHA384 (g-sha384.ads)::
19013 * GNAT.SHA512 (g-sha512.ads)::
19014 * GNAT.Signals (g-signal.ads)::
19015 * GNAT.Sockets (g-socket.ads)::
19016 * GNAT.Source_Info (g-souinf.ads)::
19017 * GNAT.Spelling_Checker (g-speche.ads)::
19018 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
19019 * GNAT.Spitbol.Patterns (g-spipat.ads)::
19020 * GNAT.Spitbol (g-spitbo.ads)::
19021 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
19022 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
19023 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
19024 * GNAT.SSE (g-sse.ads)::
19025 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
19026 * GNAT.Strings (g-string.ads)::
19027 * GNAT.String_Split (g-strspl.ads)::
19028 * GNAT.Table (g-table.ads)::
19029 * GNAT.Task_Lock (g-tasloc.ads)::
19030 * GNAT.Threads (g-thread.ads)::
19031 * GNAT.Time_Stamp (g-timsta.ads)::
19032 * GNAT.Traceback (g-traceb.ads)::
19033 * GNAT.Traceback.Symbolic (g-trasym.ads)::
19034 * GNAT.UTF_32 (g-utf_32.ads)::
19035 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
19036 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
19037 * GNAT.Wide_String_Split (g-wistsp.ads)::
19038 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
19039 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
19040 * Interfaces.C.Extensions (i-cexten.ads)::
19041 * Interfaces.C.Streams (i-cstrea.ads)::
19042 * Interfaces.Packed_Decimal (i-pacdec.ads)::
19043 * Interfaces.VxWorks (i-vxwork.ads)::
19044 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
19045 * System.Address_Image (s-addima.ads)::
19046 * System.Assertions (s-assert.ads)::
19047 * System.Memory (s-memory.ads)::
19048 * System.Multiprocessors (s-multip.ads)::
19049 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
19050 * System.Partition_Interface (s-parint.ads)::
19051 * System.Pool_Global (s-pooglo.ads)::
19052 * System.Pool_Local (s-pooloc.ads)::
19053 * System.Restrictions (s-restri.ads)::
19054 * System.Rident (s-rident.ads)::
19055 * System.Strings.Stream_Ops (s-ststop.ads)::
19056 * System.Unsigned_Types (s-unstyp.ads)::
19057 * System.Wch_Cnv (s-wchcnv.ads)::
19058 * System.Wch_Con (s-wchcon.ads)::
19059 @end menu
19061 @node Ada.Characters.Latin_9 (a-chlat9.ads)
19062 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
19063 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
19064 @cindex Latin_9 constants for Character
19066 @noindent
19067 This child of @code{Ada.Characters}
19068 provides a set of definitions corresponding to those in the
19069 RM-defined package @code{Ada.Characters.Latin_1} but with the
19070 few modifications required for @code{Latin-9}
19071 The provision of such a package
19072 is specifically authorized by the Ada Reference Manual
19073 (RM A.3.3(27)).
19075 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
19076 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
19077 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
19078 @cindex Latin_1 constants for Wide_Character
19080 @noindent
19081 This child of @code{Ada.Characters}
19082 provides a set of definitions corresponding to those in the
19083 RM-defined package @code{Ada.Characters.Latin_1} but with the
19084 types of the constants being @code{Wide_Character}
19085 instead of @code{Character}.  The provision of such a package
19086 is specifically authorized by the Ada Reference Manual
19087 (RM A.3.3(27)).
19089 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
19090 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
19091 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
19092 @cindex Latin_9 constants for Wide_Character
19094 @noindent
19095 This child of @code{Ada.Characters}
19096 provides a set of definitions corresponding to those in the
19097 GNAT defined package @code{Ada.Characters.Latin_9} but with the
19098 types of the constants being @code{Wide_Character}
19099 instead of @code{Character}.  The provision of such a package
19100 is specifically authorized by the Ada Reference Manual
19101 (RM A.3.3(27)).
19103 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
19104 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
19105 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
19106 @cindex Latin_1 constants for Wide_Wide_Character
19108 @noindent
19109 This child of @code{Ada.Characters}
19110 provides a set of definitions corresponding to those in the
19111 RM-defined package @code{Ada.Characters.Latin_1} but with the
19112 types of the constants being @code{Wide_Wide_Character}
19113 instead of @code{Character}.  The provision of such a package
19114 is specifically authorized by the Ada Reference Manual
19115 (RM A.3.3(27)).
19117 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
19118 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
19119 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
19120 @cindex Latin_9 constants for Wide_Wide_Character
19122 @noindent
19123 This child of @code{Ada.Characters}
19124 provides a set of definitions corresponding to those in the
19125 GNAT defined package @code{Ada.Characters.Latin_9} but with the
19126 types of the constants being @code{Wide_Wide_Character}
19127 instead of @code{Character}.  The provision of such a package
19128 is specifically authorized by the Ada Reference Manual
19129 (RM A.3.3(27)).
19131 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
19132 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
19133 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
19134 @cindex Formal container for doubly linked lists
19136 @noindent
19137 This child of @code{Ada.Containers} defines a modified version of the
19138 Ada 2005 container for doubly linked lists, meant to facilitate formal
19139 verification of code using such containers. The specification of this
19140 unit is compatible with SPARK 2014.
19142 Note that although this container was designed with formal verification
19143 in mind, it may well be generally useful in that it is a simplified more
19144 efficient version than the one defined in the standard. In particular it
19145 does not have the complex overhead required to detect cursor tampering.
19147 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
19148 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
19149 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
19150 @cindex Formal container for hashed maps
19152 @noindent
19153 This child of @code{Ada.Containers} defines a modified version of the
19154 Ada 2005 container for hashed maps, meant to facilitate formal
19155 verification of code using such containers. The specification of this
19156 unit is compatible with SPARK 2014.
19158 Note that although this container was designed with formal verification
19159 in mind, it may well be generally useful in that it is a simplified more
19160 efficient version than the one defined in the standard. In particular it
19161 does not have the complex overhead required to detect cursor tampering.
19163 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
19164 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
19165 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
19166 @cindex Formal container for hashed sets
19168 @noindent
19169 This child of @code{Ada.Containers} defines a modified version of the
19170 Ada 2005 container for hashed sets, meant to facilitate formal
19171 verification of code using such containers. The specification of this
19172 unit is compatible with SPARK 2014.
19174 Note that although this container was designed with formal verification
19175 in mind, it may well be generally useful in that it is a simplified more
19176 efficient version than the one defined in the standard. In particular it
19177 does not have the complex overhead required to detect cursor tampering.
19179 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
19180 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
19181 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
19182 @cindex Formal container for ordered maps
19184 @noindent
19185 This child of @code{Ada.Containers} defines a modified version of the
19186 Ada 2005 container for ordered maps, meant to facilitate formal
19187 verification of code using such containers. The specification of this
19188 unit is compatible with SPARK 2014.
19190 Note that although this container was designed with formal verification
19191 in mind, it may well be generally useful in that it is a simplified more
19192 efficient version than the one defined in the standard. In particular it
19193 does not have the complex overhead required to detect cursor tampering.
19195 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
19196 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
19197 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
19198 @cindex Formal container for ordered sets
19200 @noindent
19201 This child of @code{Ada.Containers} defines a modified version of the
19202 Ada 2005 container for ordered sets, meant to facilitate formal
19203 verification of code using such containers. The specification of this
19204 unit is compatible with SPARK 2014.
19206 Note that although this container was designed with formal verification
19207 in mind, it may well be generally useful in that it is a simplified more
19208 efficient version than the one defined in the standard. In particular it
19209 does not have the complex overhead required to detect cursor tampering.
19211 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
19212 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
19213 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
19214 @cindex Formal container for vectors
19216 @noindent
19217 This child of @code{Ada.Containers} defines a modified version of the
19218 Ada 2005 container for vectors, meant to facilitate formal
19219 verification of code using such containers. The specification of this
19220 unit is compatible with SPARK 2014.
19222 Note that although this container was designed with formal verification
19223 in mind, it may well be generally useful in that it is a simplified more
19224 efficient version than the one defined in the standard. In particular it
19225 does not have the complex overhead required to detect cursor tampering.
19227 @node Ada.Command_Line.Environment (a-colien.ads)
19228 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
19229 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
19230 @cindex Environment entries
19232 @noindent
19233 This child of @code{Ada.Command_Line}
19234 provides a mechanism for obtaining environment values on systems
19235 where this concept makes sense.
19237 @node Ada.Command_Line.Remove (a-colire.ads)
19238 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
19239 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
19240 @cindex Removing command line arguments
19241 @cindex Command line, argument removal
19243 @noindent
19244 This child of @code{Ada.Command_Line}
19245 provides a mechanism for logically removing
19246 arguments from the argument list.  Once removed, an argument is not visible
19247 to further calls on the subprograms in @code{Ada.Command_Line} will not
19248 see the removed argument.
19250 @node Ada.Command_Line.Response_File (a-clrefi.ads)
19251 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
19252 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
19253 @cindex Response file for command line
19254 @cindex Command line, response file
19255 @cindex Command line, handling long command lines
19257 @noindent
19258 This child of @code{Ada.Command_Line} provides a mechanism facilities for
19259 getting command line arguments from a text file, called a "response file".
19260 Using a response file allow passing a set of arguments to an executable longer
19261 than the maximum allowed by the system on the command line.
19263 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
19264 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
19265 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
19266 @cindex C Streams, Interfacing with Direct_IO
19268 @noindent
19269 This package provides subprograms that allow interfacing between
19270 C streams and @code{Direct_IO}.  The stream identifier can be
19271 extracted from a file opened on the Ada side, and an Ada file
19272 can be constructed from a stream opened on the C side.
19274 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
19275 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
19276 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
19277 @cindex Null_Occurrence, testing for
19279 @noindent
19280 This child subprogram provides a way of testing for the null
19281 exception occurrence (@code{Null_Occurrence}) without raising
19282 an exception.
19284 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
19285 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
19286 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
19287 @cindex Null_Occurrence, testing for
19289 @noindent
19290 This child subprogram is used for handling otherwise unhandled
19291 exceptions (hence the name last chance), and perform clean ups before
19292 terminating the program. Note that this subprogram never returns.
19294 @node Ada.Exceptions.Traceback (a-exctra.ads)
19295 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
19296 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
19297 @cindex Traceback for Exception Occurrence
19299 @noindent
19300 This child package provides the subprogram (@code{Tracebacks}) to
19301 give a traceback array of addresses based on an exception
19302 occurrence.
19304 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
19305 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
19306 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
19307 @cindex C Streams, Interfacing with Sequential_IO
19309 @noindent
19310 This package provides subprograms that allow interfacing between
19311 C streams and @code{Sequential_IO}.  The stream identifier can be
19312 extracted from a file opened on the Ada side, and an Ada file
19313 can be constructed from a stream opened on the C side.
19315 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
19316 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
19317 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
19318 @cindex C Streams, Interfacing with Stream_IO
19320 @noindent
19321 This package provides subprograms that allow interfacing between
19322 C streams and @code{Stream_IO}.  The stream identifier can be
19323 extracted from a file opened on the Ada side, and an Ada file
19324 can be constructed from a stream opened on the C side.
19326 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
19327 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
19328 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
19329 @cindex @code{Unbounded_String}, IO support
19330 @cindex @code{Text_IO}, extensions for unbounded strings
19332 @noindent
19333 This package provides subprograms for Text_IO for unbounded
19334 strings, avoiding the necessity for an intermediate operation
19335 with ordinary strings.
19337 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
19338 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
19339 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
19340 @cindex @code{Unbounded_Wide_String}, IO support
19341 @cindex @code{Text_IO}, extensions for unbounded wide strings
19343 @noindent
19344 This package provides subprograms for Text_IO for unbounded
19345 wide strings, avoiding the necessity for an intermediate operation
19346 with ordinary wide strings.
19348 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
19349 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
19350 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
19351 @cindex @code{Unbounded_Wide_Wide_String}, IO support
19352 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
19354 @noindent
19355 This package provides subprograms for Text_IO for unbounded
19356 wide wide strings, avoiding the necessity for an intermediate operation
19357 with ordinary wide wide strings.
19359 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
19360 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
19361 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
19362 @cindex C Streams, Interfacing with @code{Text_IO}
19364 @noindent
19365 This package provides subprograms that allow interfacing between
19366 C streams and @code{Text_IO}.  The stream identifier can be
19367 extracted from a file opened on the Ada side, and an Ada file
19368 can be constructed from a stream opened on the C side.
19370 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
19371 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
19372 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
19373 @cindex @code{Text_IO} resetting standard files
19375 @noindent
19376 This procedure is used to reset the status of the standard files used
19377 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
19378 embedded application) where the status of the files may change during
19379 execution (for example a standard input file may be redefined to be
19380 interactive).
19382 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
19383 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
19384 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
19385 @cindex Unicode categorization, Wide_Character
19387 @noindent
19388 This package provides subprograms that allow categorization of
19389 Wide_Character values according to Unicode categories.
19391 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
19392 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
19393 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
19394 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
19396 @noindent
19397 This package provides subprograms that allow interfacing between
19398 C streams and @code{Wide_Text_IO}.  The stream identifier can be
19399 extracted from a file opened on the Ada side, and an Ada file
19400 can be constructed from a stream opened on the C side.
19402 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
19403 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
19404 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
19405 @cindex @code{Wide_Text_IO} resetting standard files
19407 @noindent
19408 This procedure is used to reset the status of the standard files used
19409 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
19410 embedded application) where the status of the files may change during
19411 execution (for example a standard input file may be redefined to be
19412 interactive).
19414 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
19415 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
19416 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
19417 @cindex Unicode categorization, Wide_Wide_Character
19419 @noindent
19420 This package provides subprograms that allow categorization of
19421 Wide_Wide_Character values according to Unicode categories.
19423 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
19424 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
19425 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
19426 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
19428 @noindent
19429 This package provides subprograms that allow interfacing between
19430 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
19431 extracted from a file opened on the Ada side, and an Ada file
19432 can be constructed from a stream opened on the C side.
19434 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
19435 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
19436 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
19437 @cindex @code{Wide_Wide_Text_IO} resetting standard files
19439 @noindent
19440 This procedure is used to reset the status of the standard files used
19441 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
19442 restart in an embedded application) where the status of the files may
19443 change during execution (for example a standard input file may be
19444 redefined to be interactive).
19446 @node GNAT.Altivec (g-altive.ads)
19447 @section @code{GNAT.Altivec} (@file{g-altive.ads})
19448 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
19449 @cindex AltiVec
19451 @noindent
19452 This is the root package of the GNAT AltiVec binding. It provides
19453 definitions of constants and types common to all the versions of the
19454 binding.
19456 @node GNAT.Altivec.Conversions (g-altcon.ads)
19457 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
19458 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
19459 @cindex AltiVec
19461 @noindent
19462 This package provides the Vector/View conversion routines.
19464 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
19465 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
19466 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
19467 @cindex AltiVec
19469 @noindent
19470 This package exposes the Ada interface to the AltiVec operations on
19471 vector objects. A soft emulation is included by default in the GNAT
19472 library. The hard binding is provided as a separate package. This unit
19473 is common to both bindings.
19475 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
19476 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
19477 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
19478 @cindex AltiVec
19480 @noindent
19481 This package exposes the various vector types part of the Ada binding
19482 to AltiVec facilities.
19484 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
19485 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19486 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19487 @cindex AltiVec
19489 @noindent
19490 This package provides public 'View' data types from/to which private
19491 vector representations can be converted via
19492 GNAT.Altivec.Conversions. This allows convenient access to individual
19493 vector elements and provides a simple way to initialize vector
19494 objects.
19496 @node GNAT.Array_Split (g-arrspl.ads)
19497 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19498 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19499 @cindex Array splitter
19501 @noindent
19502 Useful array-manipulation routines: given a set of separators, split
19503 an array wherever the separators appear, and provide direct access
19504 to the resulting slices.
19506 @node GNAT.AWK (g-awk.ads)
19507 @section @code{GNAT.AWK} (@file{g-awk.ads})
19508 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
19509 @cindex Parsing
19510 @cindex AWK
19512 @noindent
19513 Provides AWK-like parsing functions, with an easy interface for parsing one
19514 or more files containing formatted data.  The file is viewed as a database
19515 where each record is a line and a field is a data element in this line.
19517 @node GNAT.Bounded_Buffers (g-boubuf.ads)
19518 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19519 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19520 @cindex Parsing
19521 @cindex Bounded Buffers
19523 @noindent
19524 Provides a concurrent generic bounded buffer abstraction.  Instances are
19525 useful directly or as parts of the implementations of other abstractions,
19526 such as mailboxes.
19528 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
19529 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19530 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19531 @cindex Parsing
19532 @cindex Mailboxes
19534 @noindent
19535 Provides a thread-safe asynchronous intertask mailbox communication facility.
19537 @node GNAT.Bubble_Sort (g-bubsor.ads)
19538 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19539 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19540 @cindex Sorting
19541 @cindex Bubble sort
19543 @noindent
19544 Provides a general implementation of bubble sort usable for sorting arbitrary
19545 data items.  Exchange and comparison procedures are provided by passing
19546 access-to-procedure values.
19548 @node GNAT.Bubble_Sort_A (g-busora.ads)
19549 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19550 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19551 @cindex Sorting
19552 @cindex Bubble sort
19554 @noindent
19555 Provides a general implementation of bubble sort usable for sorting arbitrary
19556 data items.  Move and comparison procedures are provided by passing
19557 access-to-procedure values. This is an older version, retained for
19558 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
19560 @node GNAT.Bubble_Sort_G (g-busorg.ads)
19561 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19562 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19563 @cindex Sorting
19564 @cindex Bubble sort
19566 @noindent
19567 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
19568 are provided as generic parameters, this improves efficiency, especially
19569 if the procedures can be inlined, at the expense of duplicating code for
19570 multiple instantiations.
19572 @node GNAT.Byte_Order_Mark (g-byorma.ads)
19573 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19574 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19575 @cindex UTF-8 representation
19576 @cindex Wide characte representations
19578 @noindent
19579 Provides a routine which given a string, reads the start of the string to
19580 see whether it is one of the standard byte order marks (BOM's) which signal
19581 the encoding of the string. The routine includes detection of special XML
19582 sequences for various UCS input formats.
19584 @node GNAT.Byte_Swapping (g-bytswa.ads)
19585 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19586 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19587 @cindex Byte swapping
19588 @cindex Endianness
19590 @noindent
19591 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
19592 Machine-specific implementations are available in some cases.
19594 @node GNAT.Calendar (g-calend.ads)
19595 @section @code{GNAT.Calendar} (@file{g-calend.ads})
19596 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
19597 @cindex @code{Calendar}
19599 @noindent
19600 Extends the facilities provided by @code{Ada.Calendar} to include handling
19601 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
19602 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
19603 C @code{timeval} format.
19605 @node GNAT.Calendar.Time_IO (g-catiio.ads)
19606 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19607 @cindex @code{Calendar}
19608 @cindex Time
19609 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19611 @node GNAT.Case_Util (g-casuti.ads)
19612 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
19613 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
19614 @cindex Casing utilities
19615 @cindex Character handling (@code{GNAT.Case_Util})
19617 @noindent
19618 A set of simple routines for handling upper and lower casing of strings
19619 without the overhead of the full casing tables
19620 in @code{Ada.Characters.Handling}.
19622 @node GNAT.CGI (g-cgi.ads)
19623 @section @code{GNAT.CGI} (@file{g-cgi.ads})
19624 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
19625 @cindex CGI (Common Gateway Interface)
19627 @noindent
19628 This is a package for interfacing a GNAT program with a Web server via the
19629 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
19630 parameters, which are a set of key/value pairs sent by the Web server.  It
19631 builds a table whose index is the key and provides some services to deal
19632 with this table.
19634 @node GNAT.CGI.Cookie (g-cgicoo.ads)
19635 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19636 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19637 @cindex CGI (Common Gateway Interface) cookie support
19638 @cindex Cookie support in CGI
19640 @noindent
19641 This is a package to interface a GNAT program with a Web server via the
19642 Common Gateway Interface (CGI).  It exports services to deal with Web
19643 cookies (piece of information kept in the Web client software).
19645 @node GNAT.CGI.Debug (g-cgideb.ads)
19646 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19647 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19648 @cindex CGI (Common Gateway Interface) debugging
19650 @noindent
19651 This is a package to help debugging CGI (Common Gateway Interface)
19652 programs written in Ada.
19654 @node GNAT.Command_Line (g-comlin.ads)
19655 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
19656 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
19657 @cindex Command line
19659 @noindent
19660 Provides a high level interface to @code{Ada.Command_Line} facilities,
19661 including the ability to scan for named switches with optional parameters
19662 and expand file names using wild card notations.
19664 @node GNAT.Compiler_Version (g-comver.ads)
19665 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19666 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19667 @cindex Compiler Version
19668 @cindex Version, of compiler
19670 @noindent
19671 Provides a routine for obtaining the version of the compiler used to
19672 compile the program. More accurately this is the version of the binder
19673 used to bind the program (this will normally be the same as the version
19674 of the compiler if a consistent tool set is used to compile all units
19675 of a partition).
19677 @node GNAT.Ctrl_C (g-ctrl_c.ads)
19678 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19679 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19680 @cindex Interrupt
19682 @noindent
19683 Provides a simple interface to handle Ctrl-C keyboard events.
19685 @node GNAT.CRC32 (g-crc32.ads)
19686 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
19687 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
19688 @cindex CRC32
19689 @cindex Cyclic Redundancy Check
19691 @noindent
19692 This package implements the CRC-32 algorithm.  For a full description
19693 of this algorithm see
19694 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
19695 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
19696 Aug.@: 1988.  Sarwate, D.V@.
19698 @node GNAT.Current_Exception (g-curexc.ads)
19699 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19700 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19701 @cindex Current exception
19702 @cindex Exception retrieval
19704 @noindent
19705 Provides access to information on the current exception that has been raised
19706 without the need for using the Ada 95 / Ada 2005 exception choice parameter
19707 specification syntax.
19708 This is particularly useful in simulating typical facilities for
19709 obtaining information about exceptions provided by Ada 83 compilers.
19711 @node GNAT.Debug_Pools (g-debpoo.ads)
19712 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19713 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19714 @cindex Debugging
19715 @cindex Debug pools
19716 @cindex Memory corruption debugging
19718 @noindent
19719 Provide a debugging storage pools that helps tracking memory corruption
19720 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
19721 @value{EDITION} User's Guide}.
19723 @node GNAT.Debug_Utilities (g-debuti.ads)
19724 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19725 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19726 @cindex Debugging
19728 @noindent
19729 Provides a few useful utilities for debugging purposes, including conversion
19730 to and from string images of address values. Supports both C and Ada formats
19731 for hexadecimal literals.
19733 @node GNAT.Decode_String (g-decstr.ads)
19734 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
19735 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
19736 @cindex Decoding strings
19737 @cindex String decoding
19738 @cindex Wide character encoding
19739 @cindex UTF-8
19740 @cindex Unicode
19742 @noindent
19743 A generic package providing routines for decoding wide character and wide wide
19744 character strings encoded as sequences of 8-bit characters using a specified
19745 encoding method. Includes validation routines, and also routines for stepping
19746 to next or previous encoded character in an encoded string.
19747 Useful in conjunction with Unicode character coding. Note there is a
19748 preinstantiation for UTF-8. See next entry.
19750 @node GNAT.Decode_UTF8_String (g-deutst.ads)
19751 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19752 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19753 @cindex Decoding strings
19754 @cindex Decoding UTF-8 strings
19755 @cindex UTF-8 string decoding
19756 @cindex Wide character decoding
19757 @cindex UTF-8
19758 @cindex Unicode
19760 @noindent
19761 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
19763 @node GNAT.Directory_Operations (g-dirope.ads)
19764 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19765 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19766 @cindex Directory operations
19768 @noindent
19769 Provides a set of routines for manipulating directories, including changing
19770 the current directory, making new directories, and scanning the files in a
19771 directory.
19773 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
19774 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19775 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19776 @cindex Directory operations iteration
19778 @noindent
19779 A child unit of GNAT.Directory_Operations providing additional operations
19780 for iterating through directories.
19782 @node GNAT.Dynamic_HTables (g-dynhta.ads)
19783 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19784 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19785 @cindex Hash tables
19787 @noindent
19788 A generic implementation of hash tables that can be used to hash arbitrary
19789 data.  Provided in two forms, a simple form with built in hash functions,
19790 and a more complex form in which the hash function is supplied.
19792 @noindent
19793 This package provides a facility similar to that of @code{GNAT.HTable},
19794 except that this package declares a type that can be used to define
19795 dynamic instances of the hash table, while an instantiation of
19796 @code{GNAT.HTable} creates a single instance of the hash table.
19798 @node GNAT.Dynamic_Tables (g-dyntab.ads)
19799 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19800 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19801 @cindex Table implementation
19802 @cindex Arrays, extendable
19804 @noindent
19805 A generic package providing a single dimension array abstraction where the
19806 length of the array can be dynamically modified.
19808 @noindent
19809 This package provides a facility similar to that of @code{GNAT.Table},
19810 except that this package declares a type that can be used to define
19811 dynamic instances of the table, while an instantiation of
19812 @code{GNAT.Table} creates a single instance of the table type.
19814 @node GNAT.Encode_String (g-encstr.ads)
19815 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
19816 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
19817 @cindex Encoding strings
19818 @cindex String encoding
19819 @cindex Wide character encoding
19820 @cindex UTF-8
19821 @cindex Unicode
19823 @noindent
19824 A generic package providing routines for encoding wide character and wide
19825 wide character strings as sequences of 8-bit characters using a specified
19826 encoding method. Useful in conjunction with Unicode character coding.
19827 Note there is a preinstantiation for UTF-8. See next entry.
19829 @node GNAT.Encode_UTF8_String (g-enutst.ads)
19830 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19831 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19832 @cindex Encoding strings
19833 @cindex Encoding UTF-8 strings
19834 @cindex UTF-8 string encoding
19835 @cindex Wide character encoding
19836 @cindex UTF-8
19837 @cindex Unicode
19839 @noindent
19840 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
19842 @node GNAT.Exception_Actions (g-excact.ads)
19843 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19844 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19845 @cindex Exception actions
19847 @noindent
19848 Provides callbacks when an exception is raised. Callbacks can be registered
19849 for specific exceptions, or when any exception is raised. This
19850 can be used for instance to force a core dump to ease debugging.
19852 @node GNAT.Exception_Traces (g-exctra.ads)
19853 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19854 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19855 @cindex Exception traces
19856 @cindex Debugging
19858 @noindent
19859 Provides an interface allowing to control automatic output upon exception
19860 occurrences.
19862 @node GNAT.Exceptions (g-except.ads)
19863 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
19864 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
19865 @cindex Exceptions, Pure
19866 @cindex Pure packages, exceptions
19868 @noindent
19869 Normally it is not possible to raise an exception with
19870 a message from a subprogram in a pure package, since the
19871 necessary types and subprograms are in @code{Ada.Exceptions}
19872 which is not a pure unit. @code{GNAT.Exceptions} provides a
19873 facility for getting around this limitation for a few
19874 predefined exceptions, and for example allow raising
19875 @code{Constraint_Error} with a message from a pure subprogram.
19877 @node GNAT.Expect (g-expect.ads)
19878 @section @code{GNAT.Expect} (@file{g-expect.ads})
19879 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
19881 @noindent
19882 Provides a set of subprograms similar to what is available
19883 with the standard Tcl Expect tool.
19884 It allows you to easily spawn and communicate with an external process.
19885 You can send commands or inputs to the process, and compare the output
19886 with some expected regular expression. Currently @code{GNAT.Expect}
19887 is implemented on all native GNAT ports except for OpenVMS@.
19888 It is not implemented for cross ports, and in particular is not
19889 implemented for VxWorks or LynxOS@.
19891 @node GNAT.Expect.TTY (g-exptty.ads)
19892 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
19893 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
19895 @noindent
19896 As GNAT.Expect but using pseudo-terminal.
19897 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
19898 ports except for OpenVMS@. It is not implemented for cross ports, and
19899 in particular is not implemented for VxWorks or LynxOS@.
19901 @node GNAT.Float_Control (g-flocon.ads)
19902 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
19903 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
19904 @cindex Floating-Point Processor
19906 @noindent
19907 Provides an interface for resetting the floating-point processor into the
19908 mode required for correct semantic operation in Ada.  Some third party
19909 library calls may cause this mode to be modified, and the Reset procedure
19910 in this package can be used to reestablish the required mode.
19912 @node GNAT.Formatted_String (g-forstr.ads)
19913 @section @code{GNAT.Formatted_String} (@file{g-forstr.ads})
19914 @cindex @code{GNAT.Formatted_String} (@file{g-forstr.ads})
19915 @cindex Formatted String
19917 @noindent
19918 Provides support for C/C++ printf() formatted strings. The format is
19919 copied from the printf() routine and should therefore gives identical
19920 output. Some generic routines are provided to be able to use types
19921 derived from Integer, Float or enumerations as values for the
19922 formatted string.
19924 @node GNAT.Heap_Sort (g-heasor.ads)
19925 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
19926 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
19927 @cindex Sorting
19929 @noindent
19930 Provides a general implementation of heap sort usable for sorting arbitrary
19931 data items. Exchange and comparison procedures are provided by passing
19932 access-to-procedure values.  The algorithm used is a modified heap sort
19933 that performs approximately N*log(N) comparisons in the worst case.
19935 @node GNAT.Heap_Sort_A (g-hesora.ads)
19936 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
19937 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
19938 @cindex Sorting
19940 @noindent
19941 Provides a general implementation of heap sort usable for sorting arbitrary
19942 data items. Move and comparison procedures are provided by passing
19943 access-to-procedure values.  The algorithm used is a modified heap sort
19944 that performs approximately N*log(N) comparisons in the worst case.
19945 This differs from @code{GNAT.Heap_Sort} in having a less convenient
19946 interface, but may be slightly more efficient.
19948 @node GNAT.Heap_Sort_G (g-hesorg.ads)
19949 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
19950 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
19951 @cindex Sorting
19953 @noindent
19954 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
19955 are provided as generic parameters, this improves efficiency, especially
19956 if the procedures can be inlined, at the expense of duplicating code for
19957 multiple instantiations.
19959 @node GNAT.HTable (g-htable.ads)
19960 @section @code{GNAT.HTable} (@file{g-htable.ads})
19961 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
19962 @cindex Hash tables
19964 @noindent
19965 A generic implementation of hash tables that can be used to hash arbitrary
19966 data.  Provides two approaches, one a simple static approach, and the other
19967 allowing arbitrary dynamic hash tables.
19969 @node GNAT.IO (g-io.ads)
19970 @section @code{GNAT.IO} (@file{g-io.ads})
19971 @cindex @code{GNAT.IO} (@file{g-io.ads})
19972 @cindex Simple I/O
19973 @cindex Input/Output facilities
19975 @noindent
19976 A simple preelaborable input-output package that provides a subset of
19977 simple Text_IO functions for reading characters and strings from
19978 Standard_Input, and writing characters, strings and integers to either
19979 Standard_Output or Standard_Error.
19981 @node GNAT.IO_Aux (g-io_aux.ads)
19982 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
19983 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
19984 @cindex Text_IO
19985 @cindex Input/Output facilities
19987 Provides some auxiliary functions for use with Text_IO, including a test
19988 for whether a file exists, and functions for reading a line of text.
19990 @node GNAT.Lock_Files (g-locfil.ads)
19991 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
19992 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
19993 @cindex File locking
19994 @cindex Locking using files
19996 @noindent
19997 Provides a general interface for using files as locks.  Can be used for
19998 providing program level synchronization.
20000 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
20001 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
20002 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
20003 @cindex Random number generation
20005 @noindent
20006 The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
20007 a modified version of the Blum-Blum-Shub generator.
20009 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
20010 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
20011 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
20012 @cindex Random number generation
20014 @noindent
20015 The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
20016 a modified version of the Blum-Blum-Shub generator.
20018 @node GNAT.MD5 (g-md5.ads)
20019 @section @code{GNAT.MD5} (@file{g-md5.ads})
20020 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
20021 @cindex Message Digest MD5
20023 @noindent
20024 Implements the MD5 Message-Digest Algorithm as described in RFC 1321, and
20025 the HMAC-MD5 message authentication function as described in RFC 2104 and
20026 FIPS PUB 198.
20028 @node GNAT.Memory_Dump (g-memdum.ads)
20029 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
20030 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
20031 @cindex Dump Memory
20033 @noindent
20034 Provides a convenient routine for dumping raw memory to either the
20035 standard output or standard error files. Uses GNAT.IO for actual
20036 output.
20038 @node GNAT.Most_Recent_Exception (g-moreex.ads)
20039 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
20040 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
20041 @cindex Exception, obtaining most recent
20043 @noindent
20044 Provides access to the most recently raised exception.  Can be used for
20045 various logging purposes, including duplicating functionality of some
20046 Ada 83 implementation dependent extensions.
20048 @node GNAT.OS_Lib (g-os_lib.ads)
20049 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
20050 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
20051 @cindex Operating System interface
20052 @cindex Spawn capability
20054 @noindent
20055 Provides a range of target independent operating system interface functions,
20056 including time/date management, file operations, subprocess management,
20057 including a portable spawn procedure, and access to environment variables
20058 and error return codes.
20060 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
20061 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
20062 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
20063 @cindex Hash functions
20065 @noindent
20066 Provides a generator of static minimal perfect hash functions. No
20067 collisions occur and each item can be retrieved from the table in one
20068 probe (perfect property). The hash table size corresponds to the exact
20069 size of the key set and no larger (minimal property). The key set has to
20070 be know in advance (static property). The hash functions are also order
20071 preserving. If w2 is inserted after w1 in the generator, their
20072 hashcode are in the same order. These hashing functions are very
20073 convenient for use with realtime applications.
20075 @node GNAT.Random_Numbers (g-rannum.ads)
20076 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
20077 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
20078 @cindex Random number generation
20080 @noindent
20081 Provides random number capabilities which extend those available in the
20082 standard Ada library and are more convenient to use.
20084 @node GNAT.Regexp (g-regexp.ads)
20085 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
20086 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
20087 @cindex Regular expressions
20088 @cindex Pattern matching
20090 @noindent
20091 A simple implementation of regular expressions, using a subset of regular
20092 expression syntax copied from familiar Unix style utilities.  This is the
20093 simplest of the three pattern matching packages provided, and is particularly
20094 suitable for ``file globbing'' applications.
20096 @node GNAT.Registry (g-regist.ads)
20097 @section @code{GNAT.Registry} (@file{g-regist.ads})
20098 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
20099 @cindex Windows Registry
20101 @noindent
20102 This is a high level binding to the Windows registry.  It is possible to
20103 do simple things like reading a key value, creating a new key.  For full
20104 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
20105 package provided with the Win32Ada binding
20107 @node GNAT.Regpat (g-regpat.ads)
20108 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
20109 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
20110 @cindex Regular expressions
20111 @cindex Pattern matching
20113 @noindent
20114 A complete implementation of Unix-style regular expression matching, copied
20115 from the original V7 style regular expression library written in C by
20116 Henry Spencer (and binary compatible with this C library).
20118 @node GNAT.Rewrite_Data (g-rewdat.ads)
20119 @section @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
20120 @cindex @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
20121 @cindex Rewrite data
20123 @noindent
20124 A unit to rewrite on-the-fly string occurrences in a stream of
20125 data. The implementation has a very minimal memory footprint as the
20126 full content to be processed is not loaded into memory all at once. This makes
20127 this interface usable for large files or socket streams.
20129 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
20130 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
20131 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
20132 @cindex Secondary Stack Info
20134 @noindent
20135 Provide the capability to query the high water mark of the current task's
20136 secondary stack.
20138 @node GNAT.Semaphores (g-semaph.ads)
20139 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
20140 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
20141 @cindex Semaphores
20143 @noindent
20144 Provides classic counting and binary semaphores using protected types.
20146 @node GNAT.Serial_Communications (g-sercom.ads)
20147 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
20148 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
20149 @cindex Serial_Communications
20151 @noindent
20152 Provides a simple interface to send and receive data over a serial
20153 port. This is only supported on GNU/Linux and Windows.
20155 @node GNAT.SHA1 (g-sha1.ads)
20156 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
20157 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
20158 @cindex Secure Hash Algorithm SHA-1
20160 @noindent
20161 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
20162 and RFC 3174, and the HMAC-SHA1 message authentication function as described
20163 in RFC 2104 and FIPS PUB 198.
20165 @node GNAT.SHA224 (g-sha224.ads)
20166 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
20167 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
20168 @cindex Secure Hash Algorithm SHA-224
20170 @noindent
20171 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3,
20172 and the HMAC-SHA224 message authentication function as described
20173 in RFC 2104 and FIPS PUB 198.
20175 @node GNAT.SHA256 (g-sha256.ads)
20176 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
20177 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
20178 @cindex Secure Hash Algorithm SHA-256
20180 @noindent
20181 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3,
20182 and the HMAC-SHA256 message authentication function as described
20183 in RFC 2104 and FIPS PUB 198.
20185 @node GNAT.SHA384 (g-sha384.ads)
20186 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
20187 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
20188 @cindex Secure Hash Algorithm SHA-384
20190 @noindent
20191 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3,
20192 and the HMAC-SHA384 message authentication function as described
20193 in RFC 2104 and FIPS PUB 198.
20195 @node GNAT.SHA512 (g-sha512.ads)
20196 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
20197 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
20198 @cindex Secure Hash Algorithm SHA-512
20200 @noindent
20201 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3,
20202 and the HMAC-SHA512 message authentication function as described
20203 in RFC 2104 and FIPS PUB 198.
20205 @node GNAT.Signals (g-signal.ads)
20206 @section @code{GNAT.Signals} (@file{g-signal.ads})
20207 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
20208 @cindex Signals
20210 @noindent
20211 Provides the ability to manipulate the blocked status of signals on supported
20212 targets.
20214 @node GNAT.Sockets (g-socket.ads)
20215 @section @code{GNAT.Sockets} (@file{g-socket.ads})
20216 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
20217 @cindex Sockets
20219 @noindent
20220 A high level and portable interface to develop sockets based applications.
20221 This package is based on the sockets thin binding found in
20222 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
20223 on all native GNAT ports except for OpenVMS@.  It is not implemented
20224 for the LynxOS@ cross port.
20226 @node GNAT.Source_Info (g-souinf.ads)
20227 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
20228 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
20229 @cindex Source Information
20231 @noindent
20232 Provides subprograms that give access to source code information known at
20233 compile time, such as the current file name and line number. Also provides
20234 subprograms yielding the date and time of the current compilation (like the
20235 C macros @code{__DATE__} and @code{__TIME__})
20237 @node GNAT.Spelling_Checker (g-speche.ads)
20238 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
20239 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
20240 @cindex Spell checking
20242 @noindent
20243 Provides a function for determining whether one string is a plausible
20244 near misspelling of another string.
20246 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
20247 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
20248 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
20249 @cindex Spell checking
20251 @noindent
20252 Provides a generic function that can be instantiated with a string type for
20253 determining whether one string is a plausible near misspelling of another
20254 string.
20256 @node GNAT.Spitbol.Patterns (g-spipat.ads)
20257 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
20258 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
20259 @cindex SPITBOL pattern matching
20260 @cindex Pattern matching
20262 @noindent
20263 A complete implementation of SNOBOL4 style pattern matching.  This is the
20264 most elaborate of the pattern matching packages provided.  It fully duplicates
20265 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
20266 efficient algorithm developed by Robert Dewar for the SPITBOL system.
20268 @node GNAT.Spitbol (g-spitbo.ads)
20269 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
20270 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
20271 @cindex SPITBOL interface
20273 @noindent
20274 The top level package of the collection of SPITBOL-style functionality, this
20275 package provides basic SNOBOL4 string manipulation functions, such as
20276 Pad, Reverse, Trim, Substr capability, as well as a generic table function
20277 useful for constructing arbitrary mappings from strings in the style of
20278 the SNOBOL4 TABLE function.
20280 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
20281 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
20282 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
20283 @cindex Sets of strings
20284 @cindex SPITBOL Tables
20286 @noindent
20287 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
20288 for type @code{Standard.Boolean}, giving an implementation of sets of
20289 string values.
20291 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
20292 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
20293 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
20294 @cindex Integer maps
20295 @cindex Maps
20296 @cindex SPITBOL Tables
20298 @noindent
20299 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
20300 for type @code{Standard.Integer}, giving an implementation of maps
20301 from string to integer values.
20303 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
20304 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
20305 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
20306 @cindex String maps
20307 @cindex Maps
20308 @cindex SPITBOL Tables
20310 @noindent
20311 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
20312 a variable length string type, giving an implementation of general
20313 maps from strings to strings.
20315 @node GNAT.SSE (g-sse.ads)
20316 @section @code{GNAT.SSE} (@file{g-sse.ads})
20317 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
20319 @noindent
20320 Root of a set of units aimed at offering Ada bindings to a subset of
20321 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
20322 targets.  It exposes vector component types together with a general
20323 introduction to the binding contents and use.
20325 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
20326 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
20327 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
20329 @noindent
20330 SSE vector types for use with SSE related intrinsics.
20332 @node GNAT.Strings (g-string.ads)
20333 @section @code{GNAT.Strings} (@file{g-string.ads})
20334 @cindex @code{GNAT.Strings} (@file{g-string.ads})
20336 @noindent
20337 Common String access types and related subprograms. Basically it
20338 defines a string access and an array of string access types.
20340 @node GNAT.String_Split (g-strspl.ads)
20341 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
20342 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
20343 @cindex String splitter
20345 @noindent
20346 Useful string manipulation routines: given a set of separators, split
20347 a string wherever the separators appear, and provide direct access
20348 to the resulting slices. This package is instantiated from
20349 @code{GNAT.Array_Split}.
20351 @node GNAT.Table (g-table.ads)
20352 @section @code{GNAT.Table} (@file{g-table.ads})
20353 @cindex @code{GNAT.Table} (@file{g-table.ads})
20354 @cindex Table implementation
20355 @cindex Arrays, extendable
20357 @noindent
20358 A generic package providing a single dimension array abstraction where the
20359 length of the array can be dynamically modified.
20361 @noindent
20362 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
20363 except that this package declares a single instance of the table type,
20364 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
20365 used to define dynamic instances of the table.
20367 @node GNAT.Task_Lock (g-tasloc.ads)
20368 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
20369 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
20370 @cindex Task synchronization
20371 @cindex Task locking
20372 @cindex Locking
20374 @noindent
20375 A very simple facility for locking and unlocking sections of code using a
20376 single global task lock.  Appropriate for use in situations where contention
20377 between tasks is very rarely expected.
20379 @node GNAT.Threads (g-thread.ads)
20380 @section @code{GNAT.Threads} (@file{g-thread.ads})
20381 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
20382 @cindex Foreign threads
20383 @cindex Threads, foreign
20385 @noindent
20386 Provides facilities for dealing with foreign threads which need to be known
20387 by the GNAT run-time system. Consult the documentation of this package for
20388 further details if your program has threads that are created by a non-Ada
20389 environment which then accesses Ada code.
20391 @node GNAT.Time_Stamp (g-timsta.ads)
20392 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
20393 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
20394 @cindex Time stamp
20395 @cindex Current time
20397 @noindent
20398 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
20399 represents the current date and time in ISO 8601 format. This is a very simple
20400 routine with minimal code and there are no dependencies on any other unit.
20402 @node GNAT.Traceback (g-traceb.ads)
20403 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
20404 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
20405 @cindex Trace back facilities
20407 @noindent
20408 Provides a facility for obtaining non-symbolic traceback information, useful
20409 in various debugging situations.
20411 @node GNAT.Traceback.Symbolic (g-trasym.ads)
20412 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
20413 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
20414 @cindex Trace back facilities
20416 @node GNAT.UTF_32 (g-utf_32.ads)
20417 @section @code{GNAT.UTF_32} (@file{g-table.ads})
20418 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
20419 @cindex Wide character codes
20421 @noindent
20422 This is a package intended to be used in conjunction with the
20423 @code{Wide_Character} type in Ada 95 and the
20424 @code{Wide_Wide_Character} type in Ada 2005 (available
20425 in @code{GNAT} in Ada 2005 mode). This package contains
20426 Unicode categorization routines, as well as lexical
20427 categorization routines corresponding to the Ada 2005
20428 lexical rules for identifiers and strings, and also a
20429 lower case to upper case fold routine corresponding to
20430 the Ada 2005 rules for identifier equivalence.
20432 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
20433 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
20434 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
20435 @cindex Spell checking
20437 @noindent
20438 Provides a function for determining whether one wide wide string is a plausible
20439 near misspelling of another wide wide string, where the strings are represented
20440 using the UTF_32_String type defined in System.Wch_Cnv.
20442 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
20443 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
20444 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
20445 @cindex Spell checking
20447 @noindent
20448 Provides a function for determining whether one wide string is a plausible
20449 near misspelling of another wide string.
20451 @node GNAT.Wide_String_Split (g-wistsp.ads)
20452 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
20453 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
20454 @cindex Wide_String splitter
20456 @noindent
20457 Useful wide string manipulation routines: given a set of separators, split
20458 a wide string wherever the separators appear, and provide direct access
20459 to the resulting slices. This package is instantiated from
20460 @code{GNAT.Array_Split}.
20462 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
20463 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
20464 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.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.
20471 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
20472 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
20473 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
20474 @cindex Wide_Wide_String splitter
20476 @noindent
20477 Useful wide wide string manipulation routines: given a set of separators, split
20478 a wide wide string wherever the separators appear, and provide direct access
20479 to the resulting slices. This package is instantiated from
20480 @code{GNAT.Array_Split}.
20482 @node Interfaces.C.Extensions (i-cexten.ads)
20483 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
20484 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
20486 @noindent
20487 This package contains additional C-related definitions, intended
20488 for use with either manually or automatically generated bindings
20489 to C libraries.
20491 @node Interfaces.C.Streams (i-cstrea.ads)
20492 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
20493 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
20494 @cindex  C streams, interfacing
20496 @noindent
20497 This package is a binding for the most commonly used operations
20498 on C streams.
20500 @node Interfaces.Packed_Decimal (i-pacdec.ads)
20501 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20502 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20503 @cindex  IBM Packed Format
20504 @cindex  Packed Decimal
20506 @noindent
20507 This package provides a set of routines for conversions to and
20508 from a packed decimal format compatible with that used on IBM
20509 mainframes.
20511 @node Interfaces.VxWorks (i-vxwork.ads)
20512 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20513 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20514 @cindex Interfacing to VxWorks
20515 @cindex VxWorks, interfacing
20517 @noindent
20518 This package provides a limited binding to the VxWorks API.
20519 In particular, it interfaces with the
20520 VxWorks hardware interrupt facilities.
20522 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
20523 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20524 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20525 @cindex Interfacing to VxWorks' I/O
20526 @cindex VxWorks, I/O interfacing
20527 @cindex VxWorks, Get_Immediate
20528 @cindex Get_Immediate, VxWorks
20530 @noindent
20531 This package provides a binding to the ioctl (IO/Control)
20532 function of VxWorks, defining a set of option values and
20533 function codes. A particular use of this package is
20534 to enable the use of Get_Immediate under VxWorks.
20536 @node System.Address_Image (s-addima.ads)
20537 @section @code{System.Address_Image} (@file{s-addima.ads})
20538 @cindex @code{System.Address_Image} (@file{s-addima.ads})
20539 @cindex Address image
20540 @cindex Image, of an address
20542 @noindent
20543 This function provides a useful debugging
20544 function that gives an (implementation dependent)
20545 string which identifies an address.
20547 @node System.Assertions (s-assert.ads)
20548 @section @code{System.Assertions} (@file{s-assert.ads})
20549 @cindex @code{System.Assertions} (@file{s-assert.ads})
20550 @cindex Assertions
20551 @cindex Assert_Failure, exception
20553 @noindent
20554 This package provides the declaration of the exception raised
20555 by an run-time assertion failure, as well as the routine that
20556 is used internally to raise this assertion.
20558 @node System.Memory (s-memory.ads)
20559 @section @code{System.Memory} (@file{s-memory.ads})
20560 @cindex @code{System.Memory} (@file{s-memory.ads})
20561 @cindex Memory allocation
20563 @noindent
20564 This package provides the interface to the low level routines used
20565 by the generated code for allocation and freeing storage for the
20566 default storage pool (analogous to the C routines malloc and free.
20567 It also provides a reallocation interface analogous to the C routine
20568 realloc. The body of this unit may be modified to provide alternative
20569 allocation mechanisms for the default pool, and in addition, direct
20570 calls to this unit may be made for low level allocation uses (for
20571 example see the body of @code{GNAT.Tables}).
20573 @node System.Multiprocessors (s-multip.ads)
20574 @section @code{System.Multiprocessors} (@file{s-multip.ads})
20575 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
20576 @cindex Multiprocessor interface
20577 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20578 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20579 technically an implementation-defined addition).
20581 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
20582 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20583 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20584 @cindex Multiprocessor interface
20585 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20586 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20587 technically an implementation-defined addition).
20589 @node System.Partition_Interface (s-parint.ads)
20590 @section @code{System.Partition_Interface} (@file{s-parint.ads})
20591 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
20592 @cindex Partition interfacing functions
20594 @noindent
20595 This package provides facilities for partition interfacing.  It
20596 is used primarily in a distribution context when using Annex E
20597 with @code{GLADE}.
20599 @node System.Pool_Global (s-pooglo.ads)
20600 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
20601 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
20602 @cindex Storage pool, global
20603 @cindex Global storage pool
20605 @noindent
20606 This package provides a storage pool that is equivalent to the default
20607 storage pool used for access types for which no pool is specifically
20608 declared. It uses malloc/free to allocate/free and does not attempt to
20609 do any automatic reclamation.
20611 @node System.Pool_Local (s-pooloc.ads)
20612 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
20613 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
20614 @cindex Storage pool, local
20615 @cindex Local storage pool
20617 @noindent
20618 This package provides a storage pool that is intended for use with locally
20619 defined access types. It uses malloc/free for allocate/free, and maintains
20620 a list of allocated blocks, so that all storage allocated for the pool can
20621 be freed automatically when the pool is finalized.
20623 @node System.Restrictions (s-restri.ads)
20624 @section @code{System.Restrictions} (@file{s-restri.ads})
20625 @cindex @code{System.Restrictions} (@file{s-restri.ads})
20626 @cindex Run-time restrictions access
20628 @noindent
20629 This package provides facilities for accessing at run time
20630 the status of restrictions specified at compile time for
20631 the partition. Information is available both with regard
20632 to actual restrictions specified, and with regard to
20633 compiler determined information on which restrictions
20634 are violated by one or more packages in the partition.
20636 @node System.Rident (s-rident.ads)
20637 @section @code{System.Rident} (@file{s-rident.ads})
20638 @cindex @code{System.Rident} (@file{s-rident.ads})
20639 @cindex Restrictions definitions
20641 @noindent
20642 This package provides definitions of the restrictions
20643 identifiers supported by GNAT, and also the format of
20644 the restrictions provided in package System.Restrictions.
20645 It is not normally necessary to @code{with} this generic package
20646 since the necessary instantiation is included in
20647 package System.Restrictions.
20649 @node System.Strings.Stream_Ops (s-ststop.ads)
20650 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20651 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20652 @cindex Stream operations
20653 @cindex String stream operations
20655 @noindent
20656 This package provides a set of stream subprograms for standard string types.
20657 It is intended primarily to support implicit use of such subprograms when
20658 stream attributes are applied to string types, but the subprograms in this
20659 package can be used directly by application programs.
20661 @node System.Unsigned_Types (s-unstyp.ads)
20662 @section @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20663 @cindex @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20665 @noindent
20666 This package contains definitions of standard unsigned types that
20667 correspond in size to the standard signed types declared in Standard,
20668 and (unlike the types in Interfaces) have corresponding names. It
20669 also contains some related definitions for other specialized types
20670 used by the compiler in connection with packed array types.
20672 @node System.Wch_Cnv (s-wchcnv.ads)
20673 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20674 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20675 @cindex Wide Character, Representation
20676 @cindex Wide String, Conversion
20677 @cindex Representation of wide characters
20679 @noindent
20680 This package provides routines for converting between
20681 wide and wide wide characters and a representation as a value of type
20682 @code{Standard.String}, using a specified wide character
20683 encoding method.  It uses definitions in
20684 package @code{System.Wch_Con}.
20686 @node System.Wch_Con (s-wchcon.ads)
20687 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
20688 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
20690 @noindent
20691 This package provides definitions and descriptions of
20692 the various methods used for encoding wide characters
20693 in ordinary strings.  These definitions are used by
20694 the package @code{System.Wch_Cnv}.
20696 @node Interfacing to Other Languages
20697 @chapter Interfacing to Other Languages
20698 @noindent
20699 The facilities in annex B of the Ada Reference Manual are fully
20700 implemented in GNAT, and in addition, a full interface to C++ is
20701 provided.
20703 @menu
20704 * Interfacing to C::
20705 * Interfacing to C++::
20706 * Interfacing to COBOL::
20707 * Interfacing to Fortran::
20708 * Interfacing to non-GNAT Ada code::
20709 @end menu
20711 @node Interfacing to C
20712 @section Interfacing to C
20714 @noindent
20715 Interfacing to C with GNAT can use one of two approaches:
20717 @itemize @bullet
20718 @item
20719 The types in the package @code{Interfaces.C} may be used.
20720 @item
20721 Standard Ada types may be used directly.  This may be less portable to
20722 other compilers, but will work on all GNAT compilers, which guarantee
20723 correspondence between the C and Ada types.
20724 @end itemize
20726 @noindent
20727 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
20728 effect, since this is the default.  The following table shows the
20729 correspondence between Ada scalar types and the corresponding C types.
20731 @table @code
20732 @item Integer
20733 @code{int}
20734 @item Short_Integer
20735 @code{short}
20736 @item Short_Short_Integer
20737 @code{signed char}
20738 @item Long_Integer
20739 @code{long}
20740 @item Long_Long_Integer
20741 @code{long long}
20742 @item Short_Float
20743 @code{float}
20744 @item Float
20745 @code{float}
20746 @item Long_Float
20747 @code{double}
20748 @item Long_Long_Float
20749 This is the longest floating-point type supported by the hardware.
20750 @end table
20752 @noindent
20753 Additionally, there are the following general correspondences between Ada
20754 and C types:
20755 @itemize @bullet
20756 @item
20757 Ada enumeration types map to C enumeration types directly if pragma
20758 @code{Convention C} is specified, which causes them to have int
20759 length.  Without pragma @code{Convention C}, Ada enumeration types map to
20760 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
20761 @code{int}, respectively) depending on the number of values passed.
20762 This is the only case in which pragma @code{Convention C} affects the
20763 representation of an Ada type.
20765 @item
20766 Ada access types map to C pointers, except for the case of pointers to
20767 unconstrained types in Ada, which have no direct C equivalent.
20769 @item
20770 Ada arrays map directly to C arrays.
20772 @item
20773 Ada records map directly to C structures.
20775 @item
20776 Packed Ada records map to C structures where all members are bit fields
20777 of the length corresponding to the @code{@var{type}'Size} value in Ada.
20778 @end itemize
20780 @node Interfacing to C++
20781 @section Interfacing to C++
20783 @noindent
20784 The interface to C++ makes use of the following pragmas, which are
20785 primarily intended to be constructed automatically using a binding generator
20786 tool, although it is possible to construct them by hand.
20788 Using these pragmas it is possible to achieve complete
20789 inter-operability between Ada tagged types and C++ class definitions.
20790 See @ref{Implementation Defined Pragmas}, for more details.
20792 @table @code
20793 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
20794 The argument denotes an entity in the current declarative region that is
20795 declared as a tagged or untagged record type. It indicates that the type
20796 corresponds to an externally declared C++ class type, and is to be laid
20797 out the same way that C++ would lay out the type.
20799 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
20800 for backward compatibility but its functionality is available
20801 using pragma @code{Import} with @code{Convention} = @code{CPP}.
20803 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
20804 This pragma identifies an imported function (imported in the usual way
20805 with pragma @code{Import}) as corresponding to a C++ constructor.
20806 @end table
20808 A few restrictions are placed on the use of the @code{Access} attribute
20809 in conjunction with subprograms subject to convention @code{CPP}: the
20810 attribute may be used neither on primitive operations of a tagged
20811 record type with convention @code{CPP}, imported or not, nor on
20812 subprograms imported with pragma @code{CPP_Constructor}.
20814 In addition, C++ exceptions are propagated and can be handled in an
20815 @code{others} choice of an exception handler. The corresponding Ada
20816 occurrence has no message, and the simple name of the exception identity
20817 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
20818 tasks works properly when such foreign exceptions are propagated.
20820 It is also possible to import a C++ exception using the following syntax:
20822 @smallexample @c ada
20823 LOCAL_NAME : exception;
20824 pragma Import (Cpp,
20825   [Entity =>] LOCAL_NAME,
20826   [External_Name =>] static_string_EXPRESSION);
20827 @end smallexample
20829 @noindent
20830 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
20831 cover a specific C++ exception in an exception handler.
20833 @node Interfacing to COBOL
20834 @section Interfacing to COBOL
20836 @noindent
20837 Interfacing to COBOL is achieved as described in section B.4 of
20838 the Ada Reference Manual.
20840 @node Interfacing to Fortran
20841 @section Interfacing to Fortran
20843 @noindent
20844 Interfacing to Fortran is achieved as described in section B.5 of the
20845 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
20846 multi-dimensional array causes the array to be stored in column-major
20847 order as required for convenient interface to Fortran.
20849 @node Interfacing to non-GNAT Ada code
20850 @section Interfacing to non-GNAT Ada code
20852 It is possible to specify the convention @code{Ada} in a pragma
20853 @code{Import} or pragma @code{Export}.  However this refers to
20854 the calling conventions used by GNAT, which may or may not be
20855 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
20856 compiler to allow interoperation.
20858 If arguments types are kept simple, and if the foreign compiler generally
20859 follows system calling conventions, then it may be possible to integrate
20860 files compiled by other Ada compilers, provided that the elaboration
20861 issues are adequately addressed (for example by eliminating the
20862 need for any load time elaboration).
20864 In particular, GNAT running on VMS is designed to
20865 be highly compatible with the DEC Ada 83 compiler, so this is one
20866 case in which it is possible to import foreign units of this type,
20867 provided that the data items passed are restricted to simple scalar
20868 values or simple record types without variants, or simple array
20869 types with fixed bounds.
20871 @node Specialized Needs Annexes
20872 @chapter Specialized Needs Annexes
20874 @noindent
20875 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
20876 required in all implementations.  However, as described in this chapter,
20877 GNAT implements all of these annexes:
20879 @table @asis
20880 @item Systems Programming (Annex C)
20881 The Systems Programming Annex is fully implemented.
20883 @item Real-Time Systems (Annex D)
20884 The Real-Time Systems Annex is fully implemented.
20886 @item Distributed Systems (Annex E)
20887 Stub generation is fully implemented in the GNAT compiler.  In addition,
20888 a complete compatible PCS is available as part of the GLADE system,
20889 a separate product.  When the two
20890 products are used in conjunction, this annex is fully implemented.
20892 @item Information Systems (Annex F)
20893 The Information Systems annex is fully implemented.
20895 @item Numerics (Annex G)
20896 The Numerics Annex is fully implemented.
20898 @item Safety and Security / High-Integrity Systems (Annex H)
20899 The Safety and Security Annex (termed the High-Integrity Systems Annex
20900 in Ada 2005) is fully implemented.
20901 @end table
20903 @node Implementation of Specific Ada Features
20904 @chapter Implementation of Specific Ada Features
20906 @noindent
20907 This chapter describes the GNAT implementation of several Ada language
20908 facilities.
20910 @menu
20911 * Machine Code Insertions::
20912 * GNAT Implementation of Tasking::
20913 * GNAT Implementation of Shared Passive Packages::
20914 * Code Generation for Array Aggregates::
20915 * The Size of Discriminated Records with Default Discriminants::
20916 * Strict Conformance to the Ada Reference Manual::
20917 @end menu
20919 @node Machine Code Insertions
20920 @section Machine Code Insertions
20921 @cindex Machine Code insertions
20923 @noindent
20924 Package @code{Machine_Code} provides machine code support as described
20925 in the Ada Reference Manual in two separate forms:
20926 @itemize @bullet
20927 @item
20928 Machine code statements, consisting of qualified expressions that
20929 fit the requirements of RM section 13.8.
20930 @item
20931 An intrinsic callable procedure, providing an alternative mechanism of
20932 including machine instructions in a subprogram.
20933 @end itemize
20935 @noindent
20936 The two features are similar, and both are closely related to the mechanism
20937 provided by the asm instruction in the GNU C compiler.  Full understanding
20938 and use of the facilities in this package requires understanding the asm
20939 instruction, see @ref{Extended Asm,,, gcc, Using the GNU Compiler
20940 Collection (GCC)}.
20942 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
20943 semantic restrictions and effects as described below.  Both are provided so
20944 that the procedure call can be used as a statement, and the function call
20945 can be used to form a code_statement.
20947 Consider this C @code{asm} instruction:
20948 @smallexample
20949    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
20950 @end smallexample
20952 @noindent
20953 The equivalent can be written for GNAT as:
20955 @smallexample @c ada
20956 Asm ("fsinx %1 %0",
20957      My_Float'Asm_Output ("=f", result),
20958      My_Float'Asm_Input  ("f",  angle));
20959 @end smallexample
20961 @noindent
20962 The first argument to @code{Asm} is the assembler template, and is
20963 identical to what is used in GNU C@.  This string must be a static
20964 expression.  The second argument is the output operand list.  It is
20965 either a single @code{Asm_Output} attribute reference, or a list of such
20966 references enclosed in parentheses (technically an array aggregate of
20967 such references).
20969 The @code{Asm_Output} attribute denotes a function that takes two
20970 parameters.  The first is a string, the second is the name of a variable
20971 of the type designated by the attribute prefix.  The first (string)
20972 argument is required to be a static expression and designates the
20973 constraint (@pxref{Constraints,,, gcc, Using the GNU Compiler
20974 Collection (GCC)})
20975 for the parameter (e.g.@: what kind of register is required).  The second
20976 argument is the variable to be written or updated with the
20977 result.  The possible values for constraint are the same as those used in
20978 the RTL, and are dependent on the configuration file used to build the
20979 GCC back end.  If there are no output operands, then this argument may
20980 either be omitted, or explicitly given as @code{No_Output_Operands}.
20981 No support is provided for GNU C's symbolic names for output parameters.
20983 The second argument of @code{@var{my_float}'Asm_Output} functions as
20984 though it were an @code{out} parameter, which is a little curious, but
20985 all names have the form of expressions, so there is no syntactic
20986 irregularity, even though normally functions would not be permitted
20987 @code{out} parameters.  The third argument is the list of input
20988 operands.  It is either a single @code{Asm_Input} attribute reference, or
20989 a list of such references enclosed in parentheses (technically an array
20990 aggregate of such references).
20992 The @code{Asm_Input} attribute denotes a function that takes two
20993 parameters.  The first is a string, the second is an expression of the
20994 type designated by the prefix.  The first (string) argument is required
20995 to be a static expression, and is the constraint for the parameter,
20996 (e.g.@: what kind of register is required).  The second argument is the
20997 value to be used as the input argument.  The possible values for the
20998 constraint are the same as those used in the RTL, and are dependent on
20999 the configuration file used to built the GCC back end.
21000 No support is provided for GNU C's symbolic names for input parameters.
21002 If there are no input operands, this argument may either be omitted, or
21003 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
21004 present in the above example, is a list of register names, called the
21005 @dfn{clobber} argument.  This argument, if given, must be a static string
21006 expression, and is a space or comma separated list of names of registers
21007 that must be considered destroyed as a result of the @code{Asm} call.  If
21008 this argument is the null string (the default value), then the code
21009 generator assumes that no additional registers are destroyed.
21010 In addition to registers, the special clobbers @code{memory} and
21011 @code{cc} as described in the GNU C docs are both supported.
21013 The fifth argument, not present in the above example, called the
21014 @dfn{volatile} argument, is by default @code{False}.  It can be set to
21015 the literal value @code{True} to indicate to the code generator that all
21016 optimizations with respect to the instruction specified should be
21017 suppressed, and in particular an instruction that has outputs
21018 will still be generated, even if none of the outputs are
21019 used.  @xref{Volatile,,,
21020 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
21021 Generally it is strongly advisable to use Volatile for any ASM statement
21022 that is missing either input or output operands or to avoid unwanted
21023 optimizations. A warning is generated if this advice is not followed.
21025 No support is provided for GNU C's @code{asm goto} feature.
21027 The @code{Asm} subprograms may be used in two ways.  First the procedure
21028 forms can be used anywhere a procedure call would be valid, and
21029 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
21030 be used to intersperse machine instructions with other Ada statements.
21031 Second, the function forms, which return a dummy value of the limited
21032 private type @code{Asm_Insn}, can be used in code statements, and indeed
21033 this is the only context where such calls are allowed.  Code statements
21034 appear as aggregates of the form:
21036 @smallexample @c ada
21037 Asm_Insn'(Asm (@dots{}));
21038 Asm_Insn'(Asm_Volatile (@dots{}));
21039 @end smallexample
21041 @noindent
21042 In accordance with RM rules, such code statements are allowed only
21043 within subprograms whose entire body consists of such statements.  It is
21044 not permissible to intermix such statements with other Ada statements.
21046 Typically the form using intrinsic procedure calls is more convenient
21047 and more flexible.  The code statement form is provided to meet the RM
21048 suggestion that such a facility should be made available.  The following
21049 is the exact syntax of the call to @code{Asm}. As usual, if named notation
21050 is used, the arguments may be given in arbitrary order, following the
21051 normal rules for use of positional and named arguments:
21053 @smallexample
21054 ASM_CALL ::= Asm (
21055                  [Template =>] static_string_EXPRESSION
21056                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
21057                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
21058                [,[Clobber  =>] static_string_EXPRESSION ]
21059                [,[Volatile =>] static_boolean_EXPRESSION] )
21061 OUTPUT_OPERAND_LIST ::=
21062   [PREFIX.]No_Output_Operands
21063 | OUTPUT_OPERAND_ATTRIBUTE
21064 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
21066 OUTPUT_OPERAND_ATTRIBUTE ::=
21067   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
21069 INPUT_OPERAND_LIST ::=
21070   [PREFIX.]No_Input_Operands
21071 | INPUT_OPERAND_ATTRIBUTE
21072 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
21074 INPUT_OPERAND_ATTRIBUTE ::=
21075   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
21076 @end smallexample
21078 @noindent
21079 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
21080 are declared in the package @code{Machine_Code} and must be referenced
21081 according to normal visibility rules. In particular if there is no
21082 @code{use} clause for this package, then appropriate package name
21083 qualification is required.
21085 @node GNAT Implementation of Tasking
21086 @section GNAT Implementation of Tasking
21088 @noindent
21089 This chapter outlines the basic GNAT approach to tasking (in particular,
21090 a multi-layered library for portability) and discusses issues related
21091 to compliance with the Real-Time Systems Annex.
21093 @menu
21094 * Mapping Ada Tasks onto the Underlying Kernel Threads::
21095 * Ensuring Compliance with the Real-Time Annex::
21096 @end menu
21098 @node Mapping Ada Tasks onto the Underlying Kernel Threads
21099 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
21101 @noindent
21102 GNAT's run-time support comprises two layers:
21104 @itemize @bullet
21105 @item GNARL (GNAT Run-time Layer)
21106 @item GNULL (GNAT Low-level Library)
21107 @end itemize
21109 @noindent
21110 In GNAT, Ada's tasking services rely on a platform and OS independent
21111 layer known as GNARL@.  This code is responsible for implementing the
21112 correct semantics of Ada's task creation, rendezvous, protected
21113 operations etc.
21115 GNARL decomposes Ada's tasking semantics into simpler lower level
21116 operations such as create a thread, set the priority of a thread,
21117 yield, create a lock, lock/unlock, etc.  The spec for these low-level
21118 operations constitutes GNULLI, the GNULL Interface.  This interface is
21119 directly inspired from the POSIX real-time API@.
21121 If the underlying executive or OS implements the POSIX standard
21122 faithfully, the GNULL Interface maps as is to the services offered by
21123 the underlying kernel.  Otherwise, some target dependent glue code maps
21124 the services offered by the underlying kernel to the semantics expected
21125 by GNARL@.
21127 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
21128 key point is that each Ada task is mapped on a thread in the underlying
21129 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
21131 In addition Ada task priorities map onto the underlying thread priorities.
21132 Mapping Ada tasks onto the underlying kernel threads has several advantages:
21134 @itemize @bullet
21135 @item
21136 The underlying scheduler is used to schedule the Ada tasks.  This
21137 makes Ada tasks as efficient as kernel threads from a scheduling
21138 standpoint.
21140 @item
21141 Interaction with code written in C containing threads is eased
21142 since at the lowest level Ada tasks and C threads map onto the same
21143 underlying kernel concept.
21145 @item
21146 When an Ada task is blocked during I/O the remaining Ada tasks are
21147 able to proceed.
21149 @item
21150 On multiprocessor systems Ada tasks can execute in parallel.
21151 @end itemize
21153 @noindent
21154 Some threads libraries offer a mechanism to fork a new process, with the
21155 child process duplicating the threads from the parent.
21156 GNAT does not
21157 support this functionality when the parent contains more than one task.
21158 @cindex Forking a new process
21160 @node Ensuring Compliance with the Real-Time Annex
21161 @subsection Ensuring Compliance with the Real-Time Annex
21162 @cindex Real-Time Systems Annex compliance
21164 @noindent
21165 Although mapping Ada tasks onto
21166 the underlying threads has significant advantages, it does create some
21167 complications when it comes to respecting the scheduling semantics
21168 specified in the real-time annex (Annex D).
21170 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
21171 scheduling policy states:
21173 @quotation
21174 @emph{When the active priority of a ready task that is not running
21175 changes, or the setting of its base priority takes effect, the
21176 task is removed from the ready queue for its old active priority
21177 and is added at the tail of the ready queue for its new active
21178 priority, except in the case where the active priority is lowered
21179 due to the loss of inherited priority, in which case the task is
21180 added at the head of the ready queue for its new active priority.}
21181 @end quotation
21183 @noindent
21184 While most kernels do put tasks at the end of the priority queue when
21185 a task changes its priority, (which respects the main
21186 FIFO_Within_Priorities requirement), almost none keep a thread at the
21187 beginning of its priority queue when its priority drops from the loss
21188 of inherited priority.
21190 As a result most vendors have provided incomplete Annex D implementations.
21192 The GNAT run-time, has a nice cooperative solution to this problem
21193 which ensures that accurate FIFO_Within_Priorities semantics are
21194 respected.
21196 The principle is as follows.  When an Ada task T is about to start
21197 running, it checks whether some other Ada task R with the same
21198 priority as T has been suspended due to the loss of priority
21199 inheritance.  If this is the case, T yields and is placed at the end of
21200 its priority queue.  When R arrives at the front of the queue it
21201 executes.
21203 Note that this simple scheme preserves the relative order of the tasks
21204 that were ready to execute in the priority queue where R has been
21205 placed at the end.
21207 @node GNAT Implementation of Shared Passive Packages
21208 @section GNAT Implementation of Shared Passive Packages
21209 @cindex Shared passive packages
21211 @noindent
21212 GNAT fully implements the pragma @code{Shared_Passive} for
21213 @cindex pragma @code{Shared_Passive}
21214 the purpose of designating shared passive packages.
21215 This allows the use of passive partitions in the
21216 context described in the Ada Reference Manual; i.e., for communication
21217 between separate partitions of a distributed application using the
21218 features in Annex E.
21219 @cindex Annex E
21220 @cindex Distribution Systems Annex
21222 However, the implementation approach used by GNAT provides for more
21223 extensive usage as follows:
21225 @table @emph
21226 @item Communication between separate programs
21228 This allows separate programs to access the data in passive
21229 partitions, using protected objects for synchronization where
21230 needed. The only requirement is that the two programs have a
21231 common shared file system. It is even possible for programs
21232 running on different machines with different architectures
21233 (e.g.@: different endianness) to communicate via the data in
21234 a passive partition.
21236 @item Persistence between program runs
21238 The data in a passive package can persist from one run of a
21239 program to another, so that a later program sees the final
21240 values stored by a previous run of the same program.
21242 @end table
21244 @noindent
21245 The implementation approach used is to store the data in files. A
21246 separate stream file is created for each object in the package, and
21247 an access to an object causes the corresponding file to be read or
21248 written.
21250 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
21251 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
21252 set to the directory to be used for these files.
21253 The files in this directory
21254 have names that correspond to their fully qualified names. For
21255 example, if we have the package
21257 @smallexample @c ada
21258 package X is
21259   pragma Shared_Passive (X);
21260   Y : Integer;
21261   Z : Float;
21262 end X;
21263 @end smallexample
21265 @noindent
21266 and the environment variable is set to @code{/stemp/}, then the files created
21267 will have the names:
21269 @smallexample
21270 /stemp/x.y
21271 /stemp/x.z
21272 @end smallexample
21274 @noindent
21275 These files are created when a value is initially written to the object, and
21276 the files are retained until manually deleted. This provides the persistence
21277 semantics. If no file exists, it means that no partition has assigned a value
21278 to the variable; in this case the initial value declared in the package
21279 will be used. This model ensures that there are no issues in synchronizing
21280 the elaboration process, since elaboration of passive packages elaborates the
21281 initial values, but does not create the files.
21283 The files are written using normal @code{Stream_IO} access.
21284 If you want to be able
21285 to communicate between programs or partitions running on different
21286 architectures, then you should use the XDR versions of the stream attribute
21287 routines, since these are architecture independent.
21289 If active synchronization is required for access to the variables in the
21290 shared passive package, then as described in the Ada Reference Manual, the
21291 package may contain protected objects used for this purpose. In this case
21292 a lock file (whose name is @file{___lock} (three underscores)
21293 is created in the shared memory directory.
21294 @cindex @file{___lock} file (for shared passive packages)
21295 This is used to provide the required locking
21296 semantics for proper protected object synchronization.
21298 As of January 2003, GNAT supports shared passive packages on all platforms
21299 except for OpenVMS.
21301 @node Code Generation for Array Aggregates
21302 @section Code Generation for Array Aggregates
21304 @menu
21305 * Static constant aggregates with static bounds::
21306 * Constant aggregates with unconstrained nominal types::
21307 * Aggregates with static bounds::
21308 * Aggregates with non-static bounds::
21309 * Aggregates in assignment statements::
21310 @end menu
21312 @noindent
21313 Aggregates have a rich syntax and allow the user to specify the values of
21314 complex data structures by means of a single construct.  As a result, the
21315 code generated for aggregates can be quite complex and involve loops, case
21316 statements and multiple assignments.  In the simplest cases, however, the
21317 compiler will recognize aggregates whose components and constraints are
21318 fully static, and in those cases the compiler will generate little or no
21319 executable code.  The following is an outline of the code that GNAT generates
21320 for various aggregate constructs.  For further details, you will find it
21321 useful to examine the output produced by the -gnatG flag to see the expanded
21322 source that is input to the code generator.  You may also want to examine
21323 the assembly code generated at various levels of optimization.
21325 The code generated for aggregates depends on the context, the component values,
21326 and the type.  In the context of an object declaration the code generated is
21327 generally simpler than in the case of an assignment.  As a general rule, static
21328 component values and static subtypes also lead to simpler code.
21330 @node Static constant aggregates with static bounds
21331 @subsection Static constant aggregates with static bounds
21333 @noindent
21334 For the declarations:
21335 @smallexample @c ada
21336     type One_Dim is array (1..10) of integer;
21337     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
21338 @end smallexample
21340 @noindent
21341 GNAT generates no executable code: the constant ar0 is placed in static memory.
21342 The same is true for constant aggregates with named associations:
21344 @smallexample @c ada
21345     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
21346     Cr3 : constant One_Dim := (others => 7777);
21347 @end smallexample
21349 @noindent
21350 The same is true for multidimensional constant arrays such as:
21352 @smallexample @c ada
21353     type two_dim is array (1..3, 1..3) of integer;
21354     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
21355 @end smallexample
21357 @noindent
21358 The same is true for arrays of one-dimensional arrays: the following are
21359 static:
21361 @smallexample @c ada
21362 type ar1b  is array (1..3) of boolean;
21363 type ar_ar is array (1..3) of ar1b;
21364 None  : constant ar1b := (others => false);     --  fully static
21365 None2 : constant ar_ar := (1..3 => None);       --  fully static
21366 @end smallexample
21368 @noindent
21369 However, for multidimensional aggregates with named associations, GNAT will
21370 generate assignments and loops, even if all associations are static.  The
21371 following two declarations generate a loop for the first dimension, and
21372 individual component assignments for the second dimension:
21374 @smallexample @c ada
21375 Zero1: constant two_dim := (1..3 => (1..3 => 0));
21376 Zero2: constant two_dim := (others => (others => 0));
21377 @end smallexample
21379 @node Constant aggregates with unconstrained nominal types
21380 @subsection Constant aggregates with unconstrained nominal types
21382 @noindent
21383 In such cases the aggregate itself establishes the subtype, so that
21384 associations with @code{others} cannot be used.  GNAT determines the
21385 bounds for the actual subtype of the aggregate, and allocates the
21386 aggregate statically as well.  No code is generated for the following:
21388 @smallexample @c ada
21389     type One_Unc is array (natural range <>) of integer;
21390     Cr_Unc : constant One_Unc := (12,24,36);
21391 @end smallexample
21393 @node Aggregates with static bounds
21394 @subsection Aggregates with static bounds
21396 @noindent
21397 In all previous examples the aggregate was the initial (and immutable) value
21398 of a constant.  If the aggregate initializes a variable, then code is generated
21399 for it as a combination of individual assignments and loops over the target
21400 object.  The declarations
21402 @smallexample @c ada
21403        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
21404        Cr_Var2 : One_Dim := (others > -1);
21405 @end smallexample
21407 @noindent
21408 generate the equivalent of
21410 @smallexample @c ada
21411        Cr_Var1 (1) := 2;
21412        Cr_Var1 (2) := 3;
21413        Cr_Var1 (3) := 5;
21414        Cr_Var1 (4) := 11;
21416        for I in Cr_Var2'range loop
21417           Cr_Var2 (I) := -1;
21418        end loop;
21419 @end smallexample
21421 @node Aggregates with non-static bounds
21422 @subsection Aggregates with non-static bounds
21424 @noindent
21425 If the bounds of the aggregate are not statically compatible with the bounds
21426 of the nominal subtype  of the target, then constraint checks have to be
21427 generated on the bounds.  For a multidimensional array, constraint checks may
21428 have to be applied to sub-arrays individually, if they do not have statically
21429 compatible subtypes.
21431 @node Aggregates in assignment statements
21432 @subsection Aggregates in assignment statements
21434 @noindent
21435 In general, aggregate assignment requires the construction of a temporary,
21436 and a copy from the temporary to the target of the assignment.  This is because
21437 it is not always possible to convert the assignment into a series of individual
21438 component assignments.  For example, consider the simple case:
21440 @smallexample @c ada
21441         A := (A(2), A(1));
21442 @end smallexample
21444 @noindent
21445 This cannot be converted into:
21447 @smallexample @c ada
21448         A(1) := A(2);
21449         A(2) := A(1);
21450 @end smallexample
21452 @noindent
21453 So the aggregate has to be built first in a separate location, and then
21454 copied into the target.  GNAT recognizes simple cases where this intermediate
21455 step is not required, and the assignments can be performed in place, directly
21456 into the target.  The following sufficient criteria are applied:
21458 @itemize @bullet
21459 @item
21460 The bounds of the aggregate are static, and the associations are static.
21461 @item
21462 The components of the aggregate are static constants, names of
21463 simple variables that are not renamings, or expressions not involving
21464 indexed components whose operands obey these rules.
21465 @end itemize
21467 @noindent
21468 If any of these conditions are violated, the aggregate will be built in
21469 a temporary (created either by the front-end or the code generator) and then
21470 that temporary will be copied onto the target.
21472 @node The Size of Discriminated Records with Default Discriminants
21473 @section The Size of Discriminated Records with Default Discriminants
21475 @noindent
21476 If a discriminated type @code{T} has discriminants with default values, it is
21477 possible to declare an object of this type without providing an explicit
21478 constraint:
21480 @smallexample @c ada
21481 @group
21482 type Size is range 1..100;
21484 type Rec (D : Size := 15) is record
21485    Name : String (1..D);
21486 end T;
21488 Word : Rec;
21489 @end group
21490 @end smallexample
21492 @noindent
21493 Such an object is said to be @emph{unconstrained}.
21494 The discriminant of the object
21495 can be modified by a full assignment to the object, as long as it preserves the
21496 relation between the value of the discriminant, and the value of the components
21497 that depend on it:
21499 @smallexample @c ada
21500 @group
21501 Word := (3, "yes");
21503 Word := (5, "maybe");
21505 Word := (5, "no"); -- raises Constraint_Error
21506 @end group
21507 @end smallexample
21509 @noindent
21510 In order to support this behavior efficiently, an unconstrained object is
21511 given the maximum size that any value of the type requires. In the case
21512 above, @code{Word} has storage for the discriminant and for
21513 a @code{String} of length 100.
21514 It is important to note that unconstrained objects do not require dynamic
21515 allocation. It would be an improper implementation to place on the heap those
21516 components whose size depends on discriminants. (This improper implementation
21517 was used by some Ada83 compilers, where the @code{Name} component above
21518 would have
21519 been stored as a pointer to a dynamic string). Following the principle that
21520 dynamic storage management should never be introduced implicitly,
21521 an Ada compiler should reserve the full size for an unconstrained declared
21522 object, and place it on the stack.
21524 This maximum size approach
21525 has been a source of surprise to some users, who expect the default
21526 values of the discriminants to determine the size reserved for an
21527 unconstrained object: ``If the default is 15, why should the object occupy
21528 a larger size?''
21529 The answer, of course, is that the discriminant may be later modified,
21530 and its full range of values must be taken into account. This is why the
21531 declaration:
21533 @smallexample
21534 @group
21535 type Rec (D : Positive := 15) is record
21536    Name : String (1..D);
21537 end record;
21539 Too_Large : Rec;
21540 @end group
21541 @end smallexample
21543 @noindent
21544 is flagged by the compiler with a warning:
21545 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
21546 because the required size includes @code{Positive'Last}
21547 bytes. As the first example indicates, the proper approach is to declare an
21548 index type of ``reasonable'' range so that unconstrained objects are not too
21549 large.
21551 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
21552 created in the heap by means of an allocator, then it is @emph{not}
21553 unconstrained:
21554 it is constrained by the default values of the discriminants, and those values
21555 cannot be modified by full assignment. This is because in the presence of
21556 aliasing all views of the object (which may be manipulated by different tasks,
21557 say) must be consistent, so it is imperative that the object, once created,
21558 remain invariant.
21560 @node Strict Conformance to the Ada Reference Manual
21561 @section Strict Conformance to the Ada Reference Manual
21563 @noindent
21564 The dynamic semantics defined by the Ada Reference Manual impose a set of
21565 run-time checks to be generated. By default, the GNAT compiler will insert many
21566 run-time checks into the compiled code, including most of those required by the
21567 Ada Reference Manual. However, there are three checks that are not enabled
21568 in the default mode for efficiency reasons: arithmetic overflow checking for
21569 integer operations (including division by zero), checks for access before
21570 elaboration on subprogram calls, and stack overflow checking (most operating
21571 systems do not perform this check by default).
21573 Strict conformance to the Ada Reference Manual can be achieved by adding
21574 three compiler options for overflow checking for integer operations
21575 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
21576 calls and generic instantiations (@option{-gnatE}), and stack overflow
21577 checking (@option{-fstack-check}).
21579 Note that the result of a floating point arithmetic operation in overflow and
21580 invalid situations, when the @code{Machine_Overflows} attribute of the result
21581 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
21582 case for machines compliant with the IEEE floating-point standard, but on
21583 machines that are not fully compliant with this standard, such as Alpha, the
21584 @option{-mieee} compiler flag must be used for achieving IEEE confirming
21585 behavior (although at the cost of a significant performance penalty), so
21586 infinite and NaN values are properly generated.
21589 @node Implementation of Ada 2012 Features
21590 @chapter Implementation of Ada 2012 Features
21591 @cindex Ada 2012 implementation status
21593 This chapter contains a complete list of Ada 2012 features that have been
21594 implemented as of GNAT version 6.4. Generally, these features are only
21595 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
21596 @cindex @option{-gnat12} option
21597 or if the configuration pragma @code{Ada_2012} is used.
21598 @cindex pragma @code{Ada_2012}
21599 @cindex configuration pragma @code{Ada_2012}
21600 @cindex @code{Ada_2012} configuration pragma
21601 However, new pragmas, attributes, and restrictions are
21602 unconditionally available, since the Ada 95 standard allows the addition of
21603 new pragmas, attributes, and restrictions (there are exceptions, which are
21604 documented in the individual descriptions), and also certain packages
21605 were made available in earlier versions of Ada.
21607 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
21608 This date shows the implementation date of the feature. Any wavefront
21609 subsequent to this date will contain the indicated feature, as will any
21610 subsequent releases. A date of 0000-00-00 means that GNAT has always
21611 implemented the feature, or implemented it as soon as it appeared as a
21612 binding interpretation.
21614 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
21615 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
21616 The features are ordered based on the relevant sections of the Ada
21617 Reference Manual (``RM'').  When a given AI relates to multiple points
21618 in the RM, the earliest is used.
21620 A complete description of the AIs may be found in
21621 @url{www.ada-auth.org/ai05-summary.html}.
21623 @itemize @bullet
21625 @item
21626 @emph{AI-0176 Quantified expressions (2010-09-29)}
21627 @cindex AI-0176 (Ada 2012 feature)
21629 @noindent
21630   Both universally and existentially quantified expressions are implemented.
21631   They use the new syntax for iterators proposed in AI05-139-2, as well as
21632   the standard Ada loop syntax.
21634 @noindent
21635   RM References:  1.01.04 (12)   2.09 (2/2)   4.04 (7)   4.05.09 (0)
21637 @item
21638 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
21639 @cindex AI-0079 (Ada 2012 feature)
21641 @noindent
21642   Wide characters in the unicode category @i{other_format} are now allowed in
21643   source programs between tokens, but not within a token such as an identifier.
21645 @noindent
21646   RM References:  2.01 (4/2)   2.02 (7)
21648 @item
21649 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
21650 @cindex AI-0091 (Ada 2012 feature)
21652 @noindent
21653   Wide characters in the unicode category @i{other_format} are not permitted
21654   within  an identifier, since this can be a security problem. The error
21655   message for this case has been improved to be more specific, but GNAT has
21656   never allowed such characters to appear in identifiers.
21658 @noindent
21659   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)
21661 @item
21662 @emph{AI-0100 Placement of pragmas  (2010-07-01)}
21663 @cindex AI-0100 (Ada 2012 feature)
21665 @noindent
21666   This AI is an earlier version of AI-163. It simplifies the rules
21667   for legal placement of pragmas. In the case of lists that allow pragmas, if
21668   the list may have no elements, then the list may consist solely of pragmas.
21670 @noindent
21671   RM References:  2.08 (7)
21673 @item
21674 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
21675 @cindex AI-0163 (Ada 2012 feature)
21677 @noindent
21678   A statement sequence may be composed entirely of pragmas. It is no longer
21679   necessary to add a dummy @code{null} statement to make the sequence legal.
21681 @noindent
21682   RM References:  2.08 (7)   2.08 (16)
21685 @item
21686 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
21687 @cindex AI-0080 (Ada 2012 feature)
21689 @noindent
21690   This is an editorial change only, described as non-testable in the AI.
21692 @noindent
21693   RM References:  3.01 (7)
21696 @item
21697 @emph{AI-0183 Aspect specifications (2010-08-16)}
21698 @cindex AI-0183 (Ada 2012 feature)
21700 @noindent
21701   Aspect specifications have been fully implemented except for pre and post-
21702   conditions, and type invariants, which have their own separate AI's. All
21703   forms of declarations listed in the AI are supported. The following is a
21704   list of the aspects supported (with GNAT implementation aspects marked)
21706 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
21707 @item @code{Ada_2005} @tab                      -- GNAT
21708 @item @code{Ada_2012} @tab                      -- GNAT
21709 @item @code{Address} @tab
21710 @item @code{Alignment} @tab
21711 @item @code{Atomic} @tab
21712 @item @code{Atomic_Components} @tab
21713 @item @code{Bit_Order} @tab
21714 @item @code{Component_Size} @tab
21715 @item @code{Contract_Cases} @tab                -- GNAT
21716 @item @code{Discard_Names} @tab
21717 @item @code{External_Tag} @tab
21718 @item @code{Favor_Top_Level} @tab               -- GNAT
21719 @item @code{Inline} @tab
21720 @item @code{Inline_Always} @tab                 -- GNAT
21721 @item @code{Invariant} @tab                     -- GNAT
21722 @item @code{Machine_Radix} @tab
21723 @item @code{No_Return} @tab
21724 @item @code{Object_Size} @tab                   -- GNAT
21725 @item @code{Pack} @tab
21726 @item @code{Persistent_BSS} @tab                -- GNAT
21727 @item @code{Post} @tab
21728 @item @code{Pre} @tab
21729 @item @code{Predicate} @tab
21730 @item @code{Preelaborable_Initialization} @tab
21731 @item @code{Pure_Function} @tab                 -- GNAT
21732 @item @code{Remote_Access_Type} @tab            -- GNAT
21733 @item @code{Shared} @tab                        -- GNAT
21734 @item @code{Size} @tab
21735 @item @code{Storage_Pool} @tab
21736 @item @code{Storage_Size} @tab
21737 @item @code{Stream_Size} @tab
21738 @item @code{Suppress} @tab
21739 @item @code{Suppress_Debug_Info} @tab           -- GNAT
21740 @item @code{Test_Case} @tab                     -- GNAT
21741 @item @code{Thread_Local_Storage} @tab          -- GNAT
21742 @item @code{Type_Invariant} @tab
21743 @item @code{Unchecked_Union} @tab
21744 @item @code{Universal_Aliasing} @tab            -- GNAT
21745 @item @code{Unmodified} @tab                    -- GNAT
21746 @item @code{Unreferenced} @tab                  -- GNAT
21747 @item @code{Unreferenced_Objects} @tab          -- GNAT
21748 @item @code{Unsuppress} @tab
21749 @item @code{Value_Size} @tab                    -- GNAT
21750 @item @code{Volatile} @tab
21751 @item @code{Volatile_Components}
21752 @item @code{Warnings} @tab                      -- GNAT
21753 @end multitable
21755 @noindent
21756   Note that for aspects with an expression, e.g. @code{Size}, the expression is
21757   treated like a default expression (visibility is analyzed at the point of
21758   occurrence of the aspect, but evaluation of the expression occurs at the
21759   freeze point of the entity involved).
21761 @noindent
21762   RM References:  3.02.01 (3)   3.02.02 (2)   3.03.01 (2/2)   3.08 (6)
21763   3.09.03 (1.1/2)   6.01 (2/2)   6.07 (2/2)   9.05.02 (2/2)   7.01 (3)   7.03
21764   (2)   7.03 (3)   9.01 (2/2)   9.01 (3/2)   9.04 (2/2)   9.04 (3/2)
21765   9.05.02 (2/2)   11.01 (2)   12.01 (3)   12.03 (2/2)   12.04 (2/2)   12.05 (2)
21766   12.06 (2.1/2)   12.06 (2.2/2)   12.07 (2)   13.01 (0.1/2)   13.03 (5/1)
21767   13.03.01 (0)
21770 @item
21771 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
21772 @cindex AI-0128 (Ada 2012 feature)
21774 @noindent
21775   If an equality operator ("=") is declared for a type, then the implicitly
21776   declared inequality operator ("/=") is a primitive operation of the type.
21777   This is the only reasonable interpretation, and is the one always implemented
21778   by GNAT, but the RM was not entirely clear in making this point.
21780 @noindent
21781   RM References:  3.02.03 (6)   6.06 (6)
21783 @item
21784 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
21785 @cindex AI-0003 (Ada 2012 feature)
21787 @noindent
21788    In Ada 2012, a qualified expression is considered to be syntactically a name,
21789    meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
21790    useful in disambiguating some cases of overloading.
21792 @noindent
21793   RM References:  3.03 (11)   3.03 (21)   4.01 (2)   4.04 (7)   4.07 (3)
21794   5.04 (7)
21796 @item
21797 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
21798 @cindex AI-0120 (Ada 2012 feature)
21800 @noindent
21801   This is an RM editorial change only. The section that lists objects that are
21802   constant failed to include the current instance of a protected object
21803   within a protected function. This has always been treated as a constant
21804   in GNAT.
21806 @noindent
21807   RM References:  3.03 (21)
21809 @item
21810 @emph{AI-0008 General access to constrained objects (0000-00-00)}
21811 @cindex AI-0008 (Ada 2012 feature)
21813 @noindent
21814   The wording in the RM implied that if you have a general access to a
21815   constrained object, it could be used to modify the discriminants. This was
21816   obviously not intended. @code{Constraint_Error} should be raised, and GNAT
21817   has always done so in this situation.
21819 @noindent
21820   RM References:  3.03 (23)   3.10.02 (26/2)   4.01 (9)   6.04.01 (17)   8.05.01 (5/2)
21823 @item
21824 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
21825 @cindex AI-0093 (Ada 2012 feature)
21827 @noindent
21828   This is an editorial change only, to make more widespread use of the Ada 2012
21829   ``immutably limited''.
21831 @noindent
21832   RM References:  3.03 (23.4/3)
21836 @item
21837 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
21838 @cindex AI-0096 (Ada 2012 feature)
21840 @noindent
21841   In general it is illegal for a type derived from a formal limited type to be
21842   nonlimited.  This AI makes an exception to this rule: derivation is legal
21843   if it appears in the private part of the generic, and the formal type is not
21844   tagged. If the type is tagged, the legality check must be applied to the
21845   private part of the package.
21847 @noindent
21848   RM References:  3.04 (5.1/2)   6.02 (7)
21851 @item
21852 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
21853 @cindex AI-0181 (Ada 2012 feature)
21855 @noindent
21856   From Ada 2005 on, soft hyphen is considered a non-graphic character, which
21857   means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
21858   @code{Image} and @code{Value} attributes for the character types. Strictly
21859   speaking this is an inconsistency with Ada 95, but in practice the use of
21860   these attributes is so obscure that it will not cause problems.
21862 @noindent
21863   RM References:  3.05.02 (2/2)   A.01 (35/2)   A.03.03 (21)
21866 @item
21867 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
21868 @cindex AI-0182 (Ada 2012 feature)
21870 @noindent
21871   This AI allows @code{Character'Value} to accept the string @code{'?'} where
21872   @code{?} is any character including non-graphic control characters. GNAT has
21873   always accepted such strings. It also allows strings such as
21874   @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
21875   permission and raises @code{Constraint_Error}, as is certainly still
21876   permitted.
21878 @noindent
21879   RM References:  3.05 (56/2)
21882 @item
21883 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
21884 @cindex AI-0214 (Ada 2012 feature)
21886 @noindent
21887   Ada 2012 relaxes the restriction that forbids discriminants of tagged types
21888   to have default expressions by allowing them when the type is limited. It
21889   is often useful to define a default value for a discriminant even though
21890   it can't be changed by assignment.
21892 @noindent
21893   RM References:  3.07 (9.1/2)   3.07.02 (3)
21896 @item
21897 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
21898 @cindex AI-0102 (Ada 2012 feature)
21900 @noindent
21901   It is illegal to assign an anonymous access constant to an anonymous access
21902   variable. The RM did not have a clear rule to prevent this, but GNAT has
21903   always generated an error for this usage.
21905 @noindent
21906   RM References:  3.07 (16)   3.07.01 (9)   6.04.01 (6)   8.06 (27/2)
21909 @item
21910 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
21911 @cindex AI-0158 (Ada 2012 feature)
21913 @noindent
21914   This AI extends the syntax of membership tests to simplify complex conditions
21915   that can be expressed as membership in a subset of values of any type. It
21916   introduces syntax for a list of expressions that may be used in loop contexts
21917   as well.
21919 @noindent
21920   RM References:  3.08.01 (5)   4.04 (3)   4.05.02 (3)   4.05.02 (5)   4.05.02 (27)
21923 @item
21924 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
21925 @cindex AI-0173 (Ada 2012 feature)
21927 @noindent
21928   The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
21929   with the tag of an abstract type, and @code{False} otherwise.
21931 @noindent
21932   RM References:  3.09 (7.4/2)   3.09 (12.4/2)
21936 @item
21937 @emph{AI-0076 function with controlling result (0000-00-00)}
21938 @cindex AI-0076 (Ada 2012 feature)
21940 @noindent
21941   This is an editorial change only. The RM defines calls with controlling
21942   results, but uses the term ``function with controlling result'' without an
21943   explicit definition.
21945 @noindent
21946   RM References:  3.09.02 (2/2)
21949 @item
21950 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
21951 @cindex AI-0126 (Ada 2012 feature)
21953 @noindent
21954   This AI clarifies dispatching rules, and simply confirms that dispatching
21955   executes the operation of the parent type when there is no explicitly or
21956   implicitly declared operation for the descendant type. This has always been
21957   the case in all versions of GNAT.
21959 @noindent
21960   RM References:  3.09.02 (20/2)   3.09.02 (20.1/2)   3.09.02 (20.2/2)
21963 @item
21964 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
21965 @cindex AI-0097 (Ada 2012 feature)
21967 @noindent
21968   The RM as written implied that in some cases it was possible to create an
21969   object of an abstract type, by having an abstract extension inherit a non-
21970   abstract constructor from its parent type. This mistake has been corrected
21971   in GNAT and in the RM, and this construct is now illegal.
21973 @noindent
21974   RM References:  3.09.03 (4/2)
21977 @item
21978 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
21979 @cindex AI-0203 (Ada 2012 feature)
21981 @noindent
21982   A return_subtype_indication cannot denote an abstract subtype. GNAT has never
21983   permitted such usage.
21985 @noindent
21986   RM References:  3.09.03 (8/3)
21989 @item
21990 @emph{AI-0198 Inheriting abstract operators  (0000-00-00)}
21991 @cindex AI-0198 (Ada 2012 feature)
21993 @noindent
21994   This AI resolves a conflict between two rules involving inherited abstract
21995   operations and predefined operators. If a derived numeric type inherits
21996   an abstract operator, it overrides the predefined one. This interpretation
21997   was always the one implemented in GNAT.
21999 @noindent
22000   RM References:  3.09.03 (4/3)
22002 @item
22003 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
22004 @cindex AI-0073 (Ada 2012 feature)
22006 @noindent
22007   This AI covers a number of issues regarding returning abstract types. In
22008   particular generic functions cannot have abstract result types or access
22009   result types designated an abstract type. There are some other cases which
22010   are detailed in the AI. Note that this binding interpretation has not been
22011   retrofitted to operate before Ada 2012 mode, since it caused a significant
22012   number of regressions.
22014 @noindent
22015   RM References:  3.09.03 (8)   3.09.03 (10)   6.05 (8/2)
22018 @item
22019 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
22020 @cindex AI-0070 (Ada 2012 feature)
22022 @noindent
22023   This is an editorial change only, there are no testable consequences short of
22024   checking for the absence of generated code for an interface declaration.
22026 @noindent
22027   RM References:  3.09.04 (18/2)
22030 @item
22031 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
22032 @cindex AI-0208 (Ada 2012 feature)
22034 @noindent
22035   The wording in the Ada 2005 RM concerning characteristics of incomplete views
22036   was incorrect and implied that some programs intended to be legal were now
22037   illegal. GNAT had never considered such programs illegal, so it has always
22038   implemented the intent of this AI.
22040 @noindent
22041   RM References:  3.10.01 (2.4/2)   3.10.01 (2.6/2)
22044 @item
22045 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
22046 @cindex AI-0162 (Ada 2012 feature)
22048 @noindent
22049   Incomplete types are made more useful by allowing them to be completed by
22050   private types and private extensions.
22052 @noindent
22053   RM References:  3.10.01 (2.5/2)   3.10.01 (2.6/2)   3.10.01 (3)   3.10.01 (4/2)
22057 @item
22058 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
22059 @cindex AI-0098 (Ada 2012 feature)
22061 @noindent
22062   An unintentional omission in the RM implied some inconsistent restrictions on
22063   the use of anonymous access to subprogram values. These restrictions were not
22064   intentional, and have never been enforced by GNAT.
22066 @noindent
22067   RM References:  3.10.01 (6)   3.10.01 (9.2/2)
22070 @item
22071 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
22072 @cindex AI-0199 (Ada 2012 feature)
22074 @noindent
22075   A choice list in a record aggregate can include several components of
22076   (distinct) anonymous access types as long as they have matching designated
22077   subtypes.
22079 @noindent
22080   RM References:  4.03.01 (16)
22083 @item
22084 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
22085 @cindex AI-0220 (Ada 2012 feature)
22087 @noindent
22088   This AI addresses a wording problem in the RM that appears to permit some
22089   complex cases of aggregates with non-static discriminants. GNAT has always
22090   implemented the intended semantics.
22092 @noindent
22093   RM References:  4.03.01 (17)
22095 @item
22096 @emph{AI-0147 Conditional expressions (2009-03-29)}
22097 @cindex AI-0147 (Ada 2012 feature)
22099 @noindent
22100   Conditional expressions are permitted. The form of such an expression is:
22102 @smallexample
22103     (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
22104 @end smallexample
22106   The parentheses can be omitted in contexts where parentheses are present
22107   anyway, such as subprogram arguments and pragma arguments. If the @b{else}
22108   clause is omitted, @b{else True} is assumed;
22109   thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
22110   @emph{(A implies B)} in standard logic.
22112 @noindent
22113   RM References:  4.03.03 (15)   4.04 (1)   4.04 (7)   4.05.07 (0)   4.07 (2)
22114   4.07 (3)   4.09 (12)   4.09 (33)   5.03 (3)   5.03 (4)   7.05 (2.1/2)
22117 @item
22118 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
22119 @cindex AI-0037 (Ada 2012 feature)
22121 @noindent
22122   This AI confirms that an association of the form @code{Indx => <>} in an
22123   array aggregate must raise @code{Constraint_Error} if @code{Indx}
22124   is out of range. The RM specified a range check on other associations, but
22125   not when the value of the association was defaulted. GNAT has always inserted
22126   a constraint check on the index value.
22128 @noindent
22129   RM References:  4.03.03 (29)
22132 @item
22133 @emph{AI-0123 Composability of equality (2010-04-13)}
22134 @cindex AI-0123 (Ada 2012 feature)
22136 @noindent
22137   Equality of untagged record composes, so that the predefined equality for a
22138   composite type that includes a component of some untagged record type
22139   @code{R} uses the equality operation of @code{R} (which may be user-defined
22140   or predefined). This makes the behavior of untagged records identical to that
22141   of tagged types in this respect.
22143   This change is an incompatibility with previous versions of Ada, but it
22144   corrects a non-uniformity that was often a source of confusion. Analysis of
22145   a large number of industrial programs indicates that in those rare cases
22146   where a composite type had an untagged record component with a user-defined
22147   equality, either there was no use of the composite equality, or else the code
22148   expected the same composability as for tagged types, and thus had a bug that
22149   would be fixed by this change.
22151 @noindent
22152   RM References:  4.05.02 (9.7/2)   4.05.02 (14)   4.05.02 (15)   4.05.02 (24)
22153   8.05.04 (8)
22156 @item
22157 @emph{AI-0088 The value of exponentiation (0000-00-00)}
22158 @cindex AI-0088 (Ada 2012 feature)
22160 @noindent
22161   This AI clarifies the equivalence rule given for the dynamic semantics of
22162   exponentiation: the value of the operation can be obtained by repeated
22163   multiplication, but the operation can be implemented otherwise (for example
22164   using the familiar divide-by-two-and-square algorithm, even if this is less
22165   accurate), and does not imply repeated reads of a volatile base.
22167 @noindent
22168   RM References:  4.05.06 (11)
22170 @item
22171 @emph{AI-0188 Case expressions (2010-01-09)}
22172 @cindex AI-0188 (Ada 2012 feature)
22174 @noindent
22175   Case expressions are permitted. This allows use of constructs such as:
22176 @smallexample
22177   X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
22178 @end smallexample
22180 @noindent
22181   RM References:  4.05.07 (0)   4.05.08 (0)   4.09 (12)   4.09 (33)
22183 @item
22184 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
22185 @cindex AI-0104 (Ada 2012 feature)
22187 @noindent
22188   The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
22189   @code{Constraint_Error} because the default value of the allocated object is
22190   @b{null}. This useless construct is illegal in Ada 2012.
22192 @noindent
22193   RM References:  4.08 (2)
22195 @item
22196 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
22197 @cindex AI-0157 (Ada 2012 feature)
22199 @noindent
22200   Allocation and Deallocation from an empty storage pool (i.e. allocation or
22201   deallocation of a pointer for which a static storage size clause of zero
22202   has been given) is now illegal and is detected as such. GNAT
22203   previously gave a warning but not an error.
22205 @noindent
22206   RM References:  4.08 (5.3/2)   13.11.02 (4)   13.11.02 (17)
22208 @item
22209 @emph{AI-0179 Statement not required after label (2010-04-10)}
22210 @cindex AI-0179 (Ada 2012 feature)
22212 @noindent
22213   It is not necessary to have a statement following a label, so a label
22214   can appear at the end of a statement sequence without the need for putting a
22215   null statement afterwards, but it is not allowable to have only labels and
22216   no real statements in a statement sequence.
22218 @noindent
22219   RM References:  5.01 (2)
22222 @item
22223 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
22224 @cindex AI-139-2 (Ada 2012 feature)
22226 @noindent
22227   The new syntax for iterating over arrays and containers is now implemented.
22228   Iteration over containers is for now limited to read-only iterators. Only
22229   default iterators are supported, with the syntax:  @code{@b{for} Elem @b{of} C}.
22231 @noindent
22232   RM References:  5.05
22234 @item
22235 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
22236 @cindex AI-0134 (Ada 2012 feature)
22238 @noindent
22239   For full conformance, the profiles of anonymous-access-to-subprogram
22240   parameters must match. GNAT has always enforced this rule.
22242 @noindent
22243   RM References:  6.03.01 (18)
22245 @item
22246 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
22247 @cindex AI-0207 (Ada 2012 feature)
22249 @noindent
22250   This AI confirms that access_to_constant indication must match for mode
22251   conformance. This was implemented in GNAT when the qualifier was originally
22252   introduced in Ada 2005.
22254 @noindent
22255   RM References:  6.03.01 (16/2)
22258 @item
22259 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
22260 @cindex AI-0046 (Ada 2012 feature)
22262 @noindent
22263   For full conformance, in the case of access parameters, the null exclusion
22264   must match (either both or neither must have @code{@b{not null}}).
22266 @noindent
22267   RM References:  6.03.02 (18)
22270 @item
22271 @emph{AI-0118 The association of parameter associations (0000-00-00)}
22272 @cindex AI-0118 (Ada 2012 feature)
22274 @noindent
22275   This AI clarifies the rules for named associations in subprogram calls and
22276   generic instantiations. The rules have been in place since Ada 83.
22278 @noindent
22279   RM References:  6.04.01 (2)   12.03 (9)
22282 @item
22283 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
22284 @cindex AI-0196 (Ada 2012 feature)
22286 @noindent
22287   Null exclusion checks are not made for @code{@b{out}} parameters when
22288   evaluating the actual parameters. GNAT has never generated these checks.
22290 @noindent
22291   RM References:  6.04.01 (13)
22293 @item
22294 @emph{AI-0015 Constant return objects (0000-00-00)}
22295 @cindex AI-0015 (Ada 2012 feature)
22297 @noindent
22298   The return object declared in an @i{extended_return_statement} may be
22299   declared constant. This was always intended, and GNAT has always allowed it.
22301 @noindent
22302   RM References:  6.05 (2.1/2)   3.03 (10/2)   3.03 (21)   6.05 (5/2)
22303   6.05 (5.7/2)
22306 @item
22307 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
22308 @cindex AI-0032 (Ada 2012 feature)
22310 @noindent
22311   If a function returns a class-wide type, the object of an extended return
22312   statement can be declared with a specific type that is covered by the class-
22313   wide type. This has been implemented in GNAT since the introduction of
22314   extended returns. Note AI-0103 complements this AI by imposing matching
22315   rules for constrained return types.
22317 @noindent
22318   RM References:  6.05 (5.2/2)   6.05 (5.3/2)   6.05 (5.6/2)   6.05 (5.8/2)
22319   6.05 (8/2)
22321 @item
22322 @emph{AI-0103 Static matching for extended return (2010-07-23)}
22323 @cindex AI-0103 (Ada 2012 feature)
22325 @noindent
22326   If the return subtype of a function is an elementary type or a constrained
22327   type, the subtype indication in an extended return statement must match
22328   statically this return subtype.
22330 @noindent
22331   RM References:  6.05 (5.2/2)
22334 @item
22335 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
22336 @cindex AI-0058 (Ada 2012 feature)
22338 @noindent
22339   The RM had some incorrect wording implying wrong treatment of abnormal
22340   completion in an extended return. GNAT has always implemented the intended
22341   correct semantics as described by this AI.
22343 @noindent
22344   RM References:  6.05 (22/2)
22347 @item
22348 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
22349 @cindex AI-0050 (Ada 2012 feature)
22351 @noindent
22352   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
22353   not take advantage of these incorrect permissions in any case.
22355 @noindent
22356   RM References:  6.05 (24/2)
22359 @item
22360 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
22361 @cindex AI-0125 (Ada 2012 feature)
22363 @noindent
22364   In Ada 2012, the declaration of a primitive operation of a type extension
22365   or private extension can also override an inherited primitive that is not
22366   visible at the point of this declaration.
22368 @noindent
22369   RM References:  7.03.01 (6)   8.03 (23)   8.03.01 (5/2)   8.03.01 (6/2)
22371 @item
22372 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
22373 @cindex AI-0062 (Ada 2012 feature)
22375 @noindent
22376   A full constant may have a null exclusion even if its associated deferred
22377   constant does not. GNAT has always allowed this.
22379 @noindent
22380   RM References:  7.04 (6/2)   7.04 (7.1/2)
22383 @item
22384 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
22385 @cindex AI-0178 (Ada 2012 feature)
22387 @noindent
22388   This AI clarifies the role of incomplete views and plugs an omission in the
22389   RM. GNAT always correctly restricted the use of incomplete views and types.
22391 @noindent
22392   RM References:  7.05 (3/2)   7.05 (6/2)
22394 @item
22395 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
22396 @cindex AI-0087 (Ada 2012 feature)
22398 @noindent
22399   The actual for a formal nonlimited derived type cannot be limited. In
22400   particular, a formal derived type that extends a limited interface but which
22401   is not explicitly limited cannot be instantiated with a limited type.
22403 @noindent
22404   RM References:  7.05 (5/2)   12.05.01 (5.1/2)
22406 @item
22407 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
22408 @cindex AI-0099 (Ada 2012 feature)
22410 @noindent
22411   This AI clarifies that ``needs finalization'' is part of dynamic semantics,
22412   and therefore depends on the run-time characteristics of an object (i.e. its
22413   tag) and not on its nominal type. As the AI indicates: ``we do not expect
22414   this to affect any implementation''.
22416 @noindent
22417   RM References:  7.06.01 (6)   7.06.01 (7)   7.06.01 (8)   7.06.01 (9/2)
22421 @item
22422 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
22423 @cindex AI-0064 (Ada 2012 feature)
22425 @noindent
22426   This is an editorial change only. The intended behavior is already checked
22427   by an existing ACATS test, which GNAT has always executed correctly.
22429 @noindent
22430   RM References:  7.06.01 (17.1/1)
22432 @item
22433 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
22434 @cindex AI-0026 (Ada 2012 feature)
22436 @noindent
22437   Record representation clauses concerning Unchecked_Union types cannot mention
22438   the discriminant of the type. The type of a component declared in the variant
22439   part of an Unchecked_Union cannot be controlled, have controlled components,
22440   nor have protected or task parts. If an Unchecked_Union type is declared
22441   within the body of a generic unit or its descendants, then the type of a
22442   component declared in the variant part cannot be a formal private type or a
22443   formal private extension declared within the same generic unit.
22445 @noindent
22446   RM References:  7.06 (9.4/2)   B.03.03 (9/2)   B.03.03 (10/2)
22449 @item
22450 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
22451 @cindex AI-0205 (Ada 2012 feature)
22453 @noindent
22454   This AI corrects a simple omission in the RM. Return objects have always
22455   been visible within an extended return statement.
22457 @noindent
22458   RM References:  8.03 (17)
22461 @item
22462 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
22463 @cindex AI-0042 (Ada 2012 feature)
22465 @noindent
22466   This AI fixes a wording gap in the RM. An operation of a synchronized
22467   interface can be implemented by a protected or task entry, but the abstract
22468   operation is not being overridden in the usual sense, and it must be stated
22469   separately that this implementation is legal. This has always been the case
22470   in GNAT.
22472 @noindent
22473   RM References:  9.01 (9.2/2)   9.04 (11.1/2)
22475 @item
22476 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
22477 @cindex AI-0030 (Ada 2012 feature)
22479 @noindent
22480   Requeue is permitted to a protected, synchronized or task interface primitive
22481   providing it is known that the overriding operation is an entry. Otherwise
22482   the requeue statement has the same effect as a procedure call. Use of pragma
22483   @code{Implemented} provides a way to impose a static requirement on the
22484   overriding operation by adhering to one of the implementation kinds: entry,
22485   protected procedure or any of the above.
22487 @noindent
22488   RM References:  9.05 (9)   9.05.04 (2)   9.05.04 (3)   9.05.04 (5)
22489   9.05.04 (6)   9.05.04 (7)   9.05.04 (12)
22492 @item
22493 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
22494 @cindex AI-0201 (Ada 2012 feature)
22496 @noindent
22497   If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
22498   attribute, then individual components may not be addressable by independent
22499   tasks. However, if the representation clause has no effect (is confirming),
22500   then independence is not compromised. Furthermore, in GNAT, specification of
22501   other appropriately addressable component sizes (e.g. 16 for 8-bit
22502   characters) also preserves independence. GNAT now gives very clear warnings
22503   both for the declaration of such a type, and for any assignment to its components.
22505 @noindent
22506   RM References:  9.10 (1/3)   C.06 (22/2)   C.06 (23/2)
22508 @item
22509 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
22510 @cindex AI-0009 (Ada 2012 feature)
22512 @noindent
22513   This AI introduces the new pragmas @code{Independent} and
22514   @code{Independent_Components},
22515   which control guaranteeing independence of access to objects and components.
22516   The AI also requires independence not unaffected by confirming rep clauses.
22518 @noindent
22519   RM References:  9.10 (1)   13.01 (15/1)   13.02 (9)   13.03 (13)   C.06 (2)
22520   C.06 (4)   C.06 (6)   C.06 (9)   C.06 (13)   C.06 (14)
22523 @item
22524 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
22525 @cindex AI-0072 (Ada 2012 feature)
22527 @noindent
22528   This AI clarifies that task signalling for reading @code{'Terminated} only
22529   occurs if the result is True. GNAT semantics has always been consistent with
22530   this notion of task signalling.
22532 @noindent
22533   RM References:  9.10 (6.1/1)
22535 @item
22536 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
22537 @cindex AI-0108 (Ada 2012 feature)
22539 @noindent
22540   This AI confirms that an incomplete type from a limited view does not have
22541   discriminants. This has always been the case in GNAT.
22543 @noindent
22544   RM References:  10.01.01 (12.3/2)
22546 @item
22547 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
22548 @cindex AI-0129 (Ada 2012 feature)
22550 @noindent
22551   This AI clarifies the description of limited views: a limited view of a
22552   package includes only one view of a type that has an incomplete declaration
22553   and a full declaration (there is no possible ambiguity in a client package).
22554   This AI also fixes an omission: a nested package in the private part has no
22555   limited view. GNAT always implemented this correctly.
22557 @noindent
22558   RM References:  10.01.01 (12.2/2)   10.01.01 (12.3/2)
22562 @item
22563 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
22564 @cindex AI-0077 (Ada 2012 feature)
22566 @noindent
22567   This AI clarifies that a declaration does not include a context clause,
22568   and confirms that it is illegal to have a context in which both a limited
22569   and a nonlimited view of a package are accessible. Such double visibility
22570   was always rejected by GNAT.
22572 @noindent
22573   RM References:  10.01.02 (12/2)   10.01.02 (21/2)   10.01.02 (22/2)
22575 @item
22576 @emph{AI-0122 Private with and children of generics (0000-00-00)}
22577 @cindex AI-0122 (Ada 2012 feature)
22579 @noindent
22580   This AI clarifies the visibility of private children of generic units within
22581   instantiations of a parent. GNAT has always handled this correctly.
22583 @noindent
22584   RM References:  10.01.02 (12/2)
22588 @item
22589 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
22590 @cindex AI-0040 (Ada 2012 feature)
22592 @noindent
22593   This AI confirms that a limited with clause in a child unit cannot name
22594   an ancestor of the unit. This has always been checked in GNAT.
22596 @noindent
22597   RM References:  10.01.02 (20/2)
22599 @item
22600 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
22601 @cindex AI-0132 (Ada 2012 feature)
22603 @noindent
22604   This AI fills a gap in the description of library unit pragmas. The pragma
22605   clearly must apply to a library unit, even if it does not carry the name
22606   of the enclosing unit. GNAT has always enforced the required check.
22608 @noindent
22609   RM References:  10.01.05 (7)
22612 @item
22613 @emph{AI-0034 Categorization of limited views (0000-00-00)}
22614 @cindex AI-0034 (Ada 2012 feature)
22616 @noindent
22617   The RM makes certain limited with clauses illegal because of categorization
22618   considerations, when the corresponding normal with would be legal. This is
22619   not intended, and GNAT has always implemented the recommended behavior.
22621 @noindent
22622   RM References:  10.02.01 (11/1)   10.02.01 (17/2)
22625 @item
22626 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
22627 @cindex AI-0035 (Ada 2012 feature)
22629 @noindent
22630   This AI remedies some inconsistencies in the legality rules for Pure units.
22631   Derived access types are legal in a pure unit (on the assumption that the
22632   rule for a zero storage pool size has been enforced on the ancestor type).
22633   The rules are enforced in generic instances and in subunits. GNAT has always
22634   implemented the recommended behavior.
22636 @noindent
22637   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)
22640 @item
22641 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
22642 @cindex AI-0219 (Ada 2012 feature)
22644 @noindent
22645   This AI refines the rules for the cases with limited parameters which do not
22646   allow the implementations to omit ``redundant''. GNAT now properly conforms
22647   to the requirements of this binding interpretation.
22649 @noindent
22650   RM References:  10.02.01 (18/2)
22652 @item
22653 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
22654 @cindex AI-0043 (Ada 2012 feature)
22656 @noindent
22657   This AI covers various omissions in the RM regarding the raising of
22658   exceptions. GNAT has always implemented the intended semantics.
22660 @noindent
22661   RM References:  11.04.01 (10.1/2)   11 (2)
22664 @item
22665 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
22666 @cindex AI-0200 (Ada 2012 feature)
22668 @noindent
22669   This AI plugs a gap in the RM which appeared to allow some obviously intended
22670   illegal instantiations. GNAT has never allowed these instantiations.
22672 @noindent
22673   RM References:  12.07 (16)
22676 @item
22677 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
22678 @cindex AI-0112 (Ada 2012 feature)
22680 @noindent
22681   This AI concerns giving names to various representation aspects, but the
22682   practical effect is simply to make the use of duplicate
22683   @code{Atomic}[@code{_Components}],
22684   @code{Volatile}[@code{_Components}] and
22685   @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
22686   now performs this required check.
22688 @noindent
22689   RM References:  13.01 (8)
22691 @item
22692 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
22693 @cindex AI-0106 (Ada 2012 feature)
22695 @noindent
22696   The RM appeared to allow representation pragmas on generic formal parameters,
22697   but this was not intended, and GNAT has never permitted this usage.
22699 @noindent
22700   RM References:  13.01 (9.1/1)
22703 @item
22704 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
22705 @cindex AI-0012 (Ada 2012 feature)
22707 @noindent
22708   It is now illegal to give an inappropriate component size or a pragma
22709   @code{Pack} that attempts to change the component size in the case of atomic
22710   or aliased components. Previously GNAT ignored such an attempt with a
22711   warning.
22713 @noindent
22714   RM References:  13.02 (6.1/2)   13.02 (7)   C.06 (10)   C.06 (11)   C.06 (21)
22717 @item
22718 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
22719 @cindex AI-0039 (Ada 2012 feature)
22721 @noindent
22722   The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
22723   for stream attributes, but these were never useful and are now illegal. GNAT
22724   has always regarded such expressions as illegal.
22726 @noindent
22727   RM References:  13.03 (4)   13.03 (6)   13.13.02 (38/2)
22730 @item
22731 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
22732 @cindex AI-0095 (Ada 2012 feature)
22734 @noindent
22735   The prefix of @code{'Address} cannot statically denote a subprogram with
22736   convention @code{Intrinsic}. The use of the @code{Address} attribute raises
22737   @code{Program_Error} if the prefix denotes a subprogram with convention
22738   @code{Intrinsic}.
22740 @noindent
22741   RM References:  13.03 (11/1)
22744 @item
22745 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
22746 @cindex AI-0116 (Ada 2012 feature)
22748 @noindent
22749   This AI requires that the alignment of a class-wide object be no greater
22750   than the alignment of any type in the class. GNAT has always followed this
22751   recommendation.
22753 @noindent
22754   RM References:  13.03 (29)   13.11 (16)
22757 @item
22758 @emph{AI-0146 Type invariants (2009-09-21)}
22759 @cindex AI-0146 (Ada 2012 feature)
22761 @noindent
22762   Type invariants may be specified for private types using the aspect notation.
22763   Aspect @code{Type_Invariant} may be specified for any private type,
22764   @code{Type_Invariant'Class} can
22765   only be specified for tagged types, and is inherited by any descendent of the
22766   tagged types. The invariant is a boolean expression that is tested for being
22767   true in the following situations: conversions to the private type, object
22768   declarations for the private type that are default initialized, and
22769   [@b{in}] @b{out}
22770   parameters and returned result on return from any primitive operation for
22771   the type that is visible to a client.
22772   GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
22773   @code{Invariant'Class} for @code{Type_Invariant'Class}.
22775 @noindent
22776   RM References:  13.03.03 (00)
22778 @item
22779 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
22780 @cindex AI-0078 (Ada 2012 feature)
22782 @noindent
22783   In Ada 2012, compilers are required to support unchecked conversion where the
22784   target alignment is a multiple of the source alignment. GNAT always supported
22785   this case (and indeed all cases of differing alignments, doing copies where
22786   required if the alignment was reduced).
22788 @noindent
22789   RM References:  13.09 (7)
22792 @item
22793 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
22794 @cindex AI-0195 (Ada 2012 feature)
22796 @noindent
22797   The handling of invalid values is now designated to be implementation
22798   defined. This is a documentation change only, requiring Annex M in the GNAT
22799   Reference Manual to document this handling.
22800   In GNAT, checks for invalid values are made
22801   only when necessary to avoid erroneous behavior. Operations like assignments
22802   which cannot cause erroneous behavior ignore the possibility of invalid
22803   values and do not do a check. The date given above applies only to the
22804   documentation change, this behavior has always been implemented by GNAT.
22806 @noindent
22807   RM References:  13.09.01 (10)
22809 @item
22810 @emph{AI-0193 Alignment of allocators (2010-09-16)}
22811 @cindex AI-0193 (Ada 2012 feature)
22813 @noindent
22814   This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
22815   analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
22816   of size.
22818 @noindent
22819   RM References:  13.11 (16)   13.11 (21)   13.11.01 (0)   13.11.01 (1)
22820   13.11.01 (2)   13.11.01 (3)
22823 @item
22824 @emph{AI-0177 Parameterized expressions (2010-07-10)}
22825 @cindex AI-0177 (Ada 2012 feature)
22827 @noindent
22828   The new Ada 2012 notion of parameterized expressions is implemented. The form
22829   is:
22830 @smallexample
22831   @i{function specification} @b{is} (@i{expression})
22832 @end smallexample
22834 @noindent
22835   This is exactly equivalent to the
22836   corresponding function body that returns the expression, but it can appear
22837   in a package spec. Note that the expression must be parenthesized.
22839 @noindent
22840   RM References:  13.11.01 (3/2)
22842 @item
22843 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
22844 @cindex AI-0033 (Ada 2012 feature)
22846 @noindent
22847   Neither of these two pragmas may appear within a generic template, because
22848   the generic might be instantiated at other than the library level.
22850 @noindent
22851   RM References:  13.11.02 (16)   C.03.01 (7/2)   C.03.01 (8/2)
22854 @item
22855 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
22856 @cindex AI-0161 (Ada 2012 feature)
22858 @noindent
22859   A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
22860   of the default stream attributes for elementary types. If this restriction is
22861   in force, then it is necessary to provide explicit subprograms for any
22862   stream attributes used.
22864 @noindent
22865   RM References:  13.12.01 (4/2)   13.13.02 (40/2)   13.13.02 (52/2)
22867 @item
22868 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
22869 @cindex AI-0194 (Ada 2012 feature)
22871 @noindent
22872   The @code{Stream_Size} attribute returns the default number of bits in the
22873   stream representation of the given type.
22874   This value is not affected by the presence
22875   of stream subprogram attributes for the type. GNAT has always implemented
22876   this interpretation.
22878 @noindent
22879   RM References:  13.13.02 (1.2/2)
22881 @item
22882 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
22883 @cindex AI-0109 (Ada 2012 feature)
22885 @noindent
22886   This AI is an editorial change only. It removes the need for a tag check
22887   that can never fail.
22889 @noindent
22890   RM References:  13.13.02 (34/2)
22892 @item
22893 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
22894 @cindex AI-0007 (Ada 2012 feature)
22896 @noindent
22897   The RM as written appeared to limit the possibilities of declaring read
22898   attribute procedures for private scalar types. This limitation was not
22899   intended, and has never been enforced by GNAT.
22901 @noindent
22902   RM References:  13.13.02 (50/2)   13.13.02 (51/2)
22905 @item
22906 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
22907 @cindex AI-0065 (Ada 2012 feature)
22909 @noindent
22910   This AI clarifies the fact that all remote access types support external
22911   streaming. This fixes an obvious oversight in the definition of the
22912   language, and GNAT always implemented the intended correct rules.
22914 @noindent
22915   RM References:  13.13.02 (52/2)
22917 @item
22918 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
22919 @cindex AI-0019 (Ada 2012 feature)
22921 @noindent
22922   The RM suggests that primitive subprograms of a specific tagged type are
22923   frozen when the tagged type is frozen. This would be an incompatible change
22924   and is not intended. GNAT has never attempted this kind of freezing and its
22925   behavior is consistent with the recommendation of this AI.
22927 @noindent
22928   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)
22930 @item
22931 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
22932 @cindex AI-0017 (Ada 2012 feature)
22934 @noindent
22935   So-called ``Taft-amendment types'' (i.e., types that are completed in package
22936   bodies) are not frozen by the occurrence of bodies in the
22937   enclosing declarative part. GNAT always implemented this properly.
22939 @noindent
22940   RM References:  13.14 (3/1)
22943 @item
22944 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
22945 @cindex AI-0060 (Ada 2012 feature)
22947 @noindent
22948   This AI extends the definition of remote access types to include access
22949   to limited, synchronized, protected or task class-wide interface types.
22950   GNAT already implemented this extension.
22952 @noindent
22953   RM References:  A (4)   E.02.02 (9/1)   E.02.02 (9.2/1)   E.02.02 (14/2)   E.02.02 (18)
22955 @item
22956 @emph{AI-0114 Classification of letters (0000-00-00)}
22957 @cindex AI-0114 (Ada 2012 feature)
22959 @noindent
22960   The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
22961   181 (@code{MICRO SIGN}), and
22962   186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
22963   lower case letters by Unicode.
22964   However, they are not allowed in identifiers, and they
22965   return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
22966   This behavior is consistent with that defined in Ada 95.
22968 @noindent
22969   RM References:  A.03.02 (59)   A.04.06 (7)
22972 @item
22973 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
22974 @cindex AI-0185 (Ada 2012 feature)
22976 @noindent
22977   Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
22978   classification functions for @code{Wide_Character} and
22979   @code{Wide_Wide_Character}, as well as providing
22980   case folding routines for @code{Wide_[Wide_]Character} and
22981   @code{Wide_[Wide_]String}.
22983 @noindent
22984   RM References:  A.03.05 (0)   A.03.06 (0)
22987 @item
22988 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
22989 @cindex AI-0031 (Ada 2012 feature)
22991 @noindent
22992   A new version of @code{Find_Token} is added to all relevant string packages,
22993   with an extra parameter @code{From}. Instead of starting at the first
22994   character of the string, the search for a matching Token starts at the
22995   character indexed by the value of @code{From}.
22996   These procedures are available in all versions of Ada
22997   but if used in versions earlier than Ada 2012 they will generate a warning
22998   that an Ada 2012 subprogram is being used.
23000 @noindent
23001   RM References:  A.04.03 (16)   A.04.03 (67)   A.04.03 (68/1)   A.04.04 (51)
23002   A.04.05 (46)
23005 @item
23006 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
23007 @cindex AI-0056 (Ada 2012 feature)
23009 @noindent
23010   The wording in the Ada 2005 RM implied an incompatible handling of the
23011   @code{Index} functions, resulting in raising an exception instead of
23012   returning zero in some situations.
23013   This was not intended and has been corrected.
23014   GNAT always returned zero, and is thus consistent with this AI.
23016 @noindent
23017   RM References:  A.04.03 (56.2/2)   A.04.03 (58.5/2)
23020 @item
23021 @emph{AI-0137 String encoding package (2010-03-25)}
23022 @cindex AI-0137 (Ada 2012 feature)
23024 @noindent
23025   The packages @code{Ada.Strings.UTF_Encoding}, together with its child
23026   packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
23027   and @code{Wide_Wide_Strings} have been
23028   implemented. These packages (whose documentation can be found in the spec
23029   files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
23030   @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
23031   @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
23032   values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
23033   UTF-16), as well as conversions between the different UTF encodings. With
23034   the exception of @code{Wide_Wide_Strings}, these packages are available in
23035   Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
23036   The @code{Wide_Wide_Strings package}
23037   is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
23038   mode since it uses @code{Wide_Wide_Character}).
23040 @noindent
23041   RM References:  A.04.11
23043 @item
23044 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
23045 @cindex AI-0038 (Ada 2012 feature)
23047 @noindent
23048   These are minor errors in the description on three points. The intent on
23049   all these points has always been clear, and GNAT has always implemented the
23050   correct intended semantics.
23052 @noindent
23053   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)
23055 @item
23056 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
23057 @cindex AI-0044 (Ada 2012 feature)
23059 @noindent
23060   This AI places restrictions on allowed instantiations of generic containers.
23061   These restrictions are not checked by the compiler, so there is nothing to
23062   change in the implementation. This affects only the RM documentation.
23064 @noindent
23065   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)
23067 @item
23068 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
23069 @cindex AI-0127 (Ada 2012 feature)
23071 @noindent
23072   This package provides an interface for identifying the current locale.
23074 @noindent
23075   RM References:  A.19    A.19.01    A.19.02    A.19.03    A.19.05    A.19.06
23076   A.19.07    A.19.08    A.19.09    A.19.10    A.19.11    A.19.12    A.19.13
23080 @item
23081 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
23082 @cindex AI-0002 (Ada 2012 feature)
23084 @noindent
23085   The compiler is not required to support exporting an Ada subprogram with
23086   convention C if there are parameters or a return type of an unconstrained
23087   array type (such as @code{String}). GNAT allows such declarations but
23088   generates warnings. It is possible, but complicated, to write the
23089   corresponding C code and certainly such code would be specific to GNAT and
23090   non-portable.
23092 @noindent
23093   RM References:  B.01 (17)   B.03 (62)   B.03 (71.1/2)
23096 @item
23097 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
23098 @cindex AI05-0216 (Ada 2012 feature)
23100 @noindent
23101   It is clearly the intention that @code{No_Task_Hierarchy} is intended to
23102   forbid tasks declared locally within subprograms, or functions returning task
23103   objects, and that is the implementation that GNAT has always provided.
23104   However the language in the RM was not sufficiently clear on this point.
23105   Thus this is a documentation change in the RM only.
23107 @noindent
23108   RM References:  D.07 (3/3)
23110 @item
23111 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
23112 @cindex AI-0211 (Ada 2012 feature)
23114 @noindent
23115   The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
23116   @code{Ada.Real_Time.Timing_Events.Set_Handler}.
23118 @noindent
23119   RM References:  D.07 (5)   D.07 (10/2)   D.07 (10.4/2)   D.07 (10.7/2)
23121 @item
23122 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
23123 @cindex AI-0190 (Ada 2012 feature)
23125 @noindent
23126   This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
23127   used to control storage pools globally.
23128   In particular, you can force every access
23129   type that is used for allocation (@b{new}) to have an explicit storage pool,
23130   or you can declare a pool globally to be used for all access types that lack
23131   an explicit one.
23133 @noindent
23134   RM References:  D.07 (8)
23136 @item
23137 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
23138 @cindex AI-0189 (Ada 2012 feature)
23140 @noindent
23141   This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
23142   which says that no dynamic allocation will occur once elaboration is
23143   completed.
23144   In general this requires a run-time check, which is not required, and which
23145   GNAT does not attempt. But the static cases of allocators in a task body or
23146   in the body of the main program are detected and flagged at compile or bind
23147   time.
23149 @noindent
23150   RM References:  D.07 (19.1/2)   H.04 (23.3/2)
23152 @item
23153 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
23154 @cindex AI-0171 (Ada 2012 feature)
23156 @noindent
23157   A new package @code{System.Multiprocessors} is added, together with the
23158   definition of pragma @code{CPU} for controlling task affinity. A new no
23159   dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
23160   is added to the Ravenscar profile.
23162 @noindent
23163   RM References:  D.13.01 (4/2)   D.16
23166 @item
23167 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
23168 @cindex AI-0210 (Ada 2012 feature)
23170 @noindent
23171   This is a documentation only issue regarding wording of metric requirements,
23172   that does not affect the implementation of the compiler.
23174 @noindent
23175   RM References:  D.15 (24/2)
23178 @item
23179 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
23180 @cindex AI-0206 (Ada 2012 feature)
23182 @noindent
23183   Remote types packages are now allowed to depend on preelaborated packages.
23184   This was formerly considered illegal.
23186 @noindent
23187   RM References:  E.02.02 (6)
23191 @item
23192 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
23193 @cindex AI-0152 (Ada 2012 feature)
23195 @noindent
23196   Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
23197   where the type of the returned value is an anonymous access type.
23199 @noindent
23200   RM References:  H.04 (8/1)
23201 @end itemize
23204 @node Obsolescent Features
23205 @chapter Obsolescent Features
23207 @noindent
23208 This chapter describes features that are provided by GNAT, but are
23209 considered obsolescent since there are preferred ways of achieving
23210 the same effect. These features are provided solely for historical
23211 compatibility purposes.
23213 @menu
23214 * pragma No_Run_Time::
23215 * pragma Ravenscar::
23216 * pragma Restricted_Run_Time::
23217 * pragma Task_Info::
23218 * System.Task_Info (s-tasinf.ads)::
23219 @end menu
23221 @node pragma No_Run_Time
23222 @section pragma No_Run_Time
23224 The pragma @code{No_Run_Time} is used to achieve an affect similar
23225 to the use of the "Zero Foot Print" configurable run time, but without
23226 requiring a specially configured run time. The result of using this
23227 pragma, which must be used for all units in a partition, is to restrict
23228 the use of any language features requiring run-time support code. The
23229 preferred usage is to use an appropriately configured run-time that
23230 includes just those features that are to be made accessible.
23232 @node pragma Ravenscar
23233 @section pragma Ravenscar
23235 The pragma @code{Ravenscar} has exactly the same effect as pragma
23236 @code{Profile (Ravenscar)}. The latter usage is preferred since it
23237 is part of the new Ada 2005 standard.
23239 @node pragma Restricted_Run_Time
23240 @section pragma Restricted_Run_Time
23242 The pragma @code{Restricted_Run_Time} has exactly the same effect as
23243 pragma @code{Profile (Restricted)}. The latter usage is
23244 preferred since the Ada 2005 pragma @code{Profile} is intended for
23245 this kind of implementation dependent addition.
23247 @node pragma Task_Info
23248 @section pragma Task_Info
23250 The functionality provided by pragma @code{Task_Info} is now part of the
23251 Ada language. The @code{CPU} aspect and the package
23252 @code{System.Multiprocessors} offer a less system-dependent way to specify
23253 task affinity or to query the number of processsors.
23255 @noindent
23256 Syntax
23258 @smallexample @c ada
23259 pragma Task_Info (EXPRESSION);
23260 @end smallexample
23262 @noindent
23263 This pragma appears within a task definition (like pragma
23264 @code{Priority}) and applies to the task in which it appears.  The
23265 argument must be of type @code{System.Task_Info.Task_Info_Type}.
23266 The @code{Task_Info} pragma provides system dependent control over
23267 aspects of tasking implementation, for example, the ability to map
23268 tasks to specific processors.  For details on the facilities available
23269 for the version of GNAT that you are using, see the documentation
23270 in the spec of package System.Task_Info in the runtime
23271 library.
23273 @node System.Task_Info (s-tasinf.ads)
23274 @section package System.Task_Info (@file{s-tasinf.ads})
23276 @noindent
23277 This package provides target dependent functionality that is used
23278 to support the @code{Task_Info} pragma. The predefined Ada package
23279  @code{System.Multiprocessors} and the @code{CPU} aspect now provide a
23280 standard replacement for GNAT's @code{Task_Info} functionality.
23282 @include fdl.texi
23283 @c GNU Free Documentation License
23285 @node Concept Index
23286 @unnumbered Index
23288 @printindex cp
23290 @contents
23292 @bye