* snames.ads-tmpl (Name_Ivdep): New pragma-related name.
[official-gcc.git] / gcc / ada / gnat_rm.texi
blob34ac0e17aa9f89a3ad470c96cf19a2fd013c5c25
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::
89  --- The Detailed Node Listing ---
91 About This Guide
93 * What This Reference Manual Contains::
94 * Related Information::
96 Implementation Defined Pragmas
98 * Pragma Abort_Defer::
99 * Pragma Abstract_State::
100 * Pragma Ada_83::
101 * Pragma Ada_95::
102 * Pragma Ada_05::
103 * Pragma Ada_2005::
104 * Pragma Ada_12::
105 * Pragma Ada_2012::
106 * Pragma Allow_Integer_Address::
107 * Pragma Annotate::
108 * Pragma Assert::
109 * Pragma Assert_And_Cut::
110 * Pragma Assertion_Policy::
111 * Pragma Assume::
112 * Pragma Assume_No_Invalid_Values::
113 * Pragma Attribute_Definition::
114 * Pragma Ast_Entry::
115 * Pragma C_Pass_By_Copy::
116 * Pragma Check::
117 * Pragma Check_Float_Overflow::
118 * Pragma Check_Name::
119 * Pragma Check_Policy::
120 * Pragma CIL_Constructor::
121 * Pragma Comment::
122 * Pragma Common_Object::
123 * Pragma Compile_Time_Error::
124 * Pragma Compile_Time_Warning::
125 * Pragma Compiler_Unit::
126 * Pragma Compiler_Unit_Warning::
127 * Pragma Complete_Representation::
128 * Pragma Complex_Representation::
129 * Pragma Component_Alignment::
130 * Pragma Contract_Cases::
131 * Pragma Convention_Identifier::
132 * Pragma CPP_Class::
133 * Pragma CPP_Constructor::
134 * Pragma CPP_Virtual::
135 * Pragma CPP_Vtable::
136 * Pragma CPU::
137 * Pragma Debug::
138 * Pragma Debug_Policy::
139 * Pragma Default_Storage_Pool::
140 * Pragma Depends::
141 * Pragma Detect_Blocking::
142 * Pragma Disable_Atomic_Synchronization::
143 * Pragma Dispatching_Domain::
144 * Pragma Elaboration_Checks::
145 * Pragma Eliminate::
146 * Pragma Enable_Atomic_Synchronization::
147 * Pragma Export_Exception::
148 * Pragma Export_Function::
149 * Pragma Export_Object::
150 * Pragma Export_Procedure::
151 * Pragma Export_Value::
152 * Pragma Export_Valued_Procedure::
153 * Pragma Extend_System::
154 * Pragma Extensions_Allowed::
155 * Pragma External::
156 * Pragma External_Name_Casing::
157 * Pragma Fast_Math::
158 * Pragma Favor_Top_Level::
159 * Pragma Finalize_Storage_Only::
160 * Pragma Float_Representation::
161 * Pragma Global::
162 * Pragma Ident::
163 * Pragma Implementation_Defined::
164 * Pragma Implemented::
165 * Pragma Implicit_Packing::
166 * Pragma Import_Exception::
167 * Pragma Import_Function::
168 * Pragma Import_Object::
169 * Pragma Import_Procedure::
170 * Pragma Import_Valued_Procedure::
171 * Pragma Independent::
172 * Pragma Independent_Components::
173 * Pragma Initial_Condition::
174 * Pragma Initialize_Scalars::
175 * Pragma Initializes::
176 * Pragma Inline_Always::
177 * Pragma Inline_Generic::
178 * Pragma Interface::
179 * Pragma Interface_Name::
180 * Pragma Interrupt_Handler::
181 * Pragma Interrupt_State::
182 * Pragma Invariant::
183 * Pragma Java_Constructor::
184 * Pragma Java_Interface::
185 * Pragma Keep_Names::
186 * Pragma License::
187 * Pragma Link_With::
188 * Pragma Linker_Alias::
189 * Pragma Linker_Constructor::
190 * Pragma Linker_Destructor::
191 * Pragma Linker_Section::
192 * Pragma Long_Float::
193 * Pragma Loop_Invariant::
194 * Pragma Loop_Optimize::
195 * Pragma Loop_Variant::
196 * Pragma Machine_Attribute::
197 * Pragma Main::
198 * Pragma Main_Storage::
199 * Pragma No_Body::
200 * Pragma No_Inline::
201 * Pragma No_Return::
202 * Pragma No_Run_Time::
203 * Pragma No_Strict_Aliasing ::
204 * Pragma Normalize_Scalars::
205 * Pragma Obsolescent::
206 * Pragma Optimize_Alignment::
207 * Pragma Ordered::
208 * Pragma Overflow_Mode::
209 * Pragma Overriding_Renamings::
210 * Pragma Partition_Elaboration_Policy::
211 * Pragma Passive::
212 * Pragma Persistent_BSS::
213 * Pragma Polling::
214 * Pragma Post::
215 * Pragma Postcondition::
216 * Pragma Post_Class::
217 * Pragma Pre::
218 * Pragma Precondition::
219 * Pragma Predicate::
220 * Pragma Preelaborable_Initialization::
221 * Pragma Preelaborate_05::
222 * Pragma Pre_Class::
223 * Pragma Priority_Specific_Dispatching::
224 * Pragma Profile::
225 * Pragma Profile_Warnings::
226 * Pragma Propagate_Exceptions::
227 * Pragma Provide_Shift_Operators::
228 * Pragma Psect_Object::
229 * Pragma Pure_05::
230 * Pragma Pure_12::
231 * Pragma Pure_Function::
232 * Pragma Ravenscar::
233 * Pragma Refined_State::
234 * Pragma Relative_Deadline::
235 * Pragma Remote_Access_Type::
236 * Pragma Restricted_Run_Time::
237 * Pragma Restriction_Warnings::
238 * Pragma Reviewable::
239 * Pragma Share_Generic::
240 * Pragma Shared::
241 * Pragma Short_Circuit_And_Or::
242 * Pragma Short_Descriptors::
243 * Pragma Simple_Storage_Pool_Type::
244 * Pragma Source_File_Name::
245 * Pragma Source_File_Name_Project::
246 * Pragma Source_Reference::
247 * Pragma SPARK_Mode::
248 * Pragma Static_Elaboration_Desired::
249 * Pragma Stream_Convert::
250 * Pragma Style_Checks::
251 * Pragma Subtitle::
252 * Pragma Suppress::
253 * Pragma Suppress_All::
254 * Pragma Suppress_Debug_Info::
255 * Pragma Suppress_Exception_Locations::
256 * Pragma Suppress_Initialization::
257 * Pragma Task_Info::
258 * Pragma Task_Name::
259 * Pragma Task_Storage::
260 * Pragma Test_Case::
261 * Pragma Thread_Local_Storage::
262 * Pragma Time_Slice::
263 * Pragma Title::
264 * Pragma Type_Invariant::
265 * Pragma Type_Invariant_Class::
266 * Pragma Unchecked_Union::
267 * Pragma Unimplemented_Unit::
268 * Pragma Universal_Aliasing ::
269 * Pragma Universal_Data::
270 * Pragma Unmodified::
271 * Pragma Unreferenced::
272 * Pragma Unreferenced_Objects::
273 * Pragma Unreserve_All_Interrupts::
274 * Pragma Unsuppress::
275 * Pragma Use_VADS_Size::
276 * Pragma Validity_Checks::
277 * Pragma Volatile::
278 * Pragma Warning_As_Error::
279 * Pragma Warnings::
280 * Pragma Weak_External::
281 * Pragma Wide_Character_Encoding::
283 Implementation Defined Aspects
285 * Aspect Abstract_State::
286 * Aspect Contract_Cases::
287 * Aspect Depends::
288 * Aspect Dimension::
289 * Aspect Dimension_System::
290 * Aspect Favor_Top_Level::
291 * Aspect Global::
292 * Aspect Initial_Condition::
293 * Aspect Initializes::
294 * Aspect Inline_Always::
295 * Aspect Invariant::
296 * Aspect Linker_Section::
297 * Aspect Object_Size::
298 * Aspect Persistent_BSS::
299 * Aspect Predicate::
300 * Aspect Preelaborate_05::
301 * Aspect Pure_05::
302 * Aspect Pure_12::
303 * Aspect Pure_Function::
304 * Aspect Refined_State::
305 * Aspect Remote_Access_Type::
306 * Aspect Scalar_Storage_Order::
307 * Aspect Shared::
308 * Aspect Simple_Storage_Pool::
309 * Aspect Simple_Storage_Pool_Type::
310 * Aspect SPARK_Mode::
311 * Aspect Suppress_Debug_Info::
312 * Aspect Test_Case::
313 * Aspect Universal_Aliasing::
314 * Aspect Universal_Data::
315 * Aspect Unmodified::
316 * Aspect Unreferenced::
317 * Aspect Unreferenced_Objects::
318 * Aspect Value_Size::
319 * Aspect Warnings::
321 Implementation Defined Attributes
323 * Attribute Abort_Signal::
324 * Attribute Address_Size::
325 * Attribute Asm_Input::
326 * Attribute Asm_Output::
327 * Attribute AST_Entry::
328 * Attribute Bit::
329 * Attribute Bit_Position::
330 * Attribute Compiler_Version::
331 * Attribute Code_Address::
332 * Attribute Default_Bit_Order::
333 * Attribute Descriptor_Size::
334 * Attribute Elaborated::
335 * Attribute Elab_Body::
336 * Attribute Elab_Spec::
337 * Attribute Elab_Subp_Body::
338 * Attribute Emax::
339 * Attribute Enabled::
340 * Attribute Enum_Rep::
341 * Attribute Enum_Val::
342 * Attribute Epsilon::
343 * Attribute Fixed_Value::
344 * Attribute Has_Access_Values::
345 * Attribute Has_Discriminants::
346 * Attribute Img::
347 * Attribute Integer_Value::
348 * Attribute Invalid_Value::
349 * Attribute Large::
350 * Attribute Library_Level::
351 * Attribute Loop_Entry::
352 * Attribute Machine_Size::
353 * Attribute Mantissa::
354 * Attribute Max_Interrupt_Priority::
355 * Attribute Max_Priority::
356 * Attribute Maximum_Alignment::
357 * Attribute Mechanism_Code::
358 * Attribute Null_Parameter::
359 * Attribute Object_Size::
360 * Attribute Passed_By_Reference::
361 * Attribute Pool_Address::
362 * Attribute Range_Length::
363 * Attribute Ref::
364 * Attribute Restriction_Set::
365 * Attribute Result::
366 * Attribute Safe_Emax::
367 * Attribute Safe_Large::
368 * Attribute Scalar_Storage_Order::
369 * Attribute Simple_Storage_Pool::
370 * Attribute Small::
371 * Attribute Storage_Unit::
372 * Attribute Stub_Type::
373 * Attribute System_Allocator_Alignment::
374 * Attribute Target_Name::
375 * Attribute Tick::
376 * Attribute To_Address::
377 * Attribute Type_Class::
378 * Attribute UET_Address::
379 * Attribute Unconstrained_Array::
380 * Attribute Universal_Literal_String::
381 * Attribute Unrestricted_Access::
382 * Attribute Update::
383 * Attribute Valid_Scalars::
384 * Attribute VADS_Size::
385 * Attribute Value_Size::
386 * Attribute Wchar_T_Size::
387 * Attribute Word_Size::
389 Standard and Implementation Defined Restrictions
391 * Partition-Wide Restrictions::
392 * Program Unit Level Restrictions::
394 Partition-Wide Restrictions
396 * Immediate_Reclamation::
397 * Max_Asynchronous_Select_Nesting::
398 * Max_Entry_Queue_Length::
399 * Max_Protected_Entries::
400 * Max_Select_Alternatives::
401 * Max_Storage_At_Blocking::
402 * Max_Task_Entries::
403 * Max_Tasks::
404 * No_Abort_Statements::
405 * No_Access_Parameter_Allocators::
406 * No_Access_Subprograms::
407 * No_Allocators::
408 * No_Anonymous_Allocators::
409 * No_Calendar::
410 * No_Coextensions::
411 * No_Default_Initialization::
412 * No_Delay::
413 * No_Dependence::
414 * No_Direct_Boolean_Operators::
415 * No_Dispatch::
416 * No_Dispatching_Calls::
417 * No_Dynamic_Attachment::
418 * No_Dynamic_Priorities::
419 * No_Entry_Calls_In_Elaboration_Code::
420 * No_Enumeration_Maps::
421 * No_Exception_Handlers::
422 * No_Exception_Propagation::
423 * No_Exception_Registration::
424 * No_Exceptions::
425 * No_Finalization::
426 * No_Fixed_Point::
427 * No_Floating_Point::
428 * No_Implicit_Conditionals::
429 * No_Implicit_Dynamic_Code::
430 * No_Implicit_Heap_Allocations::
431 * No_Implicit_Loops::
432 * No_Initialize_Scalars::
433 * No_IO::
434 * No_Local_Allocators::
435 * No_Local_Protected_Objects::
436 * No_Local_Timing_Events::
437 * No_Nested_Finalization::
438 * No_Protected_Type_Allocators::
439 * No_Protected_Types::
440 * No_Recursion::
441 * No_Reentrancy::
442 * No_Relative_Delay::
443 * No_Requeue_Statements::
444 * No_Secondary_Stack::
445 * No_Select_Statements::
446 * No_Specific_Termination_Handlers::
447 * No_Specification_of_Aspect::
448 * No_Standard_Allocators_After_Elaboration::
449 * No_Standard_Storage_Pools::
450 * No_Stream_Optimizations::
451 * No_Streams::
452 * No_Task_Allocators::
453 * No_Task_Attributes_Package::
454 * No_Task_Hierarchy::
455 * No_Task_Termination::
456 * No_Tasking::
457 * No_Terminate_Alternatives::
458 * No_Unchecked_Access::
459 * Simple_Barriers::
460 * Static_Priorities::
461 * Static_Storage_Size::
463 Program Unit Level Restrictions
465 * No_Elaboration_Code::
466 * No_Entry_Queue::
467 * No_Implementation_Aspect_Specifications::
468 * No_Implementation_Attributes::
469 * No_Implementation_Identifiers::
470 * No_Implementation_Pragmas::
471 * No_Implementation_Restrictions::
472 * No_Implementation_Units::
473 * No_Implicit_Aliasing::
474 * No_Obsolescent_Features::
475 * No_Wide_Characters::
476 * SPARK_05::
478 The Implementation of Standard I/O
480 * Standard I/O Packages::
481 * FORM Strings::
482 * Direct_IO::
483 * Sequential_IO::
484 * Text_IO::
485 * Wide_Text_IO::
486 * Wide_Wide_Text_IO::
487 * Stream_IO::
488 * Text Translation::
489 * Shared Files::
490 * Filenames encoding::
491 * Open Modes::
492 * Operations on C Streams::
493 * Interfacing to C Streams::
495 The GNAT Library
497 * Ada.Characters.Latin_9 (a-chlat9.ads)::
498 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
499 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
500 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
501 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
502 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
503 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
504 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
505 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
506 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
507 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
508 * Ada.Command_Line.Environment (a-colien.ads)::
509 * Ada.Command_Line.Remove (a-colire.ads)::
510 * Ada.Command_Line.Response_File (a-clrefi.ads)::
511 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
512 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
513 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
514 * Ada.Exceptions.Traceback (a-exctra.ads)::
515 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
516 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
517 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
518 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
519 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
520 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
521 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
522 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
523 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
524 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
525 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
526 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
527 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
528 * GNAT.Altivec (g-altive.ads)::
529 * GNAT.Altivec.Conversions (g-altcon.ads)::
530 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
531 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
532 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
533 * GNAT.Array_Split (g-arrspl.ads)::
534 * GNAT.AWK (g-awk.ads)::
535 * GNAT.Bounded_Buffers (g-boubuf.ads)::
536 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
537 * GNAT.Bubble_Sort (g-bubsor.ads)::
538 * GNAT.Bubble_Sort_A (g-busora.ads)::
539 * GNAT.Bubble_Sort_G (g-busorg.ads)::
540 * GNAT.Byte_Order_Mark (g-byorma.ads)::
541 * GNAT.Byte_Swapping (g-bytswa.ads)::
542 * GNAT.Calendar (g-calend.ads)::
543 * GNAT.Calendar.Time_IO (g-catiio.ads)::
544 * GNAT.Case_Util (g-casuti.ads)::
545 * GNAT.CGI (g-cgi.ads)::
546 * GNAT.CGI.Cookie (g-cgicoo.ads)::
547 * GNAT.CGI.Debug (g-cgideb.ads)::
548 * GNAT.Command_Line (g-comlin.ads)::
549 * GNAT.Compiler_Version (g-comver.ads)::
550 * GNAT.Ctrl_C (g-ctrl_c.ads)::
551 * GNAT.CRC32 (g-crc32.ads)::
552 * GNAT.Current_Exception (g-curexc.ads)::
553 * GNAT.Debug_Pools (g-debpoo.ads)::
554 * GNAT.Debug_Utilities (g-debuti.ads)::
555 * GNAT.Decode_String (g-decstr.ads)::
556 * GNAT.Decode_UTF8_String (g-deutst.ads)::
557 * GNAT.Directory_Operations (g-dirope.ads)::
558 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
559 * GNAT.Dynamic_HTables (g-dynhta.ads)::
560 * GNAT.Dynamic_Tables (g-dyntab.ads)::
561 * GNAT.Encode_String (g-encstr.ads)::
562 * GNAT.Encode_UTF8_String (g-enutst.ads)::
563 * GNAT.Exception_Actions (g-excact.ads)::
564 * GNAT.Exception_Traces (g-exctra.ads)::
565 * GNAT.Exceptions (g-except.ads)::
566 * GNAT.Expect (g-expect.ads)::
567 * GNAT.Expect.TTY (g-exptty.ads)::
568 * GNAT.Float_Control (g-flocon.ads)::
569 * GNAT.Heap_Sort (g-heasor.ads)::
570 * GNAT.Heap_Sort_A (g-hesora.ads)::
571 * GNAT.Heap_Sort_G (g-hesorg.ads)::
572 * GNAT.HTable (g-htable.ads)::
573 * GNAT.IO (g-io.ads)::
574 * GNAT.IO_Aux (g-io_aux.ads)::
575 * GNAT.Lock_Files (g-locfil.ads)::
576 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
577 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
578 * GNAT.MD5 (g-md5.ads)::
579 * GNAT.Memory_Dump (g-memdum.ads)::
580 * GNAT.Most_Recent_Exception (g-moreex.ads)::
581 * GNAT.OS_Lib (g-os_lib.ads)::
582 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
583 * GNAT.Random_Numbers (g-rannum.ads)::
584 * GNAT.Regexp (g-regexp.ads)::
585 * GNAT.Registry (g-regist.ads)::
586 * GNAT.Regpat (g-regpat.ads)::
587 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
588 * GNAT.Semaphores (g-semaph.ads)::
589 * GNAT.Serial_Communications (g-sercom.ads)::
590 * GNAT.SHA1 (g-sha1.ads)::
591 * GNAT.SHA224 (g-sha224.ads)::
592 * GNAT.SHA256 (g-sha256.ads)::
593 * GNAT.SHA384 (g-sha384.ads)::
594 * GNAT.SHA512 (g-sha512.ads)::
595 * GNAT.Signals (g-signal.ads)::
596 * GNAT.Sockets (g-socket.ads)::
597 * GNAT.Source_Info (g-souinf.ads)::
598 * GNAT.Spelling_Checker (g-speche.ads)::
599 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
600 * GNAT.Spitbol.Patterns (g-spipat.ads)::
601 * GNAT.Spitbol (g-spitbo.ads)::
602 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
603 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
604 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
605 * GNAT.SSE (g-sse.ads)::
606 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
607 * GNAT.Strings (g-string.ads)::
608 * GNAT.String_Split (g-strspl.ads)::
609 * GNAT.Table (g-table.ads)::
610 * GNAT.Task_Lock (g-tasloc.ads)::
611 * GNAT.Threads (g-thread.ads)::
612 * GNAT.Time_Stamp (g-timsta.ads)::
613 * GNAT.Traceback (g-traceb.ads)::
614 * GNAT.Traceback.Symbolic (g-trasym.ads)::
615 * GNAT.UTF_32 (g-utf_32.ads)::
616 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
617 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
618 * GNAT.Wide_String_Split (g-wistsp.ads)::
619 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
620 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
621 * Interfaces.C.Extensions (i-cexten.ads)::
622 * Interfaces.C.Streams (i-cstrea.ads)::
623 * Interfaces.CPP (i-cpp.ads)::
624 * Interfaces.Packed_Decimal (i-pacdec.ads)::
625 * Interfaces.VxWorks (i-vxwork.ads)::
626 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
627 * System.Address_Image (s-addima.ads)::
628 * System.Assertions (s-assert.ads)::
629 * System.Memory (s-memory.ads)::
630 * System.Multiprocessors (s-multip.ads)::
631 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
632 * System.Partition_Interface (s-parint.ads)::
633 * System.Pool_Global (s-pooglo.ads)::
634 * System.Pool_Local (s-pooloc.ads)::
635 * System.Restrictions (s-restri.ads)::
636 * System.Rident (s-rident.ads)::
637 * System.Strings.Stream_Ops (s-ststop.ads)::
638 * System.Task_Info (s-tasinf.ads)::
639 * System.Wch_Cnv (s-wchcnv.ads)::
640 * System.Wch_Con (s-wchcon.ads)::
642 Text_IO
644 * Text_IO Stream Pointer Positioning::
645 * Text_IO Reading and Writing Non-Regular Files::
646 * Get_Immediate::
647 * Treating Text_IO Files as Streams::
648 * Text_IO Extensions::
649 * Text_IO Facilities for Unbounded Strings::
651 Wide_Text_IO
653 * Wide_Text_IO Stream Pointer Positioning::
654 * Wide_Text_IO Reading and Writing Non-Regular Files::
656 Wide_Wide_Text_IO
658 * Wide_Wide_Text_IO Stream Pointer Positioning::
659 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
661 Interfacing to Other Languages
663 * Interfacing to C::
664 * Interfacing to C++::
665 * Interfacing to COBOL::
666 * Interfacing to Fortran::
667 * Interfacing to non-GNAT Ada code::
669 Specialized Needs Annexes
671 Implementation of Specific Ada Features
672 * Machine Code Insertions::
673 * GNAT Implementation of Tasking::
674 * GNAT Implementation of Shared Passive Packages::
675 * Code Generation for Array Aggregates::
676 * The Size of Discriminated Records with Default Discriminants::
677 * Strict Conformance to the Ada Reference Manual::
679 Implementation of Ada 2012 Features
681 Obsolescent Features
683 GNU Free Documentation License
685 Index
686 @end menu
688 @end ifnottex
690 @node About This Guide
691 @unnumbered About This Guide
693 @noindent
694 This manual contains useful information in writing programs using the
695 @value{EDITION} compiler.  It includes information on implementation dependent
696 characteristics of @value{EDITION}, including all the information required by
697 Annex M of the Ada language standard.
699 @value{EDITION} implements Ada 95, Ada 2005 and Ada 2012, and it may also be
700 invoked in Ada 83 compatibility mode.
701 By default, @value{EDITION} assumes Ada 2012,
702 but you can override with a compiler switch
703 to explicitly specify the language version.
704 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
705 @value{EDITION} User's Guide}, for details on these switches.)
706 Throughout this manual, references to ``Ada'' without a year suffix
707 apply to all the Ada versions of the language.
709 Ada is designed to be highly portable.
710 In general, a program will have the same effect even when compiled by
711 different compilers on different platforms.
712 However, since Ada is designed to be used in a
713 wide variety of applications, it also contains a number of system
714 dependent features to be used in interfacing to the external world.
715 @cindex Implementation-dependent features
716 @cindex Portability
718 Note: Any program that makes use of implementation-dependent features
719 may be non-portable.  You should follow good programming practice and
720 isolate and clearly document any sections of your program that make use
721 of these features in a non-portable manner.
723 @ifset PROEDITION
724 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
725 ``GNAT'' in the remainder of this document.
726 @end ifset
728 @menu
729 * What This Reference Manual Contains::
730 * Conventions::
731 * Related Information::
732 @end menu
734 @node What This Reference Manual Contains
735 @unnumberedsec What This Reference Manual Contains
737 @noindent
738 This reference manual contains the following chapters:
740 @itemize @bullet
741 @item
742 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
743 pragmas, which can be used to extend and enhance the functionality of the
744 compiler.
746 @item
747 @ref{Implementation Defined Attributes}, lists GNAT
748 implementation-dependent attributes, which can be used to extend and
749 enhance the functionality of the compiler.
751 @item
752 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
753 implementation-dependent restrictions, which can be used to extend and
754 enhance the functionality of the compiler.
756 @item
757 @ref{Implementation Advice}, provides information on generally
758 desirable behavior which are not requirements that all compilers must
759 follow since it cannot be provided on all systems, or which may be
760 undesirable on some systems.
762 @item
763 @ref{Implementation Defined Characteristics}, provides a guide to
764 minimizing implementation dependent features.
766 @item
767 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
768 implemented by GNAT, and how they can be imported into user
769 application programs.
771 @item
772 @ref{Representation Clauses and Pragmas}, describes in detail the
773 way that GNAT represents data, and in particular the exact set
774 of representation clauses and pragmas that is accepted.
776 @item
777 @ref{Standard Library Routines}, provides a listing of packages and a
778 brief description of the functionality that is provided by Ada's
779 extensive set of standard library routines as implemented by GNAT@.
781 @item
782 @ref{The Implementation of Standard I/O}, details how the GNAT
783 implementation of the input-output facilities.
785 @item
786 @ref{The GNAT Library}, is a catalog of packages that complement
787 the Ada predefined library.
789 @item
790 @ref{Interfacing to Other Languages}, describes how programs
791 written in Ada using GNAT can be interfaced to other programming
792 languages.
794 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
795 of the specialized needs annexes.
797 @item
798 @ref{Implementation of Specific Ada Features}, discusses issues related
799 to GNAT's implementation of machine code insertions, tasking, and several
800 other features.
802 @item
803 @ref{Implementation of Ada 2012 Features}, describes the status of the
804 GNAT implementation of the Ada 2012 language standard.
806 @item
807 @ref{Obsolescent Features} documents implementation dependent features,
808 including pragmas and attributes, which are considered obsolescent, since
809 there are other preferred ways of achieving the same results. These
810 obsolescent forms are retained for backwards compatibility.
812 @end itemize
814 @cindex Ada 95 Language Reference Manual
815 @cindex Ada 2005 Language Reference Manual
816 @noindent
817 This reference manual assumes a basic familiarity with the Ada 95 language, as
818 described in the International Standard ANSI/ISO/IEC-8652:1995,
819 January 1995.
820 It does not require knowledge of the new features introduced by Ada 2005,
821 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
822 and Amendment 1).
823 Both reference manuals are included in the GNAT documentation
824 package.
826 @node Conventions
827 @unnumberedsec Conventions
828 @cindex Conventions, typographical
829 @cindex Typographical conventions
831 @noindent
832 Following are examples of the typographical and graphic conventions used
833 in this guide:
835 @itemize @bullet
836 @item
837 @code{Functions}, @code{utility program names}, @code{standard names},
838 and @code{classes}.
840 @item
841 @code{Option flags}
843 @item
844 @file{File names}, @samp{button names}, and @samp{field names}.
846 @item
847 @code{Variables}, @env{environment variables}, and @var{metasyntactic
848 variables}.
850 @item
851 @emph{Emphasis}.
853 @item
854 [optional information or parameters]
856 @item
857 Examples are described by text
858 @smallexample
859 and then shown this way.
860 @end smallexample
861 @end itemize
863 @noindent
864 Commands that are entered by the user are preceded in this manual by the
865 characters @samp{$ } (dollar sign followed by space).  If your system uses this
866 sequence as a prompt, then the commands will appear exactly as you see them
867 in the manual.  If your system uses some other prompt, then the command will
868 appear with the @samp{$} replaced by whatever prompt character you are using.
870 @node Related Information
871 @unnumberedsec Related Information
872 @noindent
873 See the following documents for further information on GNAT:
875 @itemize @bullet
876 @item
877 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
878 @value{EDITION} User's Guide}, which provides information on how to use the
879 GNAT compiler system.
881 @item
882 @cite{Ada 95 Reference Manual}, which contains all reference
883 material for the Ada 95 programming language.
885 @item
886 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
887 of the Ada 95 standard.  The annotations describe
888 detailed aspects of the design decision, and in particular contain useful
889 sections on Ada 83 compatibility.
891 @item
892 @cite{Ada 2005 Reference Manual}, which contains all reference
893 material for the Ada 2005 programming language.
895 @item
896 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
897 of the Ada 2005 standard.  The annotations describe
898 detailed aspects of the design decision, and in particular contain useful
899 sections on Ada 83 and Ada 95 compatibility.
901 @item
902 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
903 which contains specific information on compatibility between GNAT and
904 DEC Ada 83 systems.
906 @item
907 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
908 describes in detail the pragmas and attributes provided by the DEC Ada 83
909 compiler system.
911 @end itemize
913 @node Implementation Defined Pragmas
914 @chapter Implementation Defined Pragmas
916 @noindent
917 Ada defines a set of pragmas that can be used to supply additional
918 information to the compiler.  These language defined pragmas are
919 implemented in GNAT and work as described in the Ada Reference Manual.
921 In addition, Ada allows implementations to define additional pragmas
922 whose meaning is defined by the implementation.  GNAT provides a number
923 of these implementation-defined pragmas, which can be used to extend
924 and enhance the functionality of the compiler.  This section of the GNAT
925 Reference Manual describes these additional pragmas.
927 Note that any program using these pragmas might not be portable to other
928 compilers (although GNAT implements this set of pragmas on all
929 platforms).  Therefore if portability to other compilers is an important
930 consideration, the use of these pragmas should be minimized.
932 @menu
933 * Pragma Abort_Defer::
934 * Pragma Abstract_State::
935 * Pragma Ada_83::
936 * Pragma Ada_95::
937 * Pragma Ada_05::
938 * Pragma Ada_2005::
939 * Pragma Ada_12::
940 * Pragma Ada_2012::
941 * Pragma Allow_Integer_Address::
942 * Pragma Annotate::
943 * Pragma Assert::
944 * Pragma Assert_And_Cut::
945 * Pragma Assertion_Policy::
946 * Pragma Assume::
947 * Pragma Assume_No_Invalid_Values::
948 * Pragma Attribute_Definition::
949 * Pragma Ast_Entry::
950 * Pragma C_Pass_By_Copy::
951 * Pragma Check::
952 * Pragma Check_Float_Overflow::
953 * Pragma Check_Name::
954 * Pragma Check_Policy::
955 * Pragma CIL_Constructor::
956 * Pragma Comment::
957 * Pragma Common_Object::
958 * Pragma Compile_Time_Error::
959 * Pragma Compile_Time_Warning::
960 * Pragma Compiler_Unit::
961 * Pragma Compiler_Unit_Warning::
962 * Pragma Complete_Representation::
963 * Pragma Complex_Representation::
964 * Pragma Component_Alignment::
965 * Pragma Contract_Cases::
966 * Pragma Convention_Identifier::
967 * Pragma CPP_Class::
968 * Pragma CPP_Constructor::
969 * Pragma CPP_Virtual::
970 * Pragma CPP_Vtable::
971 * Pragma CPU::
972 * Pragma Debug::
973 * Pragma Debug_Policy::
974 * Pragma Default_Storage_Pool::
975 * Pragma Depends::
976 * Pragma Detect_Blocking::
977 * Pragma Disable_Atomic_Synchronization::
978 * Pragma Dispatching_Domain::
979 * Pragma Elaboration_Checks::
980 * Pragma Eliminate::
981 * Pragma Enable_Atomic_Synchronization::
982 * Pragma Export_Exception::
983 * Pragma Export_Function::
984 * Pragma Export_Object::
985 * Pragma Export_Procedure::
986 * Pragma Export_Value::
987 * Pragma Export_Valued_Procedure::
988 * Pragma Extend_System::
989 * Pragma Extensions_Allowed::
990 * Pragma External::
991 * Pragma External_Name_Casing::
992 * Pragma Fast_Math::
993 * Pragma Favor_Top_Level::
994 * Pragma Finalize_Storage_Only::
995 * Pragma Float_Representation::
996 * Pragma Global::
997 * Pragma Ident::
998 * Pragma Implementation_Defined::
999 * Pragma Implemented::
1000 * Pragma Implicit_Packing::
1001 * Pragma Import_Exception::
1002 * Pragma Import_Function::
1003 * Pragma Import_Object::
1004 * Pragma Import_Procedure::
1005 * Pragma Import_Valued_Procedure::
1006 * Pragma Independent::
1007 * Pragma Independent_Components::
1008 * Pragma Initial_Condition::
1009 * Pragma Initialize_Scalars::
1010 * Pragma Initializes::
1011 * Pragma Inline_Always::
1012 * Pragma Inline_Generic::
1013 * Pragma Interface::
1014 * Pragma Interface_Name::
1015 * Pragma Interrupt_Handler::
1016 * Pragma Interrupt_State::
1017 * Pragma Invariant::
1018 * Pragma Java_Constructor::
1019 * Pragma Java_Interface::
1020 * Pragma Keep_Names::
1021 * Pragma License::
1022 * Pragma Link_With::
1023 * Pragma Linker_Alias::
1024 * Pragma Linker_Constructor::
1025 * Pragma Linker_Destructor::
1026 * Pragma Linker_Section::
1027 * Pragma Long_Float::
1028 * Pragma Loop_Invariant::
1029 * Pragma Loop_Optimize::
1030 * Pragma Loop_Variant::
1031 * Pragma Machine_Attribute::
1032 * Pragma Main::
1033 * Pragma Main_Storage::
1034 * Pragma No_Body::
1035 * Pragma No_Inline::
1036 * Pragma No_Return::
1037 * Pragma No_Run_Time::
1038 * Pragma No_Strict_Aliasing::
1039 * Pragma Normalize_Scalars::
1040 * Pragma Obsolescent::
1041 * Pragma Optimize_Alignment::
1042 * Pragma Ordered::
1043 * Pragma Overflow_Mode::
1044 * Pragma Overriding_Renamings::
1045 * Pragma Partition_Elaboration_Policy::
1046 * Pragma Passive::
1047 * Pragma Persistent_BSS::
1048 * Pragma Polling::
1049 * Pragma Post::
1050 * Pragma Postcondition::
1051 * Pragma Post_Class::
1052 * Pragma Pre::
1053 * Pragma Precondition::
1054 * Pragma Predicate::
1055 * Pragma Preelaborable_Initialization::
1056 * Pragma Preelaborate_05::
1057 * Pragma Pre_Class::
1058 * Pragma Priority_Specific_Dispatching::
1059 * Pragma Profile::
1060 * Pragma Profile_Warnings::
1061 * Pragma Propagate_Exceptions::
1062 * Pragma Provide_Shift_Operators::
1063 * Pragma Psect_Object::
1064 * Pragma Pure_05::
1065 * Pragma Pure_12::
1066 * Pragma Pure_Function::
1067 * Pragma Ravenscar::
1068 * Pragma Refined_State::
1069 * Pragma Relative_Deadline::
1070 * Pragma Remote_Access_Type::
1071 * Pragma Restricted_Run_Time::
1072 * Pragma Restriction_Warnings::
1073 * Pragma Reviewable::
1074 * Pragma Share_Generic::
1075 * Pragma Shared::
1076 * Pragma Short_Circuit_And_Or::
1077 * Pragma Short_Descriptors::
1078 * Pragma Simple_Storage_Pool_Type::
1079 * Pragma Source_File_Name::
1080 * Pragma Source_File_Name_Project::
1081 * Pragma Source_Reference::
1082 * Pragma SPARK_Mode::
1083 * Pragma Static_Elaboration_Desired::
1084 * Pragma Stream_Convert::
1085 * Pragma Style_Checks::
1086 * Pragma Subtitle::
1087 * Pragma Suppress::
1088 * Pragma Suppress_All::
1089 * Pragma Suppress_Debug_Info::
1090 * Pragma Suppress_Exception_Locations::
1091 * Pragma Suppress_Initialization::
1092 * Pragma Task_Info::
1093 * Pragma Task_Name::
1094 * Pragma Task_Storage::
1095 * Pragma Test_Case::
1096 * Pragma Thread_Local_Storage::
1097 * Pragma Time_Slice::
1098 * Pragma Title::
1099 * Pragma Type_Invariant::
1100 * Pragma Type_Invariant_Class::
1101 * Pragma Unchecked_Union::
1102 * Pragma Unimplemented_Unit::
1103 * Pragma Universal_Aliasing ::
1104 * Pragma Universal_Data::
1105 * Pragma Unmodified::
1106 * Pragma Unreferenced::
1107 * Pragma Unreferenced_Objects::
1108 * Pragma Unreserve_All_Interrupts::
1109 * Pragma Unsuppress::
1110 * Pragma Use_VADS_Size::
1111 * Pragma Validity_Checks::
1112 * Pragma Volatile::
1113 * Pragma Warning_As_Error::
1114 * Pragma Warnings::
1115 * Pragma Weak_External::
1116 * Pragma Wide_Character_Encoding::
1117 @end menu
1119 @node Pragma Abort_Defer
1120 @unnumberedsec Pragma Abort_Defer
1121 @findex Abort_Defer
1122 @cindex Deferring aborts
1123 @noindent
1124 Syntax:
1125 @smallexample
1126 pragma Abort_Defer;
1127 @end smallexample
1129 @noindent
1130 This pragma must appear at the start of the statement sequence of a
1131 handled sequence of statements (right after the @code{begin}).  It has
1132 the effect of deferring aborts for the sequence of statements (but not
1133 for the declarations or handlers, if any, associated with this statement
1134 sequence).
1136 @node Pragma Abstract_State
1137 @unnumberedsec Pragma Abstract_State
1138 @findex Abstract_State
1139 @noindent
1140 For the description of this pragma, see SPARK 2014 Reference Manual,
1141 section 7.1.4.
1143 @node Pragma Ada_83
1144 @unnumberedsec Pragma Ada_83
1145 @findex Ada_83
1146 @noindent
1147 Syntax:
1148 @smallexample @c ada
1149 pragma Ada_83;
1150 @end smallexample
1152 @noindent
1153 A configuration pragma that establishes Ada 83 mode for the unit to
1154 which it applies, regardless of the mode set by the command line
1155 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
1156 the syntax and semantics of Ada 83, as defined in the original Ada
1157 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
1158 and Ada 2005 are not recognized, optional package bodies are allowed,
1159 and generics may name types with unknown discriminants without using
1160 the @code{(<>)} notation.  In addition, some but not all of the additional
1161 restrictions of Ada 83 are enforced.
1163 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
1164 Ada 83 code to be compiled and adapted to GNAT with less effort.
1165 Secondly, it aids in keeping code backwards compatible with Ada 83.
1166 However, there is no guarantee that code that is processed correctly
1167 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1168 83 compiler, since GNAT does not enforce all the additional checks
1169 required by Ada 83.
1171 @node Pragma Ada_95
1172 @unnumberedsec Pragma Ada_95
1173 @findex Ada_95
1174 @noindent
1175 Syntax:
1176 @smallexample @c ada
1177 pragma Ada_95;
1178 @end smallexample
1180 @noindent
1181 A configuration pragma that establishes Ada 95 mode for the unit to which
1182 it applies, regardless of the mode set by the command line switches.
1183 This mode is set automatically for the @code{Ada} and @code{System}
1184 packages and their children, so you need not specify it in these
1185 contexts.  This pragma is useful when writing a reusable component that
1186 itself uses Ada 95 features, but which is intended to be usable from
1187 either Ada 83 or Ada 95 programs.
1189 @node Pragma Ada_05
1190 @unnumberedsec Pragma Ada_05
1191 @findex Ada_05
1192 @noindent
1193 Syntax:
1194 @smallexample @c ada
1195 pragma Ada_05;
1196 pragma Ada_05 (local_NAME);
1197 @end smallexample
1199 @noindent
1200 A configuration pragma that establishes Ada 2005 mode for the unit to which
1201 it applies, regardless of the mode set by the command line switches.
1202 This pragma is useful when writing a reusable component that
1203 itself uses Ada 2005 features, but which is intended to be usable from
1204 either Ada 83 or Ada 95 programs.
1206 The one argument form (which is not a configuration pragma)
1207 is used for managing the transition from
1208 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
1209 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
1210 mode will generate a warning. In addition, in Ada_83 or Ada_95
1211 mode, a preference rule is established which does not choose
1212 such an entity unless it is unambiguously specified. This avoids
1213 extra subprograms marked this way from generating ambiguities in
1214 otherwise legal pre-Ada_2005 programs. The one argument form is
1215 intended for exclusive use in the GNAT run-time library.
1217 @node Pragma Ada_2005
1218 @unnumberedsec Pragma Ada_2005
1219 @findex Ada_2005
1220 @noindent
1221 Syntax:
1222 @smallexample @c ada
1223 pragma Ada_2005;
1224 @end smallexample
1226 @noindent
1227 This configuration pragma is a synonym for pragma Ada_05 and has the
1228 same syntax and effect.
1230 @node Pragma Ada_12
1231 @unnumberedsec Pragma Ada_12
1232 @findex Ada_12
1233 @noindent
1234 Syntax:
1235 @smallexample @c ada
1236 pragma Ada_12;
1237 pragma Ada_12 (local_NAME);
1238 @end smallexample
1240 @noindent
1241 A configuration pragma that establishes Ada 2012 mode for the unit to which
1242 it applies, regardless of the mode set by the command line switches.
1243 This mode is set automatically for the @code{Ada} and @code{System}
1244 packages and their children, so you need not specify it in these
1245 contexts.  This pragma is useful when writing a reusable component that
1246 itself uses Ada 2012 features, but which is intended to be usable from
1247 Ada 83, Ada 95, or Ada 2005 programs.
1249 The one argument form, which is not a configuration pragma,
1250 is used for managing the transition from Ada
1251 2005 to Ada 2012 in the run-time library. If an entity is marked
1252 as Ada_201 only, then referencing the entity in any pre-Ada_2012
1253 mode will generate a warning. In addition, in any pre-Ada_2012
1254 mode, a preference rule is established which does not choose
1255 such an entity unless it is unambiguously specified. This avoids
1256 extra subprograms marked this way from generating ambiguities in
1257 otherwise legal pre-Ada_2012 programs. The one argument form is
1258 intended for exclusive use in the GNAT run-time library.
1260 @node Pragma Ada_2012
1261 @unnumberedsec Pragma Ada_2012
1262 @findex Ada_2005
1263 @noindent
1264 Syntax:
1265 @smallexample @c ada
1266 pragma Ada_2012;
1267 @end smallexample
1269 @noindent
1270 This configuration pragma is a synonym for pragma Ada_12 and has the
1271 same syntax and effect.
1273 @node Pragma Allow_Integer_Address
1274 @unnumberedsec Pragma Allow_Integer_Address
1275 @findex Allow_Integer_Address
1276 @noindent
1277 Syntax:
1278 @smallexample @c ada
1279 pragma Allow_Integer_Address;
1280 @end smallexample
1282 @noindent
1283 In almost all versions of GNAT, @code{System.Address} is a private
1284 type in accordance with the implementation advice in the RM. This
1285 means that integer values,
1286 in particular integer literals, are not allowed as address values.
1287 If the configuration pragma
1288 @code{Allow_Integer_Address} is given, then integer expressions may
1289 be used anywhere a value of type @code{System.Address} is required.
1290 The effect is to introduce an implicit unchecked conversion from the
1291 integer value to type @code{System.Address}. The reverse case of using
1292 an address where an integer type is required is handled analogously.
1293 The following example compiles without errors:
1295 @smallexample @c ada
1296 pragma Allow_Integer_Address;
1297 with System; use System;
1298 package AddrAsInt is
1299    X : Integer;
1300    Y : Integer;
1301    for X'Address use 16#1240#;
1302    for Y use at 16#3230#;
1303    m : Address := 16#4000#;
1304    n : constant Address := 4000;
1305    p : constant Address := Address (X + Y);
1306    v : Integer := y'Address;
1307    w : constant Integer := Integer (Y'Address);
1308    type R is new integer;
1309    RR : R := 1000;
1310    Z : Integer;
1311    for Z'Address use RR;
1312 end AddrAsInt;
1313 @end smallexample
1315 @noindent
1316 Note that pragma @code{Allow_Integer_Address} is ignored if
1317 @code{System.Address}
1318 is not a private type. In implementations of @code{GNAT} where
1319 System.Address is a visible integer type (notably the implementations
1320 for @code{OpenVMS}), this pragma serves no purpose but is ignored
1321 rather than rejected to allow common sets of sources to be used
1322 in the two situations.
1324 @node Pragma Annotate
1325 @unnumberedsec Pragma Annotate
1326 @findex Annotate
1327 @noindent
1328 Syntax:
1329 @smallexample @c ada
1330 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1332 ARG ::= NAME | EXPRESSION
1333 @end smallexample
1335 @noindent
1336 This pragma is used to annotate programs.  @var{identifier} identifies
1337 the type of annotation.  GNAT verifies that it is an identifier, but does
1338 not otherwise analyze it. The second optional identifier is also left
1339 unanalyzed, and by convention is used to control the action of the tool to
1340 which the annotation is addressed.  The remaining @var{arg} arguments
1341 can be either string literals or more generally expressions.
1342 String literals are assumed to be either of type
1343 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1344 depending on the character literals they contain.
1345 All other kinds of arguments are analyzed as expressions, and must be
1346 unambiguous.
1348 The analyzed pragma is retained in the tree, but not otherwise processed
1349 by any part of the GNAT compiler, except to generate corresponding note
1350 lines in the generated ALI file. For the format of these note lines, see
1351 the compiler source file lib-writ.ads. This pragma is intended for use by
1352 external tools, including ASIS@. The use of pragma Annotate does not
1353 affect the compilation process in any way. This pragma may be used as
1354 a configuration pragma.
1356 @node Pragma Assert
1357 @unnumberedsec Pragma Assert
1358 @findex Assert
1359 @noindent
1360 Syntax:
1361 @smallexample @c ada
1362 pragma Assert (
1363   boolean_EXPRESSION
1364   [, string_EXPRESSION]);
1365 @end smallexample
1367 @noindent
1368 The effect of this pragma depends on whether the corresponding command
1369 line switch is set to activate assertions.  The pragma expands into code
1370 equivalent to the following:
1372 @smallexample @c ada
1373 if assertions-enabled then
1374    if not boolean_EXPRESSION then
1375       System.Assertions.Raise_Assert_Failure
1376         (string_EXPRESSION);
1377    end if;
1378 end if;
1379 @end smallexample
1381 @noindent
1382 The string argument, if given, is the message that will be associated
1383 with the exception occurrence if the exception is raised.  If no second
1384 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1385 where @var{file} is the name of the source file containing the assert,
1386 and @var{nnn} is the line number of the assert.  A pragma is not a
1387 statement, so if a statement sequence contains nothing but a pragma
1388 assert, then a null statement is required in addition, as in:
1390 @smallexample @c ada
1391 @dots{}
1392 if J > 3 then
1393    pragma Assert (K > 3, "Bad value for K");
1394    null;
1395 end if;
1396 @end smallexample
1398 @noindent
1399 Note that, as with the @code{if} statement to which it is equivalent, the
1400 type of the expression is either @code{Standard.Boolean}, or any type derived
1401 from this standard type.
1403 Assert checks can be either checked or ignored. By default they are ignored.
1404 They will be checked if either the command line switch @option{-gnata} is
1405 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1406 to enable @code{Assert_Checks}.
1408 If assertions are ignored, then there
1409 is no run-time effect (and in particular, any side effects from the
1410 expression will not occur at run time).  (The expression is still
1411 analyzed at compile time, and may cause types to be frozen if they are
1412 mentioned here for the first time).
1414 If assertions are checked, then the given expression is tested, and if
1415 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1416 which results in the raising of @code{Assert_Failure} with the given message.
1418 You should generally avoid side effects in the expression arguments of
1419 this pragma, because these side effects will turn on and off with the
1420 setting of the assertions mode, resulting in assertions that have an
1421 effect on the program.  However, the expressions are analyzed for
1422 semantic correctness whether or not assertions are enabled, so turning
1423 assertions on and off cannot affect the legality of a program.
1425 Note that the implementation defined policy @code{DISABLE}, given in a
1426 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1428 Note: this is a standard language-defined pragma in versions
1429 of Ada from 2005 on. In GNAT, it is implemented in all versions
1430 of Ada, and the DISABLE policy is an implementation-defined
1431 addition.
1433 @node Pragma Assert_And_Cut
1434 @unnumberedsec Pragma Assert_And_Cut
1435 @findex Assert_And_Cut
1436 @noindent
1437 Syntax:
1438 @smallexample @c ada
1439 pragma Assert_And_Cut (
1440   boolean_EXPRESSION
1441   [, string_EXPRESSION]);
1442 @end smallexample
1444 @noindent
1445 The effect of this pragma is identical to that of pragma @code{Assert},
1446 except that in an @code{Assertion_Policy} pragma, the identifier
1447 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1448 (or disabled).
1450 The intention is that this be used within a subprogram when the
1451 given test expresion sums up all the work done so far in the
1452 subprogram, so that the rest of the subprogram can be verified
1453 (informally or formally) using only the entry preconditions,
1454 and the expression in this pragma. This allows dividing up
1455 a subprogram into sections for the purposes of testing or
1456 formal verification. The pragma also serves as useful
1457 documentation.
1459 @node Pragma Assertion_Policy
1460 @unnumberedsec Pragma Assertion_Policy
1461 @findex Assertion_Policy
1462 @noindent
1463 Syntax:
1464 @smallexample @c ada
1465 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1467 pragma Assertion_Policy (
1468     ASSERTION_KIND => POLICY_IDENTIFIER
1469  @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1471 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1473 RM_ASSERTION_KIND ::= Assert               |
1474                       Static_Predicate     |
1475                       Dynamic_Predicate    |
1476                       Pre                  |
1477                       Pre'Class            |
1478                       Post                 |
1479                       Post'Class           |
1480                       Type_Invariant       |
1481                       Type_Invariant'Class
1483 ID_ASSERTION_KIND ::= Assertions           |
1484                       Assert_And_Cut       |
1485                       Assume               |
1486                       Contract_Cases       |
1487                       Debug                |
1488                       Invariant            |
1489                       Invariant'Class      |
1490                       Loop_Invariant       |
1491                       Loop_Variant         |
1492                       Postcondition        |
1493                       Precondition         |
1494                       Predicate            |
1495                       Refined_Post         |
1496                       Statement_Assertions
1498 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1499 @end smallexample
1501 @noindent
1502 This is a standard Ada 2012 pragma that is available as an
1503 implementation-defined pragma in earlier versions of Ada.
1504 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1505 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1506 are implementation defined additions recognized by the GNAT compiler.
1508 The pragma applies in both cases to pragmas and aspects with matching
1509 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1510 applies to both the @code{Precondition} pragma
1511 and the aspect @code{Precondition}. Note that the identifiers for
1512 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
1513 Pre_Class and Post_Class), since these pragmas are intended to be
1514 identical to the corresponding aspects).
1516 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1517 the corresponding pragma or aspect is activated.
1518 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1519 the corresponding pragma or aspect is deactivated.
1520 This pragma overrides the effect of the @option{-gnata} switch on the
1521 command line.
1523 The implementation defined policy @code{DISABLE} is like
1524 @code{IGNORE} except that it completely disables semantic
1525 checking of the corresponding pragma or aspect. This is
1526 useful when the pragma or aspect argument references subprograms
1527 in a with'ed package which is replaced by a dummy package
1528 for the final build.
1530 The implementation defined policy @code{Assertions} applies to all
1531 assertion kinds. The form with no assertion kind given implies this
1532 choice, so it applies to all assertion kinds (RM defined, and
1533 implementation defined).
1535 The implementation defined policy @code{Statement_Assertions}
1536 applies to @code{Assert}, @code{Assert_And_Cut},
1537 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
1539 @node Pragma Assume
1540 @unnumberedsec Pragma Assume
1541 @findex Assume
1542 @noindent
1543 Syntax:
1544 @smallexample @c ada
1545 pragma Assume (
1546   boolean_EXPRESSION
1547   [, string_EXPRESSION]);
1548 @end smallexample
1550 @noindent
1551 The effect of this pragma is identical to that of pragma @code{Assert},
1552 except that in an @code{Assertion_Policy} pragma, the identifier
1553 @code{Assume} is used to control whether it is ignored or checked
1554 (or disabled).
1556 The intention is that this be used for assumptions about the
1557 external environment. So you cannot expect to verify formally
1558 or informally that the condition is met, this must be
1559 established by examining things outside the program itself.
1560 For example, we may have code that depends on the size of
1561 @code{Long_Long_Integer} being at least 64. So we could write:
1563 @smallexample @c ada
1564 pragma Assume (Long_Long_Integer'Size >= 64);
1565 @end smallexample
1567 @noindent
1568 This assumption cannot be proved from the program itself,
1569 but it acts as a useful run-time check that the assumption
1570 is met, and documents the need to ensure that it is met by
1571 reference to information outside the program.
1573 @node Pragma Assume_No_Invalid_Values
1574 @unnumberedsec Pragma Assume_No_Invalid_Values
1575 @findex Assume_No_Invalid_Values
1576 @cindex Invalid representations
1577 @cindex Invalid values
1578 @noindent
1579 Syntax:
1580 @smallexample @c ada
1581 pragma Assume_No_Invalid_Values (On | Off);
1582 @end smallexample
1584 @noindent
1585 This is a configuration pragma that controls the assumptions made by the
1586 compiler about the occurrence of invalid representations (invalid values)
1587 in the code.
1589 The default behavior (corresponding to an Off argument for this pragma), is
1590 to assume that values may in general be invalid unless the compiler can
1591 prove they are valid. Consider the following example:
1593 @smallexample @c ada
1594 V1 : Integer range 1 .. 10;
1595 V2 : Integer range 11 .. 20;
1597 for J in V2 .. V1 loop
1598    ...
1599 end loop;
1600 @end smallexample
1602 @noindent
1603 if V1 and V2 have valid values, then the loop is known at compile
1604 time not to execute since the lower bound must be greater than the
1605 upper bound. However in default mode, no such assumption is made,
1606 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1607 is given, the compiler will assume that any occurrence of a variable
1608 other than in an explicit @code{'Valid} test always has a valid
1609 value, and the loop above will be optimized away.
1611 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1612 you know your code is free of uninitialized variables and other
1613 possible sources of invalid representations, and may result in
1614 more efficient code. A program that accesses an invalid representation
1615 with this pragma in effect is erroneous, so no guarantees can be made
1616 about its behavior.
1618 It is peculiar though permissible to use this pragma in conjunction
1619 with validity checking (-gnatVa). In such cases, accessing invalid
1620 values will generally give an exception, though formally the program
1621 is erroneous so there are no guarantees that this will always be the
1622 case, and it is recommended that these two options not be used together.
1624 @node Pragma Ast_Entry
1625 @unnumberedsec Pragma Ast_Entry
1626 @cindex OpenVMS
1627 @findex Ast_Entry
1628 @noindent
1629 Syntax:
1630 @smallexample @c ada
1631 pragma AST_Entry (entry_IDENTIFIER);
1632 @end smallexample
1634 @noindent
1635 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1636 argument is the simple name of a single entry; at most one @code{AST_Entry}
1637 pragma is allowed for any given entry.  This pragma must be used in
1638 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1639 the entry declaration and in the same task type specification or single task
1640 as the entry to which it applies.  This pragma specifies that the given entry
1641 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1642 resulting from an OpenVMS system service call.  The pragma does not affect
1643 normal use of the entry.  For further details on this pragma, see the
1644 DEC Ada Language Reference Manual, section 9.12a.
1646 @node Pragma Attribute_Definition
1647 @unnumberedsec Pragma Attribute_Definition
1648 @findex Attribute_Definition
1649 @noindent
1650 Syntax:
1651 @smallexample @c ada
1652 pragma Attribute_Definition
1653   ([Attribute  =>] ATTRIBUTE_DESIGNATOR,
1654    [Entity     =>] LOCAL_NAME,
1655    [Expression =>] EXPRESSION | NAME);
1656 @end smallexample
1658 @noindent
1659 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1660 the attribute definition clause:
1662 @smallexample @c ada
1663   for Entity'Attribute use Expression;
1664 @end smallexample
1666 If @code{Attribute} is not a recognized attribute name, the pragma is
1667 ignored, and a warning is emitted. This allows source
1668 code to be written that takes advantage of some new attribute, while remaining
1669 compilable with earlier compilers.
1671 @node Pragma C_Pass_By_Copy
1672 @unnumberedsec Pragma C_Pass_By_Copy
1673 @cindex Passing by copy
1674 @findex C_Pass_By_Copy
1675 @noindent
1676 Syntax:
1677 @smallexample @c ada
1678 pragma C_Pass_By_Copy
1679   ([Max_Size =>] static_integer_EXPRESSION);
1680 @end smallexample
1682 @noindent
1683 Normally the default mechanism for passing C convention records to C
1684 convention subprograms is to pass them by reference, as suggested by RM
1685 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1686 this default, by requiring that record formal parameters be passed by
1687 copy if all of the following conditions are met:
1689 @itemize @bullet
1690 @item
1691 The size of the record type does not exceed the value specified for
1692 @code{Max_Size}.
1693 @item
1694 The record type has @code{Convention C}.
1695 @item
1696 The formal parameter has this record type, and the subprogram has a
1697 foreign (non-Ada) convention.
1698 @end itemize
1700 @noindent
1701 If these conditions are met the argument is passed by copy, i.e.@: in a
1702 manner consistent with what C expects if the corresponding formal in the
1703 C prototype is a struct (rather than a pointer to a struct).
1705 You can also pass records by copy by specifying the convention
1706 @code{C_Pass_By_Copy} for the record type, or by using the extended
1707 @code{Import} and @code{Export} pragmas, which allow specification of
1708 passing mechanisms on a parameter by parameter basis.
1710 @node Pragma Check
1711 @unnumberedsec Pragma Check
1712 @cindex Assertions
1713 @cindex Named assertions
1714 @findex Check
1715 @noindent
1716 Syntax:
1717 @smallexample @c ada
1718 pragma Check (
1719      [Name    =>] CHECK_KIND,
1720      [Check   =>] Boolean_EXPRESSION
1721   [, [Message =>] string_EXPRESSION] );
1723 CHECK_KIND ::= IDENTIFIER           |
1724                Pre'Class            |
1725                Post'Class           |
1726                Type_Invariant'Class |
1727                Invariant'Class
1728 @end smallexample
1730 @noindent
1731 This pragma is similar to the predefined pragma @code{Assert} except that an
1732 extra identifier argument is present. In conjunction with pragma
1733 @code{Check_Policy}, this can be used to define groups of assertions that can
1734 be independently controlled. The identifier @code{Assertion} is special, it
1735 refers to the normal set of pragma @code{Assert} statements.
1737 Checks introduced by this pragma are normally deactivated by default. They can
1738 be activated either by the command line option @option{-gnata}, which turns on
1739 all checks, or individually controlled using pragma @code{Check_Policy}.
1741 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1742 permitted as check kinds, since this would cause confusion with the use
1743 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1744 pragmas, where they are used to refer to sets of assertions.
1746 @node Pragma Check_Float_Overflow
1747 @unnumberedsec Pragma Check_Float_Overflow
1748 @cindex Floating-point overflow
1749 @findex Check_Float_Overflow
1750 @noindent
1751 Syntax:
1752 @smallexample @c ada
1753 pragma Check_Float_Overflow;
1754 @end smallexample
1756 @noindent
1757 In Ada, the predefined floating-point types (@code{Short_Float},
1758 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1759 defined to be @emph{unconstrained}. This means that even though each
1760 has a well-defined base range, an operation that delivers a result
1761 outside this base range is not required to raise an exception.
1762 This implementation permission accommodates the notion
1763 of infinities in IEEE floating-point, and corresponds to the
1764 efficient execution mode on most machines. GNAT will not raise
1765 overflow exceptions on these machines; instead it will generate
1766 infinities and NaN's as defined in the IEEE standard.
1768 Generating infinities, although efficient, is not always desirable.
1769 Often the preferable approach is to check for overflow, even at the
1770 (perhaps considerable) expense of run-time performance.
1771 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1772 range constraints -- and indeed such a subtype
1773 can have the same base range as its base type. For example:
1775 @smallexample @c ada
1776 subtype My_Float is Float range Float'Range;
1777 @end smallexample
1779 @noindent
1780 Here @code{My_Float} has the same range as
1781 @code{Float} but is constrained, so operations on
1782 @code{My_Float} values will be checked for overflow
1783 against this range.
1785 This style will achieve the desired goal, but
1786 it is often more convenient to be able to simply use
1787 the standard predefined floating-point types as long
1788 as overflow checking could be guaranteed.
1789 The @code{Check_Float_Overflow}
1790 configuration pragma achieves this effect. If a unit is compiled
1791 subject to this configuration pragma, then all operations
1792 on predefined floating-point types will be treated as
1793 though those types were constrained, and overflow checks
1794 will be generated. The @code{Constraint_Error}
1795 exception is raised if the result is out of range.
1797 This mode can also be set by use of the compiler
1798 switch @option{-gnateF}.
1800 @node Pragma Check_Name
1801 @unnumberedsec Pragma Check_Name
1802 @cindex Defining check names
1803 @cindex Check names, defining
1804 @findex Check_Name
1805 @noindent
1806 Syntax:
1807 @smallexample @c ada
1808 pragma Check_Name (check_name_IDENTIFIER);
1809 @end smallexample
1811 @noindent
1812 This is a configuration pragma that defines a new implementation
1813 defined check name (unless IDENTIFIER matches one of the predefined
1814 check names, in which case the pragma has no effect). Check names
1815 are global to a partition, so if two or more configuration pragmas
1816 are present in a partition mentioning the same name, only one new
1817 check name is introduced.
1819 An implementation defined check name introduced with this pragma may
1820 be used in only three contexts: @code{pragma Suppress},
1821 @code{pragma Unsuppress},
1822 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1823 any of these three cases, the check name must be visible. A check
1824 name is visible if it is in the configuration pragmas applying to
1825 the current unit, or if it appears at the start of any unit that
1826 is part of the dependency set of the current unit (e.g., units that
1827 are mentioned in @code{with} clauses).
1829 Check names introduced by this pragma are subject to control by compiler
1830 switches (in particular -gnatp) in the usual manner.
1832 @node Pragma Check_Policy
1833 @unnumberedsec Pragma Check_Policy
1834 @cindex Controlling assertions
1835 @cindex Assertions, control
1836 @cindex Check pragma control
1837 @cindex Named assertions
1838 @findex Check
1839 @noindent
1840 Syntax:
1841 @smallexample @c ada
1842 pragma Check_Policy
1843  ([Name   =>] CHECK_KIND,
1844   [Policy =>] POLICY_IDENTIFIER);
1846 pragma Check_Policy (
1847     CHECK_KIND => POLICY_IDENTIFIER
1848  @{, CHECK_KIND => POLICY_IDENTIFIER@});
1850 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1852 CHECK_KIND ::= IDENTIFIER           |
1853                Pre'Class            |
1854                Post'Class           |
1855                Type_Invariant'Class |
1856                Invariant'Class
1858 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1859 avoids confusion between the two possible syntax forms for this pragma.
1861 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1862 @end smallexample
1864 @noindent
1865 This pragma is used to set the checking policy for assertions (specified
1866 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1867 to be checked using the @code{Check} pragma. It may appear either as
1868 a configuration pragma, or within a declarative part of package. In the
1869 latter case, it applies from the point where it appears to the end of
1870 the declarative region (like pragma @code{Suppress}).
1872 The @code{Check_Policy} pragma is similar to the
1873 predefined @code{Assertion_Policy} pragma,
1874 and if the check kind corresponds to one of the assertion kinds that
1875 are allowed by @code{Assertion_Policy}, then the effect is identical.
1877 If the first argument is Debug, then the policy applies to Debug pragmas,
1878 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1879 @code{IGNORE}, and allowing them to execute with normal semantics if
1880 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1881 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1882 be totally ignored and not analyzed semantically.
1884 Finally the first argument may be some other identifier than the above
1885 possibilities, in which case it controls a set of named assertions
1886 that can be checked using pragma @code{Check}. For example, if the pragma:
1888 @smallexample @c ada
1889 pragma Check_Policy (Critical_Error, OFF);
1890 @end smallexample
1892 @noindent
1893 is given, then subsequent @code{Check} pragmas whose first argument is also
1894 @code{Critical_Error} will be disabled.
1896 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1897 to turn on corresponding checks. The default for a set of checks for which no
1898 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1899 @option{-gnata} is given, which turns on all checks by default.
1901 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1902 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1903 compatibility with the standard @code{Assertion_Policy} pragma. The check
1904 policy setting @code{DISABLE} causes the second argument of a corresponding
1905 @code{Check} pragma to be completely ignored and not analyzed.
1907 @node Pragma CIL_Constructor
1908 @unnumberedsec Pragma CIL_Constructor
1909 @findex CIL_Constructor
1910 @noindent
1911 Syntax:
1913 @smallexample @c ada
1914 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1915 @end smallexample
1917 @noindent
1918 This pragma is used to assert that the specified Ada function should be
1919 mapped to the .NET constructor for some Ada tagged record type.
1921 See section 4.1 of the
1922 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1923 for related information.
1925 @node Pragma Comment
1926 @unnumberedsec Pragma Comment
1927 @findex Comment
1928 @noindent
1929 Syntax:
1931 @smallexample @c ada
1932 pragma Comment (static_string_EXPRESSION);
1933 @end smallexample
1935 @noindent
1936 This is almost identical in effect to pragma @code{Ident}.  It allows the
1937 placement of a comment into the object file and hence into the
1938 executable file if the operating system permits such usage.  The
1939 difference is that @code{Comment}, unlike @code{Ident}, has
1940 no limitations on placement of the pragma (it can be placed
1941 anywhere in the main source unit), and if more than one pragma
1942 is used, all comments are retained.
1944 @node Pragma Common_Object
1945 @unnumberedsec Pragma Common_Object
1946 @findex Common_Object
1947 @noindent
1948 Syntax:
1950 @smallexample @c ada
1951 pragma Common_Object (
1952      [Internal =>] LOCAL_NAME
1953   [, [External =>] EXTERNAL_SYMBOL]
1954   [, [Size     =>] EXTERNAL_SYMBOL] );
1956 EXTERNAL_SYMBOL ::=
1957   IDENTIFIER
1958 | static_string_EXPRESSION
1959 @end smallexample
1961 @noindent
1962 This pragma enables the shared use of variables stored in overlaid
1963 linker areas corresponding to the use of @code{COMMON}
1964 in Fortran.  The single
1965 object @var{LOCAL_NAME} is assigned to the area designated by
1966 the @var{External} argument.
1967 You may define a record to correspond to a series
1968 of fields.  The @var{Size} argument
1969 is syntax checked in GNAT, but otherwise ignored.
1971 @code{Common_Object} is not supported on all platforms.  If no
1972 support is available, then the code generator will issue a message
1973 indicating that the necessary attribute for implementation of this
1974 pragma is not available.
1976 @node Pragma Compile_Time_Error
1977 @unnumberedsec Pragma Compile_Time_Error
1978 @findex Compile_Time_Error
1979 @noindent
1980 Syntax:
1982 @smallexample @c ada
1983 pragma Compile_Time_Error
1984          (boolean_EXPRESSION, static_string_EXPRESSION);
1985 @end smallexample
1987 @noindent
1988 This pragma can be used to generate additional compile time
1989 error messages. It
1990 is particularly useful in generics, where errors can be issued for
1991 specific problematic instantiations. The first parameter is a boolean
1992 expression. The pragma is effective only if the value of this expression
1993 is known at compile time, and has the value True. The set of expressions
1994 whose values are known at compile time includes all static boolean
1995 expressions, and also other values which the compiler can determine
1996 at compile time (e.g., the size of a record type set by an explicit
1997 size representation clause, or the value of a variable which was
1998 initialized to a constant and is known not to have been modified).
1999 If these conditions are met, an error message is generated using
2000 the value given as the second argument. This string value may contain
2001 embedded ASCII.LF characters to break the message into multiple lines.
2003 @node Pragma Compile_Time_Warning
2004 @unnumberedsec Pragma Compile_Time_Warning
2005 @findex Compile_Time_Warning
2006 @noindent
2007 Syntax:
2009 @smallexample @c ada
2010 pragma Compile_Time_Warning
2011          (boolean_EXPRESSION, static_string_EXPRESSION);
2012 @end smallexample
2014 @noindent
2015 Same as pragma Compile_Time_Error, except a warning is issued instead
2016 of an error message. Note that if this pragma is used in a package that
2017 is with'ed by a client, the client will get the warning even though it
2018 is issued by a with'ed package (normally warnings in with'ed units are
2019 suppressed, but this is a special exception to that rule).
2021 One typical use is within a generic where compile time known characteristics
2022 of formal parameters are tested, and warnings given appropriately. Another use
2023 with a first parameter of True is to warn a client about use of a package,
2024 for example that it is not fully implemented.
2026 @node Pragma Compiler_Unit
2027 @unnumberedsec Pragma Compiler_Unit
2028 @findex Compiler_Unit
2029 @noindent
2030 Syntax:
2032 @smallexample @c ada
2033 pragma Compiler_Unit;
2034 @end smallexample
2036 @noindent
2037 This pragma is obsolete. It is equivalent to Compiler_Unit_Warning. It is
2038 retained so that old versions of the GNAT run-time that use this pragma can
2039 be compiled with newer versions of the compiler.
2041 @node Pragma Compiler_Unit_Warning
2042 @unnumberedsec Pragma Compiler_Unit_Warning
2043 @findex Compiler_Unit_Warning
2044 @noindent
2045 Syntax:
2047 @smallexample @c ada
2048 pragma Compiler_Unit_Warning;
2049 @end smallexample
2051 @noindent
2052 This pragma is intended only for internal use in the GNAT run-time library.
2053 It indicates that the unit is used as part of the compiler build. The effect
2054 is to generate warnings for the use of constructs (for example, conditional
2055 expressions) that would cause trouble when bootstrapping using an older
2056 version of GNAT. For the exact list of restrictions, see the compiler sources
2057 and references to Check_Compiler_Unit.
2059 @node Pragma Complete_Representation
2060 @unnumberedsec Pragma Complete_Representation
2061 @findex Complete_Representation
2062 @noindent
2063 Syntax:
2065 @smallexample @c ada
2066 pragma Complete_Representation;
2067 @end smallexample
2069 @noindent
2070 This pragma must appear immediately within a record representation
2071 clause. Typical placements are before the first component clause
2072 or after the last component clause. The effect is to give an error
2073 message if any component is missing a component clause. This pragma
2074 may be used to ensure that a record representation clause is
2075 complete, and that this invariant is maintained if fields are
2076 added to the record in the future.
2078 @node Pragma Complex_Representation
2079 @unnumberedsec Pragma Complex_Representation
2080 @findex Complex_Representation
2081 @noindent
2082 Syntax:
2084 @smallexample @c ada
2085 pragma Complex_Representation
2086         ([Entity =>] LOCAL_NAME);
2087 @end smallexample
2089 @noindent
2090 The @var{Entity} argument must be the name of a record type which has
2091 two fields of the same floating-point type.  The effect of this pragma is
2092 to force gcc to use the special internal complex representation form for
2093 this record, which may be more efficient.  Note that this may result in
2094 the code for this type not conforming to standard ABI (application
2095 binary interface) requirements for the handling of record types.  For
2096 example, in some environments, there is a requirement for passing
2097 records by pointer, and the use of this pragma may result in passing
2098 this type in floating-point registers.
2100 @node Pragma Component_Alignment
2101 @unnumberedsec Pragma Component_Alignment
2102 @cindex Alignments of components
2103 @findex Component_Alignment
2104 @noindent
2105 Syntax:
2107 @smallexample @c ada
2108 pragma Component_Alignment (
2109      [Form =>] ALIGNMENT_CHOICE
2110   [, [Name =>] type_LOCAL_NAME]);
2112 ALIGNMENT_CHOICE ::=
2113   Component_Size
2114 | Component_Size_4
2115 | Storage_Unit
2116 | Default
2117 @end smallexample
2119 @noindent
2120 Specifies the alignment of components in array or record types.
2121 The meaning of the @var{Form} argument is as follows:
2123 @table @code
2124 @findex Component_Size
2125 @item Component_Size
2126 Aligns scalar components and subcomponents of the array or record type
2127 on boundaries appropriate to their inherent size (naturally
2128 aligned).  For example, 1-byte components are aligned on byte boundaries,
2129 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2130 integer components are aligned on 4-byte boundaries and so on.  These
2131 alignment rules correspond to the normal rules for C compilers on all
2132 machines except the VAX@.
2134 @findex Component_Size_4
2135 @item Component_Size_4
2136 Naturally aligns components with a size of four or fewer
2137 bytes.  Components that are larger than 4 bytes are placed on the next
2138 4-byte boundary.
2140 @findex Storage_Unit
2141 @item Storage_Unit
2142 Specifies that array or record components are byte aligned, i.e.@:
2143 aligned on boundaries determined by the value of the constant
2144 @code{System.Storage_Unit}.
2146 @cindex OpenVMS
2147 @item Default
2148 Specifies that array or record components are aligned on default
2149 boundaries, appropriate to the underlying hardware or operating system or
2150 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
2151 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
2152 the @code{Default} choice is the same as @code{Component_Size} (natural
2153 alignment).
2154 @end table
2156 @noindent
2157 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2158 refer to a local record or array type, and the specified alignment
2159 choice applies to the specified type.  The use of
2160 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2161 @code{Component_Alignment} pragma to be ignored.  The use of
2162 @code{Component_Alignment} together with a record representation clause
2163 is only effective for fields not specified by the representation clause.
2165 If the @code{Name} parameter is absent, the pragma can be used as either
2166 a configuration pragma, in which case it applies to one or more units in
2167 accordance with the normal rules for configuration pragmas, or it can be
2168 used within a declarative part, in which case it applies to types that
2169 are declared within this declarative part, or within any nested scope
2170 within this declarative part.  In either case it specifies the alignment
2171 to be applied to any record or array type which has otherwise standard
2172 representation.
2174 If the alignment for a record or array type is not specified (using
2175 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2176 clause), the GNAT uses the default alignment as described previously.
2178 @node Pragma Contract_Cases
2179 @unnumberedsec Pragma Contract_Cases
2180 @cindex Contract cases
2181 @findex Contract_Cases
2182 @noindent
2183 Syntax:
2185 @smallexample @c ada
2186 pragma Contract_Cases (
2187    Condition => Consequence
2188  @{,Condition => Consequence@});
2189 @end smallexample
2191 @noindent
2192 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2193 that can complement or replace the contract given by a precondition and a
2194 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2195 by testing and formal verification tools. The compiler checks its validity and,
2196 depending on the assertion policy at the point of declaration of the pragma,
2197 it may insert a check in the executable. For code generation, the contract
2198 cases
2200 @smallexample @c ada
2201 pragma Contract_Cases (
2202   Cond1 => Pred1,
2203   Cond2 => Pred2);
2204 @end smallexample
2206 @noindent
2207 are equivalent to
2209 @smallexample @c ada
2210 C1 : constant Boolean := Cond1;  --  evaluated at subprogram entry
2211 C2 : constant Boolean := Cond2;  --  evaluated at subprogram entry
2212 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2213 pragma Postcondition (if C1 then Pred1);
2214 pragma Postcondition (if C2 then Pred2);
2215 @end smallexample
2217 @noindent
2218 The precondition ensures that one and only one of the conditions is
2219 satisfied on entry to the subprogram.
2220 The postcondition ensures that for the condition that was True on entry,
2221 the corrresponding consequence is True on exit. Other consequence expressions
2222 are not evaluated.
2224 A precondition @code{P} and postcondition @code{Q} can also be
2225 expressed as contract cases:
2227 @smallexample @c ada
2228 pragma Contract_Cases (P => Q);
2229 @end smallexample
2231 The placement and visibility rules for @code{Contract_Cases} pragmas are
2232 identical to those described for preconditions and postconditions.
2234 The compiler checks that boolean expressions given in conditions and
2235 consequences are valid, where the rules for conditions are the same as
2236 the rule for an expression in @code{Precondition} and the rules for
2237 consequences are the same as the rule for an expression in
2238 @code{Postcondition}. In particular, attributes @code{'Old} and
2239 @code{'Result} can only be used within consequence expressions.
2240 The condition for the last contract case may be @code{others}, to denote
2241 any case not captured by the previous cases. The
2242 following is an example of use within a package spec:
2244 @smallexample @c ada
2245 package Math_Functions is
2246    ...
2247    function Sqrt (Arg : Float) return Float;
2248    pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2249                           Arg >= 100       => Sqrt'Result >= 10,
2250                           others           => Sqrt'Result = 0);
2251    ...
2252 end Math_Functions;
2253 @end smallexample
2255 @noindent
2256 The meaning of contract cases is that only one case should apply at each
2257 call, as determined by the corresponding condition evaluating to True,
2258 and that the consequence for this case should hold when the subprogram
2259 returns.
2261 @node Pragma Convention_Identifier
2262 @unnumberedsec Pragma Convention_Identifier
2263 @findex Convention_Identifier
2264 @cindex Conventions, synonyms
2265 @noindent
2266 Syntax:
2268 @smallexample @c ada
2269 pragma Convention_Identifier (
2270          [Name =>]       IDENTIFIER,
2271          [Convention =>] convention_IDENTIFIER);
2272 @end smallexample
2274 @noindent
2275 This pragma provides a mechanism for supplying synonyms for existing
2276 convention identifiers. The @code{Name} identifier can subsequently
2277 be used as a synonym for the given convention in other pragmas (including
2278 for example pragma @code{Import} or another @code{Convention_Identifier}
2279 pragma). As an example of the use of this, suppose you had legacy code
2280 which used Fortran77 as the identifier for Fortran. Then the pragma:
2282 @smallexample @c ada
2283 pragma Convention_Identifier (Fortran77, Fortran);
2284 @end smallexample
2286 @noindent
2287 would allow the use of the convention identifier @code{Fortran77} in
2288 subsequent code, avoiding the need to modify the sources. As another
2289 example, you could use this to parameterize convention requirements
2290 according to systems. Suppose you needed to use @code{Stdcall} on
2291 windows systems, and @code{C} on some other system, then you could
2292 define a convention identifier @code{Library} and use a single
2293 @code{Convention_Identifier} pragma to specify which convention
2294 would be used system-wide.
2296 @node Pragma CPP_Class
2297 @unnumberedsec Pragma CPP_Class
2298 @findex CPP_Class
2299 @cindex Interfacing with C++
2300 @noindent
2301 Syntax:
2303 @smallexample @c ada
2304 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2305 @end smallexample
2307 @noindent
2308 The argument denotes an entity in the current declarative region that is
2309 declared as a record type. It indicates that the type corresponds to an
2310 externally declared C++ class type, and is to be laid out the same way
2311 that C++ would lay out the type. If the C++ class has virtual primitives
2312 then the record must be declared as a tagged record type.
2314 Types for which @code{CPP_Class} is specified do not have assignment or
2315 equality operators defined (such operations can be imported or declared
2316 as subprograms as required). Initialization is allowed only by constructor
2317 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2318 limited if not explicitly declared as limited or derived from a limited
2319 type, and an error is issued in that case.
2321 See @ref{Interfacing to C++} for related information.
2323 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2324 for backward compatibility but its functionality is available
2325 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2327 @node Pragma CPP_Constructor
2328 @unnumberedsec Pragma CPP_Constructor
2329 @cindex Interfacing with C++
2330 @findex CPP_Constructor
2331 @noindent
2332 Syntax:
2334 @smallexample @c ada
2335 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2336   [, [External_Name =>] static_string_EXPRESSION ]
2337   [, [Link_Name     =>] static_string_EXPRESSION ]);
2338 @end smallexample
2340 @noindent
2341 This pragma identifies an imported function (imported in the usual way
2342 with pragma @code{Import}) as corresponding to a C++ constructor. If
2343 @code{External_Name} and @code{Link_Name} are not specified then the
2344 @code{Entity} argument is a name that must have been previously mentioned
2345 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2346 must be of one of the following forms:
2348 @itemize @bullet
2349 @item
2350 @code{function @var{Fname} return @var{T}}
2352 @itemize @bullet
2353 @item
2354 @code{function @var{Fname} return @var{T}'Class}
2356 @item
2357 @code{function @var{Fname} (@dots{}) return @var{T}}
2358 @end itemize
2360 @item
2361 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2362 @end itemize
2364 @noindent
2365 where @var{T} is a limited record type imported from C++ with pragma
2366 @code{Import} and @code{Convention} = @code{CPP}.
2368 The first two forms import the default constructor, used when an object
2369 of type @var{T} is created on the Ada side with no explicit constructor.
2370 The latter two forms cover all the non-default constructors of the type.
2371 See the @value{EDITION} User's Guide for details.
2373 If no constructors are imported, it is impossible to create any objects
2374 on the Ada side and the type is implicitly declared abstract.
2376 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2377 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2378 GCC switch).
2379 See @ref{Interfacing to C++} for more related information.
2381 Note: The use of functions returning class-wide types for constructors is
2382 currently obsolete. They are supported for backward compatibility. The
2383 use of functions returning the type T leave the Ada sources more clear
2384 because the imported C++ constructors always return an object of type T;
2385 that is, they never return an object whose type is a descendant of type T.
2387 @node Pragma CPP_Virtual
2388 @unnumberedsec Pragma CPP_Virtual
2389 @cindex Interfacing to C++
2390 @findex CPP_Virtual
2391 @noindent
2392 This pragma is now obsolete and, other than generating a warning if warnings
2393 on obsolescent features are enabled, is completely ignored.
2394 It is retained for compatibility
2395 purposes. It used to be required to ensure compoatibility with C++, but
2396 is no longer required for that purpose because GNAT generates
2397 the same object layout as the G++ compiler by default.
2399 See @ref{Interfacing to C++} for related information.
2401 @node Pragma CPP_Vtable
2402 @unnumberedsec Pragma CPP_Vtable
2403 @cindex Interfacing with C++
2404 @findex CPP_Vtable
2405 @noindent
2406 This pragma is now obsolete and, other than generating a warning if warnings
2407 on obsolescent features are enabled, is completely ignored.
2408 It used to be required to ensure compatibility with C++, but
2409 is no longer required for that purpose because GNAT generates
2410 the same object layout than the G++ compiler by default.
2412 See @ref{Interfacing to C++} for related information.
2414 @node Pragma CPU
2415 @unnumberedsec Pragma CPU
2416 @findex CPU
2417 @noindent
2418 Syntax:
2420 @smallexample @c ada
2421 pragma CPU (EXPRESSION);
2422 @end smallexample
2424 @noindent
2425 This pragma is standard in Ada 2012, but is available in all earlier
2426 versions of Ada as an implementation-defined pragma.
2427 See Ada 2012 Reference Manual for details.
2429 @node Pragma Debug
2430 @unnumberedsec Pragma Debug
2431 @findex Debug
2432 @noindent
2433 Syntax:
2435 @smallexample @c ada
2436 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2438 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2439   PROCEDURE_NAME
2440 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2441 @end smallexample
2443 @noindent
2444 The procedure call argument has the syntactic form of an expression, meeting
2445 the syntactic requirements for pragmas.
2447 If debug pragmas are not enabled or if the condition is present and evaluates
2448 to False, this pragma has no effect. If debug pragmas are enabled, the
2449 semantics of the pragma is exactly equivalent to the procedure call statement
2450 corresponding to the argument with a terminating semicolon. Pragmas are
2451 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2452 intersperse calls to debug procedures in the middle of declarations. Debug
2453 pragmas can be enabled either by use of the command line switch @option{-gnata}
2454 or by use of the pragma @code{Check_Policy} with a first argument of
2455 @code{Debug}.
2457 @node Pragma Debug_Policy
2458 @unnumberedsec Pragma Debug_Policy
2459 @findex Debug_Policy
2460 @noindent
2461 Syntax:
2463 @smallexample @c ada
2464 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2465 @end smallexample
2467 @noindent
2468 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2469 with a first argument of @code{Debug}. It is retained for historical
2470 compatibility reasons.
2472 @node Pragma Default_Storage_Pool
2473 @unnumberedsec Pragma Default_Storage_Pool
2474 @findex Default_Storage_Pool
2475 @noindent
2476 Syntax:
2478 @smallexample @c ada
2479 pragma Default_Storage_Pool (storage_pool_NAME | null);
2480 @end smallexample
2482 @noindent
2483 This pragma is standard in Ada 2012, but is available in all earlier
2484 versions of Ada as an implementation-defined pragma.
2485 See Ada 2012 Reference Manual for details.
2487 @node Pragma Depends
2488 @unnumberedsec Pragma Depends
2489 @findex Depends
2490 @noindent
2491 For the description of this pragma, see SPARK 2014 Reference Manual,
2492 section 6.1.5.
2494 @node Pragma Detect_Blocking
2495 @unnumberedsec Pragma Detect_Blocking
2496 @findex Detect_Blocking
2497 @noindent
2498 Syntax:
2500 @smallexample @c ada
2501 pragma Detect_Blocking;
2502 @end smallexample
2504 @noindent
2505 This is a standard pragma in Ada 2005, that is available in all earlier
2506 versions of Ada as an implementation-defined pragma.
2508 This is a configuration pragma that forces the detection of potentially
2509 blocking operations within a protected operation, and to raise Program_Error
2510 if that happens.
2512 @node Pragma Disable_Atomic_Synchronization
2513 @unnumberedsec Pragma Disable_Atomic_Synchronization
2514 @cindex Atomic Synchronization
2515 @findex Disable_Atomic_Synchronization
2516 @noindent
2517 Syntax:
2519 @smallexample @c ada
2520 pragma Disable_Atomic_Synchronization [(Entity)];
2521 @end smallexample
2523 @noindent
2524 Ada requires that accesses (reads or writes) of an atomic variable be
2525 regarded as synchronization points in the case of multiple tasks.
2526 Particularly in the case of multi-processors this may require special
2527 handling, e.g. the generation of memory barriers. This capability may
2528 be turned off using this pragma in cases where it is known not to be
2529 required.
2531 The placement and scope rules for this pragma are the same as those
2532 for @code{pragma Suppress}. In particular it can be used as a
2533 configuration  pragma, or in a declaration sequence where it applies
2534 till the end of the scope. If an @code{Entity} argument is present,
2535 the action applies only to that entity.
2537 @node Pragma Dispatching_Domain
2538 @unnumberedsec Pragma Dispatching_Domain
2539 @findex Dispatching_Domain
2540 @noindent
2541 Syntax:
2543 @smallexample @c ada
2544 pragma Dispatching_Domain (EXPRESSION);
2545 @end smallexample
2547 @noindent
2548 This pragma is standard in Ada 2012, but is available in all earlier
2549 versions of Ada as an implementation-defined pragma.
2550 See Ada 2012 Reference Manual for details.
2552 @node Pragma Elaboration_Checks
2553 @unnumberedsec Pragma Elaboration_Checks
2554 @cindex Elaboration control
2555 @findex Elaboration_Checks
2556 @noindent
2557 Syntax:
2559 @smallexample @c ada
2560 pragma Elaboration_Checks (Dynamic | Static);
2561 @end smallexample
2563 @noindent
2564 This is a configuration pragma that provides control over the
2565 elaboration model used by the compilation affected by the
2566 pragma.  If the parameter is @code{Dynamic},
2567 then the dynamic elaboration
2568 model described in the Ada Reference Manual is used, as though
2569 the @option{-gnatE} switch had been specified on the command
2570 line.  If the parameter is @code{Static}, then the default GNAT static
2571 model is used.  This configuration pragma overrides the setting
2572 of the command line.  For full details on the elaboration models
2573 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2574 gnat_ugn, @value{EDITION} User's Guide}.
2576 @node Pragma Eliminate
2577 @unnumberedsec Pragma Eliminate
2578 @cindex Elimination of unused subprograms
2579 @findex Eliminate
2580 @noindent
2581 Syntax:
2583 @smallexample @c ada
2584 pragma Eliminate ([Entity          =>] DEFINING_DESIGNATOR,
2585                   [Source_Location =>] STRING_LITERAL);
2586 @end smallexample
2588 @noindent
2589 The string literal given for the source location is a string which
2590 specifies the line number of the occurrence of the entity, using
2591 the syntax for SOURCE_TRACE given below:
2593 @smallexample @c ada
2594  SOURCE_TRACE     ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2596  LBRACKET         ::= [
2597  RBRACKET         ::= ]
2599  SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2601  LINE_NUMBER      ::= DIGIT @{DIGIT@}
2602 @end smallexample
2604 @noindent
2605 Spaces around the colon in a @code{Source_Reference} are optional.
2607 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2608 explicit subprogram declaration, where the @code{entity} name in this
2609 designator appears on the source line specified by the source location.
2611 The source trace that is given as the @code{Source_Location} shall obey the
2612 following rules. The @code{FILE_NAME} is the short name (with no directory
2613 information) of an Ada source file, given using exactly the required syntax
2614 for the underlying file system (e.g. case is important if the underlying
2615 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2616 number of the occurrence of the @code{entity}
2617 as a decimal literal without an exponent or point. If an @code{entity} is not
2618 declared in a generic instantiation (this includes generic subprogram
2619 instances), the source trace includes only one source reference. If an entity
2620 is declared inside a generic instantiation, its source trace (when parsing
2621 from left to right) starts with the source location of the declaration of the
2622 entity in the generic unit and ends with the source location of the
2623 instantiation (it is given in square brackets). This approach is recursively
2624 used in case of nested instantiations: the rightmost (nested most deeply in
2625 square brackets) element of the source trace is the location of the outermost
2626 instantiation, the next to left element is the location of the next (first
2627 nested) instantiation in the code of the corresponding generic unit, and so
2628 on, and the leftmost element (that is out of any square brackets) is the
2629 location of the declaration of the entity to eliminate in a generic unit.
2631 Note that the @code{Source_Location} argument specifies which of a set of
2632 similarly named entities is being eliminated, dealing both with overloading,
2633 and also appearance of the same entity name in different scopes.
2635 This pragma indicates that the given entity is not used in the program to be
2636 compiled and built. The effect of the pragma is to allow the compiler to
2637 eliminate the code or data associated with the named entity. Any reference to
2638 an eliminated entity causes a compile-time or link-time error.
2640 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2641 in a system-independent manner, with unused entities eliminated, without
2642 needing to modify the source text. Normally the required set of
2643 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2645 Any source file change that removes, splits, or
2646 adds lines may make the set of Eliminate pragmas invalid because their
2647 @code{Source_Location} argument values may get out of date.
2649 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2650 operation. In this case all the subprograms to which the given operation can
2651 dispatch are considered to be unused (are never called as a result of a direct
2652 or a dispatching call).
2654 @node Pragma Enable_Atomic_Synchronization
2655 @unnumberedsec Pragma Enable_Atomic_Synchronization
2656 @cindex Atomic Synchronization
2657 @findex Enable_Atomic_Synchronization
2658 @noindent
2659 Syntax:
2661 @smallexample @c ada
2662 pragma Enable_Atomic_Synchronization [(Entity)];
2663 @end smallexample
2665 @noindent
2666 Ada requires that accesses (reads or writes) of an atomic variable be
2667 regarded as synchronization points in the case of multiple tasks.
2668 Particularly in the case of multi-processors this may require special
2669 handling, e.g. the generation of memory barriers. This synchronization
2670 is performed by default, but can be turned off using
2671 @code{pragma Disable_Atomic_Synchronization}. The
2672 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2673 it back on.
2675 The placement and scope rules for this pragma are the same as those
2676 for @code{pragma Unsuppress}. In particular it can be used as a
2677 configuration  pragma, or in a declaration sequence where it applies
2678 till the end of the scope. If an @code{Entity} argument is present,
2679 the action applies only to that entity.
2681 @node Pragma Export_Exception
2682 @unnumberedsec Pragma Export_Exception
2683 @cindex OpenVMS
2684 @findex Export_Exception
2685 @noindent
2686 Syntax:
2688 @smallexample @c ada
2689 pragma Export_Exception (
2690      [Internal =>] LOCAL_NAME
2691   [, [External =>] EXTERNAL_SYMBOL]
2692   [, [Form     =>] Ada | VMS]
2693   [, [Code     =>] static_integer_EXPRESSION]);
2695 EXTERNAL_SYMBOL ::=
2696   IDENTIFIER
2697 | static_string_EXPRESSION
2698 @end smallexample
2700 @noindent
2701 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
2702 causes the specified exception to be propagated outside of the Ada program,
2703 so that it can be handled by programs written in other OpenVMS languages.
2704 This pragma establishes an external name for an Ada exception and makes the
2705 name available to the OpenVMS Linker as a global symbol.  For further details
2706 on this pragma, see the
2707 DEC Ada Language Reference Manual, section 13.9a3.2.
2709 @node Pragma Export_Function
2710 @unnumberedsec Pragma Export_Function
2711 @cindex Argument passing mechanisms
2712 @findex Export_Function
2714 @noindent
2715 Syntax:
2717 @smallexample @c ada
2718 pragma Export_Function (
2719      [Internal         =>] LOCAL_NAME
2720   [, [External         =>] EXTERNAL_SYMBOL]
2721   [, [Parameter_Types  =>] PARAMETER_TYPES]
2722   [, [Result_Type      =>] result_SUBTYPE_MARK]
2723   [, [Mechanism        =>] MECHANISM]
2724   [, [Result_Mechanism =>] MECHANISM_NAME]);
2726 EXTERNAL_SYMBOL ::=
2727   IDENTIFIER
2728 | static_string_EXPRESSION
2729 | ""
2731 PARAMETER_TYPES ::=
2732   null
2733 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2735 TYPE_DESIGNATOR ::=
2736   subtype_NAME
2737 | subtype_Name ' Access
2739 MECHANISM ::=
2740   MECHANISM_NAME
2741 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2743 MECHANISM_ASSOCIATION ::=
2744   [formal_parameter_NAME =>] MECHANISM_NAME
2746 MECHANISM_NAME ::=
2747   Value
2748 | Reference
2749 | Descriptor [([Class =>] CLASS_NAME)]
2750 | Short_Descriptor [([Class =>] CLASS_NAME)]
2752 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2753 @end smallexample
2755 @noindent
2756 Use this pragma to make a function externally callable and optionally
2757 provide information on mechanisms to be used for passing parameter and
2758 result values.  We recommend, for the purposes of improving portability,
2759 this pragma always be used in conjunction with a separate pragma
2760 @code{Export}, which must precede the pragma @code{Export_Function}.
2761 GNAT does not require a separate pragma @code{Export}, but if none is
2762 present, @code{Convention Ada} is assumed, which is usually
2763 not what is wanted, so it is usually appropriate to use this
2764 pragma in conjunction with a @code{Export} or @code{Convention}
2765 pragma that specifies the desired foreign convention.
2766 Pragma @code{Export_Function}
2767 (and @code{Export}, if present) must appear in the same declarative
2768 region as the function to which they apply.
2770 @var{internal_name} must uniquely designate the function to which the
2771 pragma applies.  If more than one function name exists of this name in
2772 the declarative part you must use the @code{Parameter_Types} and
2773 @code{Result_Type} parameters is mandatory to achieve the required
2774 unique designation.  @var{subtype_mark}s in these parameters must
2775 exactly match the subtypes in the corresponding function specification,
2776 using positional notation to match parameters with subtype marks.
2777 The form with an @code{'Access} attribute can be used to match an
2778 anonymous access parameter.
2780 @cindex OpenVMS
2781 @cindex Passing by descriptor
2782 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2783 The default behavior for Export_Function is to accept either 64bit or
2784 32bit descriptors unless short_descriptor is specified, then only 32bit
2785 descriptors are accepted.
2787 @cindex Suppressing external name
2788 Special treatment is given if the EXTERNAL is an explicit null
2789 string or a static string expressions that evaluates to the null
2790 string. In this case, no external name is generated. This form
2791 still allows the specification of parameter mechanisms.
2793 @node Pragma Export_Object
2794 @unnumberedsec Pragma Export_Object
2795 @findex Export_Object
2796 @noindent
2797 Syntax:
2799 @smallexample @c ada
2800 pragma Export_Object
2801       [Internal =>] LOCAL_NAME
2802    [, [External =>] EXTERNAL_SYMBOL]
2803    [, [Size     =>] EXTERNAL_SYMBOL]
2805 EXTERNAL_SYMBOL ::=
2806   IDENTIFIER
2807 | static_string_EXPRESSION
2808 @end smallexample
2810 @noindent
2811 This pragma designates an object as exported, and apart from the
2812 extended rules for external symbols, is identical in effect to the use of
2813 the normal @code{Export} pragma applied to an object.  You may use a
2814 separate Export pragma (and you probably should from the point of view
2815 of portability), but it is not required.  @var{Size} is syntax checked,
2816 but otherwise ignored by GNAT@.
2818 @node Pragma Export_Procedure
2819 @unnumberedsec Pragma Export_Procedure
2820 @findex Export_Procedure
2821 @noindent
2822 Syntax:
2824 @smallexample @c ada
2825 pragma Export_Procedure (
2826      [Internal        =>] LOCAL_NAME
2827   [, [External        =>] EXTERNAL_SYMBOL]
2828   [, [Parameter_Types =>] PARAMETER_TYPES]
2829   [, [Mechanism       =>] MECHANISM]);
2831 EXTERNAL_SYMBOL ::=
2832   IDENTIFIER
2833 | static_string_EXPRESSION
2834 | ""
2836 PARAMETER_TYPES ::=
2837   null
2838 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2840 TYPE_DESIGNATOR ::=
2841   subtype_NAME
2842 | subtype_Name ' Access
2844 MECHANISM ::=
2845   MECHANISM_NAME
2846 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2848 MECHANISM_ASSOCIATION ::=
2849   [formal_parameter_NAME =>] MECHANISM_NAME
2851 MECHANISM_NAME ::=
2852   Value
2853 | Reference
2854 | Descriptor [([Class =>] CLASS_NAME)]
2855 | Short_Descriptor [([Class =>] CLASS_NAME)]
2857 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2858 @end smallexample
2860 @noindent
2861 This pragma is identical to @code{Export_Function} except that it
2862 applies to a procedure rather than a function and the parameters
2863 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2864 GNAT does not require a separate pragma @code{Export}, but if none is
2865 present, @code{Convention Ada} is assumed, which is usually
2866 not what is wanted, so it is usually appropriate to use this
2867 pragma in conjunction with a @code{Export} or @code{Convention}
2868 pragma that specifies the desired foreign convention.
2870 @cindex OpenVMS
2871 @cindex Passing by descriptor
2872 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2873 The default behavior for Export_Procedure is to accept either 64bit or
2874 32bit descriptors unless short_descriptor is specified, then only 32bit
2875 descriptors are accepted.
2877 @cindex Suppressing external name
2878 Special treatment is given if the EXTERNAL is an explicit null
2879 string or a static string expressions that evaluates to the null
2880 string. In this case, no external name is generated. This form
2881 still allows the specification of parameter mechanisms.
2883 @node Pragma Export_Value
2884 @unnumberedsec Pragma Export_Value
2885 @findex Export_Value
2886 @noindent
2887 Syntax:
2889 @smallexample @c ada
2890 pragma Export_Value (
2891   [Value     =>] static_integer_EXPRESSION,
2892   [Link_Name =>] static_string_EXPRESSION);
2893 @end smallexample
2895 @noindent
2896 This pragma serves to export a static integer value for external use.
2897 The first argument specifies the value to be exported. The Link_Name
2898 argument specifies the symbolic name to be associated with the integer
2899 value. This pragma is useful for defining a named static value in Ada
2900 that can be referenced in assembly language units to be linked with
2901 the application. This pragma is currently supported only for the
2902 AAMP target and is ignored for other targets.
2904 @node Pragma Export_Valued_Procedure
2905 @unnumberedsec Pragma Export_Valued_Procedure
2906 @findex Export_Valued_Procedure
2907 @noindent
2908 Syntax:
2910 @smallexample @c ada
2911 pragma Export_Valued_Procedure (
2912      [Internal        =>] LOCAL_NAME
2913   [, [External        =>] EXTERNAL_SYMBOL]
2914   [, [Parameter_Types =>] PARAMETER_TYPES]
2915   [, [Mechanism       =>] MECHANISM]);
2917 EXTERNAL_SYMBOL ::=
2918   IDENTIFIER
2919 | static_string_EXPRESSION
2920 | ""
2922 PARAMETER_TYPES ::=
2923   null
2924 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2926 TYPE_DESIGNATOR ::=
2927   subtype_NAME
2928 | subtype_Name ' Access
2930 MECHANISM ::=
2931   MECHANISM_NAME
2932 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2934 MECHANISM_ASSOCIATION ::=
2935   [formal_parameter_NAME =>] MECHANISM_NAME
2937 MECHANISM_NAME ::=
2938   Value
2939 | Reference
2940 | Descriptor [([Class =>] CLASS_NAME)]
2941 | Short_Descriptor [([Class =>] CLASS_NAME)]
2943 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2944 @end smallexample
2946 @noindent
2947 This pragma is identical to @code{Export_Procedure} except that the
2948 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2949 mode @code{OUT}, and externally the subprogram is treated as a function
2950 with this parameter as the result of the function.  GNAT provides for
2951 this capability to allow the use of @code{OUT} and @code{IN OUT}
2952 parameters in interfacing to external functions (which are not permitted
2953 in Ada functions).
2954 GNAT does not require a separate pragma @code{Export}, but if none is
2955 present, @code{Convention Ada} is assumed, which is almost certainly
2956 not what is wanted since the whole point of this pragma is to interface
2957 with foreign language functions, so it is usually appropriate to use this
2958 pragma in conjunction with a @code{Export} or @code{Convention}
2959 pragma that specifies the desired foreign convention.
2961 @cindex OpenVMS
2962 @cindex Passing by descriptor
2963 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2964 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2965 32bit descriptors unless short_descriptor is specified, then only 32bit
2966 descriptors are accepted.
2968 @cindex Suppressing external name
2969 Special treatment is given if the EXTERNAL is an explicit null
2970 string or a static string expressions that evaluates to the null
2971 string. In this case, no external name is generated. This form
2972 still allows the specification of parameter mechanisms.
2974 @node Pragma Extend_System
2975 @unnumberedsec Pragma Extend_System
2976 @cindex @code{system}, extending
2977 @cindex Dec Ada 83
2978 @findex Extend_System
2979 @noindent
2980 Syntax:
2982 @smallexample @c ada
2983 pragma Extend_System ([Name =>] IDENTIFIER);
2984 @end smallexample
2986 @noindent
2987 This pragma is used to provide backwards compatibility with other
2988 implementations that extend the facilities of package @code{System}.  In
2989 GNAT, @code{System} contains only the definitions that are present in
2990 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2991 implementation, provide many extensions to package @code{System}.
2993 For each such implementation accommodated by this pragma, GNAT provides a
2994 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2995 implementation, which provides the required additional definitions.  You
2996 can use this package in two ways.  You can @code{with} it in the normal
2997 way and access entities either by selection or using a @code{use}
2998 clause.  In this case no special processing is required.
3000 However, if existing code contains references such as
3001 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
3002 definitions provided in package @code{System}, you may use this pragma
3003 to extend visibility in @code{System} in a non-standard way that
3004 provides greater compatibility with the existing code.  Pragma
3005 @code{Extend_System} is a configuration pragma whose single argument is
3006 the name of the package containing the extended definition
3007 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
3008 control of this pragma will be processed using special visibility
3009 processing that looks in package @code{System.Aux_@var{xxx}} where
3010 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
3011 package @code{System}, but not found in package @code{System}.
3013 You can use this pragma either to access a predefined @code{System}
3014 extension supplied with the compiler, for example @code{Aux_DEC} or
3015 you can construct your own extension unit following the above
3016 definition.  Note that such a package is a child of @code{System}
3017 and thus is considered part of the implementation.
3018 To compile it you will have to use the @option{-gnatg} switch,
3019 or the @option{/GNAT_INTERNAL} qualifier on OpenVMS,
3020 for compiling System units, as explained in the
3021 @value{EDITION} User's Guide.
3023 @node Pragma Extensions_Allowed
3024 @unnumberedsec Pragma Extensions_Allowed
3025 @cindex Ada Extensions
3026 @cindex GNAT Extensions
3027 @findex Extensions_Allowed
3028 @noindent
3029 Syntax:
3031 @smallexample @c ada
3032 pragma Extensions_Allowed (On | Off);
3033 @end smallexample
3035 @noindent
3036 This configuration pragma enables or disables the implementation
3037 extension mode (the use of Off as a parameter cancels the effect
3038 of the @option{-gnatX} command switch).
3040 In extension mode, the latest version of the Ada language is
3041 implemented (currently Ada 2012), and in addition a small number
3042 of GNAT specific extensions are recognized as follows:
3044 @table @asis
3045 @item Constrained attribute for generic objects
3046 The @code{Constrained} attribute is permitted for objects of
3047 generic types. The result indicates if the corresponding actual
3048 is constrained.
3050 @end table
3052 @node Pragma External
3053 @unnumberedsec Pragma External
3054 @findex External
3055 @noindent
3056 Syntax:
3058 @smallexample @c ada
3059 pragma External (
3060   [   Convention    =>] convention_IDENTIFIER,
3061   [   Entity        =>] LOCAL_NAME
3062   [, [External_Name =>] static_string_EXPRESSION ]
3063   [, [Link_Name     =>] static_string_EXPRESSION ]);
3064 @end smallexample
3066 @noindent
3067 This pragma is identical in syntax and semantics to pragma
3068 @code{Export} as defined in the Ada Reference Manual.  It is
3069 provided for compatibility with some Ada 83 compilers that
3070 used this pragma for exactly the same purposes as pragma
3071 @code{Export} before the latter was standardized.
3073 @node Pragma External_Name_Casing
3074 @unnumberedsec Pragma External_Name_Casing
3075 @cindex Dec Ada 83 casing compatibility
3076 @cindex External Names, casing
3077 @cindex Casing of External names
3078 @findex External_Name_Casing
3079 @noindent
3080 Syntax:
3082 @smallexample @c ada
3083 pragma External_Name_Casing (
3084   Uppercase | Lowercase
3085   [, Uppercase | Lowercase | As_Is]);
3086 @end smallexample
3088 @noindent
3089 This pragma provides control over the casing of external names associated
3090 with Import and Export pragmas.  There are two cases to consider:
3092 @table @asis
3093 @item Implicit external names
3094 Implicit external names are derived from identifiers.  The most common case
3095 arises when a standard Ada Import or Export pragma is used with only two
3096 arguments, as in:
3098 @smallexample @c ada
3099    pragma Import (C, C_Routine);
3100 @end smallexample
3102 @noindent
3103 Since Ada is a case-insensitive language, the spelling of the identifier in
3104 the Ada source program does not provide any information on the desired
3105 casing of the external name, and so a convention is needed.  In GNAT the
3106 default treatment is that such names are converted to all lower case
3107 letters.  This corresponds to the normal C style in many environments.
3108 The first argument of pragma @code{External_Name_Casing} can be used to
3109 control this treatment.  If @code{Uppercase} is specified, then the name
3110 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3111 then the normal default of all lower case letters will be used.
3113 This same implicit treatment is also used in the case of extended DEC Ada 83
3114 compatible Import and Export pragmas where an external name is explicitly
3115 specified using an identifier rather than a string.
3117 @item Explicit external names
3118 Explicit external names are given as string literals.  The most common case
3119 arises when a standard Ada Import or Export pragma is used with three
3120 arguments, as in:
3122 @smallexample @c ada
3123 pragma Import (C, C_Routine, "C_routine");
3124 @end smallexample
3126 @noindent
3127 In this case, the string literal normally provides the exact casing required
3128 for the external name.  The second argument of pragma
3129 @code{External_Name_Casing} may be used to modify this behavior.
3130 If @code{Uppercase} is specified, then the name
3131 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3132 then the name will be forced to all lowercase letters.  A specification of
3133 @code{As_Is} provides the normal default behavior in which the casing is
3134 taken from the string provided.
3135 @end table
3137 @noindent
3138 This pragma may appear anywhere that a pragma is valid.  In particular, it
3139 can be used as a configuration pragma in the @file{gnat.adc} file, in which
3140 case it applies to all subsequent compilations, or it can be used as a program
3141 unit pragma, in which case it only applies to the current unit, or it can
3142 be used more locally to control individual Import/Export pragmas.
3144 It is primarily intended for use with OpenVMS systems, where many
3145 compilers convert all symbols to upper case by default.  For interfacing to
3146 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3147 the pragma:
3149 @smallexample @c ada
3150 pragma External_Name_Casing (Uppercase, Uppercase);
3151 @end smallexample
3153 @noindent
3154 to enforce the upper casing of all external symbols.
3156 @node Pragma Fast_Math
3157 @unnumberedsec Pragma Fast_Math
3158 @findex Fast_Math
3159 @noindent
3160 Syntax:
3162 @smallexample @c ada
3163 pragma Fast_Math;
3164 @end smallexample
3166 @noindent
3167 This is a configuration pragma which activates a mode in which speed is
3168 considered more important for floating-point operations than absolutely
3169 accurate adherence to the requirements of the standard. Currently the
3170 following operations are affected:
3172 @table @asis
3173 @item Complex Multiplication
3174 The normal simple formula for complex multiplication can result in intermediate
3175 overflows for numbers near the end of the range. The Ada standard requires that
3176 this situation be detected and corrected by scaling, but in Fast_Math mode such
3177 cases will simply result in overflow. Note that to take advantage of this you
3178 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3179 under control of the pragma, rather than use the preinstantiated versions.
3180 @end table
3182 @node Pragma Favor_Top_Level
3183 @unnumberedsec Pragma Favor_Top_Level
3184 @findex Favor_Top_Level
3185 @noindent
3186 Syntax:
3188 @smallexample @c ada
3189 pragma Favor_Top_Level (type_NAME);
3190 @end smallexample
3192 @noindent
3193 The named type must be an access-to-subprogram type. This pragma is an
3194 efficiency hint to the compiler, regarding the use of 'Access or
3195 'Unrestricted_Access on nested (non-library-level) subprograms. The
3196 pragma means that nested subprograms are not used with this type, or
3197 are rare, so that the generated code should be efficient in the
3198 top-level case. When this pragma is used, dynamically generated
3199 trampolines may be used on some targets for nested subprograms.
3200 See also the No_Implicit_Dynamic_Code restriction.
3202 @node Pragma Finalize_Storage_Only
3203 @unnumberedsec Pragma Finalize_Storage_Only
3204 @findex Finalize_Storage_Only
3205 @noindent
3206 Syntax:
3208 @smallexample @c ada
3209 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3210 @end smallexample
3212 @noindent
3213 This pragma allows the compiler not to emit a Finalize call for objects
3214 defined at the library level.  This is mostly useful for types where
3215 finalization is only used to deal with storage reclamation since in most
3216 environments it is not necessary to reclaim memory just before terminating
3217 execution, hence the name.
3219 @node Pragma Float_Representation
3220 @unnumberedsec Pragma Float_Representation
3221 @cindex OpenVMS
3222 @findex Float_Representation
3223 @noindent
3224 Syntax:
3226 @smallexample @c ada
3227 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3229 FLOAT_REP ::= VAX_Float | IEEE_Float
3230 @end smallexample
3232 @noindent
3233 In the one argument form, this pragma is a configuration pragma which
3234 allows control over the internal representation chosen for the predefined
3235 floating point types declared in the packages @code{Standard} and
3236 @code{System}. On all systems other than OpenVMS, the argument must
3237 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3238 argument may be @code{VAX_Float} to specify the use of the VAX float
3239 format for the floating-point types in Standard. This requires that
3240 the standard runtime libraries be recompiled.
3242 The two argument form specifies the representation to be used for
3243 the specified floating-point type. On all systems other than OpenVMS,
3244 the argument must
3245 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3247 @itemize @bullet
3248 @item
3249 For a digits value of 6, 32-bit IEEE short format will be used.
3250 @item
3251 For a digits value of 15, 64-bit IEEE long format will be used.
3252 @item
3253 No other value of digits is permitted.
3254 @end itemize
3256 On OpenVMS, the
3257 argument may be @code{VAX_Float} to specify the use of the VAX float
3258 format, as follows:
3260 @itemize @bullet
3261 @item
3262 For digits values up to 6, F float format will be used.
3263 @item
3264 For digits values from 7 to 9, D float format will be used.
3265 @item
3266 For digits values from 10 to 15, G float format will be used.
3267 @item
3268 Digits values above 15 are not allowed.
3269 @end itemize
3271 @node Pragma Global
3272 @unnumberedsec Pragma Global
3273 @findex Global
3274 @noindent
3275 For the description of this pragma, see SPARK 2014 Reference Manual,
3276 section 6.1.4.
3278 @node Pragma Ident
3279 @unnumberedsec Pragma Ident
3280 @findex Ident
3281 @noindent
3282 Syntax:
3284 @smallexample @c ada
3285 pragma Ident (static_string_EXPRESSION);
3286 @end smallexample
3288 @noindent
3289 This pragma provides a string identification in the generated object file,
3290 if the system supports the concept of this kind of identification string.
3291 This pragma is allowed only in the outermost declarative part or
3292 declarative items of a compilation unit. If more than one @code{Ident}
3293 pragma is given, only the last one processed is effective.
3294 @cindex OpenVMS
3295 On OpenVMS systems, the effect of the pragma is identical to the effect of
3296 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
3297 maximum allowed length is 31 characters, so if it is important to
3298 maintain compatibility with this compiler, you should obey this length
3299 limit.
3301 @node Pragma Implementation_Defined
3302 @unnumberedsec Pragma Implementation_Defined
3303 @findex Implementation_Defined
3304 @noindent
3305 Syntax:
3307 @smallexample @c ada
3308 pragma Implementation_Defined (local_NAME);
3309 @end smallexample
3311 @noindent
3312 This pragma marks a previously declared entioty as implementation-defined.
3313 For an overloaded entity, applies to the most recent homonym.
3315 @smallexample @c ada
3316 pragma Implementation_Defined;
3317 @end smallexample
3319 @noindent
3320 The form with no arguments appears anywhere within a scope, most
3321 typically a package spec, and indicates that all entities that are
3322 defined within the package spec are Implementation_Defined.
3324 This pragma is used within the GNAT runtime library to identify
3325 implementation-defined entities introduced in language-defined units,
3326 for the purpose of implementing the No_Implementation_Identifiers
3327 restriction.
3329 @node Pragma Implemented
3330 @unnumberedsec Pragma Implemented
3331 @findex Implemented
3332 @noindent
3333 Syntax:
3335 @smallexample @c ada
3336 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3338 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3339 @end smallexample
3341 @noindent
3342 This is an Ada 2012 representation pragma which applies to protected, task
3343 and synchronized interface primitives. The use of pragma Implemented provides
3344 a way to impose a static requirement on the overriding operation by adhering
3345 to one of the three implementation kinds: entry, protected procedure or any of
3346 the above. This pragma is available in all earlier versions of Ada as an
3347 implementation-defined pragma.
3349 @smallexample @c ada
3350 type Synch_Iface is synchronized interface;
3351 procedure Prim_Op (Obj : in out Iface) is abstract;
3352 pragma Implemented (Prim_Op, By_Protected_Procedure);
3354 protected type Prot_1 is new Synch_Iface with
3355    procedure Prim_Op;  --  Legal
3356 end Prot_1;
3358 protected type Prot_2 is new Synch_Iface with
3359    entry Prim_Op;      --  Illegal
3360 end Prot_2;
3362 task type Task_Typ is new Synch_Iface with
3363    entry Prim_Op;      --  Illegal
3364 end Task_Typ;
3365 @end smallexample
3367 @noindent
3368 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3369 Implemented determines the runtime behavior of the requeue. Implementation kind
3370 By_Entry guarantees that the action of requeueing will proceed from an entry to
3371 another entry. Implementation kind By_Protected_Procedure transforms the
3372 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3373 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3374 the target's overriding subprogram kind.
3376 @node Pragma Implicit_Packing
3377 @unnumberedsec Pragma Implicit_Packing
3378 @findex Implicit_Packing
3379 @cindex Rational Profile
3380 @noindent
3381 Syntax:
3383 @smallexample @c ada
3384 pragma Implicit_Packing;
3385 @end smallexample
3387 @noindent
3388 This is a configuration pragma that requests implicit packing for packed
3389 arrays for which a size clause is given but no explicit pragma Pack or
3390 specification of Component_Size is present. It also applies to records
3391 where no record representation clause is present. Consider this example:
3393 @smallexample @c ada
3394 type R is array (0 .. 7) of Boolean;
3395 for R'Size use 8;
3396 @end smallexample
3398 @noindent
3399 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3400 does not change the layout of a composite object. So the Size clause in the
3401 above example is normally rejected, since the default layout of the array uses
3402 8-bit components, and thus the array requires a minimum of 64 bits.
3404 If this declaration is compiled in a region of code covered by an occurrence
3405 of the configuration pragma Implicit_Packing, then the Size clause in this
3406 and similar examples will cause implicit packing and thus be accepted. For
3407 this implicit packing to occur, the type in question must be an array of small
3408 components whose size is known at compile time, and the Size clause must
3409 specify the exact size that corresponds to the number of elements in the array
3410 multiplied by the size in bits of the component type (both single and
3411 multi-dimensioned arrays can be controlled with this pragma).
3413 @cindex Array packing
3415 Similarly, the following example shows the use in the record case
3417 @smallexample @c ada
3418 type r is record
3419    a, b, c, d, e, f, g, h : boolean;
3420    chr                    : character;
3421 end record;
3422 for r'size use 16;
3423 @end smallexample
3425 @noindent
3426 Without a pragma Pack, each Boolean field requires 8 bits, so the
3427 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3428 sufficient. The use of pragma Implicit_Packing allows this record
3429 declaration to compile without an explicit pragma Pack.
3430 @node Pragma Import_Exception
3431 @unnumberedsec Pragma Import_Exception
3432 @cindex OpenVMS
3433 @findex Import_Exception
3434 @noindent
3435 Syntax:
3437 @smallexample @c ada
3438 pragma Import_Exception (
3439      [Internal =>] LOCAL_NAME
3440   [, [External =>] EXTERNAL_SYMBOL]
3441   [, [Form     =>] Ada | VMS]
3442   [, [Code     =>] static_integer_EXPRESSION]);
3444 EXTERNAL_SYMBOL ::=
3445   IDENTIFIER
3446 | static_string_EXPRESSION
3447 @end smallexample
3449 @noindent
3450 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3451 It allows OpenVMS conditions (for example, from OpenVMS system services or
3452 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3453 The pragma specifies that the exception associated with an exception
3454 declaration in an Ada program be defined externally (in non-Ada code).
3455 For further details on this pragma, see the
3456 DEC Ada Language Reference Manual, section 13.9a.3.1.
3458 @node Pragma Import_Function
3459 @unnumberedsec Pragma Import_Function
3460 @findex Import_Function
3461 @noindent
3462 Syntax:
3464 @smallexample @c ada
3465 pragma Import_Function (
3466      [Internal                 =>] LOCAL_NAME,
3467   [, [External                 =>] EXTERNAL_SYMBOL]
3468   [, [Parameter_Types          =>] PARAMETER_TYPES]
3469   [, [Result_Type              =>] SUBTYPE_MARK]
3470   [, [Mechanism                =>] MECHANISM]
3471   [, [Result_Mechanism         =>] MECHANISM_NAME]
3472   [, [First_Optional_Parameter =>] IDENTIFIER]);
3474 EXTERNAL_SYMBOL ::=
3475   IDENTIFIER
3476 | static_string_EXPRESSION
3478 PARAMETER_TYPES ::=
3479   null
3480 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3482 TYPE_DESIGNATOR ::=
3483   subtype_NAME
3484 | subtype_Name ' Access
3486 MECHANISM ::=
3487   MECHANISM_NAME
3488 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3490 MECHANISM_ASSOCIATION ::=
3491   [formal_parameter_NAME =>] MECHANISM_NAME
3493 MECHANISM_NAME ::=
3494   Value
3495 | Reference
3496 | Descriptor [([Class =>] CLASS_NAME)]
3497 | Short_Descriptor [([Class =>] CLASS_NAME)]
3499 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3500 @end smallexample
3502 @noindent
3503 This pragma is used in conjunction with a pragma @code{Import} to
3504 specify additional information for an imported function.  The pragma
3505 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3506 @code{Import_Function} pragma and both must appear in the same
3507 declarative part as the function specification.
3509 The @var{Internal} argument must uniquely designate
3510 the function to which the
3511 pragma applies.  If more than one function name exists of this name in
3512 the declarative part you must use the @code{Parameter_Types} and
3513 @var{Result_Type} parameters to achieve the required unique
3514 designation.  Subtype marks in these parameters must exactly match the
3515 subtypes in the corresponding function specification, using positional
3516 notation to match parameters with subtype marks.
3517 The form with an @code{'Access} attribute can be used to match an
3518 anonymous access parameter.
3520 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3521 parameters to specify passing mechanisms for the
3522 parameters and result.  If you specify a single mechanism name, it
3523 applies to all parameters.  Otherwise you may specify a mechanism on a
3524 parameter by parameter basis using either positional or named
3525 notation.  If the mechanism is not specified, the default mechanism
3526 is used.
3528 @cindex OpenVMS
3529 @cindex Passing by descriptor
3530 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3531 The default behavior for Import_Function is to pass a 64bit descriptor
3532 unless short_descriptor is specified, then a 32bit descriptor is passed.
3534 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3535 It specifies that the designated parameter and all following parameters
3536 are optional, meaning that they are not passed at the generated code
3537 level (this is distinct from the notion of optional parameters in Ada
3538 where the parameters are passed anyway with the designated optional
3539 parameters).  All optional parameters must be of mode @code{IN} and have
3540 default parameter values that are either known at compile time
3541 expressions, or uses of the @code{'Null_Parameter} attribute.
3543 @node Pragma Import_Object
3544 @unnumberedsec Pragma Import_Object
3545 @findex Import_Object
3546 @noindent
3547 Syntax:
3549 @smallexample @c ada
3550 pragma Import_Object
3551      [Internal =>] LOCAL_NAME
3552   [, [External =>] EXTERNAL_SYMBOL]
3553   [, [Size     =>] EXTERNAL_SYMBOL]);
3555 EXTERNAL_SYMBOL ::=
3556   IDENTIFIER
3557 | static_string_EXPRESSION
3558 @end smallexample
3560 @noindent
3561 This pragma designates an object as imported, and apart from the
3562 extended rules for external symbols, is identical in effect to the use of
3563 the normal @code{Import} pragma applied to an object.  Unlike the
3564 subprogram case, you need not use a separate @code{Import} pragma,
3565 although you may do so (and probably should do so from a portability
3566 point of view).  @var{size} is syntax checked, but otherwise ignored by
3567 GNAT@.
3569 @node Pragma Import_Procedure
3570 @unnumberedsec Pragma Import_Procedure
3571 @findex Import_Procedure
3572 @noindent
3573 Syntax:
3575 @smallexample @c ada
3576 pragma Import_Procedure (
3577      [Internal                 =>] LOCAL_NAME
3578   [, [External                 =>] EXTERNAL_SYMBOL]
3579   [, [Parameter_Types          =>] PARAMETER_TYPES]
3580   [, [Mechanism                =>] MECHANISM]
3581   [, [First_Optional_Parameter =>] IDENTIFIER]);
3583 EXTERNAL_SYMBOL ::=
3584   IDENTIFIER
3585 | static_string_EXPRESSION
3587 PARAMETER_TYPES ::=
3588   null
3589 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3591 TYPE_DESIGNATOR ::=
3592   subtype_NAME
3593 | subtype_Name ' Access
3595 MECHANISM ::=
3596   MECHANISM_NAME
3597 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3599 MECHANISM_ASSOCIATION ::=
3600   [formal_parameter_NAME =>] MECHANISM_NAME
3602 MECHANISM_NAME ::=
3603   Value
3604 | Reference
3605 | Descriptor [([Class =>] CLASS_NAME)]
3606 | Short_Descriptor [([Class =>] CLASS_NAME)]
3608 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3609 @end smallexample
3611 @noindent
3612 This pragma is identical to @code{Import_Function} except that it
3613 applies to a procedure rather than a function and the parameters
3614 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3616 @node Pragma Import_Valued_Procedure
3617 @unnumberedsec Pragma Import_Valued_Procedure
3618 @findex Import_Valued_Procedure
3619 @noindent
3620 Syntax:
3622 @smallexample @c ada
3623 pragma Import_Valued_Procedure (
3624      [Internal                 =>] LOCAL_NAME
3625   [, [External                 =>] EXTERNAL_SYMBOL]
3626   [, [Parameter_Types          =>] PARAMETER_TYPES]
3627   [, [Mechanism                =>] MECHANISM]
3628   [, [First_Optional_Parameter =>] IDENTIFIER]);
3630 EXTERNAL_SYMBOL ::=
3631   IDENTIFIER
3632 | static_string_EXPRESSION
3634 PARAMETER_TYPES ::=
3635   null
3636 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3638 TYPE_DESIGNATOR ::=
3639   subtype_NAME
3640 | subtype_Name ' Access
3642 MECHANISM ::=
3643   MECHANISM_NAME
3644 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3646 MECHANISM_ASSOCIATION ::=
3647   [formal_parameter_NAME =>] MECHANISM_NAME
3649 MECHANISM_NAME ::=
3650   Value
3651 | Reference
3652 | Descriptor [([Class =>] CLASS_NAME)]
3653 | Short_Descriptor [([Class =>] CLASS_NAME)]
3655 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3656 @end smallexample
3658 @noindent
3659 This pragma is identical to @code{Import_Procedure} except that the
3660 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3661 mode @code{OUT}, and externally the subprogram is treated as a function
3662 with this parameter as the result of the function.  The purpose of this
3663 capability is to allow the use of @code{OUT} and @code{IN OUT}
3664 parameters in interfacing to external functions (which are not permitted
3665 in Ada functions).  You may optionally use the @code{Mechanism}
3666 parameters to specify passing mechanisms for the parameters.
3667 If you specify a single mechanism name, it applies to all parameters.
3668 Otherwise you may specify a mechanism on a parameter by parameter
3669 basis using either positional or named notation.  If the mechanism is not
3670 specified, the default mechanism is used.
3672 Note that it is important to use this pragma in conjunction with a separate
3673 pragma Import that specifies the desired convention, since otherwise the
3674 default convention is Ada, which is almost certainly not what is required.
3676 @node Pragma Independent
3677 @unnumberedsec Pragma Independent
3678 @findex Independent
3679 @noindent
3680 Syntax:
3682 @smallexample @c ada
3683 pragma Independent (Local_NAME);
3684 @end smallexample
3686 @noindent
3687 This pragma is standard in Ada 2012 mode (which also provides an aspect
3688 of the same name). It is also available as an implementation-defined
3689 pragma in all earlier versions. It specifies that the
3690 designated object or all objects of the designated type must be
3691 independently addressable. This means that separate tasks can safely
3692 manipulate such objects. For example, if two components of a record are
3693 independent, then two separate tasks may access these two components.
3694 This may place
3695 constraints on the representation of the object (for instance prohibiting
3696 tight packing).
3698 @node Pragma Independent_Components
3699 @unnumberedsec Pragma Independent_Components
3700 @findex Independent_Components
3701 @noindent
3702 Syntax:
3704 @smallexample @c ada
3705 pragma Independent_Components (Local_NAME);
3706 @end smallexample
3708 @noindent
3709 This pragma is standard in Ada 2012 mode (which also provides an aspect
3710 of the same name). It is also available as an implementation-defined
3711 pragma in all earlier versions. It specifies that the components of the
3712 designated object, or the components of each object of the designated
3713 type, must be
3714 independently addressable. This means that separate tasks can safely
3715 manipulate separate components in the composite object. This may place
3716 constraints on the representation of the object (for instance prohibiting
3717 tight packing).
3719 @node Pragma Initial_Condition
3720 @unnumberedsec Pragma Initial_Condition
3721 @findex Initial_Condition
3722 @noindent
3723 For the description of this pragma, see SPARK 2014 Reference Manual,
3724 section 7.1.6.
3726 @node Pragma Initialize_Scalars
3727 @unnumberedsec Pragma Initialize_Scalars
3728 @findex Initialize_Scalars
3729 @cindex debugging with Initialize_Scalars
3730 @noindent
3731 Syntax:
3733 @smallexample @c ada
3734 pragma Initialize_Scalars;
3735 @end smallexample
3737 @noindent
3738 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3739 two important differences.  First, there is no requirement for the pragma
3740 to be used uniformly in all units of a partition, in particular, it is fine
3741 to use this just for some or all of the application units of a partition,
3742 without needing to recompile the run-time library.
3744 In the case where some units are compiled with the pragma, and some without,
3745 then a declaration of a variable where the type is defined in package
3746 Standard or is locally declared will always be subject to initialization,
3747 as will any declaration of a scalar variable.  For composite variables,
3748 whether the variable is initialized may also depend on whether the package
3749 in which the type of the variable is declared is compiled with the pragma.
3751 The other important difference is that you can control the value used
3752 for initializing scalar objects.  At bind time, you can select several
3753 options for initialization. You can
3754 initialize with invalid values (similar to Normalize_Scalars, though for
3755 Initialize_Scalars it is not always possible to determine the invalid
3756 values in complex cases like signed component fields with non-standard
3757 sizes). You can also initialize with high or
3758 low values, or with a specified bit pattern.  See the @value{EDITION}
3759 User's Guide for binder options for specifying these cases.
3761 This means that you can compile a program, and then without having to
3762 recompile the program, you can run it with different values being used
3763 for initializing otherwise uninitialized values, to test if your program
3764 behavior depends on the choice.  Of course the behavior should not change,
3765 and if it does, then most likely you have an incorrect reference to an
3766 uninitialized value.
3768 It is even possible to change the value at execution time eliminating even
3769 the need to rebind with a different switch using an environment variable.
3770 See the @value{EDITION} User's Guide for details.
3772 Note that pragma @code{Initialize_Scalars} is particularly useful in
3773 conjunction with the enhanced validity checking that is now provided
3774 in GNAT, which checks for invalid values under more conditions.
3775 Using this feature (see description of the @option{-gnatV} flag in the
3776 @value{EDITION} User's Guide) in conjunction with
3777 pragma @code{Initialize_Scalars}
3778 provides a powerful new tool to assist in the detection of problems
3779 caused by uninitialized variables.
3781 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3782 effect on the generated code. This may cause your code to be
3783 substantially larger. It may also cause an increase in the amount
3784 of stack required, so it is probably a good idea to turn on stack
3785 checking (see description of stack checking in the @value{EDITION}
3786 User's Guide) when using this pragma.
3788 @node Pragma Initializes
3789 @unnumberedsec Pragma Initializes
3790 @findex Initializes
3791 @noindent
3792 For the description of this pragma, see SPARK 2014 Reference Manual,
3793 section 7.1.5.
3795 @node Pragma Inline_Always
3796 @unnumberedsec Pragma Inline_Always
3797 @findex Inline_Always
3798 @noindent
3799 Syntax:
3801 @smallexample @c ada
3802 pragma Inline_Always (NAME [, NAME]);
3803 @end smallexample
3805 @noindent
3806 Similar to pragma @code{Inline} except that inlining is not subject to
3807 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3808 happens regardless of whether these options are used.
3810 @node Pragma Inline_Generic
3811 @unnumberedsec Pragma Inline_Generic
3812 @findex Inline_Generic
3813 @noindent
3814 Syntax:
3816 @smallexample @c ada
3817 pragma Inline_Generic (GNAME @{, GNAME@});
3819 GNAME ::= generic_unit_NAME | generic_instance_NAME
3820 @end smallexample
3822 @noindent
3823 This pragma is provided for compatibility with Dec Ada 83. It has
3824 no effect in @code{GNAT} (which always inlines generics), other
3825 than to check that the given names are all names of generic units or
3826 generic instances.
3828 @node Pragma Interface
3829 @unnumberedsec Pragma Interface
3830 @findex Interface
3831 @noindent
3832 Syntax:
3834 @smallexample @c ada
3835 pragma Interface (
3836      [Convention    =>] convention_identifier,
3837      [Entity        =>] local_NAME
3838   [, [External_Name =>] static_string_expression]
3839   [, [Link_Name     =>] static_string_expression]);
3840 @end smallexample
3842 @noindent
3843 This pragma is identical in syntax and semantics to
3844 the standard Ada pragma @code{Import}.  It is provided for compatibility
3845 with Ada 83.  The definition is upwards compatible both with pragma
3846 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3847 with some extended implementations of this pragma in certain Ada 83
3848 implementations.  The only difference between pragma @code{Interface}
3849 and pragma @code{Import} is that there is special circuitry to allow
3850 both pragmas to appear for the same subprogram entity (normally it
3851 is illegal to have multiple @code{Import} pragmas. This is useful in
3852 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3853 Ada 83 compilers.
3855 @node Pragma Interface_Name
3856 @unnumberedsec Pragma Interface_Name
3857 @findex Interface_Name
3858 @noindent
3859 Syntax:
3861 @smallexample @c ada
3862 pragma Interface_Name (
3863      [Entity        =>] LOCAL_NAME
3864   [, [External_Name =>] static_string_EXPRESSION]
3865   [, [Link_Name     =>] static_string_EXPRESSION]);
3866 @end smallexample
3868 @noindent
3869 This pragma provides an alternative way of specifying the interface name
3870 for an interfaced subprogram, and is provided for compatibility with Ada
3871 83 compilers that use the pragma for this purpose.  You must provide at
3872 least one of @var{External_Name} or @var{Link_Name}.
3874 @node Pragma Interrupt_Handler
3875 @unnumberedsec Pragma Interrupt_Handler
3876 @findex Interrupt_Handler
3877 @noindent
3878 Syntax:
3880 @smallexample @c ada
3881 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3882 @end smallexample
3884 @noindent
3885 This program unit pragma is supported for parameterless protected procedures
3886 as described in Annex C of the Ada Reference Manual. On the AAMP target
3887 the pragma can also be specified for nonprotected parameterless procedures
3888 that are declared at the library level (which includes procedures
3889 declared at the top level of a library package). In the case of AAMP,
3890 when this pragma is applied to a nonprotected procedure, the instruction
3891 @code{IERET} is generated for returns from the procedure, enabling
3892 maskable interrupts, in place of the normal return instruction.
3894 @node Pragma Interrupt_State
3895 @unnumberedsec Pragma Interrupt_State
3896 @findex Interrupt_State
3897 @noindent
3898 Syntax:
3900 @smallexample @c ada
3901 pragma Interrupt_State
3902  ([Name  =>] value,
3903   [State =>] SYSTEM | RUNTIME | USER);
3904 @end smallexample
3906 @noindent
3907 Normally certain interrupts are reserved to the implementation.  Any attempt
3908 to attach an interrupt causes Program_Error to be raised, as described in
3909 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3910 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3911 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3912 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
3913 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3914 Ada exceptions, or used to implement run-time functions such as the
3915 @code{abort} statement and stack overflow checking.
3917 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3918 such uses of interrupts.  It subsumes the functionality of pragma
3919 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
3920 available on Windows or VMS.  On all other platforms than VxWorks,
3921 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3922 and may be used to mark interrupts required by the board support package
3923 as reserved.
3925 Interrupts can be in one of three states:
3926 @itemize @bullet
3927 @item System
3929 The interrupt is reserved (no Ada handler can be installed), and the
3930 Ada run-time may not install a handler. As a result you are guaranteed
3931 standard system default action if this interrupt is raised.
3933 @item Runtime
3935 The interrupt is reserved (no Ada handler can be installed). The run time
3936 is allowed to install a handler for internal control purposes, but is
3937 not required to do so.
3939 @item User
3941 The interrupt is unreserved.  The user may install a handler to provide
3942 some other action.
3943 @end itemize
3945 @noindent
3946 These states are the allowed values of the @code{State} parameter of the
3947 pragma.  The @code{Name} parameter is a value of the type
3948 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
3949 @code{Ada.Interrupts.Names}.
3951 This is a configuration pragma, and the binder will check that there
3952 are no inconsistencies between different units in a partition in how a
3953 given interrupt is specified. It may appear anywhere a pragma is legal.
3955 The effect is to move the interrupt to the specified state.
3957 By declaring interrupts to be SYSTEM, you guarantee the standard system
3958 action, such as a core dump.
3960 By declaring interrupts to be USER, you guarantee that you can install
3961 a handler.
3963 Note that certain signals on many operating systems cannot be caught and
3964 handled by applications.  In such cases, the pragma is ignored.  See the
3965 operating system documentation, or the value of the array @code{Reserved}
3966 declared in the spec of package @code{System.OS_Interface}.
3968 Overriding the default state of signals used by the Ada runtime may interfere
3969 with an application's runtime behavior in the cases of the synchronous signals,
3970 and in the case of the signal used to implement the @code{abort} statement.
3972 @node Pragma Invariant
3973 @unnumberedsec Pragma Invariant
3974 @findex Invariant
3975 @noindent
3976 Syntax:
3978 @smallexample @c ada
3979 pragma Invariant
3980   ([Entity =>]    private_type_LOCAL_NAME,
3981    [Check  =>]    EXPRESSION
3982    [,[Message =>] String_Expression]);
3983 @end smallexample
3985 @noindent
3986 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3987 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3988 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3989 requires the use of the aspect syntax, which is not available except in 2012
3990 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3991 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3992 note that the aspect Invariant is a synonym in GNAT for the aspect
3993 Type_Invariant, but there is no pragma Type_Invariant.
3995 The pragma must appear within the visible part of the package specification,
3996 after the type to which its Entity argument appears. As with the Invariant
3997 aspect, the Check expression is not analyzed until the end of the visible
3998 part of the package, so it may contain forward references. The Message
3999 argument, if present, provides the exception message used if the invariant
4000 is violated. If no Message parameter is provided, a default message that
4001 identifies the line on which the pragma appears is used.
4003 It is permissible to have multiple Invariants for the same type entity, in
4004 which case they are and'ed together. It is permissible to use this pragma
4005 in Ada 2012 mode, but you cannot have both an invariant aspect and an
4006 invariant pragma for the same entity.
4008 For further details on the use of this pragma, see the Ada 2012 documentation
4009 of the Type_Invariant aspect.
4011 @node Pragma Java_Constructor
4012 @unnumberedsec Pragma Java_Constructor
4013 @findex Java_Constructor
4014 @noindent
4015 Syntax:
4017 @smallexample @c ada
4018 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
4019 @end smallexample
4021 @noindent
4022 This pragma is used to assert that the specified Ada function should be
4023 mapped to the Java constructor for some Ada tagged record type.
4025 See section 7.3.2 of the
4026 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4027 for related information.
4029 @node Pragma Java_Interface
4030 @unnumberedsec Pragma Java_Interface
4031 @findex Java_Interface
4032 @noindent
4033 Syntax:
4035 @smallexample @c ada
4036 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
4037 @end smallexample
4039 @noindent
4040 This pragma is used to assert that the specified Ada abstract tagged type
4041 is to be mapped to a Java interface name.
4043 See sections 7.1 and 7.2 of the
4044 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4045 for related information.
4047 @node Pragma Keep_Names
4048 @unnumberedsec Pragma Keep_Names
4049 @findex Keep_Names
4050 @noindent
4051 Syntax:
4053 @smallexample @c ada
4054 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4055 @end smallexample
4057 @noindent
4058 The @var{LOCAL_NAME} argument
4059 must refer to an enumeration first subtype
4060 in the current declarative part. The effect is to retain the enumeration
4061 literal names for use by @code{Image} and @code{Value} even if a global
4062 @code{Discard_Names} pragma applies. This is useful when you want to
4063 generally suppress enumeration literal names and for example you therefore
4064 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
4065 want to retain the names for specific enumeration types.
4067 @node Pragma License
4068 @unnumberedsec Pragma License
4069 @findex License
4070 @cindex License checking
4071 @noindent
4072 Syntax:
4074 @smallexample @c ada
4075 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4076 @end smallexample
4078 @noindent
4079 This pragma is provided to allow automated checking for appropriate license
4080 conditions with respect to the standard and modified GPL@.  A pragma
4081 @code{License}, which is a configuration pragma that typically appears at
4082 the start of a source file or in a separate @file{gnat.adc} file, specifies
4083 the licensing conditions of a unit as follows:
4085 @itemize @bullet
4086 @item Unrestricted
4087 This is used for a unit that can be freely used with no license restrictions.
4088 Examples of such units are public domain units, and units from the Ada
4089 Reference Manual.
4091 @item GPL
4092 This is used for a unit that is licensed under the unmodified GPL, and which
4093 therefore cannot be @code{with}'ed by a restricted unit.
4095 @item Modified_GPL
4096 This is used for a unit licensed under the GNAT modified GPL that includes
4097 a special exception paragraph that specifically permits the inclusion of
4098 the unit in programs without requiring the entire program to be released
4099 under the GPL@.
4101 @item Restricted
4102 This is used for a unit that is restricted in that it is not permitted to
4103 depend on units that are licensed under the GPL@.  Typical examples are
4104 proprietary code that is to be released under more restrictive license
4105 conditions.  Note that restricted units are permitted to @code{with} units
4106 which are licensed under the modified GPL (this is the whole point of the
4107 modified GPL).
4109 @end itemize
4111 @noindent
4112 Normally a unit with no @code{License} pragma is considered to have an
4113 unknown license, and no checking is done.  However, standard GNAT headers
4114 are recognized, and license information is derived from them as follows.
4116 @itemize @bullet
4118 A GNAT license header starts with a line containing 78 hyphens.  The following
4119 comment text is searched for the appearance of any of the following strings.
4121 If the string ``GNU General Public License'' is found, then the unit is assumed
4122 to have GPL license, unless the string ``As a special exception'' follows, in
4123 which case the license is assumed to be modified GPL@.
4125 If one of the strings
4126 ``This specification is adapted from the Ada Semantic Interface'' or
4127 ``This specification is derived from the Ada Reference Manual'' is found
4128 then the unit is assumed to be unrestricted.
4129 @end itemize
4131 @noindent
4132 These default actions means that a program with a restricted license pragma
4133 will automatically get warnings if a GPL unit is inappropriately
4134 @code{with}'ed.  For example, the program:
4136 @smallexample @c ada
4137 with Sem_Ch3;
4138 with GNAT.Sockets;
4139 procedure Secret_Stuff is
4140   @dots{}
4141 end Secret_Stuff
4142 @end smallexample
4144 @noindent
4145 if compiled with pragma @code{License} (@code{Restricted}) in a
4146 @file{gnat.adc} file will generate the warning:
4148 @smallexample
4149 1.  with Sem_Ch3;
4150         |
4151    >>> license of withed unit "Sem_Ch3" is incompatible
4153 2.  with GNAT.Sockets;
4154 3.  procedure Secret_Stuff is
4155 @end smallexample
4157 @noindent
4158 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4159 compiler and is licensed under the
4160 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4161 run time, and is therefore licensed under the modified GPL@.
4163 @node Pragma Link_With
4164 @unnumberedsec Pragma Link_With
4165 @findex Link_With
4166 @noindent
4167 Syntax:
4169 @smallexample @c ada
4170 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4171 @end smallexample
4173 @noindent
4174 This pragma is provided for compatibility with certain Ada 83 compilers.
4175 It has exactly the same effect as pragma @code{Linker_Options} except
4176 that spaces occurring within one of the string expressions are treated
4177 as separators. For example, in the following case:
4179 @smallexample @c ada
4180 pragma Link_With ("-labc -ldef");
4181 @end smallexample
4183 @noindent
4184 results in passing the strings @code{-labc} and @code{-ldef} as two
4185 separate arguments to the linker. In addition pragma Link_With allows
4186 multiple arguments, with the same effect as successive pragmas.
4188 @node Pragma Linker_Alias
4189 @unnumberedsec Pragma Linker_Alias
4190 @findex Linker_Alias
4191 @noindent
4192 Syntax:
4194 @smallexample @c ada
4195 pragma Linker_Alias (
4196   [Entity =>] LOCAL_NAME,
4197   [Target =>] static_string_EXPRESSION);
4198 @end smallexample
4200 @noindent
4201 @var{LOCAL_NAME} must refer to an object that is declared at the library
4202 level. This pragma establishes the given entity as a linker alias for the
4203 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4204 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4205 @var{static_string_EXPRESSION} in the object file, that is to say no space
4206 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4207 to the same address as @var{static_string_EXPRESSION} by the linker.
4209 The actual linker name for the target must be used (e.g.@: the fully
4210 encoded name with qualification in Ada, or the mangled name in C++),
4211 or it must be declared using the C convention with @code{pragma Import}
4212 or @code{pragma Export}.
4214 Not all target machines support this pragma. On some of them it is accepted
4215 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4217 @smallexample @c ada
4218 --  Example of the use of pragma Linker_Alias
4220 package p is
4221   i : Integer := 1;
4222   pragma Export (C, i);
4224   new_name_for_i : Integer;
4225   pragma Linker_Alias (new_name_for_i, "i");
4226 end p;
4227 @end smallexample
4229 @node Pragma Linker_Constructor
4230 @unnumberedsec Pragma Linker_Constructor
4231 @findex Linker_Constructor
4232 @noindent
4233 Syntax:
4235 @smallexample @c ada
4236 pragma Linker_Constructor (procedure_LOCAL_NAME);
4237 @end smallexample
4239 @noindent
4240 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4241 is declared at the library level. A procedure to which this pragma is
4242 applied will be treated as an initialization routine by the linker.
4243 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4244 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4245 of the executable is called (or immediately after the shared library is
4246 loaded if the procedure is linked in a shared library), in particular
4247 before the Ada run-time environment is set up.
4249 Because of these specific contexts, the set of operations such a procedure
4250 can perform is very limited and the type of objects it can manipulate is
4251 essentially restricted to the elementary types. In particular, it must only
4252 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4254 This pragma is used by GNAT to implement auto-initialization of shared Stand
4255 Alone Libraries, which provides a related capability without the restrictions
4256 listed above. Where possible, the use of Stand Alone Libraries is preferable
4257 to the use of this pragma.
4259 @node Pragma Linker_Destructor
4260 @unnumberedsec Pragma Linker_Destructor
4261 @findex Linker_Destructor
4262 @noindent
4263 Syntax:
4265 @smallexample @c ada
4266 pragma Linker_Destructor (procedure_LOCAL_NAME);
4267 @end smallexample
4269 @noindent
4270 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4271 is declared at the library level. A procedure to which this pragma is
4272 applied will be treated as a finalization routine by the linker.
4273 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4274 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4275 of the executable has exited (or immediately before the shared library
4276 is unloaded if the procedure is linked in a shared library), in particular
4277 after the Ada run-time environment is shut down.
4279 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4280 because of these specific contexts.
4282 @node Pragma Linker_Section
4283 @unnumberedsec Pragma Linker_Section
4284 @findex Linker_Section
4285 @noindent
4286 Syntax:
4288 @smallexample @c ada
4289 pragma Linker_Section (
4290   [Entity  =>] LOCAL_NAME,
4291   [Section =>] static_string_EXPRESSION);
4292 @end smallexample
4294 @noindent
4295 @var{LOCAL_NAME} must refer to an object, type, or subprogram that is
4296 declared at the library level. This pragma specifies the name of the
4297 linker section for the given entity. It is equivalent to
4298 @code{__attribute__((section))} in GNU C and causes @var{LOCAL_NAME} to
4299 be placed in the @var{static_string_EXPRESSION} section of the
4300 executable (assuming the linker doesn't rename the section).
4301 GNAT also provides an implementation defined aspect of the same name.
4303 In the case of specifying this aspect for a type, the effect is to
4304 specify the corresponding for all library level objects of the type which
4305 do not have an explicit linker section set. Note that this only applies to
4306 whole objects, not to components of composite objects.
4308 In the case of a subprogram, the linker section applies to all previously
4309 declared matching overloaded subprograms in the current declarative part
4310 which do not already have a linker section assigned. The linker section
4311 aspect is useful in this case for specifying different linker sections
4312 for different elements of such an overloaded set.
4314 Note that an empty string specifies that no linker section is specified.
4315 This is not quite the same as omitting the pragma or aspect, since it
4316 can be used to specify that one element of an overloaded set of subprograms
4317 has the default linker section, or that one object of a type for which a
4318 linker section is specified should has the default linker section.
4320 The compiler normally places library-level entities in standard sections
4321 depending on the class: procedures and functions generally go in the
4322 @code{.text} section, initialized variables in the @code{.data} section
4323 and uninitialized variables in the @code{.bss} section.
4325 Other, special sections may exist on given target machines to map special
4326 hardware, for example I/O ports or flash memory. This pragma is a means to
4327 defer the final layout of the executable to the linker, thus fully working
4328 at the symbolic level with the compiler.
4330 Some file formats do not support arbitrary sections so not all target
4331 machines support this pragma. The use of this pragma may cause a program
4332 execution to be erroneous if it is used to place an entity into an
4333 inappropriate section (e.g.@: a modified variable into the @code{.text}
4334 section). See also @code{pragma Persistent_BSS}.
4336 @smallexample @c ada
4337 --  Example of the use of pragma Linker_Section
4339 package IO_Card is
4340   Port_A : Integer;
4341   pragma Volatile (Port_A);
4342   pragma Linker_Section (Port_A, ".bss.port_a");
4344   Port_B : Integer;
4345   pragma Volatile (Port_B);
4346   pragma Linker_Section (Port_B, ".bss.port_b");
4348   type Port_Type is new Integer with Linker_Section => ".bss";
4349   PA : Port_Type with Linker_Section => ".bss.PA";
4350   PB : Port_Type; --  ends up in linker section ".bss"
4352   procedure Q with Linker_Section => "Qsection";
4353 end IO_Card;
4354 @end smallexample
4356 @node Pragma Long_Float
4357 @unnumberedsec Pragma Long_Float
4358 @cindex OpenVMS
4359 @findex Long_Float
4360 @noindent
4361 Syntax:
4363 @smallexample @c ada
4364 pragma Long_Float (FLOAT_FORMAT);
4366 FLOAT_FORMAT ::= D_Float | G_Float
4367 @end smallexample
4369 @noindent
4370 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4371 It allows control over the internal representation chosen for the predefined
4372 type @code{Long_Float} and for floating point type representations with
4373 @code{digits} specified in the range 7 through 15.
4374 For further details on this pragma, see the
4375 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
4376 this pragma, the standard runtime libraries must be recompiled.
4378 @node Pragma Loop_Invariant
4379 @unnumberedsec Pragma Loop_Invariant
4380 @findex Loop_Invariant
4381 @noindent
4382 Syntax:
4384 @smallexample @c ada
4385 pragma Loop_Invariant ( boolean_EXPRESSION );
4386 @end smallexample
4388 @noindent
4389 The effect of this pragma is similar to that of pragma @code{Assert},
4390 except that in an @code{Assertion_Policy} pragma, the identifier
4391 @code{Loop_Invariant} is used to control whether it is ignored or checked
4392 (or disabled).
4394 @code{Loop_Invariant} can only appear as one of the items in the sequence
4395 of statements of a loop body, or nested inside block statements that
4396 appear in the sequence of statements of a loop body.
4397 The intention is that it be used to
4398 represent a "loop invariant" assertion, i.e. something that is true each
4399 time through the loop, and which can be used to show that the loop is
4400 achieving its purpose.
4402 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4403 apply to the same loop should be grouped in the same sequence of
4404 statements.
4406 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4407 may be used to refer to the value of an expression on entry to the loop. This
4408 attribute can only be used within the expression of a @code{Loop_Invariant}
4409 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4411 @node Pragma Loop_Optimize
4412 @unnumberedsec Pragma Loop_Optimize
4413 @findex Loop_Optimize
4414 @noindent
4415 Syntax:
4417 @smallexample @c ada
4418 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4420 OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
4421 @end smallexample
4423 @noindent
4424 This pragma must appear immediately within a loop statement.  It allows the
4425 programmer to specify optimization hints for the enclosing loop.  The hints
4426 are not mutually exclusive and can be freely mixed, but not all combinations
4427 will yield a sensible outcome.
4429 There are five supported optimization hints for a loop:
4431 @itemize @bullet
4432 @item Ivdep
4434 The programmer asserts that there are no loop-carried dependencies which would prevent consecutive iterations of the loop from being executed simultaneously.
4436 @item No_Unroll
4438 The loop must not be unrolled.  This is a strong hint: the compiler will not
4439 unroll a loop marked with this hint.
4441 @item Unroll
4443 The loop should be unrolled.  This is a weak hint: the compiler will try to
4444 apply unrolling to this loop preferably to other optimizations, notably
4445 vectorization, but there is no guarantee that the loop will be unrolled.
4447 @item No_Vector
4449 The loop must not be vectorized.  This is a strong hint: the compiler will not
4450 vectorize a loop marked with this hint.
4452 @item Vector
4454 The loop should be vectorized.  This is a weak hint: the compiler will try to
4455 apply vectorization to this loop preferably to other optimizations, notably
4456 unrolling, but there is no guarantee that the loop will be vectorized.
4458 @end itemize
4460 These hints do not void the need to pass the appropriate switches to the
4461 compiler in order to enable the relevant optimizations, that is to say
4462 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4463 vectorization.
4465 @node Pragma Loop_Variant
4466 @unnumberedsec Pragma Loop_Variant
4467 @findex Loop_Variant
4468 @noindent
4469 Syntax:
4471 @smallexample @c ada
4472 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4473 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4474 CHANGE_DIRECTION ::= Increases | Decreases
4475 @end smallexample
4477 @noindent
4478 @code{Loop_Variant} can only appear as one of the items in the sequence
4479 of statements of a loop body, or nested inside block statements that
4480 appear in the sequence of statements of a loop body.
4481 It allows the specification of quantities which must always
4482 decrease or increase in successive iterations of the loop. In its simplest
4483 form, just one expression is specified, whose value must increase or decrease
4484 on each iteration of the loop.
4486 In a more complex form, multiple arguments can be given which are intepreted
4487 in a nesting lexicographic manner. For example:
4489 @smallexample @c ada
4490 pragma Loop_Variant (Increases => X, Decreases => Y);
4491 @end smallexample
4493 @noindent
4494 specifies that each time through the loop either X increases, or X stays
4495 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4496 loop is making progress. It can be useful in helping to show informally
4497 or prove formally that the loop always terminates.
4499 @code{Loop_Variant} is an assertion whose effect can be controlled using
4500 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4501 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4502 to ignore the check (in which case the pragma has no effect on the program),
4503 or @code{Disable} in which case the pragma is not even checked for correct
4504 syntax.
4506 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4507 apply to the same loop should be grouped in the same sequence of
4508 statements.
4510 The @code{Loop_Entry} attribute may be used within the expressions of the
4511 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4513 @node Pragma Machine_Attribute
4514 @unnumberedsec Pragma Machine_Attribute
4515 @findex Machine_Attribute
4516 @noindent
4517 Syntax:
4519 @smallexample @c ada
4520 pragma Machine_Attribute (
4521      [Entity         =>] LOCAL_NAME,
4522      [Attribute_Name =>] static_string_EXPRESSION
4523   [, [Info           =>] static_EXPRESSION] );
4524 @end smallexample
4526 @noindent
4527 Machine-dependent attributes can be specified for types and/or
4528 declarations.  This pragma is semantically equivalent to
4529 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4530 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4531 in GNU C, where @code{@var{attribute_name}} is recognized by the
4532 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4533 specific macro.  A string literal for the optional parameter @var{info}
4534 is transformed into an identifier, which may make this pragma unusable
4535 for some attributes.  @xref{Target Attributes,, Defining target-specific
4536 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4537 Internals}, further information.
4539 @node Pragma Main
4540 @unnumberedsec Pragma Main
4541 @cindex OpenVMS
4542 @findex Main
4543 @noindent
4544 Syntax:
4546 @smallexample @c ada
4547 pragma Main
4548  (MAIN_OPTION [, MAIN_OPTION]);
4550 MAIN_OPTION ::=
4551   [Stack_Size              =>] static_integer_EXPRESSION
4552 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4553 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
4554 @end smallexample
4556 @noindent
4557 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4558 no effect in GNAT, other than being syntax checked.
4560 @node Pragma Main_Storage
4561 @unnumberedsec Pragma Main_Storage
4562 @cindex OpenVMS
4563 @findex Main_Storage
4564 @noindent
4565 Syntax:
4567 @smallexample @c ada
4568 pragma Main_Storage
4569   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4571 MAIN_STORAGE_OPTION ::=
4572   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4573 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
4574 @end smallexample
4576 @noindent
4577 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4578 no effect in GNAT, other than being syntax checked.  Note that the pragma
4579 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4581 @node Pragma No_Body
4582 @unnumberedsec Pragma No_Body
4583 @findex No_Body
4584 @noindent
4585 Syntax:
4587 @smallexample @c ada
4588 pragma No_Body;
4589 @end smallexample
4591 @noindent
4592 There are a number of cases in which a package spec does not require a body,
4593 and in fact a body is not permitted. GNAT will not permit the spec to be
4594 compiled if there is a body around. The pragma No_Body allows you to provide
4595 a body file, even in a case where no body is allowed. The body file must
4596 contain only comments and a single No_Body pragma. This is recognized by
4597 the compiler as indicating that no body is logically present.
4599 This is particularly useful during maintenance when a package is modified in
4600 such a way that a body needed before is no longer needed. The provision of a
4601 dummy body with a No_Body pragma ensures that there is no interference from
4602 earlier versions of the package body.
4604 @node Pragma No_Inline
4605 @unnumberedsec Pragma No_Inline
4606 @findex No_Inline
4607 @noindent
4608 Syntax:
4610 @smallexample @c ada
4611 pragma No_Inline (NAME @{, NAME@});
4612 @end smallexample
4614 @noindent
4615 This pragma suppresses inlining for the callable entity or the instances of
4616 the generic subprogram designated by @var{NAME}, including inlining that
4617 results from the use of pragma @code{Inline}.  This pragma is always active,
4618 in particular it is not subject to the use of option @option{-gnatn} or
4619 @option{-gnatN}.  It is illegal to specify both pragma @code{No_Inline} and
4620 pragma @code{Inline_Always} for the same @var{NAME}.
4622 @node Pragma No_Return
4623 @unnumberedsec Pragma No_Return
4624 @findex No_Return
4625 @noindent
4626 Syntax:
4628 @smallexample @c ada
4629 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4630 @end smallexample
4632 @noindent
4633 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4634 declarations in the current declarative part.  A procedure to which this
4635 pragma is applied may not contain any explicit @code{return} statements.
4636 In addition, if the procedure contains any implicit returns from falling
4637 off the end of a statement sequence, then execution of that implicit
4638 return will cause Program_Error to be raised.
4640 One use of this pragma is to identify procedures whose only purpose is to raise
4641 an exception. Another use of this pragma is to suppress incorrect warnings
4642 about missing returns in functions, where the last statement of a function
4643 statement sequence is a call to such a procedure.
4645 Note that in Ada 2005 mode, this pragma is part of the language. It is
4646 available in all earlier versions of Ada as an implementation-defined
4647 pragma.
4649 @node Pragma No_Run_Time
4650 @unnumberedsec Pragma No_Run_Time
4651 @findex No_Run_Time
4652 @noindent
4653 Syntax:
4655 @smallexample @c ada
4656 pragma No_Run_Time;
4657 @end smallexample
4659 @noindent
4660 This is an obsolete configuration pragma that historically was used to
4661 setup what is now called the "zero footprint" library. It causes any
4662 library units outside this basic library to be ignored. The use of
4663 this pragma has been superseded by the general configurable run-time
4664 capability of @code{GNAT} where the compiler takes into account whatever
4665 units happen to be accessible in the library.
4667 @node Pragma No_Strict_Aliasing
4668 @unnumberedsec Pragma No_Strict_Aliasing
4669 @findex No_Strict_Aliasing
4670 @noindent
4671 Syntax:
4673 @smallexample @c ada
4674 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4675 @end smallexample
4677 @noindent
4678 @var{type_LOCAL_NAME} must refer to an access type
4679 declaration in the current declarative part.  The effect is to inhibit
4680 strict aliasing optimization for the given type.  The form with no
4681 arguments is a configuration pragma which applies to all access types
4682 declared in units to which the pragma applies. For a detailed
4683 description of the strict aliasing optimization, and the situations
4684 in which it must be suppressed, see @ref{Optimization and Strict
4685 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4687 This pragma currently has no effects on access to unconstrained array types.
4689 @node Pragma Normalize_Scalars
4690 @unnumberedsec Pragma Normalize_Scalars
4691 @findex Normalize_Scalars
4692 @noindent
4693 Syntax:
4695 @smallexample @c ada
4696 pragma Normalize_Scalars;
4697 @end smallexample
4699 @noindent
4700 This is a language defined pragma which is fully implemented in GNAT@.  The
4701 effect is to cause all scalar objects that are not otherwise initialized
4702 to be initialized.  The initial values are implementation dependent and
4703 are as follows:
4705 @table @code
4706 @item Standard.Character
4707 @noindent
4708 Objects whose root type is Standard.Character are initialized to
4709 Character'Last unless the subtype range excludes NUL (in which case
4710 NUL is used). This choice will always generate an invalid value if
4711 one exists.
4713 @item Standard.Wide_Character
4714 @noindent
4715 Objects whose root type is Standard.Wide_Character are initialized to
4716 Wide_Character'Last unless the subtype range excludes NUL (in which case
4717 NUL is used). This choice will always generate an invalid value if
4718 one exists.
4720 @item Standard.Wide_Wide_Character
4721 @noindent
4722 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4723 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4724 which case NUL is used). This choice will always generate an invalid value if
4725 one exists.
4727 @item Integer types
4728 @noindent
4729 Objects of an integer type are treated differently depending on whether
4730 negative values are present in the subtype. If no negative values are
4731 present, then all one bits is used as the initial value except in the
4732 special case where zero is excluded from the subtype, in which case
4733 all zero bits are used. This choice will always generate an invalid
4734 value if one exists.
4736 For subtypes with negative values present, the largest negative number
4737 is used, except in the unusual case where this largest negative number
4738 is in the subtype, and the largest positive number is not, in which case
4739 the largest positive value is used. This choice will always generate
4740 an invalid value if one exists.
4742 @item Floating-Point Types
4743 Objects of all floating-point types are initialized to all 1-bits. For
4744 standard IEEE format, this corresponds to a NaN (not a number) which is
4745 indeed an invalid value.
4747 @item Fixed-Point Types
4748 Objects of all fixed-point types are treated as described above for integers,
4749 with the rules applying to the underlying integer value used to represent
4750 the fixed-point value.
4752 @item Modular types
4753 Objects of a modular type are initialized to all one bits, except in
4754 the special case where zero is excluded from the subtype, in which
4755 case all zero bits are used. This choice will always generate an
4756 invalid value if one exists.
4758 @item Enumeration types
4759 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4760 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4761 whose Pos value is zero, in which case a code of zero is used. This choice
4762 will always generate an invalid value if one exists.
4764 @end table
4766 @node Pragma Obsolescent
4767 @unnumberedsec Pragma Obsolescent
4768 @findex Obsolescent
4769 @noindent
4770 Syntax:
4772 @smallexample @c ada
4773 pragma Obsolescent;
4775 pragma Obsolescent (
4776   [Message =>] static_string_EXPRESSION
4777 [,[Version =>] Ada_05]]);
4779 pragma Obsolescent (
4780   [Entity  =>] NAME
4781 [,[Message =>] static_string_EXPRESSION
4782 [,[Version =>] Ada_05]] );
4783 @end smallexample
4785 @noindent
4786 This pragma can occur immediately following a declaration of an entity,
4787 including the case of a record component. If no Entity argument is present,
4788 then this declaration is the one to which the pragma applies. If an Entity
4789 parameter is present, it must either match the name of the entity in this
4790 declaration, or alternatively, the pragma can immediately follow an enumeration
4791 type declaration, where the Entity argument names one of the enumeration
4792 literals.
4794 This pragma is used to indicate that the named entity
4795 is considered obsolescent and should not be used. Typically this is
4796 used when an API must be modified by eventually removing or modifying
4797 existing subprograms or other entities. The pragma can be used at an
4798 intermediate stage when the entity is still present, but will be
4799 removed later.
4801 The effect of this pragma is to output a warning message on a reference to
4802 an entity thus marked that the subprogram is obsolescent if the appropriate
4803 warning option in the compiler is activated. If the Message parameter is
4804 present, then a second warning message is given containing this text. In
4805 addition, a reference to the entity is considered to be a violation of pragma
4806 Restrictions (No_Obsolescent_Features).
4808 This pragma can also be used as a program unit pragma for a package,
4809 in which case the entity name is the name of the package, and the
4810 pragma indicates that the entire package is considered
4811 obsolescent. In this case a client @code{with}'ing such a package
4812 violates the restriction, and the @code{with} statement is
4813 flagged with warnings if the warning option is set.
4815 If the Version parameter is present (which must be exactly
4816 the identifier Ada_05, no other argument is allowed), then the
4817 indication of obsolescence applies only when compiling in Ada 2005
4818 mode. This is primarily intended for dealing with the situations
4819 in the predefined library where subprograms or packages
4820 have become defined as obsolescent in Ada 2005
4821 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4823 The following examples show typical uses of this pragma:
4825 @smallexample @c ada
4826 package p is
4827    pragma Obsolescent (p, Message => "use pp instead of p");
4828 end p;
4830 package q is
4831    procedure q2;
4832    pragma Obsolescent ("use q2new instead");
4834    type R is new integer;
4835    pragma Obsolescent
4836      (Entity  => R,
4837       Message => "use RR in Ada 2005",
4838       Version => Ada_05);
4840    type M is record
4841       F1 : Integer;
4842       F2 : Integer;
4843       pragma Obsolescent;
4844       F3 : Integer;
4845    end record;
4847    type E is (a, bc, 'd', quack);
4848    pragma Obsolescent (Entity => bc)
4849    pragma Obsolescent (Entity => 'd')
4851    function "+"
4852      (a, b : character) return character;
4853    pragma Obsolescent (Entity => "+");
4854 end;
4855 @end smallexample
4857 @noindent
4858 Note that, as for all pragmas, if you use a pragma argument identifier,
4859 then all subsequent parameters must also use a pragma argument identifier.
4860 So if you specify "Entity =>" for the Entity argument, and a Message
4861 argument is present, it must be preceded by "Message =>".
4863 @node Pragma Optimize_Alignment
4864 @unnumberedsec Pragma Optimize_Alignment
4865 @findex Optimize_Alignment
4866 @cindex Alignment, default settings
4867 @noindent
4868 Syntax:
4870 @smallexample @c ada
4871 pragma Optimize_Alignment (TIME | SPACE | OFF);
4872 @end smallexample
4874 @noindent
4875 This is a configuration pragma which affects the choice of default alignments
4876 for types and objects where no alignment is explicitly specified. There is a
4877 time/space trade-off in the selection of these values. Large alignments result
4878 in more efficient code, at the expense of larger data space, since sizes have
4879 to be increased to match these alignments. Smaller alignments save space, but
4880 the access code is slower. The normal choice of default alignments for types
4881 and individual alignment promotions for objects (which is what you get if you
4882 do not use this pragma, or if you use an argument of OFF), tries to balance
4883 these two requirements.
4885 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4886 First any packed record is given an alignment of 1. Second, if a size is given
4887 for the type, then the alignment is chosen to avoid increasing this size. For
4888 example, consider:
4890 @smallexample @c ada
4891    type R is record
4892       X : Integer;
4893       Y : Character;
4894    end record;
4896    for R'Size use 5*8;
4897 @end smallexample
4899 @noindent
4900 In the default mode, this type gets an alignment of 4, so that access to the
4901 Integer field X are efficient. But this means that objects of the type end up
4902 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4903 allowed to be bigger than the size of the type, but it can waste space if for
4904 example fields of type R appear in an enclosing record. If the above type is
4905 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4907 However, there is one case in which SPACE is ignored. If a variable length
4908 record (that is a discriminated record with a component which is an array
4909 whose length depends on a discriminant), has a pragma Pack, then it is not
4910 in general possible to set the alignment of such a record to one, so the
4911 pragma is ignored in this case (with a warning).
4913 Specifying SPACE also disables alignment promotions for standalone objects,
4914 which occur when the compiler increases the alignment of a specific object
4915 without changing the alignment of its type.
4917 Specifying TIME causes larger default alignments to be chosen in the case of
4918 small types with sizes that are not a power of 2. For example, consider:
4920 @smallexample @c ada
4921    type R is record
4922       A : Character;
4923       B : Character;
4924       C : Boolean;
4925    end record;
4927    pragma Pack (R);
4928    for R'Size use 17;
4929 @end smallexample
4931 @noindent
4932 The default alignment for this record is normally 1, but if this type is
4933 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4934 to 4, which wastes space for objects of the type, since they are now 4 bytes
4935 long, but results in more efficient access when the whole record is referenced.
4937 As noted above, this is a configuration pragma, and there is a requirement
4938 that all units in a partition be compiled with a consistent setting of the
4939 optimization setting. This would normally be achieved by use of a configuration
4940 pragma file containing the appropriate setting. The exception to this rule is
4941 that units with an explicit configuration pragma in the same file as the source
4942 unit are excluded from the consistency check, as are all predefined units. The
4943 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4944 pragma appears at the start of the file.
4946 @node Pragma Ordered
4947 @unnumberedsec Pragma Ordered
4948 @findex Ordered
4949 @findex pragma @code{Ordered}
4950 @noindent
4951 Syntax:
4953 @smallexample @c ada
4954 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4955 @end smallexample
4957 @noindent
4958 Most enumeration types are from a conceptual point of view unordered.
4959 For example, consider:
4961 @smallexample @c ada
4962 type Color is (Red, Blue, Green, Yellow);
4963 @end smallexample
4965 @noindent
4966 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4967 but really these relations make no sense; the enumeration type merely
4968 specifies a set of possible colors, and the order is unimportant.
4970 For unordered enumeration types, it is generally a good idea if
4971 clients avoid comparisons (other than equality or inequality) and
4972 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4973 other than the unit where the type is declared, its body, and its subunits.)
4974 For example, if code buried in some client says:
4976 @smallexample @c ada
4977 if Current_Color < Yellow then ...
4978 if Current_Color in Blue .. Green then ...
4979 @end smallexample
4981 @noindent
4982 then the client code is relying on the order, which is undesirable.
4983 It makes the code hard to read and creates maintenance difficulties if
4984 entries have to be added to the enumeration type. Instead,
4985 the code in the client should list the possibilities, or an
4986 appropriate subtype should be declared in the unit that declares
4987 the original enumeration type. E.g., the following subtype could
4988 be declared along with the type @code{Color}:
4990 @smallexample @c ada
4991 subtype RBG is Color range Red .. Green;
4992 @end smallexample
4994 @noindent
4995 and then the client could write:
4997 @smallexample @c ada
4998 if Current_Color in RBG then ...
4999 if Current_Color = Blue or Current_Color = Green then ...
5000 @end smallexample
5002 @noindent
5003 However, some enumeration types are legitimately ordered from a conceptual
5004 point of view. For example, if you declare:
5006 @smallexample @c ada
5007 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
5008 @end smallexample
5010 @noindent
5011 then the ordering imposed by the language is reasonable, and
5012 clients can depend on it, writing for example:
5014 @smallexample @c ada
5015 if D in Mon .. Fri then ...
5016 if D < Wed then ...
5017 @end smallexample
5019 @noindent
5020 The pragma @option{Ordered} is provided to mark enumeration types that
5021 are conceptually ordered, alerting the reader that clients may depend
5022 on the ordering. GNAT provides a pragma to mark enumerations as ordered
5023 rather than one to mark them as unordered, since in our experience,
5024 the great majority of enumeration types are conceptually unordered.
5026 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
5027 and @code{Wide_Wide_Character}
5028 are considered to be ordered types, so each is declared with a
5029 pragma @code{Ordered} in package @code{Standard}.
5031 Normally pragma @code{Ordered} serves only as documentation and a guide for
5032 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
5033 requests warnings for inappropriate uses (comparisons and explicit
5034 subranges) for unordered types. If this switch is used, then any
5035 enumeration type not marked with pragma @code{Ordered} will be considered
5036 as unordered, and will generate warnings for inappropriate uses.
5038 For additional information please refer to the description of the
5039 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
5041 @node Pragma Overflow_Mode
5042 @unnumberedsec Pragma Overflow_Mode
5043 @findex Overflow checks
5044 @findex Overflow mode
5045 @findex pragma @code{Overflow_Mode}
5046 @noindent
5047 Syntax:
5049 @smallexample @c ada
5050 pragma Overflow_Mode
5051  (  [General    =>] MODE
5052   [,[Assertions =>] MODE]);
5054 MODE ::= STRICT | MINIMIZED | ELIMINATED
5055 @end smallexample
5057 @noindent
5058 This pragma sets the current overflow mode to the given setting. For details
5059 of the meaning of these modes, please refer to the
5060 ``Overflow Check Handling in GNAT'' appendix in the
5061 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
5062 the given mode applies to all expressions. If both parameters are present,
5063 the @code{General} mode applies to expressions outside assertions, and
5064 the @code{Eliminated} mode applies to expressions within assertions.
5066 The case of the @code{MODE} parameter is ignored,
5067 so @code{MINIMIZED}, @code{Minimized} and
5068 @code{minimized} all have the same effect.
5070 The @code{Overflow_Mode} pragma has the same scoping and placement
5071 rules as pragma @code{Suppress}, so it can occur either as a
5072 configuration pragma, specifying a default for the whole
5073 program, or in a declarative scope, where it applies to the
5074 remaining declarations and statements in that scope.
5076 The pragma @code{Suppress (Overflow_Check)} suppresses
5077 overflow checking, but does not affect the overflow mode.
5079 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
5080 overflow checking, but does not affect the overflow mode.
5082 @node Pragma Overriding_Renamings
5083 @unnumberedsec Pragma Overriding_Renamings
5084 @findex Overriding_Renamings
5085 @cindex Rational profile
5086 @cindex Rational compatibility
5087 @noindent
5088 Syntax:
5090 @smallexample @c ada
5091 pragma Overriding_Renamings;
5092 @end smallexample
5094 @noindent
5095 This is a GNAT configuration pragma to simplify porting
5096 legacy code accepted by the Rational
5097 Ada compiler. In the presence of this pragma, a renaming declaration that
5098 renames an inherited operation declared in the same scope is legal if selected
5099 notation is used as in:
5101 @smallexample @c ada
5102 pragma Overriding_Renamings;
5104 package R is
5105   function F (..);
5106   ...
5107   function F (..) renames R.F;
5108 end R;
5109 @end smallexample
5111 even though
5112 RM 8.3 (15) stipulates that an overridden operation is not visible within the
5113 declaration of the overriding operation.
5115 @node Pragma Partition_Elaboration_Policy
5116 @unnumberedsec Pragma Partition_Elaboration_Policy
5117 @findex Partition_Elaboration_Policy
5118 @noindent
5119 Syntax:
5121 @smallexample @c ada
5122 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
5124 POLICY_IDENTIFIER ::= Concurrent | Sequential
5125 @end smallexample
5127 @noindent
5128 This pragma is standard in Ada 2005, but is available in all earlier
5129 versions of Ada as an implementation-defined pragma.
5130 See Ada 2012 Reference Manual for details.
5132 @node Pragma Passive
5133 @unnumberedsec Pragma Passive
5134 @findex Passive
5135 @noindent
5136 Syntax:
5138 @smallexample @c ada
5139 pragma Passive [(Semaphore | No)];
5140 @end smallexample
5142 @noindent
5143 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
5144 compatibility with DEC Ada 83 implementations, where it is used within a
5145 task definition to request that a task be made passive.  If the argument
5146 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
5147 treats the pragma as an assertion that the containing task is passive
5148 and that optimization of context switch with this task is permitted and
5149 desired.  If the argument @code{No} is present, the task must not be
5150 optimized.  GNAT does not attempt to optimize any tasks in this manner
5151 (since protected objects are available in place of passive tasks).
5153 For more information on the subject of passive tasks, see the section
5154 ``Passive Task Optimization'' in the GNAT Users Guide.
5156 @node Pragma Persistent_BSS
5157 @unnumberedsec Pragma Persistent_BSS
5158 @findex Persistent_BSS
5159 @noindent
5160 Syntax:
5162 @smallexample @c ada
5163 pragma Persistent_BSS [(LOCAL_NAME)]
5164 @end smallexample
5166 @noindent
5167 This pragma allows selected objects to be placed in the @code{.persistent_bss}
5168 section. On some targets the linker and loader provide for special
5169 treatment of this section, allowing a program to be reloaded without
5170 affecting the contents of this data (hence the name persistent).
5172 There are two forms of usage. If an argument is given, it must be the
5173 local name of a library level object, with no explicit initialization
5174 and whose type is potentially persistent. If no argument is given, then
5175 the pragma is a configuration pragma, and applies to all library level
5176 objects with no explicit initialization of potentially persistent types.
5178 A potentially persistent type is a scalar type, or a non-tagged,
5179 non-discriminated record, all of whose components have no explicit
5180 initialization and are themselves of a potentially persistent type,
5181 or an array, all of whose constraints are static, and whose component
5182 type is potentially persistent.
5184 If this pragma is used on a target where this feature is not supported,
5185 then the pragma will be ignored. See also @code{pragma Linker_Section}.
5187 @node Pragma Polling
5188 @unnumberedsec Pragma Polling
5189 @findex Polling
5190 @noindent
5191 Syntax:
5193 @smallexample @c ada
5194 pragma Polling (ON | OFF);
5195 @end smallexample
5197 @noindent
5198 This pragma controls the generation of polling code.  This is normally off.
5199 If @code{pragma Polling (ON)} is used then periodic calls are generated to
5200 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
5201 runtime library, and can be found in file @file{a-excpol.adb}.
5203 Pragma @code{Polling} can appear as a configuration pragma (for example it
5204 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
5205 can be used in the statement or declaration sequence to control polling
5206 more locally.
5208 A call to the polling routine is generated at the start of every loop and
5209 at the start of every subprogram call.  This guarantees that the @code{Poll}
5210 routine is called frequently, and places an upper bound (determined by
5211 the complexity of the code) on the period between two @code{Poll} calls.
5213 The primary purpose of the polling interface is to enable asynchronous
5214 aborts on targets that cannot otherwise support it (for example Windows
5215 NT), but it may be used for any other purpose requiring periodic polling.
5216 The standard version is null, and can be replaced by a user program.  This
5217 will require re-compilation of the @code{Ada.Exceptions} package that can
5218 be found in files @file{a-except.ads} and @file{a-except.adb}.
5220 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
5221 distribution) is used to enable the asynchronous abort capability on
5222 targets that do not normally support the capability.  The version of
5223 @code{Poll} in this file makes a call to the appropriate runtime routine
5224 to test for an abort condition.
5226 Note that polling can also be enabled by use of the @option{-gnatP} switch.
5227 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
5228 details.
5230 @node Pragma Post
5231 @unnumberedsec Pragma Post
5232 @cindex Post
5233 @cindex Checks, postconditions
5234 @findex Postconditions
5235 @noindent
5236 Syntax:
5238 @smallexample @c ada
5239 pragma Post (Boolean_Expression);
5240 @end smallexample
5242 @noindent
5243 The @code{Post} pragma is intended to be an exact replacement for
5244 the language-defined
5245 @code{Post} aspect, and shares its restrictions and semantics.
5246 It must appear either immediately following the corresponding
5247 subprogram declaration (only other pragmas may intervene), or
5248 if there is no separate subprogram declaration, then it can
5249 appear at the start of the declarations in a subprogram body
5250 (preceded only by other pragmas).
5252 @node Pragma Postcondition
5253 @unnumberedsec Pragma Postcondition
5254 @cindex Postcondition
5255 @cindex Checks, postconditions
5256 @findex Postconditions
5257 @noindent
5258 Syntax:
5260 @smallexample @c ada
5261 pragma Postcondition (
5262    [Check   =>] Boolean_Expression
5263  [,[Message =>] String_Expression]);
5264 @end smallexample
5266 @noindent
5267 The @code{Postcondition} pragma allows specification of automatic
5268 postcondition checks for subprograms. These checks are similar to
5269 assertions, but are automatically inserted just prior to the return
5270 statements of the subprogram with which they are associated (including
5271 implicit returns at the end of procedure bodies and associated
5272 exception handlers).
5274 In addition, the boolean expression which is the condition which
5275 must be true may contain references to function'Result in the case
5276 of a function to refer to the returned value.
5278 @code{Postcondition} pragmas may appear either immediately following the
5279 (separate) declaration of a subprogram, or at the start of the
5280 declarations of a subprogram body. Only other pragmas may intervene
5281 (that is appear between the subprogram declaration and its
5282 postconditions, or appear before the postcondition in the
5283 declaration sequence in a subprogram body). In the case of a
5284 postcondition appearing after a subprogram declaration, the
5285 formal arguments of the subprogram are visible, and can be
5286 referenced in the postcondition expressions.
5288 The postconditions are collected and automatically tested just
5289 before any return (implicit or explicit) in the subprogram body.
5290 A postcondition is only recognized if postconditions are active
5291 at the time the pragma is encountered. The compiler switch @option{gnata}
5292 turns on all postconditions by default, and pragma @code{Check_Policy}
5293 with an identifier of @code{Postcondition} can also be used to
5294 control whether postconditions are active.
5296 The general approach is that postconditions are placed in the spec
5297 if they represent functional aspects which make sense to the client.
5298 For example we might have:
5300 @smallexample @c ada
5301    function Direction return Integer;
5302    pragma Postcondition
5303     (Direction'Result = +1
5304        or else
5305      Direction'Result = -1);
5306 @end smallexample
5308 @noindent
5309 which serves to document that the result must be +1 or -1, and
5310 will test that this is the case at run time if postcondition
5311 checking is active.
5313 Postconditions within the subprogram body can be used to
5314 check that some internal aspect of the implementation,
5315 not visible to the client, is operating as expected.
5316 For instance if a square root routine keeps an internal
5317 counter of the number of times it is called, then we
5318 might have the following postcondition:
5320 @smallexample @c ada
5321    Sqrt_Calls : Natural := 0;
5323    function Sqrt (Arg : Float) return Float is
5324      pragma Postcondition
5325        (Sqrt_Calls = Sqrt_Calls'Old + 1);
5326      ...
5327    end Sqrt
5328 @end smallexample
5330 @noindent
5331 As this example, shows, the use of the @code{Old} attribute
5332 is often useful in postconditions to refer to the state on
5333 entry to the subprogram.
5335 Note that postconditions are only checked on normal returns
5336 from the subprogram. If an abnormal return results from
5337 raising an exception, then the postconditions are not checked.
5339 If a postcondition fails, then the exception
5340 @code{System.Assertions.Assert_Failure} is raised. If
5341 a message argument was supplied, then the given string
5342 will be used as the exception message. If no message
5343 argument was supplied, then the default message has
5344 the form "Postcondition failed at file:line". The
5345 exception is raised in the context of the subprogram
5346 body, so it is possible to catch postcondition failures
5347 within the subprogram body itself.
5349 Within a package spec, normal visibility rules
5350 in Ada would prevent forward references within a
5351 postcondition pragma to functions defined later in
5352 the same package. This would introduce undesirable
5353 ordering constraints. To avoid this problem, all
5354 postcondition pragmas are analyzed at the end of
5355 the package spec, allowing forward references.
5357 The following example shows that this even allows
5358 mutually recursive postconditions as in:
5360 @smallexample @c ada
5361 package Parity_Functions is
5362    function Odd  (X : Natural) return Boolean;
5363    pragma Postcondition
5364      (Odd'Result =
5365         (x = 1
5366           or else
5367         (x /= 0 and then Even (X - 1))));
5369    function Even (X : Natural) return Boolean;
5370    pragma Postcondition
5371      (Even'Result =
5372         (x = 0
5373           or else
5374         (x /= 1 and then Odd (X - 1))));
5376 end Parity_Functions;
5377 @end smallexample
5379 @noindent
5380 There are no restrictions on the complexity or form of
5381 conditions used within @code{Postcondition} pragmas.
5382 The following example shows that it is even possible
5383 to verify performance behavior.
5385 @smallexample @c ada
5386 package Sort is
5388    Performance : constant Float;
5389    --  Performance constant set by implementation
5390    --  to match target architecture behavior.
5392    procedure Treesort (Arg : String);
5393    --  Sorts characters of argument using N*logN sort
5394    pragma Postcondition
5395      (Float (Clock - Clock'Old) <=
5396         Float (Arg'Length) *
5397         log (Float (Arg'Length)) *
5398         Performance);
5399 end Sort;
5400 @end smallexample
5402 @noindent
5403 Note: postcondition pragmas associated with subprograms that are
5404 marked as Inline_Always, or those marked as Inline with front-end
5405 inlining (-gnatN option set) are accepted and legality-checked
5406 by the compiler, but are ignored at run-time even if postcondition
5407 checking is enabled.
5409 Note that pragma @code{Postcondition} differs from the language-defined
5410 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
5411 multiple occurrences, allowing occurences in the body even if there
5412 is a separate spec, and allowing a second string parameter, and the
5413 use of the pragma identifier @code{Check}. Historically, pragma
5414 @code{Postcondition} was implemented prior to the development of
5415 Ada 2012, and has been retained in its original form for
5416 compatibility purposes.
5418 @node Pragma Post_Class
5419 @unnumberedsec Pragma Post_Class
5420 @cindex Post
5421 @cindex Checks, postconditions
5422 @findex Postconditions
5423 @noindent
5424 Syntax:
5426 @smallexample @c ada
5427 pragma Post_Class (Boolean_Expression);
5428 @end smallexample
5430 @noindent
5431 The @code{Post_Class} pragma is intended to be an exact replacement for
5432 the language-defined
5433 @code{Post'Class} aspect, and shares its restrictions and semantics.
5434 It must appear either immediately following the corresponding
5435 subprogram declaration (only other pragmas may intervene), or
5436 if there is no separate subprogram declaration, then it can
5437 appear at the start of the declarations in a subprogram body
5438 (preceded only by other pragmas).
5440 Note: This pragma is called @code{Post_Class} rather than
5441 @code{Post'Class} because the latter would not be strictly
5442 conforming to the allowed syntax for pragmas. The motivation
5443 for provinding pragmas equivalent to the aspects is to allow a program
5444 to be written using the pragmas, and then compiled if necessary
5445 using an Ada compiler that does not recognize the pragmas or
5446 aspects, but is prepared to ignore the pragmas. The assertion
5447 policy that controls this pragma is @code{Post'Class}, not
5448 @code{Post_Class}.
5450 @node Pragma Pre
5451 @unnumberedsec Pragma Pre
5452 @cindex Pre
5453 @cindex Checks, preconditions
5454 @findex Preconditions
5455 @noindent
5456 Syntax:
5458 @smallexample @c ada
5459 pragma Pre (Boolean_Expression);
5460 @end smallexample
5462 @noindent
5463 The @code{Pre} pragma is intended to be an exact replacement for
5464 the language-defined
5465 @code{Pre} aspect, and shares its restrictions and semantics.
5466 It must appear either immediately following the corresponding
5467 subprogram declaration (only other pragmas may intervene), or
5468 if there is no separate subprogram declaration, then it can
5469 appear at the start of the declarations in a subprogram body
5470 (preceded only by other pragmas).
5472 @node Pragma Precondition
5473 @unnumberedsec Pragma Precondition
5474 @cindex Preconditions
5475 @cindex Checks, preconditions
5476 @findex Preconditions
5477 @noindent
5478 Syntax:
5480 @smallexample @c ada
5481 pragma Precondition (
5482    [Check   =>] Boolean_Expression
5483  [,[Message =>] String_Expression]);
5484 @end smallexample
5486 @noindent
5487 The @code{Precondition} pragma is similar to @code{Postcondition}
5488 except that the corresponding checks take place immediately upon
5489 entry to the subprogram, and if a precondition fails, the exception
5490 is raised in the context of the caller, and the attribute 'Result
5491 cannot be used within the precondition expression.
5493 Otherwise, the placement and visibility rules are identical to those
5494 described for postconditions. The following is an example of use
5495 within a package spec:
5497 @smallexample @c ada
5498 package Math_Functions is
5499    ...
5500    function Sqrt (Arg : Float) return Float;
5501    pragma Precondition (Arg >= 0.0)
5502    ...
5503 end Math_Functions;
5504 @end smallexample
5506 @noindent
5507 @code{Precondition} pragmas may appear either immediately following the
5508 (separate) declaration of a subprogram, or at the start of the
5509 declarations of a subprogram body. Only other pragmas may intervene
5510 (that is appear between the subprogram declaration and its
5511 postconditions, or appear before the postcondition in the
5512 declaration sequence in a subprogram body).
5514 Note: precondition pragmas associated with subprograms that are
5515 marked as Inline_Always, or those marked as Inline with front-end
5516 inlining (-gnatN option set) are accepted and legality-checked
5517 by the compiler, but are ignored at run-time even if precondition
5518 checking is enabled.
5520 Note that pragma @code{Precondition} differs from the language-defined
5521 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
5522 multiple occurrences, allowing occurences in the body even if there
5523 is a separate spec, and allowing a second string parameter, and the
5524 use of the pragma identifier @code{Check}. Historically, pragma
5525 @code{Precondition} was implemented prior to the development of
5526 Ada 2012, and has been retained in its original form for
5527 compatibility purposes.
5529 @node Pragma Predicate
5530 @unnumberedsec Pragma Predicate
5531 @findex Predicate
5532 @findex Predicate pragma
5533 @noindent
5534 Syntax:
5536 @smallexample @c ada
5537 pragma Predicate
5538   ([Entity =>] type_LOCAL_NAME,
5539    [Check  =>] EXPRESSION);
5540 @end smallexample
5542 @noindent
5543 This pragma (available in all versions of Ada in GNAT) encompasses both
5544 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
5545 Ada 2012. A predicate is regarded as static if it has an allowed form
5546 for @code{Static_Predicate} and is otherwise treated as a
5547 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
5548 pragma behave exactly as described in the Ada 2012 reference manual.
5549 For example, if we have
5551 @smallexample @c ada
5552 type R is range 1 .. 10;
5553 subtype S is R;
5554 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5555 subtype Q is R
5556 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5557 @end smallexample
5559 @noindent
5560 the effect is identical to the following Ada 2012 code:
5562 @smallexample @c ada
5563 type R is range 1 .. 10;
5564 subtype S is R with
5565   Static_Predicate => S not in 4 .. 6;
5566 subtype Q is R with
5567   Dynamic_Predicate => F(Q) or G(Q);
5568 @end smallexample
5570 Note that there is are no pragmas @code{Dynamic_Predicate}
5571 or @code{Static_Predicate}. That is
5572 because these pragmas would affect legality and semantics of
5573 the program and thus do not have a neutral effect if ignored.
5574 The motivation behind providing pragmas equivalent to
5575 corresponding aspects is to allow a program to be written
5576 using the pragmas, and then compiled with a compiler that
5577 will ignore the pragmas. That doesn't work in the case of
5578 static and dynamic predicates, since if the corresponding
5579 pragmas are ignored, then the behavior of the program is
5580 fundamentally changed (for example a membership test
5581 @code{A in B} would not take into account a predicate
5582 defined for subtype B). When following this approach, the
5583 use of predicates should be avoided.
5585 @node Pragma Preelaborable_Initialization
5586 @unnumberedsec Pragma Preelaborable_Initialization
5587 @findex Preelaborable_Initialization
5588 @noindent
5589 Syntax:
5591 @smallexample @c ada
5592 pragma Preelaborable_Initialization (DIRECT_NAME);
5593 @end smallexample
5595 @noindent
5596 This pragma is standard in Ada 2005, but is available in all earlier
5597 versions of Ada as an implementation-defined pragma.
5598 See Ada 2012 Reference Manual for details.
5600 @node Pragma Preelaborate_05
5601 @unnumberedsec Pragma Preelaborate_05
5602 @findex Preelaborate_05
5603 @noindent
5604 Syntax:
5606 @smallexample @c ada
5607 pragma Preelaborate_05 [(library_unit_NAME)];
5608 @end smallexample
5610 @noindent
5611 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5612 and is intended for use in the standard run-time library only. It has
5613 no effect in Ada 83 or Ada 95 mode, but is
5614 equivalent to @code{pragma Prelaborate} when operating in later
5615 Ada versions. This is used to handle some cases where packages
5616 not previously preelaborable became so in Ada 2005.
5618 @node Pragma Pre_Class
5619 @unnumberedsec Pragma Pre_Class
5620 @cindex Pre_Class
5621 @cindex Checks, preconditions
5622 @findex Preconditions
5623 @noindent
5624 Syntax:
5626 @smallexample @c ada
5627 pragma Pre_Class (Boolean_Expression);
5628 @end smallexample
5630 @noindent
5631 The @code{Pre_Class} pragma is intended to be an exact replacement for
5632 the language-defined
5633 @code{Pre'Class} aspect, and shares its restrictions and semantics.
5634 It must appear either immediately following the corresponding
5635 subprogram declaration (only other pragmas may intervene), or
5636 if there is no separate subprogram declaration, then it can
5637 appear at the start of the declarations in a subprogram body
5638 (preceded only by other pragmas).
5640 Note: This pragma is called @code{Pre_Class} rather than
5641 @code{Pre'Class} because the latter would not be strictly
5642 conforming to the allowed syntax for pragmas. The motivation
5643 for providing pragmas equivalent to the aspects is to allow a program
5644 to be written using the pragmas, and then compiled if necessary
5645 using an Ada compiler that does not recognize the pragmas or
5646 aspects, but is prepared to ignore the pragmas. The assertion
5647 policy that controls this pragma is @code{Pre'Class}, not
5648 @code{Pre_Class}.
5650 @node Pragma Priority_Specific_Dispatching
5651 @unnumberedsec Pragma Priority_Specific_Dispatching
5652 @findex Priority_Specific_Dispatching
5653 @noindent
5654 Syntax:
5656 @smallexample @c ada
5657 pragma Priority_Specific_Dispatching (
5658    POLICY_IDENTIFIER,
5659    first_priority_EXPRESSION,
5660    last_priority_EXPRESSION)
5662 POLICY_IDENTIFIER ::=
5663    EDF_Across_Priorities            |
5664    FIFO_Within_Priorities           |
5665    Non_Preemptive_Within_Priorities |
5666    Round_Robin_Within_Priorities
5667 @end smallexample
5669 @noindent
5670 This pragma is standard in Ada 2005, but is available in all earlier
5671 versions of Ada as an implementation-defined pragma.
5672 See Ada 2012 Reference Manual for details.
5674 @node Pragma Profile
5675 @unnumberedsec Pragma Profile
5676 @findex Profile
5677 @noindent
5678 Syntax:
5680 @smallexample @c ada
5681 pragma Profile (Ravenscar | Restricted | Rational);
5682 @end smallexample
5684 @noindent
5685 This pragma is standard in Ada 2005, but is available in all earlier
5686 versions of Ada as an implementation-defined pragma. This is a
5687 configuration pragma that establishes a set of configiuration pragmas
5688 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5689 The other two possibilities (@code{Restricted} or @code{Rational})
5690 are implementation-defined. The set of configuration pragmas
5691 is defined in the following sections.
5693 @itemize
5695 @item Pragma Profile (Ravenscar)
5696 @findex Ravenscar
5697 @noindent
5699 The @code{Ravenscar} profile is standard in Ada 2005,
5700 but is available in all earlier
5701 versions of Ada as an implementation-defined pragma. This profile
5702 establishes the following set of configuration pragmas:
5704 @table @code
5705 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5706 [RM D.2.2] Tasks are dispatched following a preemptive
5707 priority-ordered scheduling policy.
5709 @item Locking_Policy (Ceiling_Locking)
5710 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5711 the ceiling priority of the corresponding protected object.
5713 @item Detect_Blocking
5714 This pragma forces the detection of potentially blocking operations within a
5715 protected operation, and to raise Program_Error if that happens.
5716 @end table
5717 @noindent
5719 plus the following set of restrictions:
5721 @table @code
5722 @item Max_Entry_Queue_Length => 1
5723 No task can be queued on a protected entry.
5724 @item Max_Protected_Entries => 1
5725 @item Max_Task_Entries => 0
5726 No rendezvous statements are allowed.
5727 @item No_Abort_Statements
5728 @item No_Dynamic_Attachment
5729 @item No_Dynamic_Priorities
5730 @item No_Implicit_Heap_Allocations
5731 @item No_Local_Protected_Objects
5732 @item No_Local_Timing_Events
5733 @item No_Protected_Type_Allocators
5734 @item No_Relative_Delay
5735 @item No_Requeue_Statements
5736 @item No_Select_Statements
5737 @item No_Specific_Termination_Handlers
5738 @item No_Task_Allocators
5739 @item No_Task_Hierarchy
5740 @item No_Task_Termination
5741 @item Simple_Barriers
5742 @end table
5743 @noindent
5745 The Ravenscar profile also includes the following restrictions that specify
5746 that there are no semantic dependences on the corresponding predefined
5747 packages:
5749 @table @code
5750 @item No_Dependence => Ada.Asynchronous_Task_Control
5751 @item No_Dependence => Ada.Calendar
5752 @item No_Dependence => Ada.Execution_Time.Group_Budget
5753 @item No_Dependence => Ada.Execution_Time.Timers
5754 @item No_Dependence => Ada.Task_Attributes
5755 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5756 @end table
5758 @noindent
5760 This set of configuration pragmas and restrictions correspond to the
5761 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5762 published by the @cite{International Real-Time Ada Workshop}, 1997,
5763 and whose most recent description is available at
5764 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5766 The original definition of the profile was revised at subsequent IRTAW
5767 meetings. It has been included in the ISO
5768 @cite{Guide for the Use of the Ada Programming Language in High
5769 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5770 the next revision of the standard. The formal definition given by
5771 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5772 AI-305) available at
5773 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5774 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5776 The above set is a superset of the restrictions provided by pragma
5777 @code{Profile (Restricted)}, it includes six additional restrictions
5778 (@code{Simple_Barriers}, @code{No_Select_Statements},
5779 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5780 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
5781 that pragma @code{Profile (Ravenscar)}, like the pragma
5782 @code{Profile (Restricted)},
5783 automatically causes the use of a simplified,
5784 more efficient version of the tasking run-time system.
5786 @item Pragma Profile (Restricted)
5787 @findex Restricted Run Time
5788 @noindent
5789 This profile corresponds to the GNAT restricted run time. It
5790 establishes the following set of restrictions:
5792 @itemize @bullet
5793 @item No_Abort_Statements
5794 @item No_Entry_Queue
5795 @item No_Task_Hierarchy
5796 @item No_Task_Allocators
5797 @item No_Dynamic_Priorities
5798 @item No_Terminate_Alternatives
5799 @item No_Dynamic_Attachment
5800 @item No_Protected_Type_Allocators
5801 @item No_Local_Protected_Objects
5802 @item No_Requeue_Statements
5803 @item No_Task_Attributes_Package
5804 @item Max_Asynchronous_Select_Nesting =  0
5805 @item Max_Task_Entries =  0
5806 @item Max_Protected_Entries = 1
5807 @item Max_Select_Alternatives = 0
5808 @end itemize
5810 @noindent
5811 This set of restrictions causes the automatic selection of a simplified
5812 version of the run time that provides improved performance for the
5813 limited set of tasking functionality permitted by this set of restrictions.
5815 @item Pragma Profile (Rational)
5816 @findex Rational compatibility mode
5817 @noindent
5818 The Rational profile is intended to facilitate porting legacy code that
5819 compiles with the Rational APEX compiler, even when the code includes non-
5820 conforming Ada constructs.  The profile enables the following three pragmas:
5822 @itemize @bullet
5823 @item pragma Implicit_Packing
5824 @item pragma Overriding_Renamings
5825 @item pragma Use_VADS_Size
5826 @end itemize
5828 @end itemize
5830 @node Pragma Profile_Warnings
5831 @unnumberedsec Pragma Profile_Warnings
5832 @findex Profile_Warnings
5833 @noindent
5834 Syntax:
5836 @smallexample @c ada
5837 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5838 @end smallexample
5840 @noindent
5841 This is an implementation-defined pragma that is similar in
5842 effect to @code{pragma Profile} except that instead of
5843 generating @code{Restrictions} pragmas, it generates
5844 @code{Restriction_Warnings} pragmas. The result is that
5845 violations of the profile generate warning messages instead
5846 of error messages.
5848 @node Pragma Propagate_Exceptions
5849 @unnumberedsec Pragma Propagate_Exceptions
5850 @cindex Interfacing to C++
5851 @findex Propagate_Exceptions
5852 @noindent
5853 Syntax:
5855 @smallexample @c ada
5856 pragma Propagate_Exceptions;
5857 @end smallexample
5859 @noindent
5860 This pragma is now obsolete and, other than generating a warning if warnings
5861 on obsolescent features are enabled, is ignored.
5862 It is retained for compatibility
5863 purposes. It used to be used in connection with optimization of
5864 a now-obsolete mechanism for implementation of exceptions.
5866 @node Pragma Provide_Shift_Operators
5867 @unnumberedsec Pragma Provide_Shift_Operators
5868 @cindex Shift operators
5869 @findex Provide_Shift_Operators
5870 @noindent
5871 Syntax:
5873 @smallexample @c ada
5874 pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
5875 @end smallexample
5877 @noindent
5878 This pragma can be applied to a first subtype local name that specifies
5879 either an unsigned or signed type. It has the effect of providing the
5880 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
5881 Rotate_Left and Rotate_Right) for the given type. It is equivalent to
5882 including the function declarations for these five operators, together
5883 with the pragma Import (Intrinsic, ...) statements.
5885 @node Pragma Psect_Object
5886 @unnumberedsec Pragma Psect_Object
5887 @findex Psect_Object
5888 @noindent
5889 Syntax:
5891 @smallexample @c ada
5892 pragma Psect_Object (
5893      [Internal =>] LOCAL_NAME,
5894   [, [External =>] EXTERNAL_SYMBOL]
5895   [, [Size     =>] EXTERNAL_SYMBOL]);
5897 EXTERNAL_SYMBOL ::=
5898   IDENTIFIER
5899 | static_string_EXPRESSION
5900 @end smallexample
5902 @noindent
5903 This pragma is identical in effect to pragma @code{Common_Object}.
5905 @node Pragma Pure_05
5906 @unnumberedsec Pragma Pure_05
5907 @findex Pure_05
5908 @noindent
5909 Syntax:
5911 @smallexample @c ada
5912 pragma Pure_05 [(library_unit_NAME)];
5913 @end smallexample
5915 @noindent
5916 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5917 and is intended for use in the standard run-time library only. It has
5918 no effect in Ada 83 or Ada 95 mode, but is
5919 equivalent to @code{pragma Pure} when operating in later
5920 Ada versions. This is used to handle some cases where packages
5921 not previously pure became so in Ada 2005.
5923 @node Pragma Pure_12
5924 @unnumberedsec Pragma Pure_12
5925 @findex Pure_12
5926 @noindent
5927 Syntax:
5929 @smallexample @c ada
5930 pragma Pure_12 [(library_unit_NAME)];
5931 @end smallexample
5933 @noindent
5934 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5935 and is intended for use in the standard run-time library only. It has
5936 no effect in Ada 83, Ada 95, or Ada 2005 modes, but is
5937 equivalent to @code{pragma Pure} when operating in later
5938 Ada versions. This is used to handle some cases where packages
5939 not previously pure became so in Ada 2012.
5941 @node Pragma Pure_Function
5942 @unnumberedsec Pragma Pure_Function
5943 @findex Pure_Function
5944 @noindent
5945 Syntax:
5947 @smallexample @c ada
5948 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5949 @end smallexample
5951 @noindent
5952 This pragma appears in the same declarative part as a function
5953 declaration (or a set of function declarations if more than one
5954 overloaded declaration exists, in which case the pragma applies
5955 to all entities).  It specifies that the function @code{Entity} is
5956 to be considered pure for the purposes of code generation.  This means
5957 that the compiler can assume that there are no side effects, and
5958 in particular that two calls with identical arguments produce the
5959 same result.  It also means that the function can be used in an
5960 address clause.
5962 Note that, quite deliberately, there are no static checks to try
5963 to ensure that this promise is met, so @code{Pure_Function} can be used
5964 with functions that are conceptually pure, even if they do modify
5965 global variables.  For example, a square root function that is
5966 instrumented to count the number of times it is called is still
5967 conceptually pure, and can still be optimized, even though it
5968 modifies a global variable (the count).  Memo functions are another
5969 example (where a table of previous calls is kept and consulted to
5970 avoid re-computation).
5972 Note also that the normal rules excluding optimization of subprograms
5973 in pure units (when parameter types are descended from System.Address,
5974 or when the full view of a parameter type is limited), do not apply
5975 for the Pure_Function case. If you explicitly specify Pure_Function,
5976 the compiler may optimize away calls with identical arguments, and
5977 if that results in unexpected behavior, the proper action is not to
5978 use the pragma for subprograms that are not (conceptually) pure.
5980 @findex Pure
5981 Note: Most functions in a @code{Pure} package are automatically pure, and
5982 there is no need to use pragma @code{Pure_Function} for such functions.  One
5983 exception is any function that has at least one formal of type
5984 @code{System.Address} or a type derived from it.  Such functions are not
5985 considered pure by default, since the compiler assumes that the
5986 @code{Address} parameter may be functioning as a pointer and that the
5987 referenced data may change even if the address value does not.
5988 Similarly, imported functions are not considered to be pure by default,
5989 since there is no way of checking that they are in fact pure.  The use
5990 of pragma @code{Pure_Function} for such a function will override these default
5991 assumption, and cause the compiler to treat a designated subprogram as pure
5992 in these cases.
5994 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5995 applies to the underlying renamed function.  This can be used to
5996 disambiguate cases of overloading where some but not all functions
5997 in a set of overloaded functions are to be designated as pure.
5999 If pragma @code{Pure_Function} is applied to a library level function, the
6000 function is also considered pure from an optimization point of view, but the
6001 unit is not a Pure unit in the categorization sense. So for example, a function
6002 thus marked is free to @code{with} non-pure units.
6004 @node Pragma Ravenscar
6005 @unnumberedsec Pragma Ravenscar
6006 @findex Pragma Ravenscar
6007 @noindent
6008 Syntax:
6010 @smallexample @c ada
6011 pragma Ravenscar;
6012 @end smallexample
6014 @noindent
6015 This pragma is considered obsolescent, but is retained for
6016 compatibility purposes. It is equivalent to:
6018 @smallexample @c ada
6019 pragma Profile (Ravenscar);
6020 @end smallexample
6022 @noindent
6023 which is the preferred method of setting the @code{Ravenscar} profile.
6025 @node Pragma Refined_State
6026 @unnumberedsec Pragma Refined_State
6027 @findex Refined_State
6028 @noindent
6029 For the description of this pragma, see SPARK 2014 Reference Manual,
6030 section 7.2.2.
6032 @node Pragma Relative_Deadline
6033 @unnumberedsec Pragma Relative_Deadline
6034 @findex Relative_Deadline
6035 @noindent
6036 Syntax:
6038 @smallexample @c ada
6039 pragma Relative_Deadline (time_span_EXPRESSION);
6040 @end smallexample
6042 @noindent
6043 This pragma is standard in Ada 2005, but is available in all earlier
6044 versions of Ada as an implementation-defined pragma.
6045 See Ada 2012 Reference Manual for details.
6047 @node Pragma Remote_Access_Type
6048 @unnumberedsec Pragma Remote_Access_Type
6049 @findex Remote_Access_Type
6050 @noindent
6051 Syntax:
6053 @smallexample @c ada
6054 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
6055 @end smallexample
6057 @noindent
6058 This pragma appears in the formal part of a generic declaration.
6059 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
6060 the use of a remote access to class-wide type as actual for a formal
6061 access type.
6063 When this pragma applies to a formal access type @code{Entity}, that
6064 type is treated as a remote access to class-wide type in the generic.
6065 It must be a formal general access type, and its designated type must
6066 be the class-wide type of a formal tagged limited private type from the
6067 same generic declaration.
6069 In the generic unit, the formal type is subject to all restrictions
6070 pertaining to remote access to class-wide types. At instantiation, the
6071 actual type must be a remote access to class-wide type.
6073 @node Pragma Restricted_Run_Time
6074 @unnumberedsec Pragma Restricted_Run_Time
6075 @findex Pragma Restricted_Run_Time
6076 @noindent
6077 Syntax:
6079 @smallexample @c ada
6080 pragma Restricted_Run_Time;
6081 @end smallexample
6083 @noindent
6084 This pragma is considered obsolescent, but is retained for
6085 compatibility purposes. It is equivalent to:
6087 @smallexample @c ada
6088 pragma Profile (Restricted);
6089 @end smallexample
6091 @noindent
6092 which is the preferred method of setting the restricted run time
6093 profile.
6095 @node Pragma Restriction_Warnings
6096 @unnumberedsec Pragma Restriction_Warnings
6097 @findex Restriction_Warnings
6098 @noindent
6099 Syntax:
6101 @smallexample @c ada
6102 pragma Restriction_Warnings
6103   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
6104 @end smallexample
6106 @noindent
6107 This pragma allows a series of restriction identifiers to be
6108 specified (the list of allowed identifiers is the same as for
6109 pragma @code{Restrictions}). For each of these identifiers
6110 the compiler checks for violations of the restriction, but
6111 generates a warning message rather than an error message
6112 if the restriction is violated.
6114 One use of this is in situations where you want to know
6115 about violations of a restriction, but you want to ignore some of
6116 these violations. Consider this example, where you want to set
6117 Ada_95 mode and enable style checks, but you want to know about
6118 any other use of implementation pragmas:
6120 @smallexample @c ada
6121 pragma Restriction_Warnings (No_Implementation_Pragmas);
6122 pragma Warnings (Off, "violation of*No_Implementation_Pragmas*");
6123 pragma Ada_95;
6124 pragma Style_Checks ("2bfhkM160");
6125 pragma Warnings (On, "violation of*No_Implementation_Pragmas*");
6126 @end smallexample
6128 @noindent
6129 By including the above lines in a configuration pragmas file,
6130 the Ada_95 and Style_Checks pragmas are accepted without
6131 generating a warning, but any other use of implementation
6132 defined pragmas will cause a warning to be generated.
6134 @node Pragma Reviewable
6135 @unnumberedsec Pragma Reviewable
6136 @findex Reviewable
6137 @noindent
6138 Syntax:
6140 @smallexample @c ada
6141 pragma Reviewable;
6142 @end smallexample
6144 @noindent
6145 This pragma is an RM-defined standard pragma, but has no effect on the
6146 program being compiled, or on the code generated for the program.
6148 To obtain the required output specified in RM H.3.1, the compiler must be
6149 run with various special switches as follows:
6151 @table @i
6153 @item Where compiler-generated run-time checks remain
6155 The switch @option{-gnatGL}
6156 @findex @option{-gnatGL}
6157 may be used to list the expanded code in pseudo-Ada form.
6158 Runtime checks show up in the listing either as explicit
6159 checks or operators marked with @{@} to indicate a check is present.
6161 @item An identification of known exceptions at compile time
6163 If the program is compiled with @option{-gnatwa},
6164 @findex @option{-gnatwa}
6165 the compiler warning messages will indicate all cases where the compiler
6166 detects that an exception is certain to occur at run time.
6168 @item Possible reads of uninitialized variables
6170 The compiler warns of many such cases, but its output is incomplete.
6171 @ifclear FSFEDITION
6172 The CodePeer analysis tool
6173 @findex CodePeer static analysis tool
6174 @end ifclear
6175 @ifset FSFEDITION
6176 A supplemental static analysis tool
6177 @end ifset
6178 may be used to obtain a comprehensive list of all
6179 possible points at which uninitialized data may be read.
6181 @item Where run-time support routines are implicitly invoked
6183 In the output from @option{-gnatGL},
6184 @findex @option{-gnatGL}
6185 run-time calls are explicitly listed as calls to the relevant
6186 run-time routine.
6188 @item Object code listing
6190 This may be obtained either by using the @option{-S} switch,
6191 @findex @option{-S}
6192 or the objdump utility.
6193 @findex objdump
6195 @item Constructs known to be erroneous at compile time
6197 These are identified by warnings issued by the compiler (use @option{-gnatwa}).
6198 @findex @option{-gnatwa}
6200 @item Stack usage information
6202 Static stack usage data (maximum per-subprogram) can be obtained via the
6203 @option{-fstack-usage} switch to the compiler.
6204 @findex @option{-fstack-usage}
6205 Dynamic stack usage data (per task) can be obtained via the @option{-u} switch
6206 to gnatbind
6207 @findex @option{-u}
6208 @ifclear FSFEDITION
6209 The gnatstack utility
6210 @findex gnatstack
6211 can be used to provide additional information on stack usage.
6212 @end ifclear
6214 @item Object code listing of entire partition
6216 This can be obtained by compiling the partition with @option{-S},
6217 @findex @option{-S}
6218 or by applying objdump
6219 @findex objdump
6220 to all the object files that are part of the partition.
6222 @item A description of the run-time model
6224 The full sources of the run-time are available, and the documentation of
6225 these routines describes how these run-time routines interface to the
6226 underlying operating system facilities.
6228 @item Control and data-flow information
6230 @ifclear FSFEDITION
6231 The CodePeer tool
6232 @findex CodePeer static analysis tool
6233 @end ifclear
6234 @ifset FSFEDITION
6235 A supplemental static analysis tool
6236 @end ifset
6237 may be used to obtain complete control and data-flow information, as well as
6238 comprehensive messages identifying possible problems based on this
6239 information.
6240 @end table
6242 @node Pragma Share_Generic
6243 @unnumberedsec Pragma Share_Generic
6244 @findex Share_Generic
6245 @noindent
6246 Syntax:
6248 @smallexample @c ada
6249 pragma Share_Generic (GNAME @{, GNAME@});
6251 GNAME ::= generic_unit_NAME | generic_instance_NAME
6252 @end smallexample
6254 @noindent
6255 This pragma is provided for compatibility with Dec Ada 83. It has
6256 no effect in @code{GNAT} (which does not implement shared generics), other
6257 than to check that the given names are all names of generic units or
6258 generic instances.
6260 @node Pragma Shared
6261 @unnumberedsec Pragma Shared
6262 @findex Shared
6264 @noindent
6265 This pragma is provided for compatibility with Ada 83. The syntax and
6266 semantics are identical to pragma Atomic.
6268 @node Pragma Short_Circuit_And_Or
6269 @unnumberedsec Pragma Short_Circuit_And_Or
6270 @findex Short_Circuit_And_Or
6271 @noindent
6272 Syntax:
6274 @smallexample @c ada
6275 pragma Short_Circuit_And_Or;
6276 @end smallexample
6278 @noindent
6279 This configuration pragma causes any occurrence of the AND operator applied to
6280 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
6281 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
6282 may be useful in the context of certification protocols requiring the use of
6283 short-circuited logical operators. If this configuration pragma occurs locally
6284 within the file being compiled, it applies only to the file being compiled.
6285 There is no requirement that all units in a partition use this option.
6287 @node Pragma Short_Descriptors
6288 @unnumberedsec Pragma Short_Descriptors
6289 @findex Short_Descriptors
6290 @noindent
6291 Syntax:
6293 @smallexample @c ada
6294 pragma Short_Descriptors
6295 @end smallexample
6297 @noindent
6298 In VMS versions of the compiler, this configuration pragma causes all
6299 occurrences of the mechanism types Descriptor[_xxx] to be treated as
6300 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
6301 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
6302 versions.
6304 @node Pragma Simple_Storage_Pool_Type
6305 @unnumberedsec Pragma Simple_Storage_Pool_Type
6306 @findex Simple_Storage_Pool_Type
6307 @cindex Storage pool, simple
6308 @cindex Simple storage pool
6309 @noindent
6310 Syntax:
6312 @smallexample @c ada
6313 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
6314 @end smallexample
6316 @noindent
6317 A type can be established as a ``simple storage pool type'' by applying
6318 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
6319 A type named in the pragma must be a library-level immutably limited record
6320 type or limited tagged type declared immediately within a package declaration.
6321 The type can also be a limited private type whose full type is allowed as
6322 a simple storage pool type.
6324 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
6325 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
6326 are subtype conformant with the following subprogram declarations:
6328 @smallexample @c ada
6329 procedure Allocate
6330   (Pool                     : in out SSP;
6331    Storage_Address          : out System.Address;
6332    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6333    Alignment                : System.Storage_Elements.Storage_Count);
6335 procedure Deallocate
6336   (Pool : in out SSP;
6337    Storage_Address          : System.Address;
6338    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6339    Alignment                : System.Storage_Elements.Storage_Count);
6341 function Storage_Size (Pool : SSP)
6342   return System.Storage_Elements.Storage_Count;
6343 @end smallexample
6345 @noindent
6346 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
6347 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
6348 applying an unchecked deallocation has no effect other than to set its actual
6349 parameter to null. If @code{Storage_Size} is not declared, then the
6350 @code{Storage_Size} attribute applied to an access type associated with
6351 a pool object of type SSP returns zero. Additional operations can be declared
6352 for a simple storage pool type (such as for supporting a mark/release
6353 storage-management discipline).
6355 An object of a simple storage pool type can be associated with an access
6356 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
6358 @smallexample @c ada
6360 My_Pool : My_Simple_Storage_Pool_Type;
6362 type Acc is access My_Data_Type;
6364 for Acc'Simple_Storage_Pool use My_Pool;
6366 @end smallexample
6368 @noindent
6369 See attribute @code{Simple_Storage_Pool} for further details.
6371 @node Pragma Source_File_Name
6372 @unnumberedsec Pragma Source_File_Name
6373 @findex Source_File_Name
6374 @noindent
6375 Syntax:
6377 @smallexample @c ada
6378 pragma Source_File_Name (
6379   [Unit_Name   =>] unit_NAME,
6380   Spec_File_Name =>  STRING_LITERAL,
6381   [Index => INTEGER_LITERAL]);
6383 pragma Source_File_Name (
6384   [Unit_Name   =>] unit_NAME,
6385   Body_File_Name =>  STRING_LITERAL,
6386   [Index => INTEGER_LITERAL]);
6387 @end smallexample
6389 @noindent
6390 Use this to override the normal naming convention.  It is a configuration
6391 pragma, and so has the usual applicability of configuration pragmas
6392 (i.e.@: it applies to either an entire partition, or to all units in a
6393 compilation, or to a single unit, depending on how it is used.
6394 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
6395 the second argument is required, and indicates whether this is the file
6396 name for the spec or for the body.
6398 The optional Index argument should be used when a file contains multiple
6399 units, and when you do not want to use @code{gnatchop} to separate then
6400 into multiple files (which is the recommended procedure to limit the
6401 number of recompilations that are needed when some sources change).
6402 For instance, if the source file @file{source.ada} contains
6404 @smallexample @c ada
6405 package B is
6407 end B;
6409 with B;
6410 procedure A is
6411 begin
6412    ..
6413 end A;
6414 @end smallexample
6416 you could use the following configuration pragmas:
6418 @smallexample @c ada
6419 pragma Source_File_Name
6420   (B, Spec_File_Name => "source.ada", Index => 1);
6421 pragma Source_File_Name
6422   (A, Body_File_Name => "source.ada", Index => 2);
6423 @end smallexample
6425 Note that the @code{gnatname} utility can also be used to generate those
6426 configuration pragmas.
6428 Another form of the @code{Source_File_Name} pragma allows
6429 the specification of patterns defining alternative file naming schemes
6430 to apply to all files.
6432 @smallexample @c ada
6433 pragma Source_File_Name
6434   (  [Spec_File_Name  =>] STRING_LITERAL
6435    [,[Casing          =>] CASING_SPEC]
6436    [,[Dot_Replacement =>] STRING_LITERAL]);
6438 pragma Source_File_Name
6439   (  [Body_File_Name  =>] STRING_LITERAL
6440    [,[Casing          =>] CASING_SPEC]
6441    [,[Dot_Replacement =>] STRING_LITERAL]);
6443 pragma Source_File_Name
6444   (  [Subunit_File_Name =>] STRING_LITERAL
6445    [,[Casing            =>] CASING_SPEC]
6446    [,[Dot_Replacement   =>] STRING_LITERAL]);
6448 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
6449 @end smallexample
6451 @noindent
6452 The first argument is a pattern that contains a single asterisk indicating
6453 the point at which the unit name is to be inserted in the pattern string
6454 to form the file name.  The second argument is optional.  If present it
6455 specifies the casing of the unit name in the resulting file name string.
6456 The default is lower case.  Finally the third argument allows for systematic
6457 replacement of any dots in the unit name by the specified string literal.
6459 Note that Source_File_Name pragmas should not be used if you are using
6460 project files. The reason for this rule is that the project manager is not
6461 aware of these pragmas, and so other tools that use the projet file would not
6462 be aware of the intended naming conventions. If you are using project files,
6463 file naming is controlled by Source_File_Name_Project pragmas, which are
6464 usually supplied automatically by the project manager. A pragma
6465 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
6467 For more details on the use of the @code{Source_File_Name} pragma,
6468 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
6469 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
6470 User's Guide}.
6472 @node Pragma Source_File_Name_Project
6473 @unnumberedsec Pragma Source_File_Name_Project
6474 @findex Source_File_Name_Project
6475 @noindent
6477 This pragma has the same syntax and semantics as pragma Source_File_Name.
6478 It is only allowed as a stand alone configuration pragma.
6479 It cannot appear after a @ref{Pragma Source_File_Name}, and
6480 most importantly, once pragma Source_File_Name_Project appears,
6481 no further Source_File_Name pragmas are allowed.
6483 The intention is that Source_File_Name_Project pragmas are always
6484 generated by the Project Manager in a manner consistent with the naming
6485 specified in a project file, and when naming is controlled in this manner,
6486 it is not permissible to attempt to modify this naming scheme using
6487 Source_File_Name or Source_File_Name_Project pragmas (which would not be
6488 known to the project manager).
6490 @node Pragma Source_Reference
6491 @unnumberedsec Pragma Source_Reference
6492 @findex Source_Reference
6493 @noindent
6494 Syntax:
6496 @smallexample @c ada
6497 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
6498 @end smallexample
6500 @noindent
6501 This pragma must appear as the first line of a source file.
6502 @var{integer_literal} is the logical line number of the line following
6503 the pragma line (for use in error messages and debugging
6504 information).  @var{string_literal} is a static string constant that
6505 specifies the file name to be used in error messages and debugging
6506 information.  This is most notably used for the output of @code{gnatchop}
6507 with the @option{-r} switch, to make sure that the original unchopped
6508 source file is the one referred to.
6510 The second argument must be a string literal, it cannot be a static
6511 string expression other than a string literal.  This is because its value
6512 is needed for error messages issued by all phases of the compiler.
6514 @node Pragma SPARK_Mode
6515 @unnumberedsec Pragma SPARK_Mode
6516 @findex SPARK_Mode
6517 @noindent
6518 Syntax:
6520 @smallexample @c ada
6521 pragma SPARK_Mode [(On | Off)] ;
6522 @end smallexample
6524 @noindent
6525 In general a program can have some parts that are in SPARK 2014 (and
6526 follow all the rules in the SPARK Reference Manual), and some parts
6527 that are full Ada 2012.
6529 The SPARK_Mode pragma is used to identify which parts are in SPARK
6530 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
6531 be used in the following places:
6533 @itemize @bullet
6535 @item
6536 As a configuration pragma, in which case it sets the default mode for
6537 all units compiled with this pragma.
6539 @item
6540 Immediately following a library-level subprogram spec
6542 @item
6543 Immediately within a library-level package body
6545 @item
6546 Immediately following the @code{private} keyword of a library-level
6547 package spec
6549 @item
6550 Immediately following the @code{begin} keyword of a library-level
6551 package body
6553 @item
6554 Immediately within a library-level subprogram body
6556 @end itemize
6558 @noindent
6559 Normally a subprogram or package spec/body inherits the current mode
6560 that is active at the point it is declared. But this can be overridden
6561 by pragma within the spec or body as above.
6563 The basic consistency rule is that you can't turn SPARK_Mode back
6564 @code{On}, once you have explicitly (with a pragma) turned if
6565 @code{Off}. So the following rules apply:
6567 @noindent
6568 If a subprogram spec has SPARK_Mode @code{Off}, then the body must
6569 also have SPARK_Mode @code{Off}.
6571 @noindent
6572 For a package, we have four parts:
6574 @itemize
6575 @item
6576 the package public declarations
6577 @item
6578 the package private part
6579 @item
6580 the body of the package
6581 @item
6582 the elaboration code after @code{begin}
6583 @end itemize
6585 @noindent
6586 For a package, the rule is that if you explicitly turn SPARK_Mode
6587 @code{Off} for any part, then all the following parts must have
6588 SPARK_Mode @code{Off}. Note that this may require repeating a pragma
6589 SPARK_Mode (@code{Off}) in the body. For example, if we have a
6590 configuration pragma SPARK_Mode (@code{On}) that turns the mode on by
6591 default everywhere, and one particular package spec has pragma
6592 SPARK_Mode (@code{Off}), then that pragma will need to be repeated in
6593 the package body.
6595 @node Pragma Static_Elaboration_Desired
6596 @unnumberedsec Pragma Static_Elaboration_Desired
6597 @findex Static_Elaboration_Desired
6598 @noindent
6599 Syntax:
6601 @smallexample @c ada
6602 pragma Static_Elaboration_Desired;
6603 @end smallexample
6605 @noindent
6606 This pragma is used to indicate that the compiler should attempt to initialize
6607 statically the objects declared in the library unit to which the pragma applies,
6608 when these objects are initialized (explicitly or implicitly) by an aggregate.
6609 In the absence of this pragma, aggregates in object declarations are expanded
6610 into assignments and loops, even when the aggregate components are static
6611 constants. When the aggregate is present the compiler builds a static expression
6612 that requires no run-time code, so that the initialized object can be placed in
6613 read-only data space. If the components are not static, or the aggregate has
6614 more that 100 components, the compiler emits a warning that the pragma cannot
6615 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6616 construction of larger aggregates with static components that include an others
6617 choice.)
6619 @node Pragma Stream_Convert
6620 @unnumberedsec Pragma Stream_Convert
6621 @findex Stream_Convert
6622 @noindent
6623 Syntax:
6625 @smallexample @c ada
6626 pragma Stream_Convert (
6627   [Entity =>] type_LOCAL_NAME,
6628   [Read   =>] function_NAME,
6629   [Write  =>] function_NAME);
6630 @end smallexample
6632 @noindent
6633 This pragma provides an efficient way of providing user-defined stream
6634 attributes.  Not only is it simpler to use than specifying the attributes
6635 directly, but more importantly, it allows the specification to be made in such
6636 a way that the predefined unit Ada.Streams is not loaded unless it is actually
6637 needed (i.e. unless the stream attributes are actually used); the use of
6638 the Stream_Convert pragma adds no overhead at all, unless the stream
6639 attributes are actually used on the designated type.
6641 The first argument specifies the type for which stream functions are
6642 provided.  The second parameter provides a function used to read values
6643 of this type.  It must name a function whose argument type may be any
6644 subtype, and whose returned type must be the type given as the first
6645 argument to the pragma.
6647 The meaning of the @var{Read} parameter is that if a stream attribute directly
6648 or indirectly specifies reading of the type given as the first parameter,
6649 then a value of the type given as the argument to the Read function is
6650 read from the stream, and then the Read function is used to convert this
6651 to the required target type.
6653 Similarly the @var{Write} parameter specifies how to treat write attributes
6654 that directly or indirectly apply to the type given as the first parameter.
6655 It must have an input parameter of the type specified by the first parameter,
6656 and the return type must be the same as the input type of the Read function.
6657 The effect is to first call the Write function to convert to the given stream
6658 type, and then write the result type to the stream.
6660 The Read and Write functions must not be overloaded subprograms.  If necessary
6661 renamings can be supplied to meet this requirement.
6662 The usage of this attribute is best illustrated by a simple example, taken
6663 from the GNAT implementation of package Ada.Strings.Unbounded:
6665 @smallexample @c ada
6666 function To_Unbounded (S : String)
6667            return Unbounded_String
6668   renames To_Unbounded_String;
6670 pragma Stream_Convert
6671   (Unbounded_String, To_Unbounded, To_String);
6672 @end smallexample
6674 @noindent
6675 The specifications of the referenced functions, as given in the Ada
6676 Reference Manual are:
6678 @smallexample @c ada
6679 function To_Unbounded_String (Source : String)
6680   return Unbounded_String;
6682 function To_String (Source : Unbounded_String)
6683   return String;
6684 @end smallexample
6686 @noindent
6687 The effect is that if the value of an unbounded string is written to a stream,
6688 then the representation of the item in the stream is in the same format that
6689 would be used for @code{Standard.String'Output}, and this same representation
6690 is expected when a value of this type is read from the stream. Note that the
6691 value written always includes the bounds, even for Unbounded_String'Write,
6692 since Unbounded_String is not an array type.
6694 Note that the @code{Stream_Convert} pragma is not effective in the case of
6695 a derived type of a non-limited tagged type. If such a type is specified then
6696 the pragma is silently ignored, and the default implementation of the stream
6697 attributes is used instead.
6699 @node Pragma Style_Checks
6700 @unnumberedsec Pragma Style_Checks
6701 @findex Style_Checks
6702 @noindent
6703 Syntax:
6705 @smallexample @c ada
6706 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6707                      On | Off [, LOCAL_NAME]);
6708 @end smallexample
6710 @noindent
6711 This pragma is used in conjunction with compiler switches to control the
6712 built in style checking provided by GNAT@.  The compiler switches, if set,
6713 provide an initial setting for the switches, and this pragma may be used
6714 to modify these settings, or the settings may be provided entirely by
6715 the use of the pragma.  This pragma can be used anywhere that a pragma
6716 is legal, including use as a configuration pragma (including use in
6717 the @file{gnat.adc} file).
6719 The form with a string literal specifies which style options are to be
6720 activated.  These are additive, so they apply in addition to any previously
6721 set style check options.  The codes for the options are the same as those
6722 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6723 For example the following two methods can be used to enable
6724 layout checking:
6726 @itemize @bullet
6727 @item
6728 @smallexample @c ada
6729 pragma Style_Checks ("l");
6730 @end smallexample
6732 @item
6733 @smallexample
6734 gcc -c -gnatyl @dots{}
6735 @end smallexample
6736 @end itemize
6738 @noindent
6739 The form ALL_CHECKS activates all standard checks (its use is equivalent
6740 to the use of the @code{gnaty} switch with no options.  @xref{Top,
6741 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6742 @value{EDITION} User's Guide}, for details.)
6744 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6745 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6746 options (i.e. equivalent to -gnatyg).
6748 The forms with @code{Off} and @code{On}
6749 can be used to temporarily disable style checks
6750 as shown in the following example:
6752 @smallexample @c ada
6753 @iftex
6754 @leftskip=0cm
6755 @end iftex
6756 pragma Style_Checks ("k"); -- requires keywords in lower case
6757 pragma Style_Checks (Off); -- turn off style checks
6758 NULL;                      -- this will not generate an error message
6759 pragma Style_Checks (On);  -- turn style checks back on
6760 NULL;                      -- this will generate an error message
6761 @end smallexample
6763 @noindent
6764 Finally the two argument form is allowed only if the first argument is
6765 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
6766 for the specified entity, as shown in the following example:
6768 @smallexample @c ada
6769 @iftex
6770 @leftskip=0cm
6771 @end iftex
6772 pragma Style_Checks ("r"); -- require consistency of identifier casing
6773 Arg : Integer;
6774 Rf1 : Integer := ARG;      -- incorrect, wrong case
6775 pragma Style_Checks (Off, Arg);
6776 Rf2 : Integer := ARG;      -- OK, no error
6777 @end smallexample
6779 @node Pragma Subtitle
6780 @unnumberedsec Pragma Subtitle
6781 @findex Subtitle
6782 @noindent
6783 Syntax:
6785 @smallexample @c ada
6786 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6787 @end smallexample
6789 @noindent
6790 This pragma is recognized for compatibility with other Ada compilers
6791 but is ignored by GNAT@.
6793 @node Pragma Suppress
6794 @unnumberedsec Pragma Suppress
6795 @findex Suppress
6796 @noindent
6797 Syntax:
6799 @smallexample @c ada
6800 pragma Suppress (Identifier [, [On =>] Name]);
6801 @end smallexample
6803 @noindent
6804 This is a standard pragma, and supports all the check names required in
6805 the RM. It is included here because GNAT recognizes some additional check
6806 names that are implementation defined (as permitted by the RM):
6808 @itemize @bullet
6810 @item
6811 @code{Alignment_Check} can be used to suppress alignment checks
6812 on addresses used in address clauses. Such checks can also be suppressed
6813 by suppressing range checks, but the specific use of @code{Alignment_Check}
6814 allows suppression of alignment checks without suppressing other range checks.
6816 @item
6817 @code{Predicate_Check} can be used to control whether predicate checks are
6818 active. It is applicable only to predicates for which the policy is
6819 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6820 predicate is ignored or checked for the whole program, the use of
6821 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6822 predicate to be turned on and off at specific points in the program.
6824 @item
6825 @code{Validity_Check} can be used specifically to control validity checks.
6826 If @code{Suppress} is used to suppress validity checks, then no validity
6827 checks are performed, including those specified by the appropriate compiler
6828 switch or the @code{Validity_Checks} pragma.
6830 @item
6831 Additional check names previously introduced by use of the @code{Check_Name}
6832 pragma are also allowed.
6834 @end itemize
6836 @noindent
6837 Note that pragma Suppress gives the compiler permission to omit
6838 checks, but does not require the compiler to omit checks. The compiler
6839 will generate checks if they are essentially free, even when they are
6840 suppressed. In particular, if the compiler can prove that a certain
6841 check will necessarily fail, it will generate code to do an
6842 unconditional ``raise'', even if checks are suppressed. The compiler
6843 warns in this case.
6845 Of course, run-time checks are omitted whenever the compiler can prove
6846 that they will not fail, whether or not checks are suppressed.
6848 @node Pragma Suppress_All
6849 @unnumberedsec Pragma Suppress_All
6850 @findex Suppress_All
6851 @noindent
6852 Syntax:
6854 @smallexample @c ada
6855 pragma Suppress_All;
6856 @end smallexample
6858 @noindent
6859 This pragma can appear anywhere within a unit.
6860 The effect is to apply @code{Suppress (All_Checks)} to the unit
6861 in which it appears.  This pragma is implemented for compatibility with DEC
6862 Ada 83 usage where it appears at the end of a unit, and for compatibility
6863 with Rational Ada, where it appears as a program unit pragma.
6864 The use of the standard Ada pragma @code{Suppress (All_Checks)}
6865 as a normal configuration pragma is the preferred usage in GNAT@.
6867 @node Pragma Suppress_Debug_Info
6868 @unnumberedsec Pragma Suppress_Debug_Info
6869 @findex Suppress_Debug_Info
6870 @noindent
6871 Syntax:
6873 @smallexample @c ada
6874 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
6875 @end smallexample
6877 @noindent
6878 This pragma can be used to suppress generation of debug information
6879 for the specified entity. It is intended primarily for use in debugging
6880 the debugger, and navigating around debugger problems.
6882 @node Pragma Suppress_Exception_Locations
6883 @unnumberedsec Pragma Suppress_Exception_Locations
6884 @findex Suppress_Exception_Locations
6885 @noindent
6886 Syntax:
6888 @smallexample @c ada
6889 pragma Suppress_Exception_Locations;
6890 @end smallexample
6892 @noindent
6893 In normal mode, a raise statement for an exception by default generates
6894 an exception message giving the file name and line number for the location
6895 of the raise. This is useful for debugging and logging purposes, but this
6896 entails extra space for the strings for the messages. The configuration
6897 pragma @code{Suppress_Exception_Locations} can be used to suppress the
6898 generation of these strings, with the result that space is saved, but the
6899 exception message for such raises is null. This configuration pragma may
6900 appear in a global configuration pragma file, or in a specific unit as
6901 usual. It is not required that this pragma be used consistently within
6902 a partition, so it is fine to have some units within a partition compiled
6903 with this pragma and others compiled in normal mode without it.
6905 @node Pragma Suppress_Initialization
6906 @unnumberedsec Pragma Suppress_Initialization
6907 @findex Suppress_Initialization
6908 @cindex Suppressing initialization
6909 @cindex Initialization, suppression of
6910 @noindent
6911 Syntax:
6913 @smallexample @c ada
6914 pragma Suppress_Initialization ([Entity =>] subtype_Name);
6915 @end smallexample
6917 @noindent
6918 Here subtype_Name is the name introduced by a type declaration
6919 or subtype declaration.
6920 This pragma suppresses any implicit or explicit initialization
6921 for all variables of the given type or subtype,
6922 including initialization resulting from the use of pragmas
6923 Normalize_Scalars or Initialize_Scalars.
6925 This is considered a representation item, so it cannot be given after
6926 the type is frozen. It applies to all subsequent object declarations,
6927 and also any allocator that creates objects of the type.
6929 If the pragma is given for the first subtype, then it is considered
6930 to apply to the base type and all its subtypes. If the pragma is given
6931 for other than a first subtype, then it applies only to the given subtype.
6932 The pragma may not be given after the type is frozen.
6934 @node Pragma Task_Info
6935 @unnumberedsec Pragma Task_Info
6936 @findex Task_Info
6937 @noindent
6938 Syntax
6940 @smallexample @c ada
6941 pragma Task_Info (EXPRESSION);
6942 @end smallexample
6944 @noindent
6945 This pragma appears within a task definition (like pragma
6946 @code{Priority}) and applies to the task in which it appears.  The
6947 argument must be of type @code{System.Task_Info.Task_Info_Type}.
6948 The @code{Task_Info} pragma provides system dependent control over
6949 aspects of tasking implementation, for example, the ability to map
6950 tasks to specific processors.  For details on the facilities available
6951 for the version of GNAT that you are using, see the documentation
6952 in the spec of package System.Task_Info in the runtime
6953 library.
6955 @node Pragma Task_Name
6956 @unnumberedsec Pragma Task_Name
6957 @findex Task_Name
6958 @noindent
6959 Syntax
6961 @smallexample @c ada
6962 pragma Task_Name (string_EXPRESSION);
6963 @end smallexample
6965 @noindent
6966 This pragma appears within a task definition (like pragma
6967 @code{Priority}) and applies to the task in which it appears.  The
6968 argument must be of type String, and provides a name to be used for
6969 the task instance when the task is created.  Note that this expression
6970 is not required to be static, and in particular, it can contain
6971 references to task discriminants.  This facility can be used to
6972 provide different names for different tasks as they are created,
6973 as illustrated in the example below.
6975 The task name is recorded internally in the run-time structures
6976 and is accessible to tools like the debugger.  In addition the
6977 routine @code{Ada.Task_Identification.Image} will return this
6978 string, with a unique task address appended.
6980 @smallexample @c ada
6981 --  Example of the use of pragma Task_Name
6983 with Ada.Task_Identification;
6984 use Ada.Task_Identification;
6985 with Text_IO; use Text_IO;
6986 procedure t3 is
6988    type Astring is access String;
6990    task type Task_Typ (Name : access String) is
6991       pragma Task_Name (Name.all);
6992    end Task_Typ;
6994    task body Task_Typ is
6995       Nam : constant String := Image (Current_Task);
6996    begin
6997       Put_Line ("-->" & Nam (1 .. 14) & "<--");
6998    end Task_Typ;
7000    type Ptr_Task is access Task_Typ;
7001    Task_Var : Ptr_Task;
7003 begin
7004    Task_Var :=
7005      new Task_Typ (new String'("This is task 1"));
7006    Task_Var :=
7007      new Task_Typ (new String'("This is task 2"));
7008 end;
7009 @end smallexample
7011 @node Pragma Task_Storage
7012 @unnumberedsec Pragma Task_Storage
7013 @findex Task_Storage
7014 Syntax:
7016 @smallexample @c ada
7017 pragma Task_Storage (
7018   [Task_Type =>] LOCAL_NAME,
7019   [Top_Guard =>] static_integer_EXPRESSION);
7020 @end smallexample
7022 @noindent
7023 This pragma specifies the length of the guard area for tasks.  The guard
7024 area is an additional storage area allocated to a task.  A value of zero
7025 means that either no guard area is created or a minimal guard area is
7026 created, depending on the target.  This pragma can appear anywhere a
7027 @code{Storage_Size} attribute definition clause is allowed for a task
7028 type.
7030 @node Pragma Test_Case
7031 @unnumberedsec Pragma Test_Case
7032 @cindex Test cases
7033 @findex Test_Case
7034 @noindent
7035 Syntax:
7037 @smallexample @c ada
7038 pragma Test_Case (
7039    [Name     =>] static_string_Expression
7040   ,[Mode     =>] (Nominal | Robustness)
7041  [, Requires =>  Boolean_Expression]
7042  [, Ensures  =>  Boolean_Expression]);
7043 @end smallexample
7045 @noindent
7046 The @code{Test_Case} pragma allows defining fine-grain specifications
7047 for use by testing tools.
7048 The compiler checks the validity of the @code{Test_Case} pragma, but its
7049 presence does not lead to any modification of the code generated by the
7050 compiler.
7052 @code{Test_Case} pragmas may only appear immediately following the
7053 (separate) declaration of a subprogram in a package declaration, inside
7054 a package spec unit. Only other pragmas may intervene (that is appear
7055 between the subprogram declaration and a test case).
7057 The compiler checks that boolean expressions given in @code{Requires} and
7058 @code{Ensures} are valid, where the rules for @code{Requires} are the
7059 same as the rule for an expression in @code{Precondition} and the rules
7060 for @code{Ensures} are the same as the rule for an expression in
7061 @code{Postcondition}. In particular, attributes @code{'Old} and
7062 @code{'Result} can only be used within the @code{Ensures}
7063 expression. The following is an example of use within a package spec:
7065 @smallexample @c ada
7066 package Math_Functions is
7067    ...
7068    function Sqrt (Arg : Float) return Float;
7069    pragma Test_Case (Name     => "Test 1",
7070                      Mode     => Nominal,
7071                      Requires => Arg < 10000,
7072                      Ensures  => Sqrt'Result < 10);
7073    ...
7074 end Math_Functions;
7075 @end smallexample
7077 @noindent
7078 The meaning of a test case is that there is at least one context where
7079 @code{Requires} holds such that, if the associated subprogram is executed in
7080 that context, then @code{Ensures} holds when the subprogram returns.
7081 Mode @code{Nominal} indicates that the input context should also satisfy the
7082 precondition of the subprogram, and the output context should also satisfy its
7083 postcondition. More @code{Robustness} indicates that the precondition and
7084 postcondition of the subprogram should be ignored for this test case.
7086 @node Pragma Thread_Local_Storage
7087 @unnumberedsec Pragma Thread_Local_Storage
7088 @findex Thread_Local_Storage
7089 @cindex Task specific storage
7090 @cindex TLS (Thread Local Storage)
7091 @cindex Task_Attributes
7092 Syntax:
7094 @smallexample @c ada
7095 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
7096 @end smallexample
7098 @noindent
7099 This pragma specifies that the specified entity, which must be
7100 a variable declared in a library level package, is to be marked as
7101 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
7102 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
7103 (and hence each Ada task) to see a distinct copy of the variable.
7105 The variable may not have default initialization, and if there is
7106 an explicit initialization, it must be either @code{null} for an
7107 access variable, or a static expression for a scalar variable.
7108 This provides a low level mechanism similar to that provided by
7109 the @code{Ada.Task_Attributes} package, but much more efficient
7110 and is also useful in writing interface code that will interact
7111 with foreign threads.
7113 If this pragma is used on a system where @code{TLS} is not supported,
7114 then an error message will be generated and the program will be rejected.
7116 @node Pragma Time_Slice
7117 @unnumberedsec Pragma Time_Slice
7118 @findex Time_Slice
7119 @noindent
7120 Syntax:
7122 @smallexample @c ada
7123 pragma Time_Slice (static_duration_EXPRESSION);
7124 @end smallexample
7126 @noindent
7127 For implementations of GNAT on operating systems where it is possible
7128 to supply a time slice value, this pragma may be used for this purpose.
7129 It is ignored if it is used in a system that does not allow this control,
7130 or if it appears in other than the main program unit.
7131 @cindex OpenVMS
7132 Note that the effect of this pragma is identical to the effect of the
7133 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
7135 @node Pragma Title
7136 @unnumberedsec Pragma Title
7137 @findex Title
7138 @noindent
7139 Syntax:
7141 @smallexample @c ada
7142 pragma Title (TITLING_OPTION [, TITLING OPTION]);
7144 TITLING_OPTION ::=
7145   [Title    =>] STRING_LITERAL,
7146 | [Subtitle =>] STRING_LITERAL
7147 @end smallexample
7149 @noindent
7150 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
7151 pragma used in DEC Ada 83 implementations to provide a title and/or
7152 subtitle for the program listing.  The program listing generated by GNAT
7153 does not have titles or subtitles.
7155 Unlike other pragmas, the full flexibility of named notation is allowed
7156 for this pragma, i.e.@: the parameters may be given in any order if named
7157 notation is used, and named and positional notation can be mixed
7158 following the normal rules for procedure calls in Ada.
7160 @node Pragma Type_Invariant
7161 @unnumberedsec Pragma Type_Invariant
7162 @findex Invariant
7163 @findex Type_Invariant pragma
7164 @noindent
7165 Syntax:
7167 @smallexample @c ada
7168 pragma Type_Invariant
7169   ([Entity =>] type_LOCAL_NAME,
7170    [Check  =>] EXPRESSION);
7171 @end smallexample
7173 @noindent
7174 The @code{Type_Invariant} pragma is intended to be an exact
7175 replacement for the language-defined @code{Type_Invariant}
7176 aspect, and shares its restrictions and semantics. It differs
7177 from the language defined @code{Invariant} pragma in that it
7178 does not permit a string parameter, and it is
7179 controlled by the assertion identifier @code{Type_Invariant}
7180 rather than @code{Invariant}.
7182 @node Pragma Type_Invariant_Class
7183 @unnumberedsec Pragma Type_Invariant_Class
7184 @findex Invariant
7185 @findex Type_Invariant_Class pragma
7186 @noindent
7187 Syntax:
7189 @smallexample @c ada
7190 pragma Type_Invariant_Class
7191   ([Entity =>] type_LOCAL_NAME,
7192    [Check  =>] EXPRESSION);
7193 @end smallexample
7195 @noindent
7196 The @code{Type_Invariant_Class} pragma is intended to be an exact
7197 replacement for the language-defined @code{Type_Invariant'Class}
7198 aspect, and shares its restrictions and semantics.
7200 Note: This pragma is called @code{Type_Invariant_Class} rather than
7201 @code{Type_Invariant'Class} because the latter would not be strictly
7202 conforming to the allowed syntax for pragmas. The motivation
7203 for providing pragmas equivalent to the aspects is to allow a program
7204 to be written using the pragmas, and then compiled if necessary
7205 using an Ada compiler that does not recognize the pragmas or
7206 aspects, but is prepared to ignore the pragmas. The assertion
7207 policy that controls this pragma is @code{Type_Invariant'Class},
7208 not @code{Type_Invariant_Class}.
7210 @node Pragma Unchecked_Union
7211 @unnumberedsec Pragma Unchecked_Union
7212 @cindex Unions in C
7213 @findex Unchecked_Union
7214 @noindent
7215 Syntax:
7217 @smallexample @c ada
7218 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
7219 @end smallexample
7221 @noindent
7222 This pragma is used to specify a representation of a record type that is
7223 equivalent to a C union. It was introduced as a GNAT implementation defined
7224 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
7225 pragma, making it language defined, and GNAT fully implements this extended
7226 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
7227 details, consult the Ada 2012 Reference Manual, section B.3.3.
7229 @node Pragma Unimplemented_Unit
7230 @unnumberedsec Pragma Unimplemented_Unit
7231 @findex Unimplemented_Unit
7232 @noindent
7233 Syntax:
7235 @smallexample @c ada
7236 pragma Unimplemented_Unit;
7237 @end smallexample
7239 @noindent
7240 If this pragma occurs in a unit that is processed by the compiler, GNAT
7241 aborts with the message @samp{@var{xxx} not implemented}, where
7242 @var{xxx} is the name of the current compilation unit.  This pragma is
7243 intended to allow the compiler to handle unimplemented library units in
7244 a clean manner.
7246 The abort only happens if code is being generated.  Thus you can use
7247 specs of unimplemented packages in syntax or semantic checking mode.
7249 @node Pragma Universal_Aliasing
7250 @unnumberedsec Pragma Universal_Aliasing
7251 @findex Universal_Aliasing
7252 @noindent
7253 Syntax:
7255 @smallexample @c ada
7256 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
7257 @end smallexample
7259 @noindent
7260 @var{type_LOCAL_NAME} must refer to a type declaration in the current
7261 declarative part.  The effect is to inhibit strict type-based aliasing
7262 optimization for the given type.  In other words, the effect is as though
7263 access types designating this type were subject to pragma No_Strict_Aliasing.
7264 For a detailed description of the strict aliasing optimization, and the
7265 situations in which it must be suppressed, @xref{Optimization and Strict
7266 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
7268 @node Pragma Universal_Data
7269 @unnumberedsec Pragma Universal_Data
7270 @findex Universal_Data
7271 @noindent
7272 Syntax:
7274 @smallexample @c ada
7275 pragma Universal_Data [(library_unit_Name)];
7276 @end smallexample
7278 @noindent
7279 This pragma is supported only for the AAMP target and is ignored for
7280 other targets. The pragma specifies that all library-level objects
7281 (Counter 0 data) associated with the library unit are to be accessed
7282 and updated using universal addressing (24-bit addresses for AAMP5)
7283 rather than the default of 16-bit Data Environment (DENV) addressing.
7284 Use of this pragma will generally result in less efficient code for
7285 references to global data associated with the library unit, but
7286 allows such data to be located anywhere in memory. This pragma is
7287 a library unit pragma, but can also be used as a configuration pragma
7288 (including use in the @file{gnat.adc} file). The functionality
7289 of this pragma is also available by applying the -univ switch on the
7290 compilations of units where universal addressing of the data is desired.
7292 @node Pragma Unmodified
7293 @unnumberedsec Pragma Unmodified
7294 @findex Unmodified
7295 @cindex Warnings, unmodified
7296 @noindent
7297 Syntax:
7299 @smallexample @c ada
7300 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
7301 @end smallexample
7303 @noindent
7304 This pragma signals that the assignable entities (variables,
7305 @code{out} parameters, @code{in out} parameters) whose names are listed are
7306 deliberately not assigned in the current source unit. This
7307 suppresses warnings about the
7308 entities being referenced but not assigned, and in addition a warning will be
7309 generated if one of these entities is in fact assigned in the
7310 same unit as the pragma (or in the corresponding body, or one
7311 of its subunits).
7313 This is particularly useful for clearly signaling that a particular
7314 parameter is not modified, even though the spec suggests that it might
7317 For the variable case, warnings are never given for unreferenced variables
7318 whose name contains one of the substrings
7319 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7320 are typically to be used in cases where such warnings are expected.
7321 Thus it is never necessary to use @code{pragma Unmodified} for such
7322 variables, though it is harmless to do so.
7324 @node Pragma Unreferenced
7325 @unnumberedsec Pragma Unreferenced
7326 @findex Unreferenced
7327 @cindex Warnings, unreferenced
7328 @noindent
7329 Syntax:
7331 @smallexample @c ada
7332 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
7333 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
7334 @end smallexample
7336 @noindent
7337 This pragma signals that the entities whose names are listed are
7338 deliberately not referenced in the current source unit. This
7339 suppresses warnings about the
7340 entities being unreferenced, and in addition a warning will be
7341 generated if one of these entities is in fact subsequently referenced in the
7342 same unit as the pragma (or in the corresponding body, or one
7343 of its subunits).
7345 This is particularly useful for clearly signaling that a particular
7346 parameter is not referenced in some particular subprogram implementation
7347 and that this is deliberate. It can also be useful in the case of
7348 objects declared only for their initialization or finalization side
7349 effects.
7351 If @code{LOCAL_NAME} identifies more than one matching homonym in the
7352 current scope, then the entity most recently declared is the one to which
7353 the pragma applies. Note that in the case of accept formals, the pragma
7354 Unreferenced may appear immediately after the keyword @code{do} which
7355 allows the indication of whether or not accept formals are referenced
7356 or not to be given individually for each accept statement.
7358 The left hand side of an assignment does not count as a reference for the
7359 purpose of this pragma. Thus it is fine to assign to an entity for which
7360 pragma Unreferenced is given.
7362 Note that if a warning is desired for all calls to a given subprogram,
7363 regardless of whether they occur in the same unit as the subprogram
7364 declaration, then this pragma should not be used (calls from another
7365 unit would not be flagged); pragma Obsolescent can be used instead
7366 for this purpose, see @xref{Pragma Obsolescent}.
7368 The second form of pragma @code{Unreferenced} is used within a context
7369 clause. In this case the arguments must be unit names of units previously
7370 mentioned in @code{with} clauses (similar to the usage of pragma
7371 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
7372 units and unreferenced entities within these units.
7374 For the variable case, warnings are never given for unreferenced variables
7375 whose name contains one of the substrings
7376 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7377 are typically to be used in cases where such warnings are expected.
7378 Thus it is never necessary to use @code{pragma Unreferenced} for such
7379 variables, though it is harmless to do so.
7381 @node Pragma Unreferenced_Objects
7382 @unnumberedsec Pragma Unreferenced_Objects
7383 @findex Unreferenced_Objects
7384 @cindex Warnings, unreferenced
7385 @noindent
7386 Syntax:
7388 @smallexample @c ada
7389 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
7390 @end smallexample
7392 @noindent
7393 This pragma signals that for the types or subtypes whose names are
7394 listed, objects which are declared with one of these types or subtypes may
7395 not be referenced, and if no references appear, no warnings are given.
7397 This is particularly useful for objects which are declared solely for their
7398 initialization and finalization effect. Such variables are sometimes referred
7399 to as RAII variables (Resource Acquisition Is Initialization). Using this
7400 pragma on the relevant type (most typically a limited controlled type), the
7401 compiler will automatically suppress unwanted warnings about these variables
7402 not being referenced.
7404 @node Pragma Unreserve_All_Interrupts
7405 @unnumberedsec Pragma Unreserve_All_Interrupts
7406 @findex Unreserve_All_Interrupts
7407 @noindent
7408 Syntax:
7410 @smallexample @c ada
7411 pragma Unreserve_All_Interrupts;
7412 @end smallexample
7414 @noindent
7415 Normally certain interrupts are reserved to the implementation.  Any attempt
7416 to attach an interrupt causes Program_Error to be raised, as described in
7417 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
7418 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
7419 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
7420 interrupt execution.
7422 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
7423 a program, then all such interrupts are unreserved.  This allows the
7424 program to handle these interrupts, but disables their standard
7425 functions.  For example, if this pragma is used, then pressing
7426 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
7427 a program can then handle the @code{SIGINT} interrupt as it chooses.
7429 For a full list of the interrupts handled in a specific implementation,
7430 see the source code for the spec of @code{Ada.Interrupts.Names} in
7431 file @file{a-intnam.ads}.  This is a target dependent file that contains the
7432 list of interrupts recognized for a given target.  The documentation in
7433 this file also specifies what interrupts are affected by the use of
7434 the @code{Unreserve_All_Interrupts} pragma.
7436 For a more general facility for controlling what interrupts can be
7437 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
7438 of the @code{Unreserve_All_Interrupts} pragma.
7440 @node Pragma Unsuppress
7441 @unnumberedsec Pragma Unsuppress
7442 @findex Unsuppress
7443 @noindent
7444 Syntax:
7446 @smallexample @c ada
7447 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
7448 @end smallexample
7450 @noindent
7451 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
7452 there is no corresponding pragma @code{Suppress} in effect, it has no
7453 effect.  The range of the effect is the same as for pragma
7454 @code{Suppress}.  The meaning of the arguments is identical to that used
7455 in pragma @code{Suppress}.
7457 One important application is to ensure that checks are on in cases where
7458 code depends on the checks for its correct functioning, so that the code
7459 will compile correctly even if the compiler switches are set to suppress
7460 checks.
7462 This pragma is standard in Ada 2005. It is available in all earlier versions
7463 of Ada as an implementation-defined pragma.
7465 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
7466 a number of implementation-defined check names. See description of pragma
7467 @code{Suppress} for full details.
7469 @node Pragma Use_VADS_Size
7470 @unnumberedsec Pragma Use_VADS_Size
7471 @cindex @code{Size}, VADS compatibility
7472 @cindex Rational profile
7473 @findex Use_VADS_Size
7474 @noindent
7475 Syntax:
7477 @smallexample @c ada
7478 pragma Use_VADS_Size;
7479 @end smallexample
7481 @noindent
7482 This is a configuration pragma.  In a unit to which it applies, any use
7483 of the 'Size attribute is automatically interpreted as a use of the
7484 'VADS_Size attribute.  Note that this may result in incorrect semantic
7485 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
7486 the handling of existing code which depends on the interpretation of Size
7487 as implemented in the VADS compiler.  See description of the VADS_Size
7488 attribute for further details.
7490 @node Pragma Validity_Checks
7491 @unnumberedsec Pragma Validity_Checks
7492 @findex Validity_Checks
7493 @noindent
7494 Syntax:
7496 @smallexample @c ada
7497 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
7498 @end smallexample
7500 @noindent
7501 This pragma is used in conjunction with compiler switches to control the
7502 built-in validity checking provided by GNAT@.  The compiler switches, if set
7503 provide an initial setting for the switches, and this pragma may be used
7504 to modify these settings, or the settings may be provided entirely by
7505 the use of the pragma.  This pragma can be used anywhere that a pragma
7506 is legal, including use as a configuration pragma (including use in
7507 the @file{gnat.adc} file).
7509 The form with a string literal specifies which validity options are to be
7510 activated.  The validity checks are first set to include only the default
7511 reference manual settings, and then a string of letters in the string
7512 specifies the exact set of options required.  The form of this string
7513 is exactly as described for the @option{-gnatVx} compiler switch (see the
7514 @value{EDITION} User's Guide for details).  For example the following two
7515 methods can be used to enable validity checking for mode @code{in} and
7516 @code{in out} subprogram parameters:
7518 @itemize @bullet
7519 @item
7520 @smallexample @c ada
7521 pragma Validity_Checks ("im");
7522 @end smallexample
7524 @item
7525 @smallexample
7526 gcc -c -gnatVim @dots{}
7527 @end smallexample
7528 @end itemize
7530 @noindent
7531 The form ALL_CHECKS activates all standard checks (its use is equivalent
7532 to the use of the @code{gnatva} switch.
7534 The forms with @code{Off} and @code{On}
7535 can be used to temporarily disable validity checks
7536 as shown in the following example:
7538 @smallexample @c ada
7539 @iftex
7540 @leftskip=0cm
7541 @end iftex
7542 pragma Validity_Checks ("c"); -- validity checks for copies
7543 pragma Validity_Checks (Off); -- turn off validity checks
7544 A := B;                       -- B will not be validity checked
7545 pragma Validity_Checks (On);  -- turn validity checks back on
7546 A := C;                       -- C will be validity checked
7547 @end smallexample
7549 @node Pragma Volatile
7550 @unnumberedsec Pragma Volatile
7551 @findex Volatile
7552 @noindent
7553 Syntax:
7555 @smallexample @c ada
7556 pragma Volatile (LOCAL_NAME);
7557 @end smallexample
7559 @noindent
7560 This pragma is defined by the Ada Reference Manual, and the GNAT
7561 implementation is fully conformant with this definition.  The reason it
7562 is mentioned in this section is that a pragma of the same name was supplied
7563 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
7564 implementation of pragma Volatile is upwards compatible with the
7565 implementation in DEC Ada 83.
7567 @node Pragma Warning_As_Error
7568 @unnumberedsec Pragma Warning_As_Error
7569 @findex Warning_As_Error
7570 @noindent
7571 Syntax:
7573 @smallexample @c ada
7574 pragma Warning_As_Error (static_string_EXPRESSION);
7575 @end smallexample
7577 @noindent
7578 This configuration pragma allows the programmer to specify a set
7579 of warnings that will be treated as errors. Any warning which
7580 matches the pattern given by the pragma argument will be treated
7581 as an error. This gives much more precise control that -gnatwe
7582 which treats all warnings as errors.
7584 The pattern may contain asterisks, which match zero or more characters in
7585 the message. For example, you can use
7586 @code{pragma Warning_As_Error ("*bits of*unused")} to treat the warning
7587 message @code{warning: 960 bits of "a" unused} as an error. No other regular
7588 expression notations are permitted. All characters other than asterisk in
7589 these three specific cases are treated as literal characters in the match.
7590 The match is case insensitive, for example XYZ matches xyz.
7592 Another possibility for the static_string_EXPRESSION which works whether
7593 or not error tags are enabled (@option{-gnatw.d}) is to use the
7594 @option{-gnatw} tag string, enclosed in brackets,
7595 as shown in the example below, to treat a class of warnings as errors.
7597 The above use of patterns to match the message applies only to warning
7598 messages generated by the front end. This pragma can also be applied to
7599 warnings provided by the back end and mentioned in @ref{Pragma Warnings}.
7600 By using a single full @option{-Wxxx} switch in the pragma, such warnings
7601 can also be treated as errors.
7603 The pragma can appear either in a global configuration pragma file
7604 (e.g. @file{gnat.adc}), or at the start of a file. Given a global
7605 configuration pragma file containing:
7607 @smallexample @c ada
7608 pragma Warning_As_Error ("[-gnatwj]");
7609 @end smallexample
7611 @noindent
7612 which will treat all obsolescent feature warnings as errors, the
7613 following program compiles as shown (compile options here are
7614 @option{-gnatwa.d -gnatl -gnatj55}).
7616 @smallexample @c ada
7617      1. pragma Warning_As_Error ("*never assigned*");
7618      2. function Warnerr return String is
7619      3.    X : Integer;
7620            |
7621         >>> error: variable "X" is never read and
7622             never assigned [-gnatwv] [warning-as-error]
7624      4.    Y : Integer;
7625            |
7626         >>> warning: variable "Y" is assigned but
7627             never read [-gnatwu]
7629      5. begin
7630      6.    Y := 0;
7631      7.    return %ABC%;
7632                   |
7633         >>> error: use of "%" is an obsolescent
7634             feature (RM J.2(4)), use """ instead
7635             [-gnatwj] [warning-as-error]
7637      8. end;
7639  8 lines: No errors, 3 warnings (2 treated as errors)
7640 @end smallexample
7642 @noindent
7643 Note that this pragma does not affect the set of warnings issued in
7644 any way, it merely changes the effect of a matching warning if one
7645 is produced as a result of other warnings options. As shown in this
7646 example, if the pragma results in a warning being treated as an error,
7647 the tag is changed from "warning:" to "error:" and the string
7648 "[warning-as-error]" is appended to the end of the message.
7650 @node Pragma Warnings
7651 @unnumberedsec Pragma Warnings
7652 @findex Warnings
7653 @noindent
7654 Syntax:
7656 @smallexample @c ada
7657 pragma Warnings (On | Off [,REASON]);
7658 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
7659 pragma Warnings (static_string_EXPRESSION [,REASON]);
7660 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
7662 REASON ::= Reason => STRING_LITERAL @{& STRING_LITERAL@}
7663 @end smallexample
7665 @noindent
7666 Normally warnings are enabled, with the output being controlled by
7667 the command line switch.  Warnings (@code{Off}) turns off generation of
7668 warnings until a Warnings (@code{On}) is encountered or the end of the
7669 current unit.  If generation of warnings is turned off using this
7670 pragma, then some or all of the warning messages are suppressed,
7671 regardless of the setting of the command line switches.
7673 The @code{Reason} parameter may optionally appear as the last argument
7674 in any of the forms of this pragma. It is intended purely for the
7675 purposes of documenting the reason for the @code{Warnings} pragma.
7676 The compiler will check that the argument is a static string but
7677 otherwise ignore this argument. Other tools may provide specialized
7678 processing for this string.
7680 The form with a single argument (or two arguments if Reason present),
7681 where the first argument is @code{ON} or @code{OFF}
7682 may be used as a configuration pragma.
7684 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
7685 the specified entity.  This suppression is effective from the point where
7686 it occurs till the end of the extended scope of the variable (similar to
7687 the scope of @code{Suppress}). This form cannot be used as a configuration
7688 pragma.
7690 The form with a single static_string_EXPRESSION argument (and possible
7691 reason) provides more precise
7692 control over which warnings are active. The string is a list of letters
7693 specifying which warnings are to be activated and which deactivated. The
7694 code for these letters is the same as the string used in the command
7695 line switch controlling warnings. For a brief summary, use the gnatmake
7696 command with no arguments, which will generate usage information containing
7697 the list of warnings switches supported. For
7698 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
7699 User's Guide}. This form can also be used as a configuration pragma.
7701 @noindent
7702 The warnings controlled by the @option{-gnatw} switch are generated by the
7703 front end of the compiler. The GCC back end can provide additional warnings
7704 and they are controlled by the @option{-W} switch. Such warnings can be
7705 identified by the appearance of a string of the form @code{[-Wxxx]} in the
7706 message which designates the @option{-Wxxx} switch that controls the message.
7707 The form with a single static_string_EXPRESSION argument also works for these
7708 warnings, but the string must be a single full @option{-Wxxx} switch in this
7709 case. The above reference lists a few examples of these additional warnings.
7711 @noindent
7712 The specified warnings will be in effect until the end of the program
7713 or another pragma Warnings is encountered. The effect of the pragma is
7714 cumulative. Initially the set of warnings is the standard default set
7715 as possibly modified by compiler switches. Then each pragma Warning
7716 modifies this set of warnings as specified. This form of the pragma may
7717 also be used as a configuration pragma.
7719 The fourth form, with an @code{On|Off} parameter and a string, is used to
7720 control individual messages, based on their text. The string argument
7721 is a pattern that is used to match against the text of individual
7722 warning messages (not including the initial "warning: " tag).
7724 The pattern may contain asterisks, which match zero or more characters in
7725 the message. For example, you can use
7726 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
7727 message @code{warning: 960 bits of "a" unused}. No other regular
7728 expression notations are permitted. All characters other than asterisk in
7729 these three specific cases are treated as literal characters in the match.
7730 The match is case insensitive, for example XYZ matches xyz.
7732 The above use of patterns to match the message applies only to warning
7733 messages generated by the front end. This form of the pragma with a string
7734 argument can also be used to control warnings provided by the back end and
7735 mentioned above. By using a single full @option{-Wxxx} switch in the pragma,
7736 such warnings can be turned on and off.
7738 There are two ways to use the pragma in this form. The OFF form can be used as a
7739 configuration pragma. The effect is to suppress all warnings (if any)
7740 that match the pattern string throughout the compilation (or match the
7741 -W switch in the back end case).
7743 The second usage is to suppress a warning locally, and in this case, two
7744 pragmas must appear in sequence:
7746 @smallexample @c ada
7747 pragma Warnings (Off, Pattern);
7748 @dots{} code where given warning is to be suppressed
7749 pragma Warnings (On, Pattern);
7750 @end smallexample
7752 @noindent
7753 In this usage, the pattern string must match in the Off and On pragmas,
7754 and at least one matching warning must be suppressed.
7756 Note: to write a string that will match any warning, use the string
7757 @code{"***"}. It will not work to use a single asterisk or two asterisks
7758 since this looks like an operator name. This form with three asterisks
7759 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
7760 matching @code{pragma Warnings (On, "***")} will be required. This can be
7761 helpful in avoiding forgetting to turn warnings back on.
7763 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7764 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7765 be useful in checking whether obsolete pragmas in existing programs are hiding
7766 real problems.
7768 Note: pragma Warnings does not affect the processing of style messages. See
7769 separate entry for pragma Style_Checks for control of style messages.
7771 @node Pragma Weak_External
7772 @unnumberedsec Pragma Weak_External
7773 @findex Weak_External
7774 @noindent
7775 Syntax:
7777 @smallexample @c ada
7778 pragma Weak_External ([Entity =>] LOCAL_NAME);
7779 @end smallexample
7781 @noindent
7782 @var{LOCAL_NAME} must refer to an object that is declared at the library
7783 level. This pragma specifies that the given entity should be marked as a
7784 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
7785 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
7786 of a regular symbol, that is to say a symbol that does not have to be
7787 resolved by the linker if used in conjunction with a pragma Import.
7789 When a weak symbol is not resolved by the linker, its address is set to
7790 zero. This is useful in writing interfaces to external modules that may
7791 or may not be linked in the final executable, for example depending on
7792 configuration settings.
7794 If a program references at run time an entity to which this pragma has been
7795 applied, and the corresponding symbol was not resolved at link time, then
7796 the execution of the program is erroneous. It is not erroneous to take the
7797 Address of such an entity, for example to guard potential references,
7798 as shown in the example below.
7800 Some file formats do not support weak symbols so not all target machines
7801 support this pragma.
7803 @smallexample @c ada
7804 --  Example of the use of pragma Weak_External
7806 package External_Module is
7807   key : Integer;
7808   pragma Import (C, key);
7809   pragma Weak_External (key);
7810   function Present return boolean;
7811 end External_Module;
7813 with System; use System;
7814 package body External_Module is
7815   function Present return boolean is
7816   begin
7817     return key'Address /= System.Null_Address;
7818   end Present;
7819 end External_Module;
7820 @end smallexample
7822 @node Pragma Wide_Character_Encoding
7823 @unnumberedsec Pragma Wide_Character_Encoding
7824 @findex Wide_Character_Encoding
7825 @noindent
7826 Syntax:
7828 @smallexample @c ada
7829 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
7830 @end smallexample
7832 @noindent
7833 This pragma specifies the wide character encoding to be used in program
7834 source text appearing subsequently. It is a configuration pragma, but may
7835 also be used at any point that a pragma is allowed, and it is permissible
7836 to have more than one such pragma in a file, allowing multiple encodings
7837 to appear within the same file.
7839 The argument can be an identifier or a character literal. In the identifier
7840 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
7841 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
7842 case it is correspondingly one of the characters @samp{h}, @samp{u},
7843 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
7845 Note that when the pragma is used within a file, it affects only the
7846 encoding within that file, and does not affect withed units, specs,
7847 or subunits.
7849 @node Implementation Defined Aspects
7850 @chapter Implementation Defined Aspects
7851 Ada defines (throughout the Ada 2012 reference manual, summarized
7852 in Annex K) a set of aspects that can be specified for certain entities.
7853 These language defined aspects are implemented in GNAT in Ada 2012 mode
7854 and work as described in the Ada 2012 Reference Manual.
7856 In addition, Ada 2012 allows implementations to define additional aspects
7857 whose meaning is defined by the implementation.  GNAT provides
7858 a number of these implementation-defined aspects which can be used
7859 to extend and enhance the functionality of the compiler.  This section of
7860 the GNAT reference manual describes these additional aspects.
7862 Note that any program using these aspects may not be portable to
7863 other compilers (although GNAT implements this set of aspects on all
7864 platforms).  Therefore if portability to other compilers is an important
7865 consideration, you should minimize the use of these aspects.
7867 Note that for many of these aspects, the effect is essentially similar
7868 to the use of a pragma or attribute specification with the same name
7869 applied to the entity. For example, if we write:
7871 @smallexample @c ada
7872 type R is range 1 .. 100
7873   with Value_Size => 10;
7874 @end smallexample
7876 @noindent
7877 then the effect is the same as:
7879 @smallexample @c ada
7880 type R is range 1 .. 100;
7881 for R'Value_Size use 10;
7882 @end smallexample
7884 @noindent
7885 and if we write:
7887 @smallexample @c ada
7888 type R is new Integer
7889   with Shared => True;
7890 @end smallexample
7892 @noindent
7893 then the effect is the same as:
7895 @smallexample @c ada
7896 type R is new Integer;
7897 pragma Shared (R);
7898 @end smallexample
7900 @noindent
7901 In the documentation below, such cases are simply marked
7902 as being equivalent to the corresponding pragma or attribute definition
7903 clause.
7905 @menu
7906 * Aspect Abstract_State::
7907 * Aspect Contract_Cases::
7908 * Aspect Depends::
7909 * Aspect Dimension::
7910 * Aspect Dimension_System::
7911 * Aspect Favor_Top_Level::
7912 * Aspect Global::
7913 * Aspect Initial_Condition::
7914 * Aspect Initializes::
7915 * Aspect Inline_Always::
7916 * Aspect Invariant::
7917 * Aspect Linker_Section::
7918 * Aspect Lock_Free::
7919 * Aspect Object_Size::
7920 * Aspect Persistent_BSS::
7921 * Aspect Predicate::
7922 * Aspect Preelaborate_05::
7923 * Aspect Pure_05::
7924 * Aspect Pure_12::
7925 * Aspect Pure_Function::
7926 * Aspect Refined_State::
7927 * Aspect Remote_Access_Type::
7928 * Aspect Scalar_Storage_Order::
7929 * Aspect Shared::
7930 * Aspect Simple_Storage_Pool::
7931 * Aspect Simple_Storage_Pool_Type::
7932 * Aspect SPARK_Mode::
7933 * Aspect Suppress_Debug_Info::
7934 * Aspect Test_Case::
7935 * Aspect Universal_Aliasing::
7936 * Aspect Universal_Data::
7937 * Aspect Unmodified::
7938 * Aspect Unreferenced::
7939 * Aspect Unreferenced_Objects::
7940 * Aspect Value_Size::
7941 * Aspect Warnings::
7942 @end menu
7944 @node Aspect Abstract_State
7945 @unnumberedsec Aspect Abstract_State
7946 @findex Abstract_State
7947 @noindent
7948 This aspect is equivalent to pragma @code{Abstract_State}.
7950 @node Aspect Contract_Cases
7951 @unnumberedsec Aspect Contract_Cases
7952 @findex Contract_Cases
7953 @noindent
7954 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
7955 of clauses being enclosed in parentheses so that syntactically it is an
7956 aggregate.
7958 @node Aspect Depends
7959 @unnumberedsec Aspect Depends
7960 @findex Depends
7961 @noindent
7962 This aspect is equivalent to pragma @code{Depends}.
7964 @node Aspect Dimension
7965 @unnumberedsec Aspect Dimension
7966 @findex Dimension
7967 @noindent
7968 The @code{Dimension} aspect is used to specify the dimensions of a given
7969 subtype of a dimensioned numeric type. The aspect also specifies a symbol
7970 used when doing formatted output of dimensioned quantities. The syntax is:
7972 @smallexample @c ada
7973 with Dimension =>
7974   ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
7976 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
7978 DIMENSION_VALUE ::=
7979   RATIONAL
7980 | others               => RATIONAL
7981 | DISCRETE_CHOICE_LIST => RATIONAL
7983 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
7984 @end smallexample
7986 @noindent
7987 This aspect can only be applied to a subtype whose parent type has
7988 a @code{Dimension_Systen} aspect. The aspect must specify values for
7989 all dimensions of the system. The rational values are the powers of the
7990 corresponding dimensions that are used by the compiler to verify that
7991 physical (numeric) computations are dimensionally consistent. For example,
7992 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
7993 For further examples of the usage
7994 of this aspect, see package @code{System.Dim.Mks}.
7995 Note that when the dimensioned type is an integer type, then any
7996 dimension value must be an integer literal.
7998 @node Aspect Dimension_System
7999 @unnumberedsec Aspect Dimension_System
8000 @findex Dimension_System
8001 @noindent
8002 The @code{Dimension_System} aspect is used to define a system of
8003 dimensions that will be used in subsequent subtype declarations with
8004 @code{Dimension} aspects that reference this system. The syntax is:
8006 @smallexample @c ada
8007 with Dimension_System => (DIMENSION @{, DIMENSION@});
8009 DIMENSION ::= ([Unit_Name   =>] IDENTIFIER,
8010                [Unit_Symbol =>] SYMBOL,
8011                [Dim_Symbol  =>] SYMBOL)
8013 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
8014 @end smallexample
8016 @noindent
8017 This aspect is applied to a type, which must be a numeric derived type
8018 (typically a floating-point type), that
8019 will represent values within the dimension system. Each @code{DIMENSION}
8020 corresponds to one particular dimension. A maximum of 7 dimensions may
8021 be specified. @code{Unit_Name} is the name of the dimension (for example
8022 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
8023 of this dimension (for example @code{m} for @code{Meter}).
8024 @code{Dim_Symbol} gives
8025 the identification within the dimension system (typically this is a
8026 single letter, e.g. @code{L} standing for length for unit name @code{Meter}).
8027 The @code{Unit_Symbol} is used in formatted output of dimensioned quantities.
8028 The @code{Dim_Symbol} is used in error messages when numeric operations have
8029 inconsistent dimensions.
8031 GNAT provides the standard definition of the International MKS system in
8032 the run-time package @code{System.Dim.Mks}. You can easily define
8033 similar packages for cgs units or British units, and define conversion factors
8034 between values in different systems. The MKS system is characterized by the
8035 following aspect:
8037 @smallexample @c ada
8038    type Mks_Type is new Long_Long_Float
8039      with
8040       Dimension_System => (
8041         (Unit_Name => Meter,    Unit_Symbol => 'm',   Dim_Symbol => 'L'),
8042         (Unit_Name => Kilogram, Unit_Symbol => "kg",  Dim_Symbol => 'M'),
8043         (Unit_Name => Second,   Unit_Symbol => 's',   Dim_Symbol => 'T'),
8044         (Unit_Name => Ampere,   Unit_Symbol => 'A',   Dim_Symbol => 'I'),
8045         (Unit_Name => Kelvin,   Unit_Symbol => 'K',   Dim_Symbol => "Theta"),
8046         (Unit_Name => Mole,     Unit_Symbol => "mol", Dim_Symbol => 'N'),
8047         (Unit_Name => Candela,  Unit_Symbol => "cd",  Dim_Symbol => 'J'));
8048 @end smallexample
8050 @noindent
8051 See section ``Performing Dimensionality Analysis in GNAT'' in the GNAT Users
8052 Guide for detailed examples of use of the dimension system.
8054 @node Aspect Favor_Top_Level
8055 @unnumberedsec Aspect Favor_Top_Level
8056 @findex Favor_Top_Level
8057 @noindent
8058 This aspect is equivalent to pragma @code{Favor_Top_Level}.
8060 @node Aspect Global
8061 @unnumberedsec Aspect Global
8062 @findex Global
8063 @noindent
8064 This aspect is equivalent to pragma @code{Global}.
8066 @node Aspect Initial_Condition
8067 @unnumberedsec Aspect Initial_Condition
8068 @findex Initial_Condition
8069 @noindent
8070 This aspect is equivalent to pragma @code{Initial_Condition}.
8072 @node Aspect Initializes
8073 @unnumberedsec Aspect Initializes
8074 @findex Initializes
8075 @noindent
8076 This aspect is equivalent to pragma @code{Initializes}.
8078 @node Aspect Inline_Always
8079 @unnumberedsec Aspect Inline_Always
8080 @findex Inline_Always
8081 @noindent
8082 This aspect is equivalent to pragma @code{Inline_Always}.
8084 @node Aspect Invariant
8085 @unnumberedsec Aspect Invariant
8086 @findex Invariant
8087 @noindent
8088 This aspect is equivalent to pragma @code{Invariant}. It is a
8089 synonym for the language defined aspect @code{Type_Invariant} except
8090 that it is separately controllable using pragma @code{Assertion_Policy}.
8092 @node Aspect Linker_Section
8093 @unnumberedsec Aspect Linker_Section
8094 @findex Linker_Section
8095 @noindent
8096 This aspect is equivalent to an @code{Linker_Section} pragma.
8098 @node Aspect Lock_Free
8099 @unnumberedsec Aspect Lock_Free
8100 @findex Lock_Free
8101 @noindent
8102 This aspect is equivalent to pragma @code{Lock_Free}.
8104 @node Aspect Object_Size
8105 @unnumberedsec Aspect Object_Size
8106 @findex Object_Size
8107 @noindent
8108 This aspect is equivalent to an @code{Object_Size} attribute definition
8109 clause.
8111 @node Aspect Persistent_BSS
8112 @unnumberedsec Aspect Persistent_BSS
8113 @findex Persistent_BSS
8114 @noindent
8115 This aspect is equivalent to pragma @code{Persistent_BSS}.
8117 @node Aspect Predicate
8118 @unnumberedsec Aspect Predicate
8119 @findex Predicate
8120 @noindent
8121 This aspect is equivalent to pragma @code{Predicate}. It is thus
8122 similar to the language defined aspects @code{Dynamic_Predicate}
8123 and @code{Static_Predicate} except that whether the resulting
8124 predicate is static or dynamic is controlled by the form of the
8125 expression. It is also separately controllable using pragma
8126 @code{Assertion_Policy}.
8128 @node Aspect Preelaborate_05
8129 @unnumberedsec Aspect Preelaborate_05
8130 @findex Preelaborate_05
8131 @noindent
8132 This aspect is equivalent to pragma @code{Preelaborate_05}.
8134 @node Aspect Pure_05
8135 @unnumberedsec Aspect Pure_05
8136 @findex Pure_05
8137 @noindent
8138 This aspect is equivalent to pragma @code{Pure_05}.
8140 @node Aspect Pure_12
8141 @unnumberedsec Aspect Pure_12
8142 @findex Pure_12
8143 @noindent
8144 This aspect is equivalent to pragma @code{Pure_12}.
8146 @node Aspect Pure_Function
8147 @unnumberedsec Aspect Pure_Function
8148 @findex Pure_Function
8149 @noindent
8150 This aspect is equivalent to pragma @code{Pure_Function}.
8152 @node Aspect Refined_State
8153 @unnumberedsec Aspect Refined_State
8154 @findex Refined_State
8155 @noindent
8156 This aspect is equivalent to pragma @code{Refined_State}.
8158 @node Aspect Remote_Access_Type
8159 @unnumberedsec Aspect Remote_Access_Type
8160 @findex Remote_Access_Type
8161 @noindent
8162 This aspect is equivalent to pragma @code{Remote_Access_Type}.
8164 @node Aspect Scalar_Storage_Order
8165 @unnumberedsec Aspect Scalar_Storage_Order
8166 @findex Scalar_Storage_Order
8167 @noindent
8168 This aspect is equivalent to a @code{Scalar_Storage_Order}
8169 attribute definition clause.
8171 @node Aspect Shared
8172 @unnumberedsec Aspect Shared
8173 @findex Shared
8174 @noindent
8175 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
8176 for aspect @code{Atomic}.
8178 @node Aspect Simple_Storage_Pool
8179 @unnumberedsec Aspect Simple_Storage_Pool
8180 @findex Simple_Storage_Pool
8181 @noindent
8182 This aspect is equivalent to a @code{Simple_Storage_Pool}
8183 attribute definition clause.
8185 @node Aspect Simple_Storage_Pool_Type
8186 @unnumberedsec Aspect Simple_Storage_Pool_Type
8187 @findex Simple_Storage_Pool_Type
8188 @noindent
8189 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
8191 @node Aspect SPARK_Mode
8192 @unnumberedsec Aspect SPARK_Mode
8193 @findex SPARK_Mode
8194 @noindent
8195 This aspect is equivalent to pragma @code{SPARK_Mode} and
8196 may be specified for either or both of the specification and body
8197 of a subprogram or package.
8199 @node Aspect Suppress_Debug_Info
8200 @unnumberedsec Aspect Suppress_Debug_Info
8201 @findex Suppress_Debug_Info
8202 @noindent
8203 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
8205 @node Aspect Test_Case
8206 @unnumberedsec Aspect Test_Case
8207 @findex Test_Case
8208 @noindent
8209 This aspect is equivalent to pragma @code{Test_Case}.
8211 @node Aspect Universal_Aliasing
8212 @unnumberedsec Aspect Universal_Aliasing
8213 @findex Universal_Aliasing
8214 @noindent
8215 This aspect is equivalent to pragma @code{Universal_Aliasing}.
8217 @node Aspect Universal_Data
8218 @unnumberedsec Aspect Universal_Data
8219 @findex Universal_Data
8220 @noindent
8221 This aspect is equivalent to pragma @code{Universal_Data}.
8223 @node Aspect Unmodified
8224 @unnumberedsec Aspect Unmodified
8225 @findex Unmodified
8226 @noindent
8227 This aspect is equivalent to pragma @code{Unmodified}.
8229 @node Aspect Unreferenced
8230 @unnumberedsec Aspect Unreferenced
8231 @findex Unreferenced
8232 @noindent
8233 This aspect is equivalent to pragma @code{Unreferenced}.
8235 @node Aspect Unreferenced_Objects
8236 @unnumberedsec Aspect Unreferenced_Objects
8237 @findex Unreferenced_Objects
8238 @noindent
8239 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
8241 @node Aspect Value_Size
8242 @unnumberedsec Aspect Value_Size
8243 @findex Value_Size
8244 @noindent
8245 This aspect is equivalent to a @code{Value_Size}
8246 attribute definition clause.
8248 @node Aspect Warnings
8249 @unnumberedsec Aspect Warnings
8250 @findex Warnings
8251 @noindent
8252 This aspect is equivalent to the two argument form of pragma @code{Warnings},
8253 where the first argument is @code{ON} or @code{OFF} and the second argument
8254 is the entity.
8257 @node Implementation Defined Attributes
8258 @chapter Implementation Defined Attributes
8259 Ada defines (throughout the Ada reference manual,
8260 summarized in Annex K),
8261 a set of attributes that provide useful additional functionality in all
8262 areas of the language.  These language defined attributes are implemented
8263 in GNAT and work as described in the Ada Reference Manual.
8265 In addition, Ada allows implementations to define additional
8266 attributes whose meaning is defined by the implementation.  GNAT provides
8267 a number of these implementation-dependent attributes which can be used
8268 to extend and enhance the functionality of the compiler.  This section of
8269 the GNAT reference manual describes these additional attributes.
8271 Note that any program using these attributes may not be portable to
8272 other compilers (although GNAT implements this set of attributes on all
8273 platforms).  Therefore if portability to other compilers is an important
8274 consideration, you should minimize the use of these attributes.
8276 @menu
8277 * Attribute Abort_Signal::
8278 * Attribute Address_Size::
8279 * Attribute Asm_Input::
8280 * Attribute Asm_Output::
8281 * Attribute AST_Entry::
8282 * Attribute Bit::
8283 * Attribute Bit_Position::
8284 * Attribute Compiler_Version::
8285 * Attribute Code_Address::
8286 * Attribute Default_Bit_Order::
8287 * Attribute Descriptor_Size::
8288 * Attribute Elaborated::
8289 * Attribute Elab_Body::
8290 * Attribute Elab_Spec::
8291 * Attribute Elab_Subp_Body::
8292 * Attribute Emax::
8293 * Attribute Enabled::
8294 * Attribute Enum_Rep::
8295 * Attribute Enum_Val::
8296 * Attribute Epsilon::
8297 * Attribute Fixed_Value::
8298 * Attribute Has_Access_Values::
8299 * Attribute Has_Discriminants::
8300 * Attribute Img::
8301 * Attribute Integer_Value::
8302 * Attribute Invalid_Value::
8303 * Attribute Large::
8304 * Attribute Library_Level::
8305 * Attribute Loop_Entry::
8306 * Attribute Machine_Size::
8307 * Attribute Mantissa::
8308 * Attribute Max_Interrupt_Priority::
8309 * Attribute Max_Priority::
8310 * Attribute Maximum_Alignment::
8311 * Attribute Mechanism_Code::
8312 * Attribute Null_Parameter::
8313 * Attribute Object_Size::
8314 * Attribute Passed_By_Reference::
8315 * Attribute Pool_Address::
8316 * Attribute Range_Length::
8317 * Attribute Ref::
8318 * Attribute Restriction_Set::
8319 * Attribute Result::
8320 * Attribute Safe_Emax::
8321 * Attribute Safe_Large::
8322 * Attribute Scalar_Storage_Order::
8323 * Attribute Simple_Storage_Pool::
8324 * Attribute Small::
8325 * Attribute Storage_Unit::
8326 * Attribute Stub_Type::
8327 * Attribute System_Allocator_Alignment::
8328 * Attribute Target_Name::
8329 * Attribute Tick::
8330 * Attribute To_Address::
8331 * Attribute Type_Class::
8332 * Attribute UET_Address::
8333 * Attribute Unconstrained_Array::
8334 * Attribute Universal_Literal_String::
8335 * Attribute Unrestricted_Access::
8336 * Attribute Update::
8337 * Attribute Valid_Scalars::
8338 * Attribute VADS_Size::
8339 * Attribute Value_Size::
8340 * Attribute Wchar_T_Size::
8341 * Attribute Word_Size::
8342 @end menu
8344 @node Attribute Abort_Signal
8345 @unnumberedsec Attribute Abort_Signal
8346 @findex Abort_Signal
8347 @noindent
8348 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
8349 prefix) provides the entity for the special exception used to signal
8350 task abort or asynchronous transfer of control.  Normally this attribute
8351 should only be used in the tasking runtime (it is highly peculiar, and
8352 completely outside the normal semantics of Ada, for a user program to
8353 intercept the abort exception).
8355 @node Attribute Address_Size
8356 @unnumberedsec Attribute Address_Size
8357 @cindex Size of @code{Address}
8358 @findex Address_Size
8359 @noindent
8360 @code{Standard'Address_Size} (@code{Standard} is the only allowed
8361 prefix) is a static constant giving the number of bits in an
8362 @code{Address}. It is the same value as System.Address'Size,
8363 but has the advantage of being static, while a direct
8364 reference to System.Address'Size is non-static because Address
8365 is a private type.
8367 @node Attribute Asm_Input
8368 @unnumberedsec Attribute Asm_Input
8369 @findex Asm_Input
8370 @noindent
8371 The @code{Asm_Input} attribute denotes a function that takes two
8372 parameters.  The first is a string, the second is an expression of the
8373 type designated by the prefix.  The first (string) argument is required
8374 to be a static expression, and is the constraint for the parameter,
8375 (e.g.@: what kind of register is required).  The second argument is the
8376 value to be used as the input argument.  The possible values for the
8377 constant are the same as those used in the RTL, and are dependent on
8378 the configuration file used to built the GCC back end.
8379 @ref{Machine Code Insertions}
8381 @node Attribute Asm_Output
8382 @unnumberedsec Attribute Asm_Output
8383 @findex Asm_Output
8384 @noindent
8385 The @code{Asm_Output} attribute denotes a function that takes two
8386 parameters.  The first is a string, the second is the name of a variable
8387 of the type designated by the attribute prefix.  The first (string)
8388 argument is required to be a static expression and designates the
8389 constraint for the parameter (e.g.@: what kind of register is
8390 required).  The second argument is the variable to be updated with the
8391 result.  The possible values for constraint are the same as those used in
8392 the RTL, and are dependent on the configuration file used to build the
8393 GCC back end.  If there are no output operands, then this argument may
8394 either be omitted, or explicitly given as @code{No_Output_Operands}.
8395 @ref{Machine Code Insertions}
8397 @node Attribute AST_Entry
8398 @unnumberedsec Attribute AST_Entry
8399 @cindex OpenVMS
8400 @findex AST_Entry
8401 @noindent
8402 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
8403 the name of an entry, it yields a value of the predefined type AST_Handler
8404 (declared in the predefined package System, as extended by the use of
8405 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
8406 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
8407 Language Reference Manual}, section 9.12a.
8409 @node Attribute Bit
8410 @unnumberedsec Attribute Bit
8411 @findex Bit
8412 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
8413 offset within the storage unit (byte) that contains the first bit of
8414 storage allocated for the object.  The value of this attribute is of the
8415 type @code{Universal_Integer}, and is always a non-negative number not
8416 exceeding the value of @code{System.Storage_Unit}.
8418 For an object that is a variable or a constant allocated in a register,
8419 the value is zero.  (The use of this attribute does not force the
8420 allocation of a variable to memory).
8422 For an object that is a formal parameter, this attribute applies
8423 to either the matching actual parameter or to a copy of the
8424 matching actual parameter.
8426 For an access object the value is zero.  Note that
8427 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
8428 designated object.  Similarly for a record component
8429 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
8430 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
8431 are subject to index checks.
8433 This attribute is designed to be compatible with the DEC Ada 83 definition
8434 and implementation of the @code{Bit} attribute.
8436 @node Attribute Bit_Position
8437 @unnumberedsec Attribute Bit_Position
8438 @findex Bit_Position
8439 @noindent
8440 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
8441 of the fields of the record type, yields the bit
8442 offset within the record contains the first bit of
8443 storage allocated for the object.  The value of this attribute is of the
8444 type @code{Universal_Integer}.  The value depends only on the field
8445 @var{C} and is independent of the alignment of
8446 the containing record @var{R}.
8448 @node Attribute Compiler_Version
8449 @unnumberedsec Attribute Compiler_Version
8450 @findex Compiler_Version
8451 @noindent
8452 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
8453 prefix) yields a static string identifying the version of the compiler
8454 being used to compile the unit containing the attribute reference. A
8455 typical result would be something like "@value{EDITION} @i{version} (20090221)".
8457 @node Attribute Code_Address
8458 @unnumberedsec Attribute Code_Address
8459 @findex Code_Address
8460 @cindex Subprogram address
8461 @cindex Address of subprogram code
8462 @noindent
8463 The @code{'Address}
8464 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
8465 intended effect seems to be to provide
8466 an address value which can be used to call the subprogram by means of
8467 an address clause as in the following example:
8469 @smallexample @c ada
8470 procedure K is @dots{}
8472 procedure L;
8473 for L'Address use K'Address;
8474 pragma Import (Ada, L);
8475 @end smallexample
8477 @noindent
8478 A call to @code{L} is then expected to result in a call to @code{K}@.
8479 In Ada 83, where there were no access-to-subprogram values, this was
8480 a common work-around for getting the effect of an indirect call.
8481 GNAT implements the above use of @code{Address} and the technique
8482 illustrated by the example code works correctly.
8484 However, for some purposes, it is useful to have the address of the start
8485 of the generated code for the subprogram.  On some architectures, this is
8486 not necessarily the same as the @code{Address} value described above.
8487 For example, the @code{Address} value may reference a subprogram
8488 descriptor rather than the subprogram itself.
8490 The @code{'Code_Address} attribute, which can only be applied to
8491 subprogram entities, always returns the address of the start of the
8492 generated code of the specified subprogram, which may or may not be
8493 the same value as is returned by the corresponding @code{'Address}
8494 attribute.
8496 @node Attribute Default_Bit_Order
8497 @unnumberedsec Attribute Default_Bit_Order
8498 @cindex Big endian
8499 @cindex Little endian
8500 @findex Default_Bit_Order
8501 @noindent
8502 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
8503 permissible prefix), provides the value @code{System.Default_Bit_Order}
8504 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
8505 @code{Low_Order_First}).  This is used to construct the definition of
8506 @code{Default_Bit_Order} in package @code{System}.
8508 @node Attribute Descriptor_Size
8509 @unnumberedsec Attribute Descriptor_Size
8510 @cindex Descriptor
8511 @cindex Dope vector
8512 @findex Descriptor_Size
8513 @noindent
8514 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
8515 descriptor allocated for a type.  The result is non-zero only for unconstrained
8516 array types and the returned value is of type universal integer.  In GNAT, an
8517 array descriptor contains bounds information and is located immediately before
8518 the first element of the array.
8520 @smallexample @c ada
8521 type Unconstr_Array is array (Positive range <>) of Boolean;
8522 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
8523 @end smallexample
8525 @noindent
8526 The attribute takes into account any additional padding due to type alignment.
8527 In the example above, the descriptor contains two values of type
8528 @code{Positive} representing the low and high bound.  Since @code{Positive} has
8529 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
8530 Positive'Size + 2} or 64 bits.
8532 @node Attribute Elaborated
8533 @unnumberedsec Attribute Elaborated
8534 @findex Elaborated
8535 @noindent
8536 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
8537 value is a Boolean which indicates whether or not the given unit has been
8538 elaborated.  This attribute is primarily intended for internal use by the
8539 generated code for dynamic elaboration checking, but it can also be used
8540 in user programs.  The value will always be True once elaboration of all
8541 units has been completed.  An exception is for units which need no
8542 elaboration, the value is always False for such units.
8544 @node Attribute Elab_Body
8545 @unnumberedsec Attribute Elab_Body
8546 @findex Elab_Body
8547 @noindent
8548 This attribute can only be applied to a program unit name.  It returns
8549 the entity for the corresponding elaboration procedure for elaborating
8550 the body of the referenced unit.  This is used in the main generated
8551 elaboration procedure by the binder and is not normally used in any
8552 other context.  However, there may be specialized situations in which it
8553 is useful to be able to call this elaboration procedure from Ada code,
8554 e.g.@: if it is necessary to do selective re-elaboration to fix some
8555 error.
8557 @node Attribute Elab_Spec
8558 @unnumberedsec Attribute Elab_Spec
8559 @findex Elab_Spec
8560 @noindent
8561 This attribute can only be applied to a program unit name.  It returns
8562 the entity for the corresponding elaboration procedure for elaborating
8563 the spec of the referenced unit.  This is used in the main
8564 generated elaboration procedure by the binder and is not normally used
8565 in any other context.  However, there may be specialized situations in
8566 which it is useful to be able to call this elaboration procedure from
8567 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
8568 some error.
8570 @node Attribute Elab_Subp_Body
8571 @unnumberedsec Attribute Elab_Subp_Body
8572 @findex Elab_Subp_Body
8573 @noindent
8574 This attribute can only be applied to a library level subprogram
8575 name and is only allowed in CodePeer mode. It returns the entity
8576 for the corresponding elaboration procedure for elaborating the body
8577 of the referenced subprogram unit. This is used in the main generated
8578 elaboration procedure by the binder in CodePeer mode only and is unrecognized
8579 otherwise.
8581 @node Attribute Emax
8582 @unnumberedsec Attribute Emax
8583 @cindex Ada 83 attributes
8584 @findex Emax
8585 @noindent
8586 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
8587 the Ada 83 reference manual for an exact description of the semantics of
8588 this attribute.
8590 @node Attribute Enabled
8591 @unnumberedsec Attribute Enabled
8592 @findex Enabled
8593 @noindent
8594 The @code{Enabled} attribute allows an application program to check at compile
8595 time to see if the designated check is currently enabled. The prefix is a
8596 simple identifier, referencing any predefined check name (other than
8597 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
8598 no argument is given for the attribute, the check is for the general state
8599 of the check, if an argument is given, then it is an entity name, and the
8600 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
8601 given naming the entity (if not, then the argument is ignored).
8603 Note that instantiations inherit the check status at the point of the
8604 instantiation, so a useful idiom is to have a library package that
8605 introduces a check name with @code{pragma Check_Name}, and then contains
8606 generic packages or subprograms which use the @code{Enabled} attribute
8607 to see if the check is enabled. A user of this package can then issue
8608 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
8609 the package or subprogram, controlling whether the check will be present.
8611 @node Attribute Enum_Rep
8612 @unnumberedsec Attribute Enum_Rep
8613 @cindex Representation of enums
8614 @findex Enum_Rep
8615 @noindent
8616 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
8617 function with the following spec:
8619 @smallexample @c ada
8620 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
8621   return @i{Universal_Integer};
8622 @end smallexample
8624 @noindent
8625 It is also allowable to apply @code{Enum_Rep} directly to an object of an
8626 enumeration type or to a non-overloaded enumeration
8627 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
8628 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
8629 enumeration literal or object.
8631 The function returns the representation value for the given enumeration
8632 value.  This will be equal to value of the @code{Pos} attribute in the
8633 absence of an enumeration representation clause.  This is a static
8634 attribute (i.e.@: the result is static if the argument is static).
8636 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
8637 in which case it simply returns the integer value.  The reason for this
8638 is to allow it to be used for @code{(<>)} discrete formal arguments in
8639 a generic unit that can be instantiated with either enumeration types
8640 or integer types.  Note that if @code{Enum_Rep} is used on a modular
8641 type whose upper bound exceeds the upper bound of the largest signed
8642 integer type, and the argument is a variable, so that the universal
8643 integer calculation is done at run time, then the call to @code{Enum_Rep}
8644 may raise @code{Constraint_Error}.
8646 @node Attribute Enum_Val
8647 @unnumberedsec Attribute Enum_Val
8648 @cindex Representation of enums
8649 @findex Enum_Val
8650 @noindent
8651 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
8652 function with the following spec:
8654 @smallexample @c ada
8655 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
8656   return @var{S}'Base};
8657 @end smallexample
8659 @noindent
8660 The function returns the enumeration value whose representation matches the
8661 argument, or raises Constraint_Error if no enumeration literal of the type
8662 has the matching value.
8663 This will be equal to value of the @code{Val} attribute in the
8664 absence of an enumeration representation clause.  This is a static
8665 attribute (i.e.@: the result is static if the argument is static).
8667 @node Attribute Epsilon
8668 @unnumberedsec Attribute Epsilon
8669 @cindex Ada 83 attributes
8670 @findex Epsilon
8671 @noindent
8672 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
8673 the Ada 83 reference manual for an exact description of the semantics of
8674 this attribute.
8676 @node Attribute Fixed_Value
8677 @unnumberedsec Attribute Fixed_Value
8678 @findex Fixed_Value
8679 @noindent
8680 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
8681 function with the following specification:
8683 @smallexample @c ada
8684 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
8685   return @var{S};
8686 @end smallexample
8688 @noindent
8689 The value returned is the fixed-point value @var{V} such that
8691 @smallexample @c ada
8692 @var{V} = Arg * @var{S}'Small
8693 @end smallexample
8695 @noindent
8696 The effect is thus similar to first converting the argument to the
8697 integer type used to represent @var{S}, and then doing an unchecked
8698 conversion to the fixed-point type.  The difference is
8699 that there are full range checks, to ensure that the result is in range.
8700 This attribute is primarily intended for use in implementation of the
8701 input-output functions for fixed-point values.
8703 @node Attribute Has_Access_Values
8704 @unnumberedsec Attribute Has_Access_Values
8705 @cindex Access values, testing for
8706 @findex Has_Access_Values
8707 @noindent
8708 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
8709 is a Boolean value which is True if the is an access type, or is a composite
8710 type with a component (at any nesting depth) that is an access type, and is
8711 False otherwise.
8712 The intended use of this attribute is in conjunction with generic
8713 definitions.  If the attribute is applied to a generic private type, it
8714 indicates whether or not the corresponding actual type has access values.
8716 @node Attribute Has_Discriminants
8717 @unnumberedsec Attribute Has_Discriminants
8718 @cindex Discriminants, testing for
8719 @findex Has_Discriminants
8720 @noindent
8721 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
8722 is a Boolean value which is True if the type has discriminants, and False
8723 otherwise.  The intended use of this attribute is in conjunction with generic
8724 definitions.  If the attribute is applied to a generic private type, it
8725 indicates whether or not the corresponding actual type has discriminants.
8727 @node Attribute Img
8728 @unnumberedsec Attribute Img
8729 @findex Img
8730 @noindent
8731 The @code{Img} attribute differs from @code{Image} in that it is applied
8732 directly to an object, and yields the same result as
8733 @code{Image} for the subtype of the object.  This is convenient for
8734 debugging:
8736 @smallexample @c ada
8737 Put_Line ("X = " & X'Img);
8738 @end smallexample
8740 @noindent
8741 has the same meaning as the more verbose:
8743 @smallexample @c ada
8744 Put_Line ("X = " & @var{T}'Image (X));
8745 @end smallexample
8747 @noindent
8748 where @var{T} is the (sub)type of the object @code{X}.
8750 Note that technically, in analogy to @code{Image},
8751 @code{X'Img} returns a parameterless function
8752 that returns the appropriate string when called. This means that
8753 @code{X'Img} can be renamed as a function-returning-string, or used
8754 in an instantiation as a function parameter.
8756 @node Attribute Integer_Value
8757 @unnumberedsec Attribute Integer_Value
8758 @findex Integer_Value
8759 @noindent
8760 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
8761 function with the following spec:
8763 @smallexample @c ada
8764 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
8765   return @var{S};
8766 @end smallexample
8768 @noindent
8769 The value returned is the integer value @var{V}, such that
8771 @smallexample @c ada
8772 Arg = @var{V} * @var{T}'Small
8773 @end smallexample
8775 @noindent
8776 where @var{T} is the type of @code{Arg}.
8777 The effect is thus similar to first doing an unchecked conversion from
8778 the fixed-point type to its corresponding implementation type, and then
8779 converting the result to the target integer type.  The difference is
8780 that there are full range checks, to ensure that the result is in range.
8781 This attribute is primarily intended for use in implementation of the
8782 standard input-output functions for fixed-point values.
8784 @node Attribute Invalid_Value
8785 @unnumberedsec Attribute Invalid_Value
8786 @findex Invalid_Value
8787 @noindent
8788 For every scalar type S, S'Invalid_Value returns an undefined value of the
8789 type. If possible this value is an invalid representation for the type. The
8790 value returned is identical to the value used to initialize an otherwise
8791 uninitialized value of the type if pragma Initialize_Scalars is used,
8792 including the ability to modify the value with the binder -Sxx flag and
8793 relevant environment variables at run time.
8795 @node Attribute Large
8796 @unnumberedsec Attribute Large
8797 @cindex Ada 83 attributes
8798 @findex Large
8799 @noindent
8800 The @code{Large} attribute is provided for compatibility with Ada 83.  See
8801 the Ada 83 reference manual for an exact description of the semantics of
8802 this attribute.
8804 @node Attribute Library_Level
8805 @unnumberedsec Attribute Library_Level
8806 @findex Library_Level
8807 @noindent
8808 @noindent
8809 @code{P'Library_Level}, where P is an entity name,
8810 returns a Boolean value which is True if the entity is declared
8811 at the library level, and False otherwise. Note that within a
8812 generic instantition, the name of the generic unit denotes the
8813 instance, which means that this attribute can be used to test
8814 if a generic is instantiated at the library level, as shown
8815 in this example:
8817 @smallexample @c ada
8818 generic
8819   ...
8820 package Gen is
8821   pragma Compile_Time_Error
8822     (not Gen'Library_Level,
8823      "Gen can only be instantiated at library level");
8824   ...
8825 end Gen;
8826 @end smallexample
8828 @node Attribute Loop_Entry
8829 @unnumberedsec Attribute Loop_Entry
8830 @findex Loop_Entry
8831 @noindent
8832 Syntax:
8834 @smallexample @c ada
8835 X'Loop_Entry [(loop_name)]
8836 @end smallexample
8838 @noindent
8839 The @code{Loop_Entry} attribute is used to refer to the value that an
8840 expression had upon entry to a given loop in much the same way that the
8841 @code{Old} attribute in a subprogram postcondition can be used to refer
8842 to the value an expression had upon entry to the subprogram. The
8843 relevant loop is either identified by the given loop name, or it is the
8844 innermost enclosing loop when no loop name is given.
8846 @noindent
8847 A @code{Loop_Entry} attribute can only occur within a
8848 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
8849 @code{Loop_Entry} is to compare the current value of objects with their
8850 initial value at loop entry, in a @code{Loop_Invariant} pragma.
8852 @noindent
8853 The effect of using @code{X'Loop_Entry} is the same as declaring
8854 a constant initialized with the initial value of @code{X} at loop
8855 entry. This copy is not performed if the loop is not entered, or if the
8856 corresponding pragmas are ignored or disabled.
8858 @node Attribute Machine_Size
8859 @unnumberedsec Attribute Machine_Size
8860 @findex Machine_Size
8861 @noindent
8862 This attribute is identical to the @code{Object_Size} attribute.  It is
8863 provided for compatibility with the DEC Ada 83 attribute of this name.
8865 @node Attribute Mantissa
8866 @unnumberedsec Attribute Mantissa
8867 @cindex Ada 83 attributes
8868 @findex Mantissa
8869 @noindent
8870 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
8871 the Ada 83 reference manual for an exact description of the semantics of
8872 this attribute.
8874 @node Attribute Max_Interrupt_Priority
8875 @unnumberedsec Attribute Max_Interrupt_Priority
8876 @cindex Interrupt priority, maximum
8877 @findex Max_Interrupt_Priority
8878 @noindent
8879 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
8880 permissible prefix), provides the same value as
8881 @code{System.Max_Interrupt_Priority}.
8883 @node Attribute Max_Priority
8884 @unnumberedsec Attribute Max_Priority
8885 @cindex Priority, maximum
8886 @findex Max_Priority
8887 @noindent
8888 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
8889 prefix) provides the same value as @code{System.Max_Priority}.
8891 @node Attribute Maximum_Alignment
8892 @unnumberedsec Attribute Maximum_Alignment
8893 @cindex Alignment, maximum
8894 @findex Maximum_Alignment
8895 @noindent
8896 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
8897 permissible prefix) provides the maximum useful alignment value for the
8898 target.  This is a static value that can be used to specify the alignment
8899 for an object, guaranteeing that it is properly aligned in all
8900 cases.
8902 @node Attribute Mechanism_Code
8903 @unnumberedsec Attribute Mechanism_Code
8904 @cindex Return values, passing mechanism
8905 @cindex Parameters, passing mechanism
8906 @findex Mechanism_Code
8907 @noindent
8908 @code{@var{function}'Mechanism_Code} yields an integer code for the
8909 mechanism used for the result of function, and
8910 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
8911 used for formal parameter number @var{n} (a static integer value with 1
8912 meaning the first parameter) of @var{subprogram}.  The code returned is:
8914 @table @asis
8915 @item 1
8916 by copy (value)
8917 @item 2
8918 by reference
8919 @item 3
8920 by descriptor (default descriptor class)
8921 @item 4
8922 by descriptor (UBS: unaligned bit string)
8923 @item 5
8924 by descriptor (UBSB: aligned bit string with arbitrary bounds)
8925 @item 6
8926 by descriptor (UBA: unaligned bit array)
8927 @item 7
8928 by descriptor (S: string, also scalar access type parameter)
8929 @item 8
8930 by descriptor (SB: string with arbitrary bounds)
8931 @item 9
8932 by descriptor (A: contiguous array)
8933 @item 10
8934 by descriptor (NCA: non-contiguous array)
8935 @end table
8937 @noindent
8938 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
8939 @cindex OpenVMS
8941 @node Attribute Null_Parameter
8942 @unnumberedsec Attribute Null_Parameter
8943 @cindex Zero address, passing
8944 @findex Null_Parameter
8945 @noindent
8946 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
8947 type or subtype @var{T} allocated at machine address zero.  The attribute
8948 is allowed only as the default expression of a formal parameter, or as
8949 an actual expression of a subprogram call.  In either case, the
8950 subprogram must be imported.
8952 The identity of the object is represented by the address zero in the
8953 argument list, independent of the passing mechanism (explicit or
8954 default).
8956 This capability is needed to specify that a zero address should be
8957 passed for a record or other composite object passed by reference.
8958 There is no way of indicating this without the @code{Null_Parameter}
8959 attribute.
8961 @node Attribute Object_Size
8962 @unnumberedsec Attribute Object_Size
8963 @cindex Size, used for objects
8964 @findex Object_Size
8965 @noindent
8966 The size of an object is not necessarily the same as the size of the type
8967 of an object.  This is because by default object sizes are increased to be
8968 a multiple of the alignment of the object.  For example,
8969 @code{Natural'Size} is
8970 31, but by default objects of type @code{Natural} will have a size of 32 bits.
8971 Similarly, a record containing an integer and a character:
8973 @smallexample @c ada
8974 type Rec is record
8975    I : Integer;
8976    C : Character;
8977 end record;
8978 @end smallexample
8980 @noindent
8981 will have a size of 40 (that is @code{Rec'Size} will be 40).  The
8982 alignment will be 4, because of the
8983 integer field, and so the default size of record objects for this type
8984 will be 64 (8 bytes).
8986 If the alignment of the above record is specified to be 1, then the
8987 object size will be 40 (5 bytes). This is true by default, and also
8988 an object size of 40 can be explicitly specified in this case.
8990 A consequence of this capability is that different object sizes can be
8991 given to subtypes that would otherwise be considered in Ada to be
8992 statically matching.  But it makes no sense to consider such subtypes
8993 as statically matching.  Consequently, in @code{GNAT} we add a rule
8994 to the static matching rules that requires object sizes to match.
8995 Consider this example:
8997 @smallexample @c ada
8998  1. procedure BadAVConvert is
8999  2.    type R is new Integer;
9000  3.    subtype R1 is R range 1 .. 10;
9001  4.    subtype R2 is R range 1 .. 10;
9002  5.    for R1'Object_Size use 8;
9003  6.    for R2'Object_Size use 16;
9004  7.    type R1P is access all R1;
9005  8.    type R2P is access all R2;
9006  9.    R1PV : R1P := new R1'(4);
9007 10.    R2PV : R2P;
9008 11. begin
9009 12.    R2PV := R2P (R1PV);
9010                |
9011        >>> target designated subtype not compatible with
9012            type "R1" defined at line 3
9014 13. end;
9015 @end smallexample
9017 @noindent
9018 In the absence of lines 5 and 6,
9019 types @code{R1} and @code{R2} statically match and
9020 hence the conversion on line 12 is legal. But since lines 5 and 6
9021 cause the object sizes to differ, @code{GNAT} considers that types
9022 @code{R1} and @code{R2} are not statically matching, and line 12
9023 generates the diagnostic shown above.
9025 @noindent
9026 Similar additional checks are performed in other contexts requiring
9027 statically matching subtypes.
9029 @node Attribute Passed_By_Reference
9030 @unnumberedsec Attribute Passed_By_Reference
9031 @cindex Parameters, when passed by reference
9032 @findex Passed_By_Reference
9033 @noindent
9034 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
9035 a value of type @code{Boolean} value that is @code{True} if the type is
9036 normally passed by reference and @code{False} if the type is normally
9037 passed by copy in calls.  For scalar types, the result is always @code{False}
9038 and is static.  For non-scalar types, the result is non-static.
9040 @node Attribute Pool_Address
9041 @unnumberedsec Attribute Pool_Address
9042 @cindex Parameters, when passed by reference
9043 @findex Pool_Address
9044 @noindent
9045 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
9046 of X within its storage pool. This is the same as
9047 @code{@var{X}'Address}, except that for an unconstrained array whose
9048 bounds are allocated just before the first component,
9049 @code{@var{X}'Pool_Address} returns the address of those bounds,
9050 whereas @code{@var{X}'Address} returns the address of the first
9051 component.
9053 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
9054 the object is allocated'', which could be a user-defined storage pool,
9055 the global heap, on the stack, or in a static memory area. For an
9056 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
9057 what is passed to @code{Allocate} and returned from @code{Deallocate}.
9059 @node Attribute Range_Length
9060 @unnumberedsec Attribute Range_Length
9061 @findex Range_Length
9062 @noindent
9063 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
9064 the number of values represented by the subtype (zero for a null
9065 range).  The result is static for static subtypes.  @code{Range_Length}
9066 applied to the index subtype of a one dimensional array always gives the
9067 same result as @code{Length} applied to the array itself.
9069 @node Attribute Ref
9070 @unnumberedsec Attribute Ref
9071 @findex Ref
9072 @noindent
9075 @node Attribute Restriction_Set
9076 @unnumberedsec Attribute Restriction_Set
9077 @findex Restriction_Set
9078 @cindex Restrictions
9079 @noindent
9080 This attribute allows compile time testing of restrictions that
9081 are currently in effect. It is primarily intended for specializing
9082 code in the run-time based on restrictions that are active (e.g.
9083 don't need to save fpt registers if restriction No_Floating_Point
9084 is known to be in effect), but can be used anywhere.
9086 There are two forms:
9088 @smallexample @c ada
9089 System'Restriction_Set (partition_boolean_restriction_NAME)
9090 System'Restriction_Set (No_Dependence => library_unit_NAME);
9091 @end smallexample
9093 @noindent
9094 In the case of the first form, the only restriction names
9095 allowed are parameterless restrictions that are checked
9096 for consistency at bind time. For a complete list see the
9097 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
9099 The result returned is True if the restriction is known to
9100 be in effect, and False if the restriction is known not to
9101 be in effect. An important guarantee is that the value of
9102 a Restriction_Set attribute is known to be consistent throughout
9103 all the code of a partition.
9105 This is trivially achieved if the entire partition is compiled
9106 with a consistent set of restriction pragmas. However, the
9107 compilation model does not require this. It is possible to
9108 compile one set of units with one set of pragmas, and another
9109 set of units with another set of pragmas. It is even possible
9110 to compile a spec with one set of pragmas, and then WITH the
9111 same spec with a different set of pragmas. Inconsistencies
9112 in the actual use of the restriction are checked at bind time.
9114 In order to achieve the guarantee of consistency for the
9115 Restriction_Set pragma, we consider that a use of the pragma
9116 that yields False is equivalent to a violation of the
9117 restriction.
9119 So for example if you write
9121 @smallexample @c ada
9122 if System'Restriction_Set (No_Floating_Point) then
9123    ...
9124 else
9125    ...
9126 end if;
9127 @end smallexample
9129 @noindent
9130 And the result is False, so that the else branch is executed,
9131 you can assume that this restriction is not set for any unit
9132 in the partition. This is checked by considering this use of
9133 the restriction pragma to be a violation of the restriction
9134 No_Floating_Point. This means that no other unit can attempt
9135 to set this restriction (if some unit does attempt to set it,
9136 the binder will refuse to bind the partition).
9138 Technical note: The restriction name and the unit name are
9139 intepreted entirely syntactically, as in the corresponding
9140 Restrictions pragma, they are not analyzed semantically,
9141 so they do not have a type.
9143 @node Attribute Result
9144 @unnumberedsec Attribute Result
9145 @findex Result
9146 @noindent
9147 @code{@var{function}'Result} can only be used with in a Postcondition pragma
9148 for a function. The prefix must be the name of the corresponding function. This
9149 is used to refer to the result of the function in the postcondition expression.
9150 For a further discussion of the use of this attribute and examples of its use,
9151 see the description of pragma Postcondition.
9153 @node Attribute Safe_Emax
9154 @unnumberedsec Attribute Safe_Emax
9155 @cindex Ada 83 attributes
9156 @findex Safe_Emax
9157 @noindent
9158 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
9159 the Ada 83 reference manual for an exact description of the semantics of
9160 this attribute.
9162 @node Attribute Safe_Large
9163 @unnumberedsec Attribute Safe_Large
9164 @cindex Ada 83 attributes
9165 @findex Safe_Large
9166 @noindent
9167 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
9168 the Ada 83 reference manual for an exact description of the semantics of
9169 this attribute.
9171 @node Attribute Scalar_Storage_Order
9172 @unnumberedsec Attribute Scalar_Storage_Order
9173 @cindex Endianness
9174 @cindex Scalar storage order
9175 @findex Scalar_Storage_Order
9176 @noindent
9177 For every array or record type @var{S}, the representation attribute
9178 @code{Scalar_Storage_Order} denotes the order in which storage elements
9179 that make up scalar components are ordered within S:
9181 @smallexample @c ada
9182    --  Component type definitions
9184    subtype Yr_Type is Natural range 0 .. 127;
9185    subtype Mo_Type is Natural range 1 .. 12;
9186    subtype Da_Type is Natural range 1 .. 31;
9188    --  Record declaration
9190    type Date is record
9191       Years_Since_1980 : Yr_Type;
9192       Month            : Mo_Type;
9193       Day_Of_Month     : Da_Type;
9194    end record;
9196    --  Record representation clause
9198    for Date use record
9199       Years_Since_1980 at 0 range 0  ..  6;
9200       Month            at 0 range 7  .. 10;
9201       Day_Of_Month     at 0 range 11 .. 15;
9202    end record;
9204    --  Attribute definition clauses
9206    for Date'Bit_Order use System.High_Order_First;
9207    for Date'Scalar_Storage_Order use System.High_Order_First;
9208    --  If Scalar_Storage_Order is specified, it must be consistent with
9209    --  Bit_Order, so it's best to always define the latter explicitly if
9210    --  the former is used.
9211 @end smallexample
9213 Other properties are
9214 as for standard representation attribute @code{Bit_Order}, as defined by
9215 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
9217 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
9218 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
9219 this means that if a @code{Scalar_Storage_Order} attribute definition
9220 clause is not confirming, then the type's @code{Bit_Order} shall be
9221 specified explicitly and set to the same value.
9223 For a record extension, the derived type shall have the same scalar storage
9224 order as the parent type.
9226 If a component of @var{S} has itself a record or array type, then it shall also
9227 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
9228 if the component is a packed array, or does not start on a byte boundary, then
9229 the scalar storage order specified for S and for the nested component type shall
9230 be identical.
9232 If @var{S} appears as the type of a record or array component, the enclosing
9233 record or array shall also have a @code{Scalar_Storage_Order} attribute
9234 definition clause.
9236 No component of a type that has a @code{Scalar_Storage_Order} attribute
9237 definition may be aliased.
9239 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
9240 with a value equal to @code{System.Default_Bit_Order}) has no effect.
9242 If the opposite storage order is specified, then whenever the value of
9243 a scalar component of an object of type @var{S} is read, the storage
9244 elements of the enclosing machine scalar are first reversed (before
9245 retrieving the component value, possibly applying some shift and mask
9246 operatings on the enclosing machine scalar), and the opposite operation
9247 is done for writes.
9249 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
9250 are relaxed. Instead, the following rules apply:
9252 @itemize @bullet
9253 @item the underlying storage elements are those at positions
9254   @code{(position + first_bit / storage_element_size) ..
9255         (position + (last_bit + storage_element_size - 1) /
9256                     storage_element_size)}
9257 @item the sequence of underlying storage elements shall have
9258         a size no greater than the largest machine scalar
9259 @item the enclosing machine scalar is defined as the smallest machine
9260         scalar starting at a position no greater than
9261         @code{position + first_bit / storage_element_size} and covering
9262         storage elements at least up to @code{position + (last_bit +
9263         storage_element_size - 1) / storage_element_size}
9264 @item the position of the component is interpreted relative to that machine
9265  scalar.
9267 @end itemize
9269 @node Attribute Simple_Storage_Pool
9270 @unnumberedsec Attribute Simple_Storage_Pool
9271 @cindex Storage pool, simple
9272 @cindex Simple storage pool
9273 @findex Simple_Storage_Pool
9274 @noindent
9275 For every nonformal, nonderived access-to-object type @var{Acc}, the
9276 representation attribute @code{Simple_Storage_Pool} may be specified
9277 via an attribute_definition_clause (or by specifying the equivalent aspect):
9279 @smallexample @c ada
9281 My_Pool : My_Simple_Storage_Pool_Type;
9283 type Acc is access My_Data_Type;
9285 for Acc'Simple_Storage_Pool use My_Pool;
9287 @end smallexample
9289 @noindent
9290 The name given in an attribute_definition_clause for the
9291 @code{Simple_Storage_Pool} attribute shall denote a variable of
9292 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
9294 The use of this attribute is only allowed for a prefix denoting a type
9295 for which it has been specified. The type of the attribute is the type
9296 of the variable specified as the simple storage pool of the access type,
9297 and the attribute denotes that variable.
9299 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
9300 for the same access type.
9302 If the @code{Simple_Storage_Pool} attribute has been specified for an access
9303 type, then applying the @code{Storage_Pool} attribute to the type is flagged
9304 with a warning and its evaluation raises the exception @code{Program_Error}.
9306 If the Simple_Storage_Pool attribute has been specified for an access
9307 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
9308 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
9309 which is intended to indicate the number of storage elements reserved for
9310 the simple storage pool. If the Storage_Size function has not been defined
9311 for the simple storage pool type, then this attribute returns zero.
9313 If an access type @var{S} has a specified simple storage pool of type
9314 @var{SSP}, then the evaluation of an allocator for that access type calls
9315 the primitive @code{Allocate} procedure for type @var{SSP}, passing
9316 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
9317 semantics of such allocators is the same as those defined for allocators
9318 in section 13.11 of the Ada Reference Manual, with the term
9319 ``simple storage pool'' substituted for ``storage pool''.
9321 If an access type @var{S} has a specified simple storage pool of type
9322 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
9323 for that access type invokes the primitive @code{Deallocate} procedure
9324 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
9325 parameter. The detailed semantics of such unchecked deallocations is the same
9326 as defined in section 13.11.2 of the Ada Reference Manual, except that the
9327 term ``simple storage pool'' is substituted for ``storage pool''.
9329 @node Attribute Small
9330 @unnumberedsec Attribute Small
9331 @cindex Ada 83 attributes
9332 @findex Small
9333 @noindent
9334 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
9335 fixed-point types.
9336 GNAT also allows this attribute to be applied to floating-point types
9337 for compatibility with Ada 83.  See
9338 the Ada 83 reference manual for an exact description of the semantics of
9339 this attribute when applied to floating-point types.
9341 @node Attribute Storage_Unit
9342 @unnumberedsec Attribute Storage_Unit
9343 @findex Storage_Unit
9344 @noindent
9345 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
9346 prefix) provides the same value as @code{System.Storage_Unit}.
9348 @node Attribute Stub_Type
9349 @unnumberedsec Attribute Stub_Type
9350 @findex Stub_Type
9351 @noindent
9352 The GNAT implementation of remote access-to-classwide types is
9353 organized as described in AARM section E.4 (20.t): a value of an RACW type
9354 (designating a remote object) is represented as a normal access
9355 value, pointing to a "stub" object which in turn contains the
9356 necessary information to contact the designated remote object. A
9357 call on any dispatching operation of such a stub object does the
9358 remote call, if necessary, using the information in the stub object
9359 to locate the target partition, etc.
9361 For a prefix @code{T} that denotes a remote access-to-classwide type,
9362 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
9364 By construction, the layout of @code{T'Stub_Type} is identical to that of
9365 type @code{RACW_Stub_Type} declared in the internal implementation-defined
9366 unit @code{System.Partition_Interface}. Use of this attribute will create
9367 an implicit dependency on this unit.
9369 @node Attribute System_Allocator_Alignment
9370 @unnumberedsec Attribute System_Allocator_Alignment
9371 @cindex Alignment, allocator
9372 @findex System_Allocator_Alignment
9373 @noindent
9374 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
9375 permissible prefix) provides the observable guaranted to be honored by
9376 the system allocator (malloc). This is a static value that can be used
9377 in user storage pools based on malloc either to reject allocation
9378 with alignment too large or to enable a realignment circuitry if the
9379 alignment request is larger than this value.
9381 @node Attribute Target_Name
9382 @unnumberedsec Attribute Target_Name
9383 @findex Target_Name
9384 @noindent
9385 @code{Standard'Target_Name} (@code{Standard} is the only permissible
9386 prefix) provides a static string value that identifies the target
9387 for the current compilation. For GCC implementations, this is the
9388 standard gcc target name without the terminating slash (for
9389 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
9391 @node Attribute Tick
9392 @unnumberedsec Attribute Tick
9393 @findex Tick
9394 @noindent
9395 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
9396 provides the same value as @code{System.Tick},
9398 @node Attribute To_Address
9399 @unnumberedsec Attribute To_Address
9400 @findex To_Address
9401 @noindent
9402 The @code{System'To_Address}
9403 (@code{System} is the only permissible prefix)
9404 denotes a function identical to
9405 @code{System.Storage_Elements.To_Address} except that
9406 it is a static attribute.  This means that if its argument is
9407 a static expression, then the result of the attribute is a
9408 static expression.  This means that such an expression can be
9409 used in contexts (e.g.@: preelaborable packages) which require a
9410 static expression and where the function call could not be used
9411 (since the function call is always non-static, even if its
9412 argument is static). The argument must be in the range
9413 -(2**(m-1) .. 2**m-1, where m is the memory size
9414 (typically 32 or 64). Negative values are intepreted in a
9415 modular manner (e.g. -1 means the same as 16#FFFF_FFFF# on
9416 a 32 bits machine).
9418 @node Attribute Type_Class
9419 @unnumberedsec Attribute Type_Class
9420 @findex Type_Class
9421 @noindent
9422 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
9423 the value of the type class for the full type of @var{type}.  If
9424 @var{type} is a generic formal type, the value is the value for the
9425 corresponding actual subtype.  The value of this attribute is of type
9426 @code{System.Aux_DEC.Type_Class}, which has the following definition:
9428 @smallexample @c ada
9429   type Type_Class is
9430     (Type_Class_Enumeration,
9431      Type_Class_Integer,
9432      Type_Class_Fixed_Point,
9433      Type_Class_Floating_Point,
9434      Type_Class_Array,
9435      Type_Class_Record,
9436      Type_Class_Access,
9437      Type_Class_Task,
9438      Type_Class_Address);
9439 @end smallexample
9441 @noindent
9442 Protected types yield the value @code{Type_Class_Task}, which thus
9443 applies to all concurrent types.  This attribute is designed to
9444 be compatible with the DEC Ada 83 attribute of the same name.
9446 @node Attribute UET_Address
9447 @unnumberedsec Attribute UET_Address
9448 @findex UET_Address
9449 @noindent
9450 The @code{UET_Address} attribute can only be used for a prefix which
9451 denotes a library package.  It yields the address of the unit exception
9452 table when zero cost exception handling is used.  This attribute is
9453 intended only for use within the GNAT implementation.  See the unit
9454 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
9455 for details on how this attribute is used in the implementation.
9457 @node Attribute Unconstrained_Array
9458 @unnumberedsec Attribute Unconstrained_Array
9459 @findex Unconstrained_Array
9460 @noindent
9461 The @code{Unconstrained_Array} attribute can be used with a prefix that
9462 denotes any type or subtype. It is a static attribute that yields
9463 @code{True} if the prefix designates an unconstrained array,
9464 and @code{False} otherwise. In a generic instance, the result is
9465 still static, and yields the result of applying this test to the
9466 generic actual.
9468 @node Attribute Universal_Literal_String
9469 @unnumberedsec Attribute Universal_Literal_String
9470 @cindex Named numbers, representation of
9471 @findex Universal_Literal_String
9472 @noindent
9473 The prefix of @code{Universal_Literal_String} must be a named
9474 number.  The static result is the string consisting of the characters of
9475 the number as defined in the original source.  This allows the user
9476 program to access the actual text of named numbers without intermediate
9477 conversions and without the need to enclose the strings in quotes (which
9478 would preclude their use as numbers).
9480 For example, the following program prints the first 50 digits of pi:
9482 @smallexample @c ada
9483 with Text_IO; use Text_IO;
9484 with Ada.Numerics;
9485 procedure Pi is
9486 begin
9487    Put (Ada.Numerics.Pi'Universal_Literal_String);
9488 end;
9489 @end smallexample
9491 @node Attribute Unrestricted_Access
9492 @unnumberedsec Attribute Unrestricted_Access
9493 @cindex @code{Access}, unrestricted
9494 @findex Unrestricted_Access
9495 @noindent
9496 The @code{Unrestricted_Access} attribute is similar to @code{Access}
9497 except that all accessibility and aliased view checks are omitted.  This
9498 is a user-beware attribute.  It is similar to
9499 @code{Address}, for which it is a desirable replacement where the value
9500 desired is an access type.  In other words, its effect is identical to
9501 first applying the @code{Address} attribute and then doing an unchecked
9502 conversion to a desired access type.  In GNAT, but not necessarily in
9503 other implementations, the use of static chains for inner level
9504 subprograms means that @code{Unrestricted_Access} applied to a
9505 subprogram yields a value that can be called as long as the subprogram
9506 is in scope (normal Ada accessibility rules restrict this usage).
9508 It is possible to use @code{Unrestricted_Access} for any type, but care
9509 must be exercised if it is used to create pointers to unconstrained
9510 objects. In this case, the resulting pointer has the same scope as the
9511 context of the attribute, and may not be returned to some enclosing
9512 scope. For instance, a function cannot use @code{Unrestricted_Access}
9513 to create a unconstrained pointer and then return that value to the
9514 caller.
9516 @node Attribute Update
9517 @unnumberedsec Attribute Update
9518 @findex Update
9519 @noindent
9520 The @code{Update} attribute creates a copy of an array or record value
9521 with one or more modified components. The syntax is:
9523 @smallexample @c ada
9524 PREFIX'Update ( RECORD_COMPONENT_ASSOCIATION_LIST )
9525 PREFIX'Update ( ARRAY_COMPONENT_ASSOCIATION @{, ARRAY_COMPONENT_ASSOCIATION @} )
9526 PREFIX'Update ( MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION
9527                 @{, MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION @} )
9529 MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION ::= INDEX_EXPRESSION_LIST_LIST => EXPRESSION
9530 INDEX_EXPRESSION_LIST_LIST                   ::= INDEX_EXPRESSION_LIST @{| INDEX_EXPRESSION_LIST @}
9531 INDEX_EXPRESSION_LIST                        ::= ( EXPRESSION @{, EXPRESSION @} )
9532 @end smallexample
9534 @noindent
9535 where @code{PREFIX} is the name of an array or record object, and
9536 the association list in parentheses does not contain an @code{others}
9537 choice. The effect is to yield a copy of the array or record value which
9538 is unchanged apart from the components mentioned in the association list, which
9539 are changed to the indicated value. The original value of the array or
9540 record value is not affected. For example:
9542 @smallexample @c ada
9543 type Arr is Array (1 .. 5) of Integer;
9545 Avar1 : Arr := (1,2,3,4,5);
9546 Avar2 : Arr := Avar1'Update (2 => 10, 3 .. 4 => 20);
9547 @end smallexample
9549 @noindent
9550 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
9551 begin unmodified. Similarly:
9553 @smallexample @c ada
9554 type Rec is A, B, C : Integer;
9556 Rvar1 : Rec := (A => 1, B => 2, C => 3);
9557 Rvar2 : Rec := Rvar1'Update (B => 20);
9558 @end smallexample
9560 @noindent
9561 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
9562 with @code{Rvar1} being unmodifed.
9563 Note that the value of the attribute reference is computed
9564 completely before it is used. This means that if you write:
9566 @smallexample @c ada
9567 Avar1 := Avar1'Update (1 => 10, 2 => Function_Call);
9568 @end smallexample
9570 @noindent
9571 then the value of @code{Avar1} is not modified if @code{Function_Call}
9572 raises an exception, unlike the effect of a series of direct assignments
9573 to elements of @code{Avar1}. In general this requires that
9574 two extra complete copies of the object are required, which should be
9575 kept in mind when considering efficiency.
9577 The @code{Update} attribute cannot be applied to prefixes of a limited
9578 type, and cannot reference discriminants in the case of a record type.
9579 The accessibility level of an Update attribute result object is defined
9580 as for an aggregate.
9582 In the record case, no component can be mentioned more than once. In
9583 the array case, two overlapping ranges can appear in the association list,
9584 in which case the modifications are processed left to right.
9586 Multi-dimensional arrays can be modified, as shown by this example:
9588 @smallexample @c ada
9589 A : array (1 .. 10, 1 .. 10) of Integer;
9591 A := A'Update ((1, 2) => 20, (3, 4) => 30);
9592 @end smallexample
9594 @noindent
9595 which changes element (1,2) to 20 and (3,4) to 30.
9597 @node Attribute Valid_Scalars
9598 @unnumberedsec Attribute Valid_Scalars
9599 @findex Valid_Scalars
9600 @noindent
9601 The @code{'Valid_Scalars} attribute is intended to make it easier to
9602 check the validity of scalar subcomponents of composite objects. It
9603 is defined for any prefix @code{X} that denotes an object.
9604 The value of this attribute is of the predefined type Boolean.
9605 @code{X'Valid_Scalars} yields True if and only if evaluation of
9606 @code{P'Valid} yields True for every scalar part P of X or if X has
9607 no scalar parts. It is not specified in what order the scalar parts
9608 are checked, nor whether any more are checked after any one of them
9609 is determined to be invalid. If the prefix @code{X} is of a class-wide
9610 type @code{T'Class} (where @code{T} is the associated specific type),
9611 or if the prefix @code{X} is of a specific tagged type @code{T}, then
9612 only the scalar parts of components of @code{T} are traversed; in other
9613 words, components of extensions of @code{T} are not traversed even if
9614 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
9615 be determined at compile time that the prefix of the attribute has no
9616 scalar parts (e.g., if the prefix is of an access type, an interface type,
9617 an undiscriminated task type, or an undiscriminated protected type).
9619 @node Attribute VADS_Size
9620 @unnumberedsec Attribute VADS_Size
9621 @cindex @code{Size}, VADS compatibility
9622 @findex VADS_Size
9623 @noindent
9624 The @code{'VADS_Size} attribute is intended to make it easier to port
9625 legacy code which relies on the semantics of @code{'Size} as implemented
9626 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
9627 same semantic interpretation.  In particular, @code{'VADS_Size} applied
9628 to a predefined or other primitive type with no Size clause yields the
9629 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
9630 typical machines).  In addition @code{'VADS_Size} applied to an object
9631 gives the result that would be obtained by applying the attribute to
9632 the corresponding type.
9634 @node Attribute Value_Size
9635 @unnumberedsec Attribute Value_Size
9636 @cindex @code{Size}, setting for not-first subtype
9637 @findex Value_Size
9638 @code{@var{type}'Value_Size} is the number of bits required to represent
9639 a value of the given subtype.  It is the same as @code{@var{type}'Size},
9640 but, unlike @code{Size}, may be set for non-first subtypes.
9642 @node Attribute Wchar_T_Size
9643 @unnumberedsec Attribute Wchar_T_Size
9644 @findex Wchar_T_Size
9645 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
9646 prefix) provides the size in bits of the C @code{wchar_t} type
9647 primarily for constructing the definition of this type in
9648 package @code{Interfaces.C}.
9650 @node Attribute Word_Size
9651 @unnumberedsec Attribute Word_Size
9652 @findex Word_Size
9653 @code{Standard'Word_Size} (@code{Standard} is the only permissible
9654 prefix) provides the value @code{System.Word_Size}.
9656 @node Standard and Implementation Defined Restrictions
9657 @chapter Standard and Implementation Defined Restrictions
9659 @noindent
9660 All RM defined Restriction identifiers are implemented:
9662 @itemize @bullet
9663 @item language-defined restrictions (see 13.12.1)
9664 @item tasking restrictions (see D.7)
9665 @item high integrity restrictions (see H.4)
9666 @end itemize
9668 @noindent
9669 GNAT implements additional restriction identifiers. All restrictions, whether
9670 language defined or GNAT-specific, are listed in the following.
9672 @menu
9673 * Partition-Wide Restrictions::
9674 * Program Unit Level Restrictions::
9675 @end menu
9677 @node Partition-Wide Restrictions
9678 @section Partition-Wide Restrictions
9680 There are two separate lists of restriction identifiers. The first
9681 set requires consistency throughout a partition (in other words, if the
9682 restriction identifier is used for any compilation unit in the partition,
9683 then all compilation units in the partition must obey the restriction).
9685 @menu
9686 * Immediate_Reclamation::
9687 * Max_Asynchronous_Select_Nesting::
9688 * Max_Entry_Queue_Length::
9689 * Max_Protected_Entries::
9690 * Max_Select_Alternatives::
9691 * Max_Storage_At_Blocking::
9692 * Max_Task_Entries::
9693 * Max_Tasks::
9694 * No_Abort_Statements::
9695 * No_Access_Parameter_Allocators::
9696 * No_Access_Subprograms::
9697 * No_Allocators::
9698 * No_Anonymous_Allocators::
9699 * No_Calendar::
9700 * No_Coextensions::
9701 * No_Default_Initialization::
9702 * No_Delay::
9703 * No_Dependence::
9704 * No_Direct_Boolean_Operators::
9705 * No_Dispatch::
9706 * No_Dispatching_Calls::
9707 * No_Dynamic_Attachment::
9708 * No_Dynamic_Priorities::
9709 * No_Entry_Calls_In_Elaboration_Code::
9710 * No_Enumeration_Maps::
9711 * No_Exception_Handlers::
9712 * No_Exception_Propagation::
9713 * No_Exception_Registration::
9714 * No_Exceptions::
9715 * No_Finalization::
9716 * No_Fixed_Point::
9717 * No_Floating_Point::
9718 * No_Implicit_Conditionals::
9719 * No_Implicit_Dynamic_Code::
9720 * No_Implicit_Heap_Allocations::
9721 * No_Implicit_Loops::
9722 * No_Initialize_Scalars::
9723 * No_IO::
9724 * No_Local_Allocators::
9725 * No_Local_Protected_Objects::
9726 * No_Local_Timing_Events::
9727 * No_Nested_Finalization::
9728 * No_Protected_Type_Allocators::
9729 * No_Protected_Types::
9730 * No_Recursion::
9731 * No_Reentrancy::
9732 * No_Relative_Delay::
9733 * No_Requeue_Statements::
9734 * No_Secondary_Stack::
9735 * No_Select_Statements::
9736 * No_Specific_Termination_Handlers::
9737 * No_Specification_of_Aspect::
9738 * No_Standard_Allocators_After_Elaboration::
9739 * No_Standard_Storage_Pools::
9740 * No_Stream_Optimizations::
9741 * No_Streams::
9742 * No_Task_Allocators::
9743 * No_Task_Attributes_Package::
9744 * No_Task_Hierarchy::
9745 * No_Task_Termination::
9746 * No_Tasking::
9747 * No_Terminate_Alternatives::
9748 * No_Unchecked_Access::
9749 * Simple_Barriers::
9750 * Static_Priorities::
9751 * Static_Storage_Size::
9752 @end menu
9754 @node Immediate_Reclamation
9755 @unnumberedsubsec Immediate_Reclamation
9756 @findex Immediate_Reclamation
9757 [RM H.4] This restriction ensures that, except for storage occupied by
9758 objects created by allocators and not deallocated via unchecked
9759 deallocation, any storage reserved at run time for an object is
9760 immediately reclaimed when the object no longer exists.
9762 @node Max_Asynchronous_Select_Nesting
9763 @unnumberedsubsec Max_Asynchronous_Select_Nesting
9764 @findex Max_Asynchronous_Select_Nesting
9765 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
9766 selects. Violations of this restriction with a value of zero are
9767 detected at compile time. Violations of this restriction with values
9768 other than zero cause Storage_Error to be raised.
9770 @node Max_Entry_Queue_Length
9771 @unnumberedsubsec Max_Entry_Queue_Length
9772 @findex Max_Entry_Queue_Length
9773 [RM D.7] This restriction is a declaration that any protected entry compiled in
9774 the scope of the restriction has at most the specified number of
9775 tasks waiting on the entry at any one time, and so no queue is required.
9776 Note that this restriction is checked at run time. Violation of this
9777 restriction results in the raising of Program_Error exception at the point of
9778 the call.
9780 @findex Max_Entry_Queue_Depth
9781 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
9782 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
9783 compatibility purposes (and a warning will be generated for its use if
9784 warnings on obsolescent features are activated).
9786 @node Max_Protected_Entries
9787 @unnumberedsubsec Max_Protected_Entries
9788 @findex Max_Protected_Entries
9789 [RM D.7] Specifies the maximum number of entries per protected type. The
9790 bounds of every entry family of a protected unit shall be static, or shall be
9791 defined by a discriminant of a subtype whose corresponding bound is static.
9793 @node Max_Select_Alternatives
9794 @unnumberedsubsec Max_Select_Alternatives
9795 @findex Max_Select_Alternatives
9796 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
9798 @node Max_Storage_At_Blocking
9799 @unnumberedsubsec Max_Storage_At_Blocking
9800 @findex Max_Storage_At_Blocking
9801 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
9802 Storage_Size that can be retained by a blocked task. A violation of this
9803 restriction causes Storage_Error to be raised.
9805 @node Max_Task_Entries
9806 @unnumberedsubsec Max_Task_Entries
9807 @findex Max_Task_Entries
9808 [RM D.7] Specifies the maximum number of entries
9809 per task.  The bounds of every entry family
9810 of a task unit shall be static, or shall be
9811 defined by a discriminant of a subtype whose
9812 corresponding bound is static.
9814 @node Max_Tasks
9815 @unnumberedsubsec Max_Tasks
9816 @findex Max_Tasks
9817 [RM D.7] Specifies the maximum number of task that may be created, not
9818 counting the creation of the environment task.  Violations of this
9819 restriction with a value of zero are detected at compile
9820 time. Violations of this restriction with values other than zero cause
9821 Storage_Error to be raised.
9823 @node No_Abort_Statements
9824 @unnumberedsubsec No_Abort_Statements
9825 @findex No_Abort_Statements
9826 [RM D.7] There are no abort_statements, and there are
9827 no calls to Task_Identification.Abort_Task.
9829 @node No_Access_Parameter_Allocators
9830 @unnumberedsubsec No_Access_Parameter_Allocators
9831 @findex No_Access_Parameter_Allocators
9832 [RM H.4] This restriction ensures at compile time that there are no
9833 occurrences of an allocator as the actual parameter to an access
9834 parameter.
9836 @node No_Access_Subprograms
9837 @unnumberedsubsec No_Access_Subprograms
9838 @findex No_Access_Subprograms
9839 [RM H.4] This restriction ensures at compile time that there are no
9840 declarations of access-to-subprogram types.
9842 @node No_Allocators
9843 @unnumberedsubsec No_Allocators
9844 @findex No_Allocators
9845 [RM H.4] This restriction ensures at compile time that there are no
9846 occurrences of an allocator.
9848 @node No_Anonymous_Allocators
9849 @unnumberedsubsec No_Anonymous_Allocators
9850 @findex No_Anonymous_Allocators
9851 [RM H.4] This restriction ensures at compile time that there are no
9852 occurrences of an allocator of anonymous access type.
9854 @node No_Calendar
9855 @unnumberedsubsec No_Calendar
9856 @findex No_Calendar
9857 [GNAT] This restriction ensures at compile time that there is no implicit or
9858 explicit dependence on the package @code{Ada.Calendar}.
9860 @node No_Coextensions
9861 @unnumberedsubsec No_Coextensions
9862 @findex No_Coextensions
9863 [RM H.4] This restriction ensures at compile time that there are no
9864 coextensions. See 3.10.2.
9866 @node No_Default_Initialization
9867 @unnumberedsubsec No_Default_Initialization
9868 @findex No_Default_Initialization
9870 [GNAT] This restriction prohibits any instance of default initialization
9871 of variables.  The binder implements a consistency rule which prevents
9872 any unit compiled without the restriction from with'ing a unit with the
9873 restriction (this allows the generation of initialization procedures to
9874 be skipped, since you can be sure that no call is ever generated to an
9875 initialization procedure in a unit with the restriction active). If used
9876 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
9877 is to prohibit all cases of variables declared without a specific
9878 initializer (including the case of OUT scalar parameters).
9880 @node No_Delay
9881 @unnumberedsubsec No_Delay
9882 @findex No_Delay
9883 [RM H.4] This restriction ensures at compile time that there are no
9884 delay statements and no dependences on package Calendar.
9886 @node No_Dependence
9887 @unnumberedsubsec No_Dependence
9888 @findex No_Dependence
9889 [RM 13.12.1] This restriction checks at compile time that there are no
9890 dependence on a library unit.
9892 @node No_Direct_Boolean_Operators
9893 @unnumberedsubsec No_Direct_Boolean_Operators
9894 @findex No_Direct_Boolean_Operators
9895 [GNAT] This restriction ensures that no logical operators (and/or/xor)
9896 are used on operands of type Boolean (or any type derived from Boolean).
9897 This is intended for use in safety critical programs where the certification
9898 protocol requires the use of short-circuit (and then, or else) forms for all
9899 composite boolean operations.
9901 @node No_Dispatch
9902 @unnumberedsubsec No_Dispatch
9903 @findex No_Dispatch
9904 [RM H.4] This restriction ensures at compile time that there are no
9905 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
9907 @node No_Dispatching_Calls
9908 @unnumberedsubsec No_Dispatching_Calls
9909 @findex No_Dispatching_Calls
9910 [GNAT] This restriction ensures at compile time that the code generated by the
9911 compiler involves no dispatching calls. The use of this restriction allows the
9912 safe use of record extensions, classwide membership tests and other classwide
9913 features not involving implicit dispatching. This restriction ensures that
9914 the code contains no indirect calls through a dispatching mechanism. Note that
9915 this includes internally-generated calls created by the compiler, for example
9916 in the implementation of class-wide objects assignments. The
9917 membership test is allowed in the presence of this restriction, because its
9918 implementation requires no dispatching.
9919 This restriction is comparable to the official Ada restriction
9920 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
9921 all classwide constructs that do not imply dispatching.
9922 The following example indicates constructs that violate this restriction.
9924 @smallexample
9925 package Pkg is
9926   type T is tagged record
9927     Data : Natural;
9928   end record;
9929   procedure P (X : T);
9931   type DT is new T with record
9932     More_Data : Natural;
9933   end record;
9934   procedure Q (X : DT);
9935 end Pkg;
9937 with Pkg; use Pkg;
9938 procedure Example is
9939   procedure Test (O : T'Class) is
9940     N : Natural  := O'Size;--  Error: Dispatching call
9941     C : T'Class := O;      --  Error: implicit Dispatching Call
9942   begin
9943     if O in DT'Class then  --  OK   : Membership test
9944        Q (DT (O));         --  OK   : Type conversion plus direct call
9945     else
9946        P (O);              --  Error: Dispatching call
9947     end if;
9948   end Test;
9950   Obj : DT;
9951 begin
9952   P (Obj);                 --  OK   : Direct call
9953   P (T (Obj));             --  OK   : Type conversion plus direct call
9954   P (T'Class (Obj));       --  Error: Dispatching call
9956   Test (Obj);              --  OK   : Type conversion
9958   if Obj in T'Class then   --  OK   : Membership test
9959      null;
9960   end if;
9961 end Example;
9962 @end smallexample
9964 @node No_Dynamic_Attachment
9965 @unnumberedsubsec No_Dynamic_Attachment
9966 @findex No_Dynamic_Attachment
9967 [RM D.7] This restriction ensures that there is no call to any of the
9968 operations defined in package Ada.Interrupts
9969 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
9970 Detach_Handler, and Reference).
9972 @findex No_Dynamic_Interrupts
9973 The restriction @code{No_Dynamic_Interrupts} is recognized as a
9974 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
9975 compatibility purposes (and a warning will be generated for its use if
9976 warnings on obsolescent features are activated).
9978 @node No_Dynamic_Priorities
9979 @unnumberedsubsec No_Dynamic_Priorities
9980 @findex No_Dynamic_Priorities
9981 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
9983 @node No_Entry_Calls_In_Elaboration_Code
9984 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
9985 @findex No_Entry_Calls_In_Elaboration_Code
9986 [GNAT] This restriction ensures at compile time that no task or protected entry
9987 calls are made during elaboration code.  As a result of the use of this
9988 restriction, the compiler can assume that no code past an accept statement
9989 in a task can be executed at elaboration time.
9991 @node No_Enumeration_Maps
9992 @unnumberedsubsec No_Enumeration_Maps
9993 @findex No_Enumeration_Maps
9994 [GNAT] This restriction ensures at compile time that no operations requiring
9995 enumeration maps are used (that is Image and Value attributes applied
9996 to enumeration types).
9998 @node No_Exception_Handlers
9999 @unnumberedsubsec No_Exception_Handlers
10000 @findex No_Exception_Handlers
10001 [GNAT] This restriction ensures at compile time that there are no explicit
10002 exception handlers. It also indicates that no exception propagation will
10003 be provided. In this mode, exceptions may be raised but will result in
10004 an immediate call to the last chance handler, a routine that the user
10005 must define with the following profile:
10007 @smallexample @c ada
10008 procedure Last_Chance_Handler
10009   (Source_Location : System.Address; Line : Integer);
10010 pragma Export (C, Last_Chance_Handler,
10011                "__gnat_last_chance_handler");
10012 @end smallexample
10014 The parameter is a C null-terminated string representing a message to be
10015 associated with the exception (typically the source location of the raise
10016 statement generated by the compiler). The Line parameter when nonzero
10017 represents the line number in the source program where the raise occurs.
10019 @node No_Exception_Propagation
10020 @unnumberedsubsec No_Exception_Propagation
10021 @findex No_Exception_Propagation
10022 [GNAT] This restriction guarantees that exceptions are never propagated
10023 to an outer subprogram scope. The only case in which an exception may
10024 be raised is when the handler is statically in the same subprogram, so
10025 that the effect of a raise is essentially like a goto statement. Any
10026 other raise statement (implicit or explicit) will be considered
10027 unhandled. Exception handlers are allowed, but may not contain an
10028 exception occurrence identifier (exception choice). In addition, use of
10029 the package GNAT.Current_Exception is not permitted, and reraise
10030 statements (raise with no operand) are not permitted.
10032 @node No_Exception_Registration
10033 @unnumberedsubsec No_Exception_Registration
10034 @findex No_Exception_Registration
10035 [GNAT] This restriction ensures at compile time that no stream operations for
10036 types Exception_Id or Exception_Occurrence are used. This also makes it
10037 impossible to pass exceptions to or from a partition with this restriction
10038 in a distributed environment. If this exception is active, then the generated
10039 code is simplified by omitting the otherwise-required global registration
10040 of exceptions when they are declared.
10042 @node No_Exceptions
10043 @unnumberedsubsec No_Exceptions
10044 @findex No_Exceptions
10045 [RM H.4] This restriction ensures at compile time that there are no
10046 raise statements and no exception handlers.
10048 @node No_Finalization
10049 @unnumberedsubsec No_Finalization
10050 @findex No_Finalization
10051 [GNAT] This restriction disables the language features described in
10052 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
10053 performed by the compiler to support these features. The following types
10054 are no longer considered controlled when this restriction is in effect:
10055 @itemize @bullet
10056 @item
10057 @code{Ada.Finalization.Controlled}
10058 @item
10059 @code{Ada.Finalization.Limited_Controlled}
10060 @item
10061 Derivations from @code{Controlled} or @code{Limited_Controlled}
10062 @item
10063 Class-wide types
10064 @item
10065 Protected types
10066 @item
10067 Task types
10068 @item
10069 Array and record types with controlled components
10070 @end itemize
10071 The compiler no longer generates code to initialize, finalize or adjust an
10072 object or a nested component, either declared on the stack or on the heap. The
10073 deallocation of a controlled object no longer finalizes its contents.
10075 @node No_Fixed_Point
10076 @unnumberedsubsec No_Fixed_Point
10077 @findex No_Fixed_Point
10078 [RM H.4] This restriction ensures at compile time that there are no
10079 occurrences of fixed point types and operations.
10081 @node No_Floating_Point
10082 @unnumberedsubsec No_Floating_Point
10083 @findex No_Floating_Point
10084 [RM H.4] This restriction ensures at compile time that there are no
10085 occurrences of floating point types and operations.
10087 @node No_Implicit_Conditionals
10088 @unnumberedsubsec No_Implicit_Conditionals
10089 @findex No_Implicit_Conditionals
10090 [GNAT] This restriction ensures that the generated code does not contain any
10091 implicit conditionals, either by modifying the generated code where possible,
10092 or by rejecting any construct that would otherwise generate an implicit
10093 conditional. Note that this check does not include run time constraint
10094 checks, which on some targets may generate implicit conditionals as
10095 well. To control the latter, constraint checks can be suppressed in the
10096 normal manner. Constructs generating implicit conditionals include comparisons
10097 of composite objects and the Max/Min attributes.
10099 @node No_Implicit_Dynamic_Code
10100 @unnumberedsubsec No_Implicit_Dynamic_Code
10101 @findex No_Implicit_Dynamic_Code
10102 @cindex trampoline
10103 [GNAT] This restriction prevents the compiler from building ``trampolines''.
10104 This is a structure that is built on the stack and contains dynamic
10105 code to be executed at run time. On some targets, a trampoline is
10106 built for the following features: @code{Access},
10107 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
10108 nested task bodies; primitive operations of nested tagged types.
10109 Trampolines do not work on machines that prevent execution of stack
10110 data. For example, on windows systems, enabling DEP (data execution
10111 protection) will cause trampolines to raise an exception.
10112 Trampolines are also quite slow at run time.
10114 On many targets, trampolines have been largely eliminated. Look at the
10115 version of system.ads for your target --- if it has
10116 Always_Compatible_Rep equal to False, then trampolines are largely
10117 eliminated. In particular, a trampoline is built for the following
10118 features: @code{Address} of a nested subprogram;
10119 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
10120 but only if pragma Favor_Top_Level applies, or the access type has a
10121 foreign-language convention; primitive operations of nested tagged
10122 types.
10124 @node No_Implicit_Heap_Allocations
10125 @unnumberedsubsec No_Implicit_Heap_Allocations
10126 @findex No_Implicit_Heap_Allocations
10127 [RM D.7] No constructs are allowed to cause implicit heap allocation.
10129 @node No_Implicit_Loops
10130 @unnumberedsubsec No_Implicit_Loops
10131 @findex No_Implicit_Loops
10132 [GNAT] This restriction ensures that the generated code does not contain any
10133 implicit @code{for} loops, either by modifying
10134 the generated code where possible,
10135 or by rejecting any construct that would otherwise generate an implicit
10136 @code{for} loop. If this restriction is active, it is possible to build
10137 large array aggregates with all static components without generating an
10138 intermediate temporary, and without generating a loop to initialize individual
10139 components. Otherwise, a loop is created for arrays larger than about 5000
10140 scalar components.
10142 @node No_Initialize_Scalars
10143 @unnumberedsubsec No_Initialize_Scalars
10144 @findex No_Initialize_Scalars
10145 [GNAT] This restriction ensures that no unit in the partition is compiled with
10146 pragma Initialize_Scalars. This allows the generation of more efficient
10147 code, and in particular eliminates dummy null initialization routines that
10148 are otherwise generated for some record and array types.
10150 @node No_IO
10151 @unnumberedsubsec No_IO
10152 @findex No_IO
10153 [RM H.4] This restriction ensures at compile time that there are no
10154 dependences on any of the library units Sequential_IO, Direct_IO,
10155 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
10157 @node No_Local_Allocators
10158 @unnumberedsubsec No_Local_Allocators
10159 @findex No_Local_Allocators
10160 [RM H.4] This restriction ensures at compile time that there are no
10161 occurrences of an allocator in subprograms, generic subprograms, tasks,
10162 and entry bodies.
10164 @node No_Local_Protected_Objects
10165 @unnumberedsubsec No_Local_Protected_Objects
10166 @findex No_Local_Protected_Objects
10167 [RM D.7] This restriction ensures at compile time that protected objects are
10168 only declared at the library level.
10170 @node No_Local_Timing_Events
10171 @unnumberedsubsec No_Local_Timing_Events
10172 @findex No_Local_Timing_Events
10173 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
10174 declared at the library level.
10176 @node No_Nested_Finalization
10177 @unnumberedsubsec No_Nested_Finalization
10178 @findex No_Nested_Finalization
10179 [RM D.7] All objects requiring finalization are declared at the library level.
10181 @node No_Protected_Type_Allocators
10182 @unnumberedsubsec No_Protected_Type_Allocators
10183 @findex No_Protected_Type_Allocators
10184 [RM D.7] This restriction ensures at compile time that there are no allocator
10185 expressions that attempt to allocate protected objects.
10187 @node No_Protected_Types
10188 @unnumberedsubsec No_Protected_Types
10189 @findex No_Protected_Types
10190 [RM H.4] This restriction ensures at compile time that there are no
10191 declarations of protected types or protected objects.
10193 @node No_Recursion
10194 @unnumberedsubsec No_Recursion
10195 @findex No_Recursion
10196 [RM H.4] A program execution is erroneous if a subprogram is invoked as
10197 part of its execution.
10199 @node No_Reentrancy
10200 @unnumberedsubsec No_Reentrancy
10201 @findex No_Reentrancy
10202 [RM H.4] A program execution is erroneous if a subprogram is executed by
10203 two tasks at the same time.
10205 @node No_Relative_Delay
10206 @unnumberedsubsec No_Relative_Delay
10207 @findex No_Relative_Delay
10208 [RM D.7] This restriction ensures at compile time that there are no delay
10209 relative statements and prevents expressions such as @code{delay 1.23;} from
10210 appearing in source code.
10212 @node No_Requeue_Statements
10213 @unnumberedsubsec No_Requeue_Statements
10214 @findex No_Requeue_Statements
10215 [RM D.7] This restriction ensures at compile time that no requeue statements
10216 are permitted and prevents keyword @code{requeue} from being used in source
10217 code.
10219 @findex No_Requeue
10220 The restriction @code{No_Requeue} is recognized as a
10221 synonym for @code{No_Requeue_Statements}. This is retained for historical
10222 compatibility purposes (and a warning will be generated for its use if
10223 warnings on oNobsolescent features are activated).
10225 @node No_Secondary_Stack
10226 @unnumberedsubsec No_Secondary_Stack
10227 @findex No_Secondary_Stack
10228 [GNAT] This restriction ensures at compile time that the generated code
10229 does not contain any reference to the secondary stack.  The secondary
10230 stack is used to implement functions returning unconstrained objects
10231 (arrays or records) on some targets.
10233 @node No_Select_Statements
10234 @unnumberedsubsec No_Select_Statements
10235 @findex No_Select_Statements
10236 [RM D.7] This restriction ensures at compile time no select statements of any
10237 kind are permitted, that is the keyword @code{select} may not appear.
10239 @node No_Specific_Termination_Handlers
10240 @unnumberedsubsec No_Specific_Termination_Handlers
10241 @findex No_Specific_Termination_Handlers
10242 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
10243 or to Ada.Task_Termination.Specific_Handler.
10245 @node No_Specification_of_Aspect
10246 @unnumberedsubsec No_Specification_of_Aspect
10247 @findex No_Specification_of_Aspect
10248 [RM 13.12.1] This restriction checks at compile time that no aspect
10249 specification, attribute definition clause, or pragma is given for a
10250 given aspect.
10252 @node No_Standard_Allocators_After_Elaboration
10253 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
10254 @findex No_Standard_Allocators_After_Elaboration
10255 [RM D.7] Specifies that an allocator using a standard storage pool
10256 should never be evaluated at run time after the elaboration of the
10257 library items of the partition has completed. Otherwise, Storage_Error
10258 is raised.
10260 @node No_Standard_Storage_Pools
10261 @unnumberedsubsec No_Standard_Storage_Pools
10262 @findex No_Standard_Storage_Pools
10263 [GNAT] This restriction ensures at compile time that no access types
10264 use the standard default storage pool.  Any access type declared must
10265 have an explicit Storage_Pool attribute defined specifying a
10266 user-defined storage pool.
10268 @node No_Stream_Optimizations
10269 @unnumberedsubsec No_Stream_Optimizations
10270 @findex No_Stream_Optimizations
10271 [GNAT] This restriction affects the performance of stream operations on types
10272 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
10273 compiler uses block reads and writes when manipulating @code{String} objects
10274 due to their supperior performance. When this restriction is in effect, the
10275 compiler performs all IO operations on a per-character basis.
10277 @node No_Streams
10278 @unnumberedsubsec No_Streams
10279 @findex No_Streams
10280 [GNAT] This restriction ensures at compile/bind time that there are no
10281 stream objects created and no use of stream attributes.
10282 This restriction does not forbid dependences on the package
10283 @code{Ada.Streams}. So it is permissible to with
10284 @code{Ada.Streams} (or another package that does so itself)
10285 as long as no actual stream objects are created and no
10286 stream attributes are used.
10288 Note that the use of restriction allows optimization of tagged types,
10289 since they do not need to worry about dispatching stream operations.
10290 To take maximum advantage of this space-saving optimization, any
10291 unit declaring a tagged type should be compiled with the restriction,
10292 though this is not required.
10294 @node No_Task_Allocators
10295 @unnumberedsubsec No_Task_Allocators
10296 @findex No_Task_Allocators
10297 [RM D.7] There are no allocators for task types
10298 or types containing task subcomponents.
10300 @node No_Task_Attributes_Package
10301 @unnumberedsubsec No_Task_Attributes_Package
10302 @findex No_Task_Attributes_Package
10303 [GNAT] This restriction ensures at compile time that there are no implicit or
10304 explicit dependencies on the package @code{Ada.Task_Attributes}.
10306 @findex No_Task_Attributes
10307 The restriction @code{No_Task_Attributes} is recognized as a synonym
10308 for @code{No_Task_Attributes_Package}. This is retained for historical
10309 compatibility purposes (and a warning will be generated for its use if
10310 warnings on obsolescent features are activated).
10312 @node No_Task_Hierarchy
10313 @unnumberedsubsec No_Task_Hierarchy
10314 @findex No_Task_Hierarchy
10315 [RM D.7] All (non-environment) tasks depend
10316 directly on the environment task of the partition.
10318 @node No_Task_Termination
10319 @unnumberedsubsec No_Task_Termination
10320 @findex No_Task_Termination
10321 [RM D.7] Tasks which terminate are erroneous.
10323 @node No_Tasking
10324 @unnumberedsubsec No_Tasking
10325 @findex No_Tasking
10326 [GNAT] This restriction prevents the declaration of tasks or task types
10327 throughout the partition.  It is similar in effect to the use of
10328 @code{Max_Tasks => 0} except that violations are caught at compile time
10329 and cause an error message to be output either by the compiler or
10330 binder.
10332 @node No_Terminate_Alternatives
10333 @unnumberedsubsec No_Terminate_Alternatives
10334 @findex No_Terminate_Alternatives
10335 [RM D.7] There are no selective accepts with terminate alternatives.
10337 @node No_Unchecked_Access
10338 @unnumberedsubsec No_Unchecked_Access
10339 @findex No_Unchecked_Access
10340 [RM H.4] This restriction ensures at compile time that there are no
10341 occurrences of the Unchecked_Access attribute.
10343 @node Simple_Barriers
10344 @unnumberedsubsec Simple_Barriers
10345 @findex Simple_Barriers
10346 [RM D.7] This restriction ensures at compile time that barriers in entry
10347 declarations for protected types are restricted to either static boolean
10348 expressions or references to simple boolean variables defined in the private
10349 part of the protected type.  No other form of entry barriers is permitted.
10351 @findex Boolean_Entry_Barriers
10352 The restriction @code{Boolean_Entry_Barriers} is recognized as a
10353 synonym for @code{Simple_Barriers}. This is retained for historical
10354 compatibility purposes (and a warning will be generated for its use if
10355 warnings on obsolescent features are activated).
10357 @node Static_Priorities
10358 @unnumberedsubsec Static_Priorities
10359 @findex Static_Priorities
10360 [GNAT] This restriction ensures at compile time that all priority expressions
10361 are static, and that there are no dependences on the package
10362 @code{Ada.Dynamic_Priorities}.
10364 @node Static_Storage_Size
10365 @unnumberedsubsec Static_Storage_Size
10366 @findex Static_Storage_Size
10367 [GNAT] This restriction ensures at compile time that any expression appearing
10368 in a Storage_Size pragma or attribute definition clause is static.
10370 @node Program Unit Level Restrictions
10371 @section Program Unit Level Restrictions
10373 @noindent
10374 The second set of restriction identifiers
10375 does not require partition-wide consistency.
10376 The restriction may be enforced for a single
10377 compilation unit without any effect on any of the
10378 other compilation units in the partition.
10380 @menu
10381 * No_Elaboration_Code::
10382 * No_Entry_Queue::
10383 * No_Implementation_Aspect_Specifications::
10384 * No_Implementation_Attributes::
10385 * No_Implementation_Identifiers::
10386 * No_Implementation_Pragmas::
10387 * No_Implementation_Restrictions::
10388 * No_Implementation_Units::
10389 * No_Implicit_Aliasing::
10390 * No_Obsolescent_Features::
10391 * No_Wide_Characters::
10392 * SPARK_05::
10393 @end menu
10395 @node No_Elaboration_Code
10396 @unnumberedsubsec No_Elaboration_Code
10397 @findex No_Elaboration_Code
10398 [GNAT] This restriction ensures at compile time that no elaboration code is
10399 generated.  Note that this is not the same condition as is enforced
10400 by pragma @code{Preelaborate}.  There are cases in which pragma
10401 @code{Preelaborate} still permits code to be generated (e.g.@: code
10402 to initialize a large array to all zeroes), and there are cases of units
10403 which do not meet the requirements for pragma @code{Preelaborate},
10404 but for which no elaboration code is generated.  Generally, it is
10405 the case that preelaborable units will meet the restrictions, with
10406 the exception of large aggregates initialized with an others_clause,
10407 and exception declarations (which generate calls to a run-time
10408 registry procedure).  This restriction is enforced on
10409 a unit by unit basis, it need not be obeyed consistently
10410 throughout a partition.
10412 In the case of aggregates with others, if the aggregate has a dynamic
10413 size, there is no way to eliminate the elaboration code (such dynamic
10414 bounds would be incompatible with @code{Preelaborate} in any case). If
10415 the bounds are static, then use of this restriction actually modifies
10416 the code choice of the compiler to avoid generating a loop, and instead
10417 generate the aggregate statically if possible, no matter how many times
10418 the data for the others clause must be repeatedly generated.
10420 It is not possible to precisely document
10421 the constructs which are compatible with this restriction, since,
10422 unlike most other restrictions, this is not a restriction on the
10423 source code, but a restriction on the generated object code. For
10424 example, if the source contains a declaration:
10426 @smallexample
10427    Val : constant Integer := X;
10428 @end smallexample
10430 @noindent
10431 where X is not a static constant, it may be possible, depending
10432 on complex optimization circuitry, for the compiler to figure
10433 out the value of X at compile time, in which case this initialization
10434 can be done by the loader, and requires no initialization code. It
10435 is not possible to document the precise conditions under which the
10436 optimizer can figure this out.
10438 Note that this the implementation of this restriction requires full
10439 code generation. If it is used in conjunction with "semantics only"
10440 checking, then some cases of violations may be missed.
10442 @node No_Entry_Queue
10443 @unnumberedsubsec No_Entry_Queue
10444 @findex No_Entry_Queue
10445 [GNAT] This restriction is a declaration that any protected entry compiled in
10446 the scope of the restriction has at most one task waiting on the entry
10447 at any one time, and so no queue is required.  This restriction is not
10448 checked at compile time.  A program execution is erroneous if an attempt
10449 is made to queue a second task on such an entry.
10451 @node No_Implementation_Aspect_Specifications
10452 @unnumberedsubsec No_Implementation_Aspect_Specifications
10453 @findex No_Implementation_Aspect_Specifications
10454 [RM 13.12.1] This restriction checks at compile time that no
10455 GNAT-defined aspects are present.  With this restriction, the only
10456 aspects that can be used are those defined in the Ada Reference Manual.
10458 @node No_Implementation_Attributes
10459 @unnumberedsubsec No_Implementation_Attributes
10460 @findex No_Implementation_Attributes
10461 [RM 13.12.1] This restriction checks at compile time that no
10462 GNAT-defined attributes are present.  With this restriction, the only
10463 attributes that can be used are those defined in the Ada Reference
10464 Manual.
10466 @node No_Implementation_Identifiers
10467 @unnumberedsubsec No_Implementation_Identifiers
10468 @findex No_Implementation_Identifiers
10469 [RM 13.12.1] This restriction checks at compile time that no
10470 implementation-defined identifiers (marked with pragma Implementation_Defined)
10471 occur within language-defined packages.
10473 @node No_Implementation_Pragmas
10474 @unnumberedsubsec No_Implementation_Pragmas
10475 @findex No_Implementation_Pragmas
10476 [RM 13.12.1] This restriction checks at compile time that no
10477 GNAT-defined pragmas are present.  With this restriction, the only
10478 pragmas that can be used are those defined in the Ada Reference Manual.
10480 @node No_Implementation_Restrictions
10481 @unnumberedsubsec No_Implementation_Restrictions
10482 @findex No_Implementation_Restrictions
10483 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
10484 identifiers (other than @code{No_Implementation_Restrictions} itself)
10485 are present.  With this restriction, the only other restriction identifiers
10486 that can be used are those defined in the Ada Reference Manual.
10488 @node No_Implementation_Units
10489 @unnumberedsubsec No_Implementation_Units
10490 @findex No_Implementation_Units
10491 [RM 13.12.1] This restriction checks at compile time that there is no
10492 mention in the context clause of any implementation-defined descendants
10493 of packages Ada, Interfaces, or System.
10495 @node No_Implicit_Aliasing
10496 @unnumberedsubsec No_Implicit_Aliasing
10497 @findex No_Implicit_Aliasing
10498 [GNAT] This restriction, which is not required to be partition-wide consistent,
10499 requires an explicit aliased keyword for an object to which 'Access,
10500 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
10501 the 'Unrestricted_Access attribute for objects. Note: the reason that
10502 Unrestricted_Access is forbidden is that it would require the prefix
10503 to be aliased, and in such cases, it can always be replaced by
10504 the standard attribute Unchecked_Access which is preferable.
10506 @node No_Obsolescent_Features
10507 @unnumberedsubsec No_Obsolescent_Features
10508 @findex No_Obsolescent_Features
10509 [RM 13.12.1] This restriction checks at compile time that no obsolescent
10510 features are used, as defined in Annex J of the Ada Reference Manual.
10512 @node No_Wide_Characters
10513 @unnumberedsubsec No_Wide_Characters
10514 @findex No_Wide_Characters
10515 [GNAT] This restriction ensures at compile time that no uses of the types
10516 @code{Wide_Character} or @code{Wide_String} or corresponding wide
10517 wide types
10518 appear, and that no wide or wide wide string or character literals
10519 appear in the program (that is literals representing characters not in
10520 type @code{Character}).
10522 @node SPARK_05
10523 @unnumberedsubsec SPARK_05
10524 @findex SPARK_05
10525 [GNAT] This restriction checks at compile time that some constructs
10526 forbidden in SPARK 2005 are not present. Error messages related to
10527 SPARK restriction have the form:
10529 @findex SPARK
10530 The restriction @code{SPARK} is recognized as a
10531 synonym for @code{SPARK_05}. This is retained for historical
10532 compatibility purposes (and an unconditional warning will be generated
10533 for its use, advising replacement by @code{SPARK}.
10535 @smallexample
10536 violation of restriction "SPARK" at <file>
10537  <error message>
10538 @end smallexample
10540 This is not a replacement for the semantic checks performed by the
10541 SPARK Examiner tool, as the compiler only deals currently with code,
10542 not at all with SPARK 2005 annotations and does not guarantee catching all
10543 cases of constructs forbidden by SPARK 2005.
10545 Thus it may well be the case that code which passes the compiler with
10546 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
10547 the different visibility rules of the Examiner based on SPARK 2005
10548 @code{inherit} annotations.
10550 This restriction can be useful in providing an initial filter for code
10551 developed using SPARK 2005, or in examining legacy code to see how far
10552 it is from meeting SPARK restrictions.
10554 Note that if a unit is compiled in Ada 95 mode with SPARK restriction,
10555 violations will be reported for constructs forbidden in SPARK 95,
10556 instead of SPARK 2005.
10558 @c ------------------------
10559 @node Implementation Advice
10560 @chapter Implementation Advice
10561 @noindent
10562 The main text of the Ada Reference Manual describes the required
10563 behavior of all Ada compilers, and the GNAT compiler conforms to
10564 these requirements.
10566 In addition, there are sections throughout the Ada Reference Manual headed
10567 by the phrase ``Implementation advice''.  These sections are not normative,
10568 i.e., they do not specify requirements that all compilers must
10569 follow.  Rather they provide advice on generally desirable behavior.  You
10570 may wonder why they are not requirements.  The most typical answer is
10571 that they describe behavior that seems generally desirable, but cannot
10572 be provided on all systems, or which may be undesirable on some systems.
10574 As far as practical, GNAT follows the implementation advice sections in
10575 the Ada Reference Manual.  This chapter contains a table giving the
10576 reference manual section number, paragraph number and several keywords
10577 for each advice.  Each entry consists of the text of the advice followed
10578 by the GNAT interpretation of this advice.  Most often, this simply says
10579 ``followed'', which means that GNAT follows the advice.  However, in a
10580 number of cases, GNAT deliberately deviates from this advice, in which
10581 case the text describes what GNAT does and why.
10583 @cindex Error detection
10584 @unnumberedsec 1.1.3(20): Error Detection
10585 @sp 1
10586 @cartouche
10587 If an implementation detects the use of an unsupported Specialized Needs
10588 Annex feature at run time, it should raise @code{Program_Error} if
10589 feasible.
10590 @end cartouche
10591 Not relevant.  All specialized needs annex features are either supported,
10592 or diagnosed at compile time.
10594 @cindex Child Units
10595 @unnumberedsec 1.1.3(31): Child Units
10596 @sp 1
10597 @cartouche
10598 If an implementation wishes to provide implementation-defined
10599 extensions to the functionality of a language-defined library unit, it
10600 should normally do so by adding children to the library unit.
10601 @end cartouche
10602 Followed.
10604 @cindex Bounded errors
10605 @unnumberedsec 1.1.5(12): Bounded Errors
10606 @sp 1
10607 @cartouche
10608 If an implementation detects a bounded error or erroneous
10609 execution, it should raise @code{Program_Error}.
10610 @end cartouche
10611 Followed in all cases in which the implementation detects a bounded
10612 error or erroneous execution.  Not all such situations are detected at
10613 runtime.
10615 @cindex Pragmas
10616 @unnumberedsec 2.8(16): Pragmas
10617 @sp 1
10618 @cartouche
10619 Normally, implementation-defined pragmas should have no semantic effect
10620 for error-free programs; that is, if the implementation-defined pragmas
10621 are removed from a working program, the program should still be legal,
10622 and should still have the same semantics.
10623 @end cartouche
10624 The following implementation defined pragmas are exceptions to this
10625 rule:
10627 @table @code
10628 @item Abort_Defer
10629 Affects semantics
10630 @item Ada_83
10631 Affects legality
10632 @item Assert
10633 Affects semantics
10634 @item CPP_Class
10635 Affects semantics
10636 @item CPP_Constructor
10637 Affects semantics
10638 @item Debug
10639 Affects semantics
10640 @item Interface_Name
10641 Affects semantics
10642 @item Machine_Attribute
10643 Affects semantics
10644 @item Unimplemented_Unit
10645 Affects legality
10646 @item Unchecked_Union
10647 Affects semantics
10648 @end table
10650 @noindent
10651 In each of the above cases, it is essential to the purpose of the pragma
10652 that this advice not be followed.  For details see the separate section
10653 on implementation defined pragmas.
10655 @unnumberedsec 2.8(17-19): Pragmas
10656 @sp 1
10657 @cartouche
10658 Normally, an implementation should not define pragmas that can
10659 make an illegal program legal, except as follows:
10660 @end cartouche
10661 @sp 1
10662 @cartouche
10663 A pragma used to complete a declaration, such as a pragma @code{Import};
10664 @end cartouche
10665 @sp 1
10666 @cartouche
10667 A pragma used to configure the environment by adding, removing, or
10668 replacing @code{library_items}.
10669 @end cartouche
10670 See response to paragraph 16 of this same section.
10672 @cindex Character Sets
10673 @cindex Alternative Character Sets
10674 @unnumberedsec 3.5.2(5): Alternative Character Sets
10675 @sp 1
10676 @cartouche
10677 If an implementation supports a mode with alternative interpretations
10678 for @code{Character} and @code{Wide_Character}, the set of graphic
10679 characters of @code{Character} should nevertheless remain a proper
10680 subset of the set of graphic characters of @code{Wide_Character}.  Any
10681 character set ``localizations'' should be reflected in the results of
10682 the subprograms defined in the language-defined package
10683 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
10684 an alternative interpretation of @code{Character}, the implementation should
10685 also support a corresponding change in what is a legal
10686 @code{identifier_letter}.
10687 @end cartouche
10688 Not all wide character modes follow this advice, in particular the JIS
10689 and IEC modes reflect standard usage in Japan, and in these encoding,
10690 the upper half of the Latin-1 set is not part of the wide-character
10691 subset, since the most significant bit is used for wide character
10692 encoding.  However, this only applies to the external forms.  Internally
10693 there is no such restriction.
10695 @cindex Integer types
10696 @unnumberedsec 3.5.4(28): Integer Types
10698 @sp 1
10699 @cartouche
10700 An implementation should support @code{Long_Integer} in addition to
10701 @code{Integer} if the target machine supports 32-bit (or longer)
10702 arithmetic.  No other named integer subtypes are recommended for package
10703 @code{Standard}.  Instead, appropriate named integer subtypes should be
10704 provided in the library package @code{Interfaces} (see B.2).
10705 @end cartouche
10706 @code{Long_Integer} is supported.  Other standard integer types are supported
10707 so this advice is not fully followed.  These types
10708 are supported for convenient interface to C, and so that all hardware
10709 types of the machine are easily available.
10710 @unnumberedsec 3.5.4(29): Integer Types
10712 @sp 1
10713 @cartouche
10714 An implementation for a two's complement machine should support
10715 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
10716 implementation should support a non-binary modules up to @code{Integer'Last}.
10717 @end cartouche
10718 Followed.
10720 @cindex Enumeration values
10721 @unnumberedsec 3.5.5(8): Enumeration Values
10722 @sp 1
10723 @cartouche
10724 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
10725 subtype, if the value of the operand does not correspond to the internal
10726 code for any enumeration literal of its type (perhaps due to an
10727 un-initialized variable), then the implementation should raise
10728 @code{Program_Error}.  This is particularly important for enumeration
10729 types with noncontiguous internal codes specified by an
10730 enumeration_representation_clause.
10731 @end cartouche
10732 Followed.
10734 @cindex Float types
10735 @unnumberedsec 3.5.7(17): Float Types
10736 @sp 1
10737 @cartouche
10738 An implementation should support @code{Long_Float} in addition to
10739 @code{Float} if the target machine supports 11 or more digits of
10740 precision.  No other named floating point subtypes are recommended for
10741 package @code{Standard}.  Instead, appropriate named floating point subtypes
10742 should be provided in the library package @code{Interfaces} (see B.2).
10743 @end cartouche
10744 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
10745 former provides improved compatibility with other implementations
10746 supporting this type.  The latter corresponds to the highest precision
10747 floating-point type supported by the hardware.  On most machines, this
10748 will be the same as @code{Long_Float}, but on some machines, it will
10749 correspond to the IEEE extended form.  The notable case is all ia32
10750 (x86) implementations, where @code{Long_Long_Float} corresponds to
10751 the 80-bit extended precision format supported in hardware on this
10752 processor.  Note that the 128-bit format on SPARC is not supported,
10753 since this is a software rather than a hardware format.
10755 @cindex Multidimensional arrays
10756 @cindex Arrays, multidimensional
10757 @unnumberedsec 3.6.2(11): Multidimensional Arrays
10758 @sp 1
10759 @cartouche
10760 An implementation should normally represent multidimensional arrays in
10761 row-major order, consistent with the notation used for multidimensional
10762 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
10763 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
10764 column-major order should be used instead (see B.5, ``Interfacing with
10765 Fortran'').
10766 @end cartouche
10767 Followed.
10769 @findex Duration'Small
10770 @unnumberedsec 9.6(30-31): Duration'Small
10771 @sp 1
10772 @cartouche
10773 Whenever possible in an implementation, the value of @code{Duration'Small}
10774 should be no greater than 100 microseconds.
10775 @end cartouche
10776 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
10778 @sp 1
10779 @cartouche
10780 The time base for @code{delay_relative_statements} should be monotonic;
10781 it need not be the same time base as used for @code{Calendar.Clock}.
10782 @end cartouche
10783 Followed.
10785 @unnumberedsec 10.2.1(12): Consistent Representation
10786 @sp 1
10787 @cartouche
10788 In an implementation, a type declared in a pre-elaborated package should
10789 have the same representation in every elaboration of a given version of
10790 the package, whether the elaborations occur in distinct executions of
10791 the same program, or in executions of distinct programs or partitions
10792 that include the given version.
10793 @end cartouche
10794 Followed, except in the case of tagged types.  Tagged types involve
10795 implicit pointers to a local copy of a dispatch table, and these pointers
10796 have representations which thus depend on a particular elaboration of the
10797 package.  It is not easy to see how it would be possible to follow this
10798 advice without severely impacting efficiency of execution.
10800 @cindex Exception information
10801 @unnumberedsec 11.4.1(19): Exception Information
10802 @sp 1
10803 @cartouche
10804 @code{Exception_Message} by default and @code{Exception_Information}
10805 should produce information useful for
10806 debugging.  @code{Exception_Message} should be short, about one
10807 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
10808 should not include the
10809 @code{Exception_Name}.  @code{Exception_Information} should include both
10810 the @code{Exception_Name} and the @code{Exception_Message}.
10811 @end cartouche
10812 Followed.  For each exception that doesn't have a specified
10813 @code{Exception_Message}, the compiler generates one containing the location
10814 of the raise statement.  This location has the form ``file:line'', where
10815 file is the short file name (without path information) and line is the line
10816 number in the file.  Note that in the case of the Zero Cost Exception
10817 mechanism, these messages become redundant with the Exception_Information that
10818 contains a full backtrace of the calling sequence, so they are disabled.
10819 To disable explicitly the generation of the source location message, use the
10820 Pragma @code{Discard_Names}.
10822 @cindex Suppression of checks
10823 @cindex Checks, suppression of
10824 @unnumberedsec 11.5(28): Suppression of Checks
10825 @sp 1
10826 @cartouche
10827 The implementation should minimize the code executed for checks that
10828 have been suppressed.
10829 @end cartouche
10830 Followed.
10832 @cindex Representation clauses
10833 @unnumberedsec 13.1 (21-24): Representation Clauses
10834 @sp 1
10835 @cartouche
10836 The recommended level of support for all representation items is
10837 qualified as follows:
10838 @end cartouche
10839 @sp 1
10840 @cartouche
10841 An implementation need not support representation items containing
10842 non-static expressions, except that an implementation should support a
10843 representation item for a given entity if each non-static expression in
10844 the representation item is a name that statically denotes a constant
10845 declared before the entity.
10846 @end cartouche
10847 Followed.  In fact, GNAT goes beyond the recommended level of support
10848 by allowing nonstatic expressions in some representation clauses even
10849 without the need to declare constants initialized with the values of
10850 such expressions.
10851 For example:
10853 @smallexample @c ada
10854   X : Integer;
10855   Y : Float;
10856   for Y'Address use X'Address;>>
10857 @end smallexample
10859 @sp 1
10860 @cartouche
10861 An implementation need not support a specification for the @code{Size}
10862 for a given composite subtype, nor the size or storage place for an
10863 object (including a component) of a given composite subtype, unless the
10864 constraints on the subtype and its composite subcomponents (if any) are
10865 all static constraints.
10866 @end cartouche
10867 Followed.  Size Clauses are not permitted on non-static components, as
10868 described above.
10870 @sp 1
10871 @cartouche
10872 An aliased component, or a component whose type is by-reference, should
10873 always be allocated at an addressable location.
10874 @end cartouche
10875 Followed.
10877 @cindex Packed types
10878 @unnumberedsec 13.2(6-8): Packed Types
10879 @sp 1
10880 @cartouche
10881 If a type is packed, then the implementation should try to minimize
10882 storage allocated to objects of the type, possibly at the expense of
10883 speed of accessing components, subject to reasonable complexity in
10884 addressing calculations.
10885 @end cartouche
10886 @sp 1
10887 @cartouche
10888 The recommended level of support pragma @code{Pack} is:
10890 For a packed record type, the components should be packed as tightly as
10891 possible subject to the Sizes of the component subtypes, and subject to
10892 any @code{record_representation_clause} that applies to the type; the
10893 implementation may, but need not, reorder components or cross aligned
10894 word boundaries to improve the packing.  A component whose @code{Size} is
10895 greater than the word size may be allocated an integral number of words.
10896 @end cartouche
10897 Followed.  Tight packing of arrays is supported for all component sizes
10898 up to 64-bits. If the array component size is 1 (that is to say, if
10899 the component is a boolean type or an enumeration type with two values)
10900 then values of the type are implicitly initialized to zero. This
10901 happens both for objects of the packed type, and for objects that have a
10902 subcomponent of the packed type.
10904 @sp 1
10905 @cartouche
10906 An implementation should support Address clauses for imported
10907 subprograms.
10908 @end cartouche
10909 Followed.
10910 @cindex @code{Address} clauses
10911 @unnumberedsec 13.3(14-19): Address Clauses
10913 @sp 1
10914 @cartouche
10915 For an array @var{X}, @code{@var{X}'Address} should point at the first
10916 component of the array, and not at the array bounds.
10917 @end cartouche
10918 Followed.
10920 @sp 1
10921 @cartouche
10922 The recommended level of support for the @code{Address} attribute is:
10924 @code{@var{X}'Address} should produce a useful result if @var{X} is an
10925 object that is aliased or of a by-reference type, or is an entity whose
10926 @code{Address} has been specified.
10927 @end cartouche
10928 Followed.  A valid address will be produced even if none of those
10929 conditions have been met.  If necessary, the object is forced into
10930 memory to ensure the address is valid.
10932 @sp 1
10933 @cartouche
10934 An implementation should support @code{Address} clauses for imported
10935 subprograms.
10936 @end cartouche
10937 Followed.
10939 @sp 1
10940 @cartouche
10941 Objects (including subcomponents) that are aliased or of a by-reference
10942 type should be allocated on storage element boundaries.
10943 @end cartouche
10944 Followed.
10946 @sp 1
10947 @cartouche
10948 If the @code{Address} of an object is specified, or it is imported or exported,
10949 then the implementation should not perform optimizations based on
10950 assumptions of no aliases.
10951 @end cartouche
10952 Followed.
10954 @cindex @code{Alignment} clauses
10955 @unnumberedsec 13.3(29-35): Alignment Clauses
10956 @sp 1
10957 @cartouche
10958 The recommended level of support for the @code{Alignment} attribute for
10959 subtypes is:
10961 An implementation should support specified Alignments that are factors
10962 and multiples of the number of storage elements per word, subject to the
10963 following:
10964 @end cartouche
10965 Followed.
10967 @sp 1
10968 @cartouche
10969 An implementation need not support specified @code{Alignment}s for
10970 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
10971 loaded and stored by available machine instructions.
10972 @end cartouche
10973 Followed.
10975 @sp 1
10976 @cartouche
10977 An implementation need not support specified @code{Alignment}s that are
10978 greater than the maximum @code{Alignment} the implementation ever returns by
10979 default.
10980 @end cartouche
10981 Followed.
10983 @sp 1
10984 @cartouche
10985 The recommended level of support for the @code{Alignment} attribute for
10986 objects is:
10988 Same as above, for subtypes, but in addition:
10989 @end cartouche
10990 Followed.
10992 @sp 1
10993 @cartouche
10994 For stand-alone library-level objects of statically constrained
10995 subtypes, the implementation should support all @code{Alignment}s
10996 supported by the target linker.  For example, page alignment is likely to
10997 be supported for such objects, but not for subtypes.
10998 @end cartouche
10999 Followed.
11001 @cindex @code{Size} clauses
11002 @unnumberedsec 13.3(42-43): Size Clauses
11003 @sp 1
11004 @cartouche
11005 The recommended level of support for the @code{Size} attribute of
11006 objects is:
11008 A @code{Size} clause should be supported for an object if the specified
11009 @code{Size} is at least as large as its subtype's @code{Size}, and
11010 corresponds to a size in storage elements that is a multiple of the
11011 object's @code{Alignment} (if the @code{Alignment} is nonzero).
11012 @end cartouche
11013 Followed.
11015 @unnumberedsec 13.3(50-56): Size Clauses
11016 @sp 1
11017 @cartouche
11018 If the @code{Size} of a subtype is specified, and allows for efficient
11019 independent addressability (see 9.10) on the target architecture, then
11020 the @code{Size} of the following objects of the subtype should equal the
11021 @code{Size} of the subtype:
11023 Aliased objects (including components).
11024 @end cartouche
11025 Followed.
11027 @sp 1
11028 @cartouche
11029 @code{Size} clause on a composite subtype should not affect the
11030 internal layout of components.
11031 @end cartouche
11032 Followed. But note that this can be overridden by use of the implementation
11033 pragma Implicit_Packing in the case of packed arrays.
11035 @sp 1
11036 @cartouche
11037 The recommended level of support for the @code{Size} attribute of subtypes is:
11038 @end cartouche
11039 @sp 1
11040 @cartouche
11041 The @code{Size} (if not specified) of a static discrete or fixed point
11042 subtype should be the number of bits needed to represent each value
11043 belonging to the subtype using an unbiased representation, leaving space
11044 for a sign bit only if the subtype contains negative values.  If such a
11045 subtype is a first subtype, then an implementation should support a
11046 specified @code{Size} for it that reflects this representation.
11047 @end cartouche
11048 Followed.
11050 @sp 1
11051 @cartouche
11052 For a subtype implemented with levels of indirection, the @code{Size}
11053 should include the size of the pointers, but not the size of what they
11054 point at.
11055 @end cartouche
11056 Followed.
11058 @cindex @code{Component_Size} clauses
11059 @unnumberedsec 13.3(71-73): Component Size Clauses
11060 @sp 1
11061 @cartouche
11062 The recommended level of support for the @code{Component_Size}
11063 attribute is:
11064 @end cartouche
11065 @sp 1
11066 @cartouche
11067 An implementation need not support specified @code{Component_Sizes} that are
11068 less than the @code{Size} of the component subtype.
11069 @end cartouche
11070 Followed.
11072 @sp 1
11073 @cartouche
11074 An implementation should support specified @code{Component_Size}s that
11075 are factors and multiples of the word size.  For such
11076 @code{Component_Size}s, the array should contain no gaps between
11077 components.  For other @code{Component_Size}s (if supported), the array
11078 should contain no gaps between components when packing is also
11079 specified; the implementation should forbid this combination in cases
11080 where it cannot support a no-gaps representation.
11081 @end cartouche
11082 Followed.
11084 @cindex Enumeration representation clauses
11085 @cindex Representation clauses, enumeration
11086 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
11087 @sp 1
11088 @cartouche
11089 The recommended level of support for enumeration representation clauses
11092 An implementation need not support enumeration representation clauses
11093 for boolean types, but should at minimum support the internal codes in
11094 the range @code{System.Min_Int.System.Max_Int}.
11095 @end cartouche
11096 Followed.
11098 @cindex Record representation clauses
11099 @cindex Representation clauses, records
11100 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
11101 @sp 1
11102 @cartouche
11103 The recommended level of support for
11104 @*@code{record_representation_clauses} is:
11106 An implementation should support storage places that can be extracted
11107 with a load, mask, shift sequence of machine code, and set with a load,
11108 shift, mask, store sequence, given the available machine instructions
11109 and run-time model.
11110 @end cartouche
11111 Followed.
11113 @sp 1
11114 @cartouche
11115 A storage place should be supported if its size is equal to the
11116 @code{Size} of the component subtype, and it starts and ends on a
11117 boundary that obeys the @code{Alignment} of the component subtype.
11118 @end cartouche
11119 Followed.
11121 @sp 1
11122 @cartouche
11123 If the default bit ordering applies to the declaration of a given type,
11124 then for a component whose subtype's @code{Size} is less than the word
11125 size, any storage place that does not cross an aligned word boundary
11126 should be supported.
11127 @end cartouche
11128 Followed.
11130 @sp 1
11131 @cartouche
11132 An implementation may reserve a storage place for the tag field of a
11133 tagged type, and disallow other components from overlapping that place.
11134 @end cartouche
11135 Followed.  The storage place for the tag field is the beginning of the tagged
11136 record, and its size is Address'Size.  GNAT will reject an explicit component
11137 clause for the tag field.
11139 @sp 1
11140 @cartouche
11141 An implementation need not support a @code{component_clause} for a
11142 component of an extension part if the storage place is not after the
11143 storage places of all components of the parent type, whether or not
11144 those storage places had been specified.
11145 @end cartouche
11146 Followed.  The above advice on record representation clauses is followed,
11147 and all mentioned features are implemented.
11149 @cindex Storage place attributes
11150 @unnumberedsec 13.5.2(5): Storage Place Attributes
11151 @sp 1
11152 @cartouche
11153 If a component is represented using some form of pointer (such as an
11154 offset) to the actual data of the component, and this data is contiguous
11155 with the rest of the object, then the storage place attributes should
11156 reflect the place of the actual data, not the pointer.  If a component is
11157 allocated discontinuously from the rest of the object, then a warning
11158 should be generated upon reference to one of its storage place
11159 attributes.
11160 @end cartouche
11161 Followed.  There are no such components in GNAT@.
11163 @cindex Bit ordering
11164 @unnumberedsec 13.5.3(7-8): Bit Ordering
11165 @sp 1
11166 @cartouche
11167 The recommended level of support for the non-default bit ordering is:
11168 @end cartouche
11169 @sp 1
11170 @cartouche
11171 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
11172 should support the non-default bit ordering in addition to the default
11173 bit ordering.
11174 @end cartouche
11175 Followed.  Word size does not equal storage size in this implementation.
11176 Thus non-default bit ordering is not supported.
11178 @cindex @code{Address}, as private type
11179 @unnumberedsec 13.7(37): Address as Private
11180 @sp 1
11181 @cartouche
11182 @code{Address} should be of a private type.
11183 @end cartouche
11184 Followed.
11186 @cindex Operations, on @code{Address}
11187 @cindex @code{Address}, operations of
11188 @unnumberedsec 13.7.1(16): Address Operations
11189 @sp 1
11190 @cartouche
11191 Operations in @code{System} and its children should reflect the target
11192 environment semantics as closely as is reasonable.  For example, on most
11193 machines, it makes sense for address arithmetic to ``wrap around''.
11194 Operations that do not make sense should raise @code{Program_Error}.
11195 @end cartouche
11196 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
11197 operation raises @code{Program_Error}, since all operations make sense.
11199 @cindex Unchecked conversion
11200 @unnumberedsec 13.9(14-17): Unchecked Conversion
11201 @sp 1
11202 @cartouche
11203 The @code{Size} of an array object should not include its bounds; hence,
11204 the bounds should not be part of the converted data.
11205 @end cartouche
11206 Followed.
11208 @sp 1
11209 @cartouche
11210 The implementation should not generate unnecessary run-time checks to
11211 ensure that the representation of @var{S} is a representation of the
11212 target type.  It should take advantage of the permission to return by
11213 reference when possible.  Restrictions on unchecked conversions should be
11214 avoided unless required by the target environment.
11215 @end cartouche
11216 Followed.  There are no restrictions on unchecked conversion.  A warning is
11217 generated if the source and target types do not have the same size since
11218 the semantics in this case may be target dependent.
11220 @sp 1
11221 @cartouche
11222 The recommended level of support for unchecked conversions is:
11223 @end cartouche
11224 @sp 1
11225 @cartouche
11226 Unchecked conversions should be supported and should be reversible in
11227 the cases where this clause defines the result.  To enable meaningful use
11228 of unchecked conversion, a contiguous representation should be used for
11229 elementary subtypes, for statically constrained array subtypes whose
11230 component subtype is one of the subtypes described in this paragraph,
11231 and for record subtypes without discriminants whose component subtypes
11232 are described in this paragraph.
11233 @end cartouche
11234 Followed.
11236 @cindex Heap usage, implicit
11237 @unnumberedsec 13.11(23-25): Implicit Heap Usage
11238 @sp 1
11239 @cartouche
11240 An implementation should document any cases in which it dynamically
11241 allocates heap storage for a purpose other than the evaluation of an
11242 allocator.
11243 @end cartouche
11244 Followed, the only other points at which heap storage is dynamically
11245 allocated are as follows:
11247 @itemize @bullet
11248 @item
11249 At initial elaboration time, to allocate dynamically sized global
11250 objects.
11252 @item
11253 To allocate space for a task when a task is created.
11255 @item
11256 To extend the secondary stack dynamically when needed.  The secondary
11257 stack is used for returning variable length results.
11258 @end itemize
11260 @sp 1
11261 @cartouche
11262 A default (implementation-provided) storage pool for an
11263 access-to-constant type should not have overhead to support deallocation of
11264 individual objects.
11265 @end cartouche
11266 Followed.
11268 @sp 1
11269 @cartouche
11270 A storage pool for an anonymous access type should be created at the
11271 point of an allocator for the type, and be reclaimed when the designated
11272 object becomes inaccessible.
11273 @end cartouche
11274 Followed.
11276 @cindex Unchecked deallocation
11277 @unnumberedsec 13.11.2(17): Unchecked De-allocation
11278 @sp 1
11279 @cartouche
11280 For a standard storage pool, @code{Free} should actually reclaim the
11281 storage.
11282 @end cartouche
11283 Followed.
11285 @cindex Stream oriented attributes
11286 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
11287 @sp 1
11288 @cartouche
11289 If a stream element is the same size as a storage element, then the
11290 normal in-memory representation should be used by @code{Read} and
11291 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
11292 should use the smallest number of stream elements needed to represent
11293 all values in the base range of the scalar type.
11294 @end cartouche
11296 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
11297 which specifies using the size of the first subtype.
11298 However, such an implementation is based on direct binary
11299 representations and is therefore target- and endianness-dependent.
11300 To address this issue, GNAT also supplies an alternate implementation
11301 of the stream attributes @code{Read} and @code{Write},
11302 which uses the target-independent XDR standard representation
11303 for scalar types.
11304 @cindex XDR representation
11305 @cindex @code{Read} attribute
11306 @cindex @code{Write} attribute
11307 @cindex Stream oriented attributes
11308 The XDR implementation is provided as an alternative body of the
11309 @code{System.Stream_Attributes} package, in the file
11310 @file{s-stratt-xdr.adb} in the GNAT library.
11311 There is no @file{s-stratt-xdr.ads} file.
11312 In order to install the XDR implementation, do the following:
11313 @enumerate
11314 @item Replace the default implementation of the
11315 @code{System.Stream_Attributes} package with the XDR implementation.
11316 For example on a Unix platform issue the commands:
11317 @smallexample
11318 $ mv s-stratt.adb s-stratt-default.adb
11319 $ mv s-stratt-xdr.adb s-stratt.adb
11320 @end smallexample
11322 @item
11323 Rebuild the GNAT run-time library as documented in
11324 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
11325 @end enumerate
11327 @unnumberedsec A.1(52): Names of Predefined Numeric Types
11328 @sp 1
11329 @cartouche
11330 If an implementation provides additional named predefined integer types,
11331 then the names should end with @samp{Integer} as in
11332 @samp{Long_Integer}.  If an implementation provides additional named
11333 predefined floating point types, then the names should end with
11334 @samp{Float} as in @samp{Long_Float}.
11335 @end cartouche
11336 Followed.
11338 @findex Ada.Characters.Handling
11339 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
11340 @sp 1
11341 @cartouche
11342 If an implementation provides a localized definition of @code{Character}
11343 or @code{Wide_Character}, then the effects of the subprograms in
11344 @code{Characters.Handling} should reflect the localizations.  See also
11345 3.5.2.
11346 @end cartouche
11347 Followed.  GNAT provides no such localized definitions.
11349 @cindex Bounded-length strings
11350 @unnumberedsec A.4.4(106): Bounded-Length String Handling
11351 @sp 1
11352 @cartouche
11353 Bounded string objects should not be implemented by implicit pointers
11354 and dynamic allocation.
11355 @end cartouche
11356 Followed.  No implicit pointers or dynamic allocation are used.
11358 @cindex Random number generation
11359 @unnumberedsec A.5.2(46-47): Random Number Generation
11360 @sp 1
11361 @cartouche
11362 Any storage associated with an object of type @code{Generator} should be
11363 reclaimed on exit from the scope of the object.
11364 @end cartouche
11365 Followed.
11367 @sp 1
11368 @cartouche
11369 If the generator period is sufficiently long in relation to the number
11370 of distinct initiator values, then each possible value of
11371 @code{Initiator} passed to @code{Reset} should initiate a sequence of
11372 random numbers that does not, in a practical sense, overlap the sequence
11373 initiated by any other value.  If this is not possible, then the mapping
11374 between initiator values and generator states should be a rapidly
11375 varying function of the initiator value.
11376 @end cartouche
11377 Followed.  The generator period is sufficiently long for the first
11378 condition here to hold true.
11380 @findex Get_Immediate
11381 @unnumberedsec A.10.7(23): @code{Get_Immediate}
11382 @sp 1
11383 @cartouche
11384 The @code{Get_Immediate} procedures should be implemented with
11385 unbuffered input.  For a device such as a keyboard, input should be
11386 @dfn{available} if a key has already been typed, whereas for a disk
11387 file, input should always be available except at end of file.  For a file
11388 associated with a keyboard-like device, any line-editing features of the
11389 underlying operating system should be disabled during the execution of
11390 @code{Get_Immediate}.
11391 @end cartouche
11392 Followed on all targets except VxWorks. For VxWorks, there is no way to
11393 provide this functionality that does not result in the input buffer being
11394 flushed before the @code{Get_Immediate} call. A special unit
11395 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
11396 this functionality.
11398 @findex Export
11399 @unnumberedsec B.1(39-41): Pragma @code{Export}
11400 @sp 1
11401 @cartouche
11402 If an implementation supports pragma @code{Export} to a given language,
11403 then it should also allow the main subprogram to be written in that
11404 language.  It should support some mechanism for invoking the elaboration
11405 of the Ada library units included in the system, and for invoking the
11406 finalization of the environment task.  On typical systems, the
11407 recommended mechanism is to provide two subprograms whose link names are
11408 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
11409 elaboration code for library units.  @code{adafinal} should contain the
11410 finalization code.  These subprograms should have no effect the second
11411 and subsequent time they are called.
11412 @end cartouche
11413 Followed.
11415 @sp 1
11416 @cartouche
11417 Automatic elaboration of pre-elaborated packages should be
11418 provided when pragma @code{Export} is supported.
11419 @end cartouche
11420 Followed when the main program is in Ada.  If the main program is in a
11421 foreign language, then
11422 @code{adainit} must be called to elaborate pre-elaborated
11423 packages.
11425 @sp 1
11426 @cartouche
11427 For each supported convention @var{L} other than @code{Intrinsic}, an
11428 implementation should support @code{Import} and @code{Export} pragmas
11429 for objects of @var{L}-compatible types and for subprograms, and pragma
11430 @code{Convention} for @var{L}-eligible types and for subprograms,
11431 presuming the other language has corresponding features.  Pragma
11432 @code{Convention} need not be supported for scalar types.
11433 @end cartouche
11434 Followed.
11436 @cindex Package @code{Interfaces}
11437 @findex Interfaces
11438 @unnumberedsec B.2(12-13): Package @code{Interfaces}
11439 @sp 1
11440 @cartouche
11441 For each implementation-defined convention identifier, there should be a
11442 child package of package Interfaces with the corresponding name.  This
11443 package should contain any declarations that would be useful for
11444 interfacing to the language (implementation) represented by the
11445 convention.  Any declarations useful for interfacing to any language on
11446 the given hardware architecture should be provided directly in
11447 @code{Interfaces}.
11448 @end cartouche
11449 Followed. An additional package not defined
11450 in the Ada Reference Manual is @code{Interfaces.CPP}, used
11451 for interfacing to C++.
11453 @sp 1
11454 @cartouche
11455 An implementation supporting an interface to C, COBOL, or Fortran should
11456 provide the corresponding package or packages described in the following
11457 clauses.
11458 @end cartouche
11459 Followed.  GNAT provides all the packages described in this section.
11461 @cindex C, interfacing with
11462 @unnumberedsec B.3(63-71): Interfacing with C
11463 @sp 1
11464 @cartouche
11465 An implementation should support the following interface correspondences
11466 between Ada and C@.
11467 @end cartouche
11468 Followed.
11470 @sp 1
11471 @cartouche
11472 An Ada procedure corresponds to a void-returning C function.
11473 @end cartouche
11474 Followed.
11476 @sp 1
11477 @cartouche
11478 An Ada function corresponds to a non-void C function.
11479 @end cartouche
11480 Followed.
11482 @sp 1
11483 @cartouche
11484 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
11485 function.
11486 @end cartouche
11487 Followed.
11489 @sp 1
11490 @cartouche
11491 An Ada @code{in} parameter of an access-to-object type with designated
11492 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
11493 where @var{t} is the C type corresponding to the Ada type @var{T}.
11494 @end cartouche
11495 Followed.
11497 @sp 1
11498 @cartouche
11499 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
11500 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
11501 argument to a C function, where @var{t} is the C type corresponding to
11502 the Ada type @var{T}.  In the case of an elementary @code{out} or
11503 @code{in out} parameter, a pointer to a temporary copy is used to
11504 preserve by-copy semantics.
11505 @end cartouche
11506 Followed.
11508 @sp 1
11509 @cartouche
11510 An Ada parameter of a record type @var{T}, of any mode, is passed as a
11511 @code{@var{t}*} argument to a C function, where @var{t} is the C
11512 structure corresponding to the Ada type @var{T}.
11513 @end cartouche
11514 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
11515 pragma, or Convention, or by explicitly specifying the mechanism for a given
11516 call using an extended import or export pragma.
11518 @sp 1
11519 @cartouche
11520 An Ada parameter of an array type with component type @var{T}, of any
11521 mode, is passed as a @code{@var{t}*} argument to a C function, where
11522 @var{t} is the C type corresponding to the Ada type @var{T}.
11523 @end cartouche
11524 Followed.
11526 @sp 1
11527 @cartouche
11528 An Ada parameter of an access-to-subprogram type is passed as a pointer
11529 to a C function whose prototype corresponds to the designated
11530 subprogram's specification.
11531 @end cartouche
11532 Followed.
11534 @cindex COBOL, interfacing with
11535 @unnumberedsec B.4(95-98): Interfacing with COBOL
11536 @sp 1
11537 @cartouche
11538 An Ada implementation should support the following interface
11539 correspondences between Ada and COBOL@.
11540 @end cartouche
11541 Followed.
11543 @sp 1
11544 @cartouche
11545 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
11546 the COBOL type corresponding to @var{T}.
11547 @end cartouche
11548 Followed.
11550 @sp 1
11551 @cartouche
11552 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
11553 the corresponding COBOL type.
11554 @end cartouche
11555 Followed.
11557 @sp 1
11558 @cartouche
11559 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
11560 COBOL type corresponding to the Ada parameter type; for scalars, a local
11561 copy is used if necessary to ensure by-copy semantics.
11562 @end cartouche
11563 Followed.
11565 @cindex Fortran, interfacing with
11566 @unnumberedsec B.5(22-26): Interfacing with Fortran
11567 @sp 1
11568 @cartouche
11569 An Ada implementation should support the following interface
11570 correspondences between Ada and Fortran:
11571 @end cartouche
11572 Followed.
11574 @sp 1
11575 @cartouche
11576 An Ada procedure corresponds to a Fortran subroutine.
11577 @end cartouche
11578 Followed.
11580 @sp 1
11581 @cartouche
11582 An Ada function corresponds to a Fortran function.
11583 @end cartouche
11584 Followed.
11586 @sp 1
11587 @cartouche
11588 An Ada parameter of an elementary, array, or record type @var{T} is
11589 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
11590 the Fortran type corresponding to the Ada type @var{T}, and where the
11591 INTENT attribute of the corresponding dummy argument matches the Ada
11592 formal parameter mode; the Fortran implementation's parameter passing
11593 conventions are used.  For elementary types, a local copy is used if
11594 necessary to ensure by-copy semantics.
11595 @end cartouche
11596 Followed.
11598 @sp 1
11599 @cartouche
11600 An Ada parameter of an access-to-subprogram type is passed as a
11601 reference to a Fortran procedure whose interface corresponds to the
11602 designated subprogram's specification.
11603 @end cartouche
11604 Followed.
11606 @cindex Machine operations
11607 @unnumberedsec C.1(3-5): Access to Machine Operations
11608 @sp 1
11609 @cartouche
11610 The machine code or intrinsic support should allow access to all
11611 operations normally available to assembly language programmers for the
11612 target environment, including privileged instructions, if any.
11613 @end cartouche
11614 Followed.
11616 @sp 1
11617 @cartouche
11618 The interfacing pragmas (see Annex B) should support interface to
11619 assembler; the default assembler should be associated with the
11620 convention identifier @code{Assembler}.
11621 @end cartouche
11622 Followed.
11624 @sp 1
11625 @cartouche
11626 If an entity is exported to assembly language, then the implementation
11627 should allocate it at an addressable location, and should ensure that it
11628 is retained by the linking process, even if not otherwise referenced
11629 from the Ada code.  The implementation should assume that any call to a
11630 machine code or assembler subprogram is allowed to read or update every
11631 object that is specified as exported.
11632 @end cartouche
11633 Followed.
11635 @unnumberedsec C.1(10-16): Access to Machine Operations
11636 @sp 1
11637 @cartouche
11638 The implementation should ensure that little or no overhead is
11639 associated with calling intrinsic and machine-code subprograms.
11640 @end cartouche
11641 Followed for both intrinsics and machine-code subprograms.
11643 @sp 1
11644 @cartouche
11645 It is recommended that intrinsic subprograms be provided for convenient
11646 access to any machine operations that provide special capabilities or
11647 efficiency and that are not otherwise available through the language
11648 constructs.
11649 @end cartouche
11650 Followed.  A full set of machine operation intrinsic subprograms is provided.
11652 @sp 1
11653 @cartouche
11654 Atomic read-modify-write operations---e.g.@:, test and set, compare and
11655 swap, decrement and test, enqueue/dequeue.
11656 @end cartouche
11657 Followed on any target supporting such operations.
11659 @sp 1
11660 @cartouche
11661 Standard numeric functions---e.g.@:, sin, log.
11662 @end cartouche
11663 Followed on any target supporting such operations.
11665 @sp 1
11666 @cartouche
11667 String manipulation operations---e.g.@:, translate and test.
11668 @end cartouche
11669 Followed on any target supporting such operations.
11671 @sp 1
11672 @cartouche
11673 Vector operations---e.g.@:, compare vector against thresholds.
11674 @end cartouche
11675 Followed on any target supporting such operations.
11677 @sp 1
11678 @cartouche
11679 Direct operations on I/O ports.
11680 @end cartouche
11681 Followed on any target supporting such operations.
11683 @cindex Interrupt support
11684 @unnumberedsec C.3(28): Interrupt Support
11685 @sp 1
11686 @cartouche
11687 If the @code{Ceiling_Locking} policy is not in effect, the
11688 implementation should provide means for the application to specify which
11689 interrupts are to be blocked during protected actions, if the underlying
11690 system allows for a finer-grain control of interrupt blocking.
11691 @end cartouche
11692 Followed.  The underlying system does not allow for finer-grain control
11693 of interrupt blocking.
11695 @cindex Protected procedure handlers
11696 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
11697 @sp 1
11698 @cartouche
11699 Whenever possible, the implementation should allow interrupt handlers to
11700 be called directly by the hardware.
11701 @end cartouche
11702 Followed on any target where the underlying operating system permits
11703 such direct calls.
11705 @sp 1
11706 @cartouche
11707 Whenever practical, violations of any
11708 implementation-defined restrictions should be detected before run time.
11709 @end cartouche
11710 Followed.  Compile time warnings are given when possible.
11712 @cindex Package @code{Interrupts}
11713 @findex Interrupts
11714 @unnumberedsec C.3.2(25): Package @code{Interrupts}
11716 @sp 1
11717 @cartouche
11718 If implementation-defined forms of interrupt handler procedures are
11719 supported, such as protected procedures with parameters, then for each
11720 such form of a handler, a type analogous to @code{Parameterless_Handler}
11721 should be specified in a child package of @code{Interrupts}, with the
11722 same operations as in the predefined package Interrupts.
11723 @end cartouche
11724 Followed.
11726 @cindex Pre-elaboration requirements
11727 @unnumberedsec C.4(14): Pre-elaboration Requirements
11728 @sp 1
11729 @cartouche
11730 It is recommended that pre-elaborated packages be implemented in such a
11731 way that there should be little or no code executed at run time for the
11732 elaboration of entities not already covered by the Implementation
11733 Requirements.
11734 @end cartouche
11735 Followed.  Executable code is generated in some cases, e.g.@: loops
11736 to initialize large arrays.
11738 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
11739 @sp 1
11740 @cartouche
11741 If the pragma applies to an entity, then the implementation should
11742 reduce the amount of storage used for storing names associated with that
11743 entity.
11744 @end cartouche
11745 Followed.
11747 @cindex Package @code{Task_Attributes}
11748 @findex Task_Attributes
11749 @unnumberedsec C.7.2(30): The Package Task_Attributes
11750 @sp 1
11751 @cartouche
11752 Some implementations are targeted to domains in which memory use at run
11753 time must be completely deterministic.  For such implementations, it is
11754 recommended that the storage for task attributes will be pre-allocated
11755 statically and not from the heap.  This can be accomplished by either
11756 placing restrictions on the number and the size of the task's
11757 attributes, or by using the pre-allocated storage for the first @var{N}
11758 attribute objects, and the heap for the others.  In the latter case,
11759 @var{N} should be documented.
11760 @end cartouche
11761 Not followed.  This implementation is not targeted to such a domain.
11763 @cindex Locking Policies
11764 @unnumberedsec D.3(17): Locking Policies
11766 @sp 1
11767 @cartouche
11768 The implementation should use names that end with @samp{_Locking} for
11769 locking policies defined by the implementation.
11770 @end cartouche
11771 Followed.  Two implementation-defined locking policies are defined,
11772 whose names (@code{Inheritance_Locking} and
11773 @code{Concurrent_Readers_Locking}) follow this suggestion.
11775 @cindex Entry queuing policies
11776 @unnumberedsec D.4(16): Entry Queuing Policies
11777 @sp 1
11778 @cartouche
11779 Names that end with @samp{_Queuing} should be used
11780 for all implementation-defined queuing policies.
11781 @end cartouche
11782 Followed.  No such implementation-defined queuing policies exist.
11784 @cindex Preemptive abort
11785 @unnumberedsec D.6(9-10): Preemptive Abort
11786 @sp 1
11787 @cartouche
11788 Even though the @code{abort_statement} is included in the list of
11789 potentially blocking operations (see 9.5.1), it is recommended that this
11790 statement be implemented in a way that never requires the task executing
11791 the @code{abort_statement} to block.
11792 @end cartouche
11793 Followed.
11795 @sp 1
11796 @cartouche
11797 On a multi-processor, the delay associated with aborting a task on
11798 another processor should be bounded; the implementation should use
11799 periodic polling, if necessary, to achieve this.
11800 @end cartouche
11801 Followed.
11803 @cindex Tasking restrictions
11804 @unnumberedsec D.7(21): Tasking Restrictions
11805 @sp 1
11806 @cartouche
11807 When feasible, the implementation should take advantage of the specified
11808 restrictions to produce a more efficient implementation.
11809 @end cartouche
11810 GNAT currently takes advantage of these restrictions by providing an optimized
11811 run time when the Ravenscar profile and the GNAT restricted run time set
11812 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
11813 pragma @code{Profile (Restricted)} for more details.
11815 @cindex Time, monotonic
11816 @unnumberedsec D.8(47-49): Monotonic Time
11817 @sp 1
11818 @cartouche
11819 When appropriate, implementations should provide configuration
11820 mechanisms to change the value of @code{Tick}.
11821 @end cartouche
11822 Such configuration mechanisms are not appropriate to this implementation
11823 and are thus not supported.
11825 @sp 1
11826 @cartouche
11827 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
11828 be implemented as transformations of the same time base.
11829 @end cartouche
11830 Followed.
11832 @sp 1
11833 @cartouche
11834 It is recommended that the @dfn{best} time base which exists in
11835 the underlying system be available to the application through
11836 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
11837 @end cartouche
11838 Followed.
11840 @cindex Partition communication subsystem
11841 @cindex PCS
11842 @unnumberedsec E.5(28-29): Partition Communication Subsystem
11843 @sp 1
11844 @cartouche
11845 Whenever possible, the PCS on the called partition should allow for
11846 multiple tasks to call the RPC-receiver with different messages and
11847 should allow them to block until the corresponding subprogram body
11848 returns.
11849 @end cartouche
11850 Followed by GLADE, a separately supplied PCS that can be used with
11851 GNAT.
11853 @sp 1
11854 @cartouche
11855 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
11856 should raise @code{Storage_Error} if it runs out of space trying to
11857 write the @code{Item} into the stream.
11858 @end cartouche
11859 Followed by GLADE, a separately supplied PCS that can be used with
11860 GNAT@.
11862 @cindex COBOL support
11863 @unnumberedsec F(7): COBOL Support
11864 @sp 1
11865 @cartouche
11866 If COBOL (respectively, C) is widely supported in the target
11867 environment, implementations supporting the Information Systems Annex
11868 should provide the child package @code{Interfaces.COBOL} (respectively,
11869 @code{Interfaces.C}) specified in Annex B and should support a
11870 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
11871 pragmas (see Annex B), thus allowing Ada programs to interface with
11872 programs written in that language.
11873 @end cartouche
11874 Followed.
11876 @cindex Decimal radix support
11877 @unnumberedsec F.1(2): Decimal Radix Support
11878 @sp 1
11879 @cartouche
11880 Packed decimal should be used as the internal representation for objects
11881 of subtype @var{S} when @var{S}'Machine_Radix = 10.
11882 @end cartouche
11883 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
11884 representations.
11886 @cindex Numerics
11887 @unnumberedsec G: Numerics
11888 @sp 2
11889 @cartouche
11890 If Fortran (respectively, C) is widely supported in the target
11891 environment, implementations supporting the Numerics Annex
11892 should provide the child package @code{Interfaces.Fortran} (respectively,
11893 @code{Interfaces.C}) specified in Annex B and should support a
11894 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
11895 pragmas (see Annex B), thus allowing Ada programs to interface with
11896 programs written in that language.
11897 @end cartouche
11898 Followed.
11900 @cindex Complex types
11901 @unnumberedsec G.1.1(56-58): Complex Types
11902 @sp 2
11903 @cartouche
11904 Because the usual mathematical meaning of multiplication of a complex
11905 operand and a real operand is that of the scaling of both components of
11906 the former by the latter, an implementation should not perform this
11907 operation by first promoting the real operand to complex type and then
11908 performing a full complex multiplication.  In systems that, in the
11909 future, support an Ada binding to IEC 559:1989, the latter technique
11910 will not generate the required result when one of the components of the
11911 complex operand is infinite.  (Explicit multiplication of the infinite
11912 component by the zero component obtained during promotion yields a NaN
11913 that propagates into the final result.) Analogous advice applies in the
11914 case of multiplication of a complex operand and a pure-imaginary
11915 operand, and in the case of division of a complex operand by a real or
11916 pure-imaginary operand.
11917 @end cartouche
11918 Not followed.
11920 @sp 1
11921 @cartouche
11922 Similarly, because the usual mathematical meaning of addition of a
11923 complex operand and a real operand is that the imaginary operand remains
11924 unchanged, an implementation should not perform this operation by first
11925 promoting the real operand to complex type and then performing a full
11926 complex addition.  In implementations in which the @code{Signed_Zeros}
11927 attribute of the component type is @code{True} (and which therefore
11928 conform to IEC 559:1989 in regard to the handling of the sign of zero in
11929 predefined arithmetic operations), the latter technique will not
11930 generate the required result when the imaginary component of the complex
11931 operand is a negatively signed zero.  (Explicit addition of the negative
11932 zero to the zero obtained during promotion yields a positive zero.)
11933 Analogous advice applies in the case of addition of a complex operand
11934 and a pure-imaginary operand, and in the case of subtraction of a
11935 complex operand and a real or pure-imaginary operand.
11936 @end cartouche
11937 Not followed.
11939 @sp 1
11940 @cartouche
11941 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
11942 attempt to provide a rational treatment of the signs of zero results and
11943 result components.  As one example, the result of the @code{Argument}
11944 function should have the sign of the imaginary component of the
11945 parameter @code{X} when the point represented by that parameter lies on
11946 the positive real axis; as another, the sign of the imaginary component
11947 of the @code{Compose_From_Polar} function should be the same as
11948 (respectively, the opposite of) that of the @code{Argument} parameter when that
11949 parameter has a value of zero and the @code{Modulus} parameter has a
11950 nonnegative (respectively, negative) value.
11951 @end cartouche
11952 Followed.
11954 @cindex Complex elementary functions
11955 @unnumberedsec G.1.2(49): Complex Elementary Functions
11956 @sp 1
11957 @cartouche
11958 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
11959 @code{True} should attempt to provide a rational treatment of the signs
11960 of zero results and result components.  For example, many of the complex
11961 elementary functions have components that are odd functions of one of
11962 the parameter components; in these cases, the result component should
11963 have the sign of the parameter component at the origin.  Other complex
11964 elementary functions have zero components whose sign is opposite that of
11965 a parameter component at the origin, or is always positive or always
11966 negative.
11967 @end cartouche
11968 Followed.
11970 @cindex Accuracy requirements
11971 @unnumberedsec G.2.4(19): Accuracy Requirements
11972 @sp 1
11973 @cartouche
11974 The versions of the forward trigonometric functions without a
11975 @code{Cycle} parameter should not be implemented by calling the
11976 corresponding version with a @code{Cycle} parameter of
11977 @code{2.0*Numerics.Pi}, since this will not provide the required
11978 accuracy in some portions of the domain.  For the same reason, the
11979 version of @code{Log} without a @code{Base} parameter should not be
11980 implemented by calling the corresponding version with a @code{Base}
11981 parameter of @code{Numerics.e}.
11982 @end cartouche
11983 Followed.
11985 @cindex Complex arithmetic accuracy
11986 @cindex Accuracy, complex arithmetic
11987 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
11989 @sp 1
11990 @cartouche
11991 The version of the @code{Compose_From_Polar} function without a
11992 @code{Cycle} parameter should not be implemented by calling the
11993 corresponding version with a @code{Cycle} parameter of
11994 @code{2.0*Numerics.Pi}, since this will not provide the required
11995 accuracy in some portions of the domain.
11996 @end cartouche
11997 Followed.
11999 @cindex Sequential elaboration policy
12000 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
12002 @sp 1
12003 @cartouche
12004 If the partition elaboration policy is @code{Sequential} and the
12005 Environment task becomes permanently blocked during elaboration then the
12006 partition is deadlocked and it is recommended that the partition be
12007 immediately terminated.
12008 @end cartouche
12009 Not followed.
12011 @c -----------------------------------------
12012 @node Implementation Defined Characteristics
12013 @chapter Implementation Defined Characteristics
12015 @noindent
12016 In addition to the implementation dependent pragmas and attributes, and the
12017 implementation advice, there are a number of other Ada features that are
12018 potentially implementation dependent and are designated as
12019 implementation-defined. These are mentioned throughout the Ada Reference
12020 Manual, and are summarized in Annex M@.
12022 A requirement for conforming Ada compilers is that they provide
12023 documentation describing how the implementation deals with each of these
12024 issues.  In this chapter, you will find each point in Annex M listed
12025 followed by a description in italic font of how GNAT
12026 handles the implementation dependence.
12028 You can use this chapter as a guide to minimizing implementation
12029 dependent features in your programs if portability to other compilers
12030 and other operating systems is an important consideration.  The numbers
12031 in each section below correspond to the paragraph number in the Ada
12032 Reference Manual.
12034 @sp 1
12035 @cartouche
12036 @noindent
12037 @strong{2}.  Whether or not each recommendation given in Implementation
12038 Advice is followed.  See 1.1.2(37).
12039 @end cartouche
12040 @noindent
12041 @xref{Implementation Advice}.
12043 @sp 1
12044 @cartouche
12045 @noindent
12046 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
12047 @end cartouche
12048 @noindent
12049 The complexity of programs that can be processed is limited only by the
12050 total amount of available virtual memory, and disk space for the
12051 generated object files.
12053 @sp 1
12054 @cartouche
12055 @noindent
12056 @strong{4}.  Variations from the standard that are impractical to avoid
12057 given the implementation's execution environment.  See 1.1.3(6).
12058 @end cartouche
12059 @noindent
12060 There are no variations from the standard.
12062 @sp 1
12063 @cartouche
12064 @noindent
12065 @strong{5}.  Which @code{code_statement}s cause external
12066 interactions.  See 1.1.3(10).
12067 @end cartouche
12068 @noindent
12069 Any @code{code_statement} can potentially cause external interactions.
12071 @sp 1
12072 @cartouche
12073 @noindent
12074 @strong{6}.  The coded representation for the text of an Ada
12075 program.  See 2.1(4).
12076 @end cartouche
12077 @noindent
12078 See separate section on source representation.
12080 @sp 1
12081 @cartouche
12082 @noindent
12083 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
12084 @end cartouche
12085 @noindent
12086 See separate section on source representation.
12088 @sp 1
12089 @cartouche
12090 @noindent
12091 @strong{8}.  The representation for an end of line.  See 2.2(2).
12092 @end cartouche
12093 @noindent
12094 See separate section on source representation.
12096 @sp 1
12097 @cartouche
12098 @noindent
12099 @strong{9}.  Maximum supported line length and lexical element
12100 length.  See 2.2(15).
12101 @end cartouche
12102 @noindent
12103 The maximum line length is 255 characters and the maximum length of
12104 a lexical element is also 255 characters. This is the default setting
12105 if not overridden by the use of compiler switch @option{-gnaty} (which
12106 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
12107 line length to be specified to be any value up to 32767. The maximum
12108 length of a lexical element is the same as the maximum line length.
12110 @sp 1
12111 @cartouche
12112 @noindent
12113 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
12114 @end cartouche
12115 @noindent
12117 @xref{Implementation Defined Pragmas}.
12119 @sp 1
12120 @cartouche
12121 @noindent
12122 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
12123 @end cartouche
12124 @noindent
12125 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
12126 parameter, checks that the optimization flag is set, and aborts if it is
12127 not.
12129 @sp 1
12130 @cartouche
12131 @noindent
12132 @strong{12}.  The sequence of characters of the value returned by
12133 @code{@var{S}'Image} when some of the graphic characters of
12134 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
12135 3.5(37).
12136 @end cartouche
12137 @noindent
12138 The sequence of characters is as defined by the wide character encoding
12139 method used for the source.  See section on source representation for
12140 further details.
12142 @sp 1
12143 @cartouche
12144 @noindent
12145 @strong{13}.  The predefined integer types declared in
12146 @code{Standard}.  See 3.5.4(25).
12147 @end cartouche
12148 @noindent
12149 @table @code
12150 @item Short_Short_Integer
12151 8 bit signed
12152 @item Short_Integer
12153 (Short) 16 bit signed
12154 @item Integer
12155 32 bit signed
12156 @item Long_Integer
12157 64 bit signed (on most 64 bit targets, depending on the C definition of long).
12158 32 bit signed (all other targets)
12159 @item Long_Long_Integer
12160 64 bit signed
12161 @end table
12163 @sp 1
12164 @cartouche
12165 @noindent
12166 @strong{14}.  Any nonstandard integer types and the operators defined
12167 for them.  See 3.5.4(26).
12168 @end cartouche
12169 @noindent
12170 There are no nonstandard integer types.
12172 @sp 1
12173 @cartouche
12174 @noindent
12175 @strong{15}.  Any nonstandard real types and the operators defined for
12176 them.  See 3.5.6(8).
12177 @end cartouche
12178 @noindent
12179 There are no nonstandard real types.
12181 @sp 1
12182 @cartouche
12183 @noindent
12184 @strong{16}.  What combinations of requested decimal precision and range
12185 are supported for floating point types.  See 3.5.7(7).
12186 @end cartouche
12187 @noindent
12188 The precision and range is as defined by the IEEE standard.
12190 @sp 1
12191 @cartouche
12192 @noindent
12193 @strong{17}.  The predefined floating point types declared in
12194 @code{Standard}.  See 3.5.7(16).
12195 @end cartouche
12196 @noindent
12197 @table @code
12198 @item Short_Float
12199 32 bit IEEE short
12200 @item Float
12201 (Short) 32 bit IEEE short
12202 @item Long_Float
12203 64 bit IEEE long
12204 @item Long_Long_Float
12205 64 bit IEEE long (80 bit IEEE long on x86 processors)
12206 @end table
12208 @sp 1
12209 @cartouche
12210 @noindent
12211 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
12212 @end cartouche
12213 @noindent
12214 @code{Fine_Delta} is 2**(@minus{}63)
12216 @sp 1
12217 @cartouche
12218 @noindent
12219 @strong{19}.  What combinations of small, range, and digits are
12220 supported for fixed point types.  See 3.5.9(10).
12221 @end cartouche
12222 @noindent
12223 Any combinations are permitted that do not result in a small less than
12224 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
12225 If the mantissa is larger than 53 bits on machines where Long_Long_Float
12226 is 64 bits (true of all architectures except ia32), then the output from
12227 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
12228 is because floating-point conversions are used to convert fixed point.
12230 @sp 1
12231 @cartouche
12232 @noindent
12233 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
12234 within an unnamed @code{block_statement}.  See 3.9(10).
12235 @end cartouche
12236 @noindent
12237 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
12238 decimal integer are allocated.
12240 @sp 1
12241 @cartouche
12242 @noindent
12243 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
12244 @end cartouche
12245 @noindent
12246 @xref{Implementation Defined Attributes}.
12248 @sp 1
12249 @cartouche
12250 @noindent
12251 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
12252 @end cartouche
12253 @noindent
12254 There are no implementation-defined time types.
12256 @sp 1
12257 @cartouche
12258 @noindent
12259 @strong{23}.  The time base associated with relative delays.
12260 @end cartouche
12261 @noindent
12262 See 9.6(20).  The time base used is that provided by the C library
12263 function @code{gettimeofday}.
12265 @sp 1
12266 @cartouche
12267 @noindent
12268 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
12269 9.6(23).
12270 @end cartouche
12271 @noindent
12272 The time base used is that provided by the C library function
12273 @code{gettimeofday}.
12275 @sp 1
12276 @cartouche
12277 @noindent
12278 @strong{25}.  The time zone used for package @code{Calendar}
12279 operations.  See 9.6(24).
12280 @end cartouche
12281 @noindent
12282 The time zone used by package @code{Calendar} is the current system time zone
12283 setting for local time, as accessed by the C library function
12284 @code{localtime}.
12286 @sp 1
12287 @cartouche
12288 @noindent
12289 @strong{26}.  Any limit on @code{delay_until_statements} of
12290 @code{select_statements}.  See 9.6(29).
12291 @end cartouche
12292 @noindent
12293 There are no such limits.
12295 @sp 1
12296 @cartouche
12297 @noindent
12298 @strong{27}.  Whether or not two non-overlapping parts of a composite
12299 object are independently addressable, in the case where packing, record
12300 layout, or @code{Component_Size} is specified for the object.  See
12301 9.10(1).
12302 @end cartouche
12303 @noindent
12304 Separate components are independently addressable if they do not share
12305 overlapping storage units.
12307 @sp 1
12308 @cartouche
12309 @noindent
12310 @strong{28}.  The representation for a compilation.  See 10.1(2).
12311 @end cartouche
12312 @noindent
12313 A compilation is represented by a sequence of files presented to the
12314 compiler in a single invocation of the @command{gcc} command.
12316 @sp 1
12317 @cartouche
12318 @noindent
12319 @strong{29}.  Any restrictions on compilations that contain multiple
12320 compilation_units.  See 10.1(4).
12321 @end cartouche
12322 @noindent
12323 No single file can contain more than one compilation unit, but any
12324 sequence of files can be presented to the compiler as a single
12325 compilation.
12327 @sp 1
12328 @cartouche
12329 @noindent
12330 @strong{30}.  The mechanisms for creating an environment and for adding
12331 and replacing compilation units.  See 10.1.4(3).
12332 @end cartouche
12333 @noindent
12334 See separate section on compilation model.
12336 @sp 1
12337 @cartouche
12338 @noindent
12339 @strong{31}.  The manner of explicitly assigning library units to a
12340 partition.  See 10.2(2).
12341 @end cartouche
12342 @noindent
12343 If a unit contains an Ada main program, then the Ada units for the partition
12344 are determined by recursive application of the rules in the Ada Reference
12345 Manual section 10.2(2-6).  In other words, the Ada units will be those that
12346 are needed by the main program, and then this definition of need is applied
12347 recursively to those units, and the partition contains the transitive
12348 closure determined by this relationship.  In short, all the necessary units
12349 are included, with no need to explicitly specify the list.  If additional
12350 units are required, e.g.@: by foreign language units, then all units must be
12351 mentioned in the context clause of one of the needed Ada units.
12353 If the partition contains no main program, or if the main program is in
12354 a language other than Ada, then GNAT
12355 provides the binder options @option{-z} and @option{-n} respectively, and in
12356 this case a list of units can be explicitly supplied to the binder for
12357 inclusion in the partition (all units needed by these units will also
12358 be included automatically).  For full details on the use of these
12359 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
12360 @value{EDITION} User's Guide}.
12362 @sp 1
12363 @cartouche
12364 @noindent
12365 @strong{32}.  The implementation-defined means, if any, of specifying
12366 which compilation units are needed by a given compilation unit.  See
12367 10.2(2).
12368 @end cartouche
12369 @noindent
12370 The units needed by a given compilation unit are as defined in
12371 the Ada Reference Manual section 10.2(2-6).  There are no
12372 implementation-defined pragmas or other implementation-defined
12373 means for specifying needed units.
12375 @sp 1
12376 @cartouche
12377 @noindent
12378 @strong{33}.  The manner of designating the main subprogram of a
12379 partition.  See 10.2(7).
12380 @end cartouche
12381 @noindent
12382 The main program is designated by providing the name of the
12383 corresponding @file{ALI} file as the input parameter to the binder.
12385 @sp 1
12386 @cartouche
12387 @noindent
12388 @strong{34}.  The order of elaboration of @code{library_items}.  See
12389 10.2(18).
12390 @end cartouche
12391 @noindent
12392 The first constraint on ordering is that it meets the requirements of
12393 Chapter 10 of the Ada Reference Manual.  This still leaves some
12394 implementation dependent choices, which are resolved by first
12395 elaborating bodies as early as possible (i.e., in preference to specs
12396 where there is a choice), and second by evaluating the immediate with
12397 clauses of a unit to determine the probably best choice, and
12398 third by elaborating in alphabetical order of unit names
12399 where a choice still remains.
12401 @sp 1
12402 @cartouche
12403 @noindent
12404 @strong{35}.  Parameter passing and function return for the main
12405 subprogram.  See 10.2(21).
12406 @end cartouche
12407 @noindent
12408 The main program has no parameters.  It may be a procedure, or a function
12409 returning an integer type.  In the latter case, the returned integer
12410 value is the return code of the program (overriding any value that
12411 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
12413 @sp 1
12414 @cartouche
12415 @noindent
12416 @strong{36}.  The mechanisms for building and running partitions.  See
12417 10.2(24).
12418 @end cartouche
12419 @noindent
12420 GNAT itself supports programs with only a single partition.  The GNATDIST
12421 tool provided with the GLADE package (which also includes an implementation
12422 of the PCS) provides a completely flexible method for building and running
12423 programs consisting of multiple partitions.  See the separate GLADE manual
12424 for details.
12426 @sp 1
12427 @cartouche
12428 @noindent
12429 @strong{37}.  The details of program execution, including program
12430 termination.  See 10.2(25).
12431 @end cartouche
12432 @noindent
12433 See separate section on compilation model.
12435 @sp 1
12436 @cartouche
12437 @noindent
12438 @strong{38}.  The semantics of any non-active partitions supported by the
12439 implementation.  See 10.2(28).
12440 @end cartouche
12441 @noindent
12442 Passive partitions are supported on targets where shared memory is
12443 provided by the operating system.  See the GLADE reference manual for
12444 further details.
12446 @sp 1
12447 @cartouche
12448 @noindent
12449 @strong{39}.  The information returned by @code{Exception_Message}.  See
12450 11.4.1(10).
12451 @end cartouche
12452 @noindent
12453 Exception message returns the null string unless a specific message has
12454 been passed by the program.
12456 @sp 1
12457 @cartouche
12458 @noindent
12459 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
12460 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
12461 @end cartouche
12462 @noindent
12463 Blocks have implementation defined names of the form @code{B@var{nnn}}
12464 where @var{nnn} is an integer.
12466 @sp 1
12467 @cartouche
12468 @noindent
12469 @strong{41}.  The information returned by
12470 @code{Exception_Information}.  See 11.4.1(13).
12471 @end cartouche
12472 @noindent
12473 @code{Exception_Information} returns a string in the following format:
12475 @smallexample
12476 @emph{Exception_Name:} nnnnn
12477 @emph{Message:} mmmmm
12478 @emph{PID:} ppp
12479 @emph{Load address:} 0xhhhh
12480 @emph{Call stack traceback locations:}
12481 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
12482 @end smallexample
12484 @noindent
12485 where
12487 @itemize @bullet
12488 @item
12489 @code{nnnn} is the fully qualified name of the exception in all upper
12490 case letters. This line is always present.
12492 @item
12493 @code{mmmm} is the message (this line present only if message is non-null)
12495 @item
12496 @code{ppp} is the Process Id value as a decimal integer (this line is
12497 present only if the Process Id is nonzero). Currently we are
12498 not making use of this field.
12500 @item
12501 The Load address line, the Call stack traceback locations line and the
12502 following values are present only if at least one traceback location was
12503 recorded. The Load address indicates the address at which the main executable
12504 was loaded; this line may not be present if operating system hasn't relocated
12505 the main executable. The values are given in C style format, with lower case
12506 letters for a-f, and only as many digits present as are necessary.
12507 @end itemize
12509 @noindent
12510 The line terminator sequence at the end of each line, including
12511 the last line is a single @code{LF} character (@code{16#0A#}).
12513 @sp 1
12514 @cartouche
12515 @noindent
12516 @strong{42}.  Implementation-defined check names.  See 11.5(27).
12517 @end cartouche
12518 @noindent
12519 The implementation defined check name Alignment_Check controls checking of
12520 address clause values for proper alignment (that is, the address supplied
12521 must be consistent with the alignment of the type).
12523 The implementation defined check name Predicate_Check controls whether
12524 predicate checks are generated.
12526 The implementation defined check name Validity_Check controls whether
12527 validity checks are generated.
12529 In addition, a user program can add implementation-defined check names
12530 by means of the pragma Check_Name.
12532 @sp 1
12533 @cartouche
12534 @noindent
12535 @strong{43}.  The interpretation of each aspect of representation.  See
12536 13.1(20).
12537 @end cartouche
12538 @noindent
12539 See separate section on data representations.
12541 @sp 1
12542 @cartouche
12543 @noindent
12544 @strong{44}.  Any restrictions placed upon representation items.  See
12545 13.1(20).
12546 @end cartouche
12547 @noindent
12548 See separate section on data representations.
12550 @sp 1
12551 @cartouche
12552 @noindent
12553 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
12554 13.3(48).
12555 @end cartouche
12556 @noindent
12557 Size for an indefinite subtype is the maximum possible size, except that
12558 for the case of a subprogram parameter, the size of the parameter object
12559 is the actual size.
12561 @sp 1
12562 @cartouche
12563 @noindent
12564 @strong{46}.  The default external representation for a type tag.  See
12565 13.3(75).
12566 @end cartouche
12567 @noindent
12568 The default external representation for a type tag is the fully expanded
12569 name of the type in upper case letters.
12571 @sp 1
12572 @cartouche
12573 @noindent
12574 @strong{47}.  What determines whether a compilation unit is the same in
12575 two different partitions.  See 13.3(76).
12576 @end cartouche
12577 @noindent
12578 A compilation unit is the same in two different partitions if and only
12579 if it derives from the same source file.
12581 @sp 1
12582 @cartouche
12583 @noindent
12584 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
12585 @end cartouche
12586 @noindent
12587 The only implementation defined component is the tag for a tagged type,
12588 which contains a pointer to the dispatching table.
12590 @sp 1
12591 @cartouche
12592 @noindent
12593 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
12594 ordering.  See 13.5.3(5).
12595 @end cartouche
12596 @noindent
12597 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
12598 implementation, so no non-default bit ordering is supported.  The default
12599 bit ordering corresponds to the natural endianness of the target architecture.
12601 @sp 1
12602 @cartouche
12603 @noindent
12604 @strong{50}.  The contents of the visible part of package @code{System}
12605 and its language-defined children.  See 13.7(2).
12606 @end cartouche
12607 @noindent
12608 See the definition of these packages in files @file{system.ads} and
12609 @file{s-stoele.ads}.
12611 @sp 1
12612 @cartouche
12613 @noindent
12614 @strong{51}.  The contents of the visible part of package
12615 @code{System.Machine_Code}, and the meaning of
12616 @code{code_statements}.  See 13.8(7).
12617 @end cartouche
12618 @noindent
12619 See the definition and documentation in file @file{s-maccod.ads}.
12621 @sp 1
12622 @cartouche
12623 @noindent
12624 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
12625 @end cartouche
12626 @noindent
12627 Unchecked conversion between types of the same size
12628 results in an uninterpreted transmission of the bits from one type
12629 to the other.  If the types are of unequal sizes, then in the case of
12630 discrete types, a shorter source is first zero or sign extended as
12631 necessary, and a shorter target is simply truncated on the left.
12632 For all non-discrete types, the source is first copied if necessary
12633 to ensure that the alignment requirements of the target are met, then
12634 a pointer is constructed to the source value, and the result is obtained
12635 by dereferencing this pointer after converting it to be a pointer to the
12636 target type. Unchecked conversions where the target subtype is an
12637 unconstrained array are not permitted. If the target alignment is
12638 greater than the source alignment, then a copy of the result is
12639 made with appropriate alignment
12641 @sp 1
12642 @cartouche
12643 @noindent
12644 @strong{53}. The semantics of operations on invalid representations.
12645 See 13.9.2(10-11).
12646 @end cartouche
12647 @noindent
12648 For assignments and other operations where the use of invalid values cannot
12649 result in erroneous behavior, the compiler ignores the possibility of invalid
12650 values. An exception is raised at the point where an invalid value would
12651 result in erroneous behavior. For example executing:
12653 @smallexample @c ada
12654 procedure invalidvals is
12655    X : Integer := -1;
12656    Y : Natural range 1 .. 10;
12657    for Y'Address use X'Address;
12658    Z : Natural range 1 .. 10;
12659    A : array (Natural range 1 .. 10) of Integer;
12660 begin
12661    Z := Y;     -- no exception
12662    A (Z) := 3; -- exception raised;
12663 end;
12664 @end smallexample
12666 @noindent
12667 As indicated, an exception is raised on the array assignment, but not
12668 on the simple assignment of the invalid negative value from Y to Z.
12670 @sp 1
12671 @cartouche
12672 @noindent
12673 @strong{53}.  The manner of choosing a storage pool for an access type
12674 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
12675 @end cartouche
12676 @noindent
12677 There are 3 different standard pools used by the compiler when
12678 @code{Storage_Pool} is not specified depending whether the type is local
12679 to a subprogram or defined at the library level and whether
12680 @code{Storage_Size}is specified or not.  See documentation in the runtime
12681 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
12682 @code{System.Pool_Local} in files @file{s-poosiz.ads},
12683 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
12684 default pools used.
12686 @sp 1
12687 @cartouche
12688 @noindent
12689 @strong{54}.  Whether or not the implementation provides user-accessible
12690 names for the standard pool type(s).  See 13.11(17).
12691 @end cartouche
12692 @noindent
12694 See documentation in the sources of the run time mentioned in paragraph
12695 @strong{53} .  All these pools are accessible by means of @code{with}'ing
12696 these units.
12698 @sp 1
12699 @cartouche
12700 @noindent
12701 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
12702 @end cartouche
12703 @noindent
12704 @code{Storage_Size} is measured in storage units, and refers to the
12705 total space available for an access type collection, or to the primary
12706 stack space for a task.
12708 @sp 1
12709 @cartouche
12710 @noindent
12711 @strong{56}.  Implementation-defined aspects of storage pools.  See
12712 13.11(22).
12713 @end cartouche
12714 @noindent
12715 See documentation in the sources of the run time mentioned in paragraph
12716 @strong{53} for details on GNAT-defined aspects of storage pools.
12718 @sp 1
12719 @cartouche
12720 @noindent
12721 @strong{57}.  The set of restrictions allowed in a pragma
12722 @code{Restrictions}.  See 13.12(7).
12723 @end cartouche
12724 @noindent
12725 @xref{Standard and Implementation Defined Restrictions}.
12727 @sp 1
12728 @cartouche
12729 @noindent
12730 @strong{58}.  The consequences of violating limitations on
12731 @code{Restrictions} pragmas.  See 13.12(9).
12732 @end cartouche
12733 @noindent
12734 Restrictions that can be checked at compile time result in illegalities
12735 if violated.  Currently there are no other consequences of violating
12736 restrictions.
12738 @sp 1
12739 @cartouche
12740 @noindent
12741 @strong{59}.  The representation used by the @code{Read} and
12742 @code{Write} attributes of elementary types in terms of stream
12743 elements.  See 13.13.2(9).
12744 @end cartouche
12745 @noindent
12746 The representation is the in-memory representation of the base type of
12747 the type, using the number of bits corresponding to the
12748 @code{@var{type}'Size} value, and the natural ordering of the machine.
12750 @sp 1
12751 @cartouche
12752 @noindent
12753 @strong{60}.  The names and characteristics of the numeric subtypes
12754 declared in the visible part of package @code{Standard}.  See A.1(3).
12755 @end cartouche
12756 @noindent
12757 See items describing the integer and floating-point types supported.
12759 @sp 1
12760 @cartouche
12761 @noindent
12762 @strong{61}. The string returned by @code{Character_Set_Version}.
12763 See A.3.5(3).
12764 @end cartouche
12765 @noindent
12766 @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns
12767 the string "Unicode 4.0", referring to version 4.0 of the
12768 Unicode specification.
12770 @sp 1
12771 @cartouche
12772 @noindent
12773 @strong{62}.  The accuracy actually achieved by the elementary
12774 functions.  See A.5.1(1).
12775 @end cartouche
12776 @noindent
12777 The elementary functions correspond to the functions available in the C
12778 library.  Only fast math mode is implemented.
12780 @sp 1
12781 @cartouche
12782 @noindent
12783 @strong{63}.  The sign of a zero result from some of the operators or
12784 functions in @code{Numerics.Generic_Elementary_Functions}, when
12785 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
12786 @end cartouche
12787 @noindent
12788 The sign of zeroes follows the requirements of the IEEE 754 standard on
12789 floating-point.
12791 @sp 1
12792 @cartouche
12793 @noindent
12794 @strong{64}.  The value of
12795 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
12796 @end cartouche
12797 @noindent
12798 Maximum image width is 6864, see library file @file{s-rannum.ads}.
12800 @sp 1
12801 @cartouche
12802 @noindent
12803 @strong{65}.  The value of
12804 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
12805 @end cartouche
12806 @noindent
12807 Maximum image width is 6864, see library file @file{s-rannum.ads}.
12809 @sp 1
12810 @cartouche
12811 @noindent
12812 @strong{66}.  The algorithms for random number generation.  See
12813 A.5.2(32).
12814 @end cartouche
12815 @noindent
12816 The algorithm is the Mersenne Twister, as documented in the source file
12817 @file{s-rannum.adb}. This version of the algorithm has a period of
12818 2**19937-1.
12820 @sp 1
12821 @cartouche
12822 @noindent
12823 @strong{67}.  The string representation of a random number generator's
12824 state.  See A.5.2(38).
12825 @end cartouche
12826 @noindent
12827 The value returned by the Image function is the concatenation of
12828 the fixed-width decimal representations of the 624 32-bit integers
12829 of the state vector.
12831 @sp 1
12832 @cartouche
12833 @noindent
12834 @strong{68}.  The minimum time interval between calls to the
12835 time-dependent Reset procedure that are guaranteed to initiate different
12836 random number sequences.  See A.5.2(45).
12837 @end cartouche
12838 @noindent
12839 The minimum period between reset calls to guarantee distinct series of
12840 random numbers is one microsecond.
12842 @sp 1
12843 @cartouche
12844 @noindent
12845 @strong{69}.  The values of the @code{Model_Mantissa},
12846 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
12847 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
12848 Annex is not supported.  See A.5.3(72).
12849 @end cartouche
12850 @noindent
12851 Run the compiler with @option{-gnatS} to produce a listing of package
12852 @code{Standard}, has the values of all numeric attributes.
12854 @sp 1
12855 @cartouche
12856 @noindent
12857 @strong{70}.  Any implementation-defined characteristics of the
12858 input-output packages.  See A.7(14).
12859 @end cartouche
12860 @noindent
12861 There are no special implementation defined characteristics for these
12862 packages.
12864 @sp 1
12865 @cartouche
12866 @noindent
12867 @strong{71}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
12868 A.9(10).
12869 @end cartouche
12870 @noindent
12871 All type representations are contiguous, and the @code{Buffer_Size} is
12872 the value of @code{@var{type}'Size} rounded up to the next storage unit
12873 boundary.
12875 @sp 1
12876 @cartouche
12877 @noindent
12878 @strong{72}.  External files for standard input, standard output, and
12879 standard error See A.10(5).
12880 @end cartouche
12881 @noindent
12882 These files are mapped onto the files provided by the C streams
12883 libraries.  See source file @file{i-cstrea.ads} for further details.
12885 @sp 1
12886 @cartouche
12887 @noindent
12888 @strong{73}.  The accuracy of the value produced by @code{Put}.  See
12889 A.10.9(36).
12890 @end cartouche
12891 @noindent
12892 If more digits are requested in the output than are represented by the
12893 precision of the value, zeroes are output in the corresponding least
12894 significant digit positions.
12896 @sp 1
12897 @cartouche
12898 @noindent
12899 @strong{74}.  The meaning of @code{Argument_Count}, @code{Argument}, and
12900 @code{Command_Name}.  See A.15(1).
12901 @end cartouche
12902 @noindent
12903 These are mapped onto the @code{argv} and @code{argc} parameters of the
12904 main program in the natural manner.
12906 @sp 1
12907 @cartouche
12908 @noindent
12909 @strong{75}.  The interpretation of the @code{Form} parameter in procedure
12910 @code{Create_Directory}.  See A.16(56).
12911 @end cartouche
12912 @noindent
12913 The @code{Form} parameter is not used.
12915 @sp 1
12916 @cartouche
12917 @noindent
12918 @strong{76}.  The interpretation of the @code{Form} parameter in procedure
12919 @code{Create_Path}.  See A.16(60).
12920 @end cartouche
12921 @noindent
12922 The @code{Form} parameter is not used.
12924 @sp 1
12925 @cartouche
12926 @noindent
12927 @strong{77}.  The interpretation of the @code{Form} parameter in procedure
12928 @code{Copy_File}.  See A.16(68).
12929 @end cartouche
12930 @noindent
12931 The @code{Form} parameter is case-insensitive.
12933 Two fields are recognized in the @code{Form} parameter:
12935 @table @code
12937 @item preserve=<value>
12939 @item mode=<value>
12941 @end table
12943 @noindent
12944 <value> starts immediately after the character '=' and ends with the
12945 character immediately preceding the next comma (',') or with the last
12946 character of the parameter.
12948 The only possible values for preserve= are:
12950 @table @code
12952 @item no_attributes
12953 Do not try to preserve any file attributes. This is the default if no
12954 preserve= is found in Form.
12956 @item all_attributes
12957 Try to preserve all file attributes (timestamps, access rights).
12959 @item timestamps
12960 Preserve the timestamp of the copied file, but not the other file attributes.
12962 @end table
12964 @noindent
12965 The only possible values for mode= are:
12967 @table @code
12969 @item copy
12970 Only do the copy if the destination file does not already exist. If it already
12971 exists, Copy_File fails.
12973 @item overwrite
12974 Copy the file in all cases. Overwrite an already existing destination file.
12976 @item append
12977 Append the original file to the destination file. If the destination file does
12978 not exist, the destination file is a copy of the source file. When mode=append,
12979 the field preserve=, if it exists, is not taken into account.
12981 @end table
12983 @noindent
12984 If the Form parameter includes one or both of the fields and the value or
12985 values are incorrect, Copy_file fails with Use_Error.
12987 Examples of correct Forms:
12989 @smallexample
12990 Form => "preserve=no_attributes,mode=overwrite" (the default)
12991 Form => "mode=append"
12992 Form => "mode=copy, preserve=all_attributes"
12993 @end smallexample
12995 @noindent
12996 Examples of incorrect Forms
12998 @smallexample
12999 Form => "preserve=junk"
13000 Form => "mode=internal, preserve=timestamps"
13001 @end smallexample
13003 @sp 1
13004 @cartouche
13005 @noindent
13006 @strong{78}.  Implementation-defined convention names.  See B.1(11).
13007 @end cartouche
13008 @noindent
13009 The following convention names are supported
13011 @table @code
13012 @item  Ada
13014 @item Ada_Pass_By_Copy
13015 Allowed for any types except by-reference types such as limited
13016 records. Compatible with convention Ada, but causes any parameters
13017 with this convention to be passed by copy.
13018 @item Ada_Pass_By_Reference
13019 Allowed for any types except by-copy types such as scalars.
13020 Compatible with convention Ada, but causes any parameters
13021 with this convention to be passed by reference.
13022 @item Assembler
13023 Assembly language
13024 @item Asm
13025 Synonym for Assembler
13026 @item Assembly
13027 Synonym for Assembler
13028 @item C
13030 @item C_Pass_By_Copy
13031 Allowed only for record types, like C, but also notes that record
13032 is to be passed by copy rather than reference.
13033 @item COBOL
13034 COBOL
13035 @item C_Plus_Plus (or CPP)
13037 @item Default
13038 Treated the same as C
13039 @item External
13040 Treated the same as C
13041 @item Fortran
13042 Fortran
13043 @item Intrinsic
13044 For support of pragma @code{Import} with convention Intrinsic, see
13045 separate section on Intrinsic Subprograms.
13046 @item Stdcall
13047 Stdcall (used for Windows implementations only).  This convention correspond
13048 to the WINAPI (previously called Pascal convention) C/C++ convention under
13049 Windows.  A routine with this convention cleans the stack before
13050 exit. This pragma cannot be applied to a dispatching call.
13051 @item DLL
13052 Synonym for Stdcall
13053 @item Win32
13054 Synonym for Stdcall
13055 @item Stubbed
13056 Stubbed is a special convention used to indicate that the body of the
13057 subprogram will be entirely ignored.  Any call to the subprogram
13058 is converted into a raise of the @code{Program_Error} exception.  If a
13059 pragma @code{Import} specifies convention @code{stubbed} then no body need
13060 be present at all.  This convention is useful during development for the
13061 inclusion of subprograms whose body has not yet been written.
13063 @end table
13064 @noindent
13065 In addition, all otherwise unrecognized convention names are also
13066 treated as being synonymous with convention C@.  In all implementations
13067 except for VMS, use of such other names results in a warning.  In VMS
13068 implementations, these names are accepted silently.
13070 @sp 1
13071 @cartouche
13072 @noindent
13073 @strong{79}.  The meaning of link names.  See B.1(36).
13074 @end cartouche
13075 @noindent
13076 Link names are the actual names used by the linker.
13078 @sp 1
13079 @cartouche
13080 @noindent
13081 @strong{80}.  The manner of choosing link names when neither the link
13082 name nor the address of an imported or exported entity is specified.  See
13083 B.1(36).
13084 @end cartouche
13085 @noindent
13086 The default linker name is that which would be assigned by the relevant
13087 external language, interpreting the Ada name as being in all lower case
13088 letters.
13090 @sp 1
13091 @cartouche
13092 @noindent
13093 @strong{81}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
13094 @end cartouche
13095 @noindent
13096 The string passed to @code{Linker_Options} is presented uninterpreted as
13097 an argument to the link command, unless it contains ASCII.NUL characters.
13098 NUL characters if they appear act as argument separators, so for example
13100 @smallexample @c ada
13101 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
13102 @end smallexample
13104 @noindent
13105 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
13106 linker. The order of linker options is preserved for a given unit. The final
13107 list of options passed to the linker is in reverse order of the elaboration
13108 order. For example, linker options for a body always appear before the options
13109 from the corresponding package spec.
13111 @sp 1
13112 @cartouche
13113 @noindent
13114 @strong{82}.  The contents of the visible part of package
13115 @code{Interfaces} and its language-defined descendants.  See B.2(1).
13116 @end cartouche
13117 @noindent
13118 See files with prefix @file{i-} in the distributed library.
13120 @sp 1
13121 @cartouche
13122 @noindent
13123 @strong{83}.  Implementation-defined children of package
13124 @code{Interfaces}.  The contents of the visible part of package
13125 @code{Interfaces}.  See B.2(11).
13126 @end cartouche
13127 @noindent
13128 See files with prefix @file{i-} in the distributed library.
13130 @sp 1
13131 @cartouche
13132 @noindent
13133 @strong{84}.  The types @code{Floating}, @code{Long_Floating},
13134 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
13135 @code{COBOL_Character}; and the initialization of the variables
13136 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
13137 @code{Interfaces.COBOL}.  See B.4(50).
13138 @end cartouche
13139 @noindent
13140 @table @code
13141 @item Floating
13142 Float
13143 @item Long_Floating
13144 (Floating) Long_Float
13145 @item Binary
13146 Integer
13147 @item Long_Binary
13148 Long_Long_Integer
13149 @item Decimal_Element
13150 Character
13151 @item COBOL_Character
13152 Character
13153 @end table
13155 @noindent
13156 For initialization, see the file @file{i-cobol.ads} in the distributed library.
13158 @sp 1
13159 @cartouche
13160 @noindent
13161 @strong{85}.  Support for access to machine instructions.  See C.1(1).
13162 @end cartouche
13163 @noindent
13164 See documentation in file @file{s-maccod.ads} in the distributed library.
13166 @sp 1
13167 @cartouche
13168 @noindent
13169 @strong{86}.  Implementation-defined aspects of access to machine
13170 operations.  See C.1(9).
13171 @end cartouche
13172 @noindent
13173 See documentation in file @file{s-maccod.ads} in the distributed library.
13175 @sp 1
13176 @cartouche
13177 @noindent
13178 @strong{87}.  Implementation-defined aspects of interrupts.  See C.3(2).
13179 @end cartouche
13180 @noindent
13181 Interrupts are mapped to signals or conditions as appropriate.  See
13182 definition of unit
13183 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
13184 on the interrupts supported on a particular target.
13186 @sp 1
13187 @cartouche
13188 @noindent
13189 @strong{88}.  Implementation-defined aspects of pre-elaboration.  See
13190 C.4(13).
13191 @end cartouche
13192 @noindent
13193 GNAT does not permit a partition to be restarted without reloading,
13194 except under control of the debugger.
13196 @sp 1
13197 @cartouche
13198 @noindent
13199 @strong{89}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
13200 @end cartouche
13201 @noindent
13202 Pragma @code{Discard_Names} causes names of enumeration literals to
13203 be suppressed.  In the presence of this pragma, the Image attribute
13204 provides the image of the Pos of the literal, and Value accepts
13205 Pos values.
13207 @sp 1
13208 @cartouche
13209 @noindent
13210 @strong{90}.  The result of the @code{Task_Identification.Image}
13211 attribute.  See C.7.1(7).
13212 @end cartouche
13213 @noindent
13214 The result of this attribute is a string that identifies
13215 the object or component that denotes a given task. If a variable @code{Var}
13216 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
13217 where the suffix
13218 is the hexadecimal representation of the virtual address of the corresponding
13219 task control block. If the variable is an array of tasks, the image of each
13220 task will have the form of an indexed component indicating the position of a
13221 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
13222 component of a record, the image of the task will have the form of a selected
13223 component. These rules are fully recursive, so that the image of a task that
13224 is a subcomponent of a composite object corresponds to the expression that
13225 designates this task.
13226 @noindent
13227 If a task is created by an allocator, its image depends on the context. If the
13228 allocator is part of an object declaration, the rules described above are used
13229 to construct its image, and this image is not affected by subsequent
13230 assignments. If the allocator appears within an expression, the image
13231 includes only the name of the task type.
13232 @noindent
13233 If the configuration pragma Discard_Names is present, or if the restriction
13234 No_Implicit_Heap_Allocation is in effect,  the image reduces to
13235 the numeric suffix, that is to say the hexadecimal representation of the
13236 virtual address of the control block of the task.
13237 @sp 1
13238 @cartouche
13239 @noindent
13240 @strong{91}.  The value of @code{Current_Task} when in a protected entry
13241 or interrupt handler.  See C.7.1(17).
13242 @end cartouche
13243 @noindent
13244 Protected entries or interrupt handlers can be executed by any
13245 convenient thread, so the value of @code{Current_Task} is undefined.
13247 @sp 1
13248 @cartouche
13249 @noindent
13250 @strong{92}.  The effect of calling @code{Current_Task} from an entry
13251 body or interrupt handler.  See C.7.1(19).
13252 @end cartouche
13253 @noindent
13254 The effect of calling @code{Current_Task} from an entry body or
13255 interrupt handler is to return the identification of the task currently
13256 executing the code.
13258 @sp 1
13259 @cartouche
13260 @noindent
13261 @strong{93}.  Implementation-defined aspects of
13262 @code{Task_Attributes}.  See C.7.2(19).
13263 @end cartouche
13264 @noindent
13265 There are no implementation-defined aspects of @code{Task_Attributes}.
13267 @sp 1
13268 @cartouche
13269 @noindent
13270 @strong{94}.  Values of all @code{Metrics}.  See D(2).
13271 @end cartouche
13272 @noindent
13273 The metrics information for GNAT depends on the performance of the
13274 underlying operating system.  The sources of the run-time for tasking
13275 implementation, together with the output from @option{-gnatG} can be
13276 used to determine the exact sequence of operating systems calls made
13277 to implement various tasking constructs.  Together with appropriate
13278 information on the performance of the underlying operating system,
13279 on the exact target in use, this information can be used to determine
13280 the required metrics.
13282 @sp 1
13283 @cartouche
13284 @noindent
13285 @strong{95}.  The declarations of @code{Any_Priority} and
13286 @code{Priority}.  See D.1(11).
13287 @end cartouche
13288 @noindent
13289 See declarations in file @file{system.ads}.
13291 @sp 1
13292 @cartouche
13293 @noindent
13294 @strong{96}.  Implementation-defined execution resources.  See D.1(15).
13295 @end cartouche
13296 @noindent
13297 There are no implementation-defined execution resources.
13299 @sp 1
13300 @cartouche
13301 @noindent
13302 @strong{97}.  Whether, on a multiprocessor, a task that is waiting for
13303 access to a protected object keeps its processor busy.  See D.2.1(3).
13304 @end cartouche
13305 @noindent
13306 On a multi-processor, a task that is waiting for access to a protected
13307 object does not keep its processor busy.
13309 @sp 1
13310 @cartouche
13311 @noindent
13312 @strong{98}.  The affect of implementation defined execution resources
13313 on task dispatching.  See D.2.1(9).
13314 @end cartouche
13315 @noindent
13316 Tasks map to threads in the threads package used by GNAT@.  Where possible
13317 and appropriate, these threads correspond to native threads of the
13318 underlying operating system.
13320 @sp 1
13321 @cartouche
13322 @noindent
13323 @strong{99}.  Implementation-defined @code{policy_identifiers} allowed
13324 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
13325 @end cartouche
13326 @noindent
13327 There are no implementation-defined policy-identifiers allowed in this
13328 pragma.
13330 @sp 1
13331 @cartouche
13332 @noindent
13333 @strong{100}.  Implementation-defined aspects of priority inversion.  See
13334 D.2.2(16).
13335 @end cartouche
13336 @noindent
13337 Execution of a task cannot be preempted by the implementation processing
13338 of delay expirations for lower priority tasks.
13340 @sp 1
13341 @cartouche
13342 @noindent
13343 @strong{101}.  Implementation-defined task dispatching.  See D.2.2(18).
13344 @end cartouche
13345 @noindent
13346 The policy is the same as that of the underlying threads implementation.
13348 @sp 1
13349 @cartouche
13350 @noindent
13351 @strong{102}.  Implementation-defined @code{policy_identifiers} allowed
13352 in a pragma @code{Locking_Policy}.  See D.3(4).
13353 @end cartouche
13354 @noindent
13355 The two implementation defined policies permitted in GNAT are
13356 @code{Inheritance_Locking} and  @code{Conccurent_Readers_Locking}.  On
13357 targets that support the @code{Inheritance_Locking} policy, locking is
13358 implemented by inheritance, i.e.@: the task owning the lock operates
13359 at a priority equal to the highest priority of any task currently
13360 requesting the lock.  On targets that support the
13361 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
13362 read/write lock allowing multiple propected object functions to enter
13363 concurrently.
13365 @sp 1
13366 @cartouche
13367 @noindent
13368 @strong{103}.  Default ceiling priorities.  See D.3(10).
13369 @end cartouche
13370 @noindent
13371 The ceiling priority of protected objects of the type
13372 @code{System.Interrupt_Priority'Last} as described in the Ada
13373 Reference Manual D.3(10),
13375 @sp 1
13376 @cartouche
13377 @noindent
13378 @strong{104}.  The ceiling of any protected object used internally by
13379 the implementation.  See D.3(16).
13380 @end cartouche
13381 @noindent
13382 The ceiling priority of internal protected objects is
13383 @code{System.Priority'Last}.
13385 @sp 1
13386 @cartouche
13387 @noindent
13388 @strong{105}.  Implementation-defined queuing policies.  See D.4(1).
13389 @end cartouche
13390 @noindent
13391 There are no implementation-defined queuing policies.
13393 @sp 1
13394 @cartouche
13395 @noindent
13396 @strong{106}.  On a multiprocessor, any conditions that cause the
13397 completion of an aborted construct to be delayed later than what is
13398 specified for a single processor.  See D.6(3).
13399 @end cartouche
13400 @noindent
13401 The semantics for abort on a multi-processor is the same as on a single
13402 processor, there are no further delays.
13404 @sp 1
13405 @cartouche
13406 @noindent
13407 @strong{107}.  Any operations that implicitly require heap storage
13408 allocation.  See D.7(8).
13409 @end cartouche
13410 @noindent
13411 The only operation that implicitly requires heap storage allocation is
13412 task creation.
13414 @sp 1
13415 @cartouche
13416 @noindent
13417 @strong{108}.  Implementation-defined aspects of pragma
13418 @code{Restrictions}.  See D.7(20).
13419 @end cartouche
13420 @noindent
13421 There are no such implementation-defined aspects.
13423 @sp 1
13424 @cartouche
13425 @noindent
13426 @strong{109}.  Implementation-defined aspects of package
13427 @code{Real_Time}.  See D.8(17).
13428 @end cartouche
13429 @noindent
13430 There are no implementation defined aspects of package @code{Real_Time}.
13432 @sp 1
13433 @cartouche
13434 @noindent
13435 @strong{110}.  Implementation-defined aspects of
13436 @code{delay_statements}.  See D.9(8).
13437 @end cartouche
13438 @noindent
13439 Any difference greater than one microsecond will cause the task to be
13440 delayed (see D.9(7)).
13442 @sp 1
13443 @cartouche
13444 @noindent
13445 @strong{111}.  The upper bound on the duration of interrupt blocking
13446 caused by the implementation.  See D.12(5).
13447 @end cartouche
13448 @noindent
13449 The upper bound is determined by the underlying operating system.  In
13450 no cases is it more than 10 milliseconds.
13452 @sp 1
13453 @cartouche
13454 @noindent
13455 @strong{112}.  The means for creating and executing distributed
13456 programs.  See E(5).
13457 @end cartouche
13458 @noindent
13459 The GLADE package provides a utility GNATDIST for creating and executing
13460 distributed programs.  See the GLADE reference manual for further details.
13462 @sp 1
13463 @cartouche
13464 @noindent
13465 @strong{113}.  Any events that can result in a partition becoming
13466 inaccessible.  See E.1(7).
13467 @end cartouche
13468 @noindent
13469 See the GLADE reference manual for full details on such events.
13471 @sp 1
13472 @cartouche
13473 @noindent
13474 @strong{114}.  The scheduling policies, treatment of priorities, and
13475 management of shared resources between partitions in certain cases.  See
13476 E.1(11).
13477 @end cartouche
13478 @noindent
13479 See the GLADE reference manual for full details on these aspects of
13480 multi-partition execution.
13482 @sp 1
13483 @cartouche
13484 @noindent
13485 @strong{115}.  Events that cause the version of a compilation unit to
13486 change.  See E.3(5).
13487 @end cartouche
13488 @noindent
13489 Editing the source file of a compilation unit, or the source files of
13490 any units on which it is dependent in a significant way cause the version
13491 to change.  No other actions cause the version number to change.  All changes
13492 are significant except those which affect only layout, capitalization or
13493 comments.
13495 @sp 1
13496 @cartouche
13497 @noindent
13498 @strong{116}.  Whether the execution of the remote subprogram is
13499 immediately aborted as a result of cancellation.  See E.4(13).
13500 @end cartouche
13501 @noindent
13502 See the GLADE reference manual for details on the effect of abort in
13503 a distributed application.
13505 @sp 1
13506 @cartouche
13507 @noindent
13508 @strong{117}.  Implementation-defined aspects of the PCS@.  See E.5(25).
13509 @end cartouche
13510 @noindent
13511 See the GLADE reference manual for a full description of all implementation
13512 defined aspects of the PCS@.
13514 @sp 1
13515 @cartouche
13516 @noindent
13517 @strong{118}.  Implementation-defined interfaces in the PCS@.  See
13518 E.5(26).
13519 @end cartouche
13520 @noindent
13521 See the GLADE reference manual for a full description of all
13522 implementation defined interfaces.
13524 @sp 1
13525 @cartouche
13526 @noindent
13527 @strong{119}.  The values of named numbers in the package
13528 @code{Decimal}.  See F.2(7).
13529 @end cartouche
13530 @noindent
13531 @table @code
13532 @item Max_Scale
13534 @item Min_Scale
13536 @item Min_Delta
13537 1.0E-18
13538 @item Max_Delta
13539 1.0E+18
13540 @item Max_Decimal_Digits
13542 @end table
13544 @sp 1
13545 @cartouche
13546 @noindent
13547 @strong{120}.  The value of @code{Max_Picture_Length} in the package
13548 @code{Text_IO.Editing}.  See F.3.3(16).
13549 @end cartouche
13550 @noindent
13553 @sp 1
13554 @cartouche
13555 @noindent
13556 @strong{121}.  The value of @code{Max_Picture_Length} in the package
13557 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
13558 @end cartouche
13559 @noindent
13562 @sp 1
13563 @cartouche
13564 @noindent
13565 @strong{122}.  The accuracy actually achieved by the complex elementary
13566 functions and by other complex arithmetic operations.  See G.1(1).
13567 @end cartouche
13568 @noindent
13569 Standard library functions are used for the complex arithmetic
13570 operations.  Only fast math mode is currently supported.
13572 @sp 1
13573 @cartouche
13574 @noindent
13575 @strong{123}.  The sign of a zero result (or a component thereof) from
13576 any operator or function in @code{Numerics.Generic_Complex_Types}, when
13577 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
13578 @end cartouche
13579 @noindent
13580 The signs of zero values are as recommended by the relevant
13581 implementation advice.
13583 @sp 1
13584 @cartouche
13585 @noindent
13586 @strong{124}.  The sign of a zero result (or a component thereof) from
13587 any operator or function in
13588 @code{Numerics.Generic_Complex_Elementary_Functions}, when
13589 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
13590 @end cartouche
13591 @noindent
13592 The signs of zero values are as recommended by the relevant
13593 implementation advice.
13595 @sp 1
13596 @cartouche
13597 @noindent
13598 @strong{125}.  Whether the strict mode or the relaxed mode is the
13599 default.  See G.2(2).
13600 @end cartouche
13601 @noindent
13602 The strict mode is the default.  There is no separate relaxed mode.  GNAT
13603 provides a highly efficient implementation of strict mode.
13605 @sp 1
13606 @cartouche
13607 @noindent
13608 @strong{126}.  The result interval in certain cases of fixed-to-float
13609 conversion.  See G.2.1(10).
13610 @end cartouche
13611 @noindent
13612 For cases where the result interval is implementation dependent, the
13613 accuracy is that provided by performing all operations in 64-bit IEEE
13614 floating-point format.
13616 @sp 1
13617 @cartouche
13618 @noindent
13619 @strong{127}.  The result of a floating point arithmetic operation in
13620 overflow situations, when the @code{Machine_Overflows} attribute of the
13621 result type is @code{False}.  See G.2.1(13).
13622 @end cartouche
13623 @noindent
13624 Infinite and NaN values are produced as dictated by the IEEE
13625 floating-point standard.
13627 Note that on machines that are not fully compliant with the IEEE
13628 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
13629 must be used for achieving IEEE conforming behavior (although at the cost
13630 of a significant performance penalty), so infinite and NaN values are
13631 properly generated.
13633 @sp 1
13634 @cartouche
13635 @noindent
13636 @strong{128}.  The result interval for division (or exponentiation by a
13637 negative exponent), when the floating point hardware implements division
13638 as multiplication by a reciprocal.  See G.2.1(16).
13639 @end cartouche
13640 @noindent
13641 Not relevant, division is IEEE exact.
13643 @sp 1
13644 @cartouche
13645 @noindent
13646 @strong{129}.  The definition of close result set, which determines the
13647 accuracy of certain fixed point multiplications and divisions.  See
13648 G.2.3(5).
13649 @end cartouche
13650 @noindent
13651 Operations in the close result set are performed using IEEE long format
13652 floating-point arithmetic.  The input operands are converted to
13653 floating-point, the operation is done in floating-point, and the result
13654 is converted to the target type.
13656 @sp 1
13657 @cartouche
13658 @noindent
13659 @strong{130}.  Conditions on a @code{universal_real} operand of a fixed
13660 point multiplication or division for which the result shall be in the
13661 perfect result set.  See G.2.3(22).
13662 @end cartouche
13663 @noindent
13664 The result is only defined to be in the perfect result set if the result
13665 can be computed by a single scaling operation involving a scale factor
13666 representable in 64-bits.
13668 @sp 1
13669 @cartouche
13670 @noindent
13671 @strong{131}.  The result of a fixed point arithmetic operation in
13672 overflow situations, when the @code{Machine_Overflows} attribute of the
13673 result type is @code{False}.  See G.2.3(27).
13674 @end cartouche
13675 @noindent
13676 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
13677 types.
13679 @sp 1
13680 @cartouche
13681 @noindent
13682 @strong{132}.  The result of an elementary function reference in
13683 overflow situations, when the @code{Machine_Overflows} attribute of the
13684 result type is @code{False}.  See G.2.4(4).
13685 @end cartouche
13686 @noindent
13687 IEEE infinite and Nan values are produced as appropriate.
13689 @sp 1
13690 @cartouche
13691 @noindent
13692 @strong{133}.  The value of the angle threshold, within which certain
13693 elementary functions, complex arithmetic operations, and complex
13694 elementary functions yield results conforming to a maximum relative
13695 error bound.  See G.2.4(10).
13696 @end cartouche
13697 @noindent
13698 Information on this subject is not yet available.
13700 @sp 1
13701 @cartouche
13702 @noindent
13703 @strong{134}.  The accuracy of certain elementary functions for
13704 parameters beyond the angle threshold.  See G.2.4(10).
13705 @end cartouche
13706 @noindent
13707 Information on this subject is not yet available.
13709 @sp 1
13710 @cartouche
13711 @noindent
13712 @strong{135}.  The result of a complex arithmetic operation or complex
13713 elementary function reference in overflow situations, when the
13714 @code{Machine_Overflows} attribute of the corresponding real type is
13715 @code{False}.  See G.2.6(5).
13716 @end cartouche
13717 @noindent
13718 IEEE infinite and Nan values are produced as appropriate.
13720 @sp 1
13721 @cartouche
13722 @noindent
13723 @strong{136}.  The accuracy of certain complex arithmetic operations and
13724 certain complex elementary functions for parameters (or components
13725 thereof) beyond the angle threshold.  See G.2.6(8).
13726 @end cartouche
13727 @noindent
13728 Information on those subjects is not yet available.
13730 @sp 1
13731 @cartouche
13732 @noindent
13733 @strong{137}.  Information regarding bounded errors and erroneous
13734 execution.  See H.2(1).
13735 @end cartouche
13736 @noindent
13737 Information on this subject is not yet available.
13739 @sp 1
13740 @cartouche
13741 @noindent
13742 @strong{138}.  Implementation-defined aspects of pragma
13743 @code{Inspection_Point}.  See H.3.2(8).
13744 @end cartouche
13745 @noindent
13746 Pragma @code{Inspection_Point} ensures that the variable is live and can
13747 be examined by the debugger at the inspection point.
13749 @sp 1
13750 @cartouche
13751 @noindent
13752 @strong{139}.  Implementation-defined aspects of pragma
13753 @code{Restrictions}.  See H.4(25).
13754 @end cartouche
13755 @noindent
13756 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
13757 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
13758 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
13760 @sp 1
13761 @cartouche
13762 @noindent
13763 @strong{140}.  Any restrictions on pragma @code{Restrictions}.  See
13764 H.4(27).
13765 @end cartouche
13766 @noindent
13767 There are no restrictions on pragma @code{Restrictions}.
13769 @node Intrinsic Subprograms
13770 @chapter Intrinsic Subprograms
13771 @cindex Intrinsic Subprograms
13773 @menu
13774 * Intrinsic Operators::
13775 * Enclosing_Entity::
13776 * Exception_Information::
13777 * Exception_Message::
13778 * Exception_Name::
13779 * File::
13780 * Line::
13781 * Shifts and Rotates::
13782 * Source_Location::
13783 @end menu
13785 @noindent
13786 GNAT allows a user application program to write the declaration:
13788 @smallexample @c ada
13789    pragma Import (Intrinsic, name);
13790 @end smallexample
13792 @noindent
13793 providing that the name corresponds to one of the implemented intrinsic
13794 subprograms in GNAT, and that the parameter profile of the referenced
13795 subprogram meets the requirements.  This chapter describes the set of
13796 implemented intrinsic subprograms, and the requirements on parameter profiles.
13797 Note that no body is supplied; as with other uses of pragma Import, the
13798 body is supplied elsewhere (in this case by the compiler itself).  Note
13799 that any use of this feature is potentially non-portable, since the
13800 Ada standard does not require Ada compilers to implement this feature.
13802 @node Intrinsic Operators
13803 @section Intrinsic Operators
13804 @cindex Intrinsic operator
13806 @noindent
13807 All the predefined numeric operators in package Standard
13808 in @code{pragma Import (Intrinsic,..)}
13809 declarations.  In the binary operator case, the operands must have the same
13810 size.  The operand or operands must also be appropriate for
13811 the operator.  For example, for addition, the operands must
13812 both be floating-point or both be fixed-point, and the
13813 right operand for @code{"**"} must have a root type of
13814 @code{Standard.Integer'Base}.
13815 You can use an intrinsic operator declaration as in the following example:
13817 @smallexample @c ada
13818    type Int1 is new Integer;
13819    type Int2 is new Integer;
13821    function "+" (X1 : Int1; X2 : Int2) return Int1;
13822    function "+" (X1 : Int1; X2 : Int2) return Int2;
13823    pragma Import (Intrinsic, "+");
13824 @end smallexample
13826 @noindent
13827 This declaration would permit ``mixed mode'' arithmetic on items
13828 of the differing types @code{Int1} and @code{Int2}.
13829 It is also possible to specify such operators for private types, if the
13830 full views are appropriate arithmetic types.
13832 @node Enclosing_Entity
13833 @section Enclosing_Entity
13834 @cindex Enclosing_Entity
13835 @noindent
13836 This intrinsic subprogram is used in the implementation of the
13837 library routine @code{GNAT.Source_Info}.  The only useful use of the
13838 intrinsic import in this case is the one in this unit, so an
13839 application program should simply call the function
13840 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
13841 the current subprogram, package, task, entry, or protected subprogram.
13843 @node Exception_Information
13844 @section Exception_Information
13845 @cindex Exception_Information'
13846 @noindent
13847 This intrinsic subprogram is used in the implementation of the
13848 library routine @code{GNAT.Current_Exception}.  The only useful
13849 use of the intrinsic import in this case is the one in this unit,
13850 so an application program should simply call the function
13851 @code{GNAT.Current_Exception.Exception_Information} to obtain
13852 the exception information associated with the current exception.
13854 @node Exception_Message
13855 @section Exception_Message
13856 @cindex Exception_Message
13857 @noindent
13858 This intrinsic subprogram is used in the implementation of the
13859 library routine @code{GNAT.Current_Exception}.  The only useful
13860 use of the intrinsic import in this case is the one in this unit,
13861 so an application program should simply call the function
13862 @code{GNAT.Current_Exception.Exception_Message} to obtain
13863 the message associated with the current exception.
13865 @node Exception_Name
13866 @section Exception_Name
13867 @cindex Exception_Name
13868 @noindent
13869 This intrinsic subprogram is used in the implementation of the
13870 library routine @code{GNAT.Current_Exception}.  The only useful
13871 use of the intrinsic import in this case is the one in this unit,
13872 so an application program should simply call the function
13873 @code{GNAT.Current_Exception.Exception_Name} to obtain
13874 the name of the current exception.
13876 @node File
13877 @section File
13878 @cindex File
13879 @noindent
13880 This intrinsic subprogram is used in the implementation of the
13881 library routine @code{GNAT.Source_Info}.  The only useful use of the
13882 intrinsic import in this case is the one in this unit, so an
13883 application program should simply call the function
13884 @code{GNAT.Source_Info.File} to obtain the name of the current
13885 file.
13887 @node Line
13888 @section Line
13889 @cindex Line
13890 @noindent
13891 This intrinsic subprogram is used in the implementation of the
13892 library routine @code{GNAT.Source_Info}.  The only useful use of the
13893 intrinsic import in this case is the one in this unit, so an
13894 application program should simply call the function
13895 @code{GNAT.Source_Info.Line} to obtain the number of the current
13896 source line.
13898 @node Shifts and Rotates
13899 @section Shifts and Rotates
13900 @cindex Shift_Left
13901 @cindex Shift_Right
13902 @cindex Shift_Right_Arithmetic
13903 @cindex Rotate_Left
13904 @cindex Rotate_Right
13905 @noindent
13906 In standard Ada, the shift and rotate functions are available only
13907 for the predefined modular types in package @code{Interfaces}.  However, in
13908 GNAT it is possible to define these functions for any integer
13909 type (signed or modular), as in this example:
13911 @smallexample @c ada
13912    function Shift_Left
13913      (Value  : T;
13914       Amount : Natural) return T;
13915 @end smallexample
13917 @noindent
13918 The function name must be one of
13919 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
13920 Rotate_Right. T must be an integer type. T'Size must be
13921 8, 16, 32 or 64 bits; if T is modular, the modulus
13922 must be 2**8, 2**16, 2**32 or 2**64.
13923 The result type must be the same as the type of @code{Value}.
13924 The shift amount must be Natural.
13925 The formal parameter names can be anything.
13927 A more convenient way of providing these shift operators is to use
13928 the Provide_Shift_Operators pragma, which provides the function declarations
13929 and corresponding pragma Import's for all five shift functions.
13931 @node Source_Location
13932 @section Source_Location
13933 @cindex Source_Location
13934 @noindent
13935 This intrinsic subprogram is used in the implementation of the
13936 library routine @code{GNAT.Source_Info}.  The only useful use of the
13937 intrinsic import in this case is the one in this unit, so an
13938 application program should simply call the function
13939 @code{GNAT.Source_Info.Source_Location} to obtain the current
13940 source file location.
13942 @node Representation Clauses and Pragmas
13943 @chapter Representation Clauses and Pragmas
13944 @cindex Representation Clauses
13946 @menu
13947 * Alignment Clauses::
13948 * Size Clauses::
13949 * Storage_Size Clauses::
13950 * Size of Variant Record Objects::
13951 * Biased Representation ::
13952 * Value_Size and Object_Size Clauses::
13953 * Component_Size Clauses::
13954 * Bit_Order Clauses::
13955 * Effect of Bit_Order on Byte Ordering::
13956 * Pragma Pack for Arrays::
13957 * Pragma Pack for Records::
13958 * Record Representation Clauses::
13959 * Handling of Records with Holes::
13960 * Enumeration Clauses::
13961 * Address Clauses::
13962 * Effect of Convention on Representation::
13963 * Conventions and Anonymous Access Types::
13964 * Determining the Representations chosen by GNAT::
13965 @end menu
13967 @noindent
13968 @cindex Representation Clause
13969 @cindex Representation Pragma
13970 @cindex Pragma, representation
13971 This section describes the representation clauses accepted by GNAT, and
13972 their effect on the representation of corresponding data objects.
13974 GNAT fully implements Annex C (Systems Programming).  This means that all
13975 the implementation advice sections in chapter 13 are fully implemented.
13976 However, these sections only require a minimal level of support for
13977 representation clauses.  GNAT provides much more extensive capabilities,
13978 and this section describes the additional capabilities provided.
13980 @node Alignment Clauses
13981 @section Alignment Clauses
13982 @cindex Alignment Clause
13984 @noindent
13985 GNAT requires that all alignment clauses specify a power of 2, and all
13986 default alignments are always a power of 2.  The default alignment
13987 values are as follows:
13989 @itemize @bullet
13990 @item @emph{Primitive Types}.
13991 For primitive types, the alignment is the minimum of the actual size of
13992 objects of the type divided by @code{Storage_Unit},
13993 and the maximum alignment supported by the target.
13994 (This maximum alignment is given by the GNAT-specific attribute
13995 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
13996 @cindex @code{Maximum_Alignment} attribute
13997 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
13998 default alignment will be 8 on any target that supports alignments
13999 this large, but on some targets, the maximum alignment may be smaller
14000 than 8, in which case objects of type @code{Long_Float} will be maximally
14001 aligned.
14003 @item @emph{Arrays}.
14004 For arrays, the alignment is equal to the alignment of the component type
14005 for the normal case where no packing or component size is given.  If the
14006 array is packed, and the packing is effective (see separate section on
14007 packed arrays), then the alignment will be one for long packed arrays,
14008 or arrays whose length is not known at compile time.  For short packed
14009 arrays, which are handled internally as modular types, the alignment
14010 will be as described for primitive types, e.g.@: a packed array of length
14011 31 bits will have an object size of four bytes, and an alignment of 4.
14013 @item @emph{Records}.
14014 For the normal non-packed case, the alignment of a record is equal to
14015 the maximum alignment of any of its components.  For tagged records, this
14016 includes the implicit access type used for the tag.  If a pragma @code{Pack}
14017 is used and all components are packable (see separate section on pragma
14018 @code{Pack}), then the resulting alignment is 1, unless the layout of the
14019 record makes it profitable to increase it.
14021 A special case is when:
14022 @itemize @bullet
14023 @item
14024 the size of the record is given explicitly, or a
14025 full record representation clause is given, and
14026 @item
14027 the size of the record is 2, 4, or 8 bytes.
14028 @end itemize
14029 @noindent
14030 In this case, an alignment is chosen to match the
14031 size of the record. For example, if we have:
14033 @smallexample @c ada
14034    type Small is record
14035       A, B : Character;
14036    end record;
14037    for Small'Size use 16;
14038 @end smallexample
14040 @noindent
14041 then the default alignment of the record type @code{Small} is 2, not 1. This
14042 leads to more efficient code when the record is treated as a unit, and also
14043 allows the type to specified as @code{Atomic} on architectures requiring
14044 strict alignment.
14046 @end itemize
14048 @noindent
14049 An alignment clause may specify a larger alignment than the default value
14050 up to some maximum value dependent on the target (obtainable by using the
14051 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
14052 a smaller alignment than the default value for enumeration, integer and
14053 fixed point types, as well as for record types, for example
14055 @smallexample @c ada
14056   type V is record
14057      A : Integer;
14058   end record;
14060   for V'alignment use 1;
14061 @end smallexample
14063 @noindent
14064 @cindex Alignment, default
14065 The default alignment for the type @code{V} is 4, as a result of the
14066 Integer field in the record, but it is permissible, as shown, to
14067 override the default alignment of the record with a smaller value.
14069 @cindex Alignment, subtypes
14070 Note that according to the Ada standard, an alignment clause applies only
14071 to the first named subtype. If additional subtypes are declared, then the
14072 compiler is allowed to choose any alignment it likes, and there is no way
14073 to control this choice. Consider:
14075 @smallexample @c ada
14076    type R is range 1 .. 10_000;
14077    for R'Alignment use 1;
14078    subtype RS is R range 1 .. 1000;
14079 @end smallexample
14081 @noindent
14082 The alignment clause specifies an alignment of 1 for the first named subtype
14083 @code{R} but this does not necessarily apply to @code{RS}. When writing
14084 portable Ada code, you should avoid writing code that explicitly or
14085 implicitly relies on the alignment of such subtypes.
14087 For the GNAT compiler, if an explicit alignment clause is given, this
14088 value is also used for any subsequent subtypes. So for GNAT, in the
14089 above example, you can count on the alignment of @code{RS} being 1. But this
14090 assumption is non-portable, and other compilers may choose different
14091 alignments for the subtype @code{RS}.
14093 @node Size Clauses
14094 @section Size Clauses
14095 @cindex Size Clause
14097 @noindent
14098 The default size for a type @code{T} is obtainable through the
14099 language-defined attribute @code{T'Size} and also through the
14100 equivalent GNAT-defined attribute @code{T'Value_Size}.
14101 For objects of type @code{T}, GNAT will generally increase the type size
14102 so that the object size (obtainable through the GNAT-defined attribute
14103 @code{T'Object_Size})
14104 is a multiple of @code{T'Alignment * Storage_Unit}.
14105 For example
14107 @smallexample @c ada
14108    type Smallint is range 1 .. 6;
14110    type Rec is record
14111       Y1 : integer;
14112       Y2 : boolean;
14113    end record;
14114 @end smallexample
14116 @noindent
14117 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
14118 as specified by the RM rules,
14119 but objects of this type will have a size of 8
14120 (@code{Smallint'Object_Size} = 8),
14121 since objects by default occupy an integral number
14122 of storage units.  On some targets, notably older
14123 versions of the Digital Alpha, the size of stand
14124 alone objects of this type may be 32, reflecting
14125 the inability of the hardware to do byte load/stores.
14127 Similarly, the size of type @code{Rec} is 40 bits
14128 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
14129 the alignment is 4, so objects of this type will have
14130 their size increased to 64 bits so that it is a multiple
14131 of the alignment (in bits).  This decision is
14132 in accordance with the specific Implementation Advice in RM 13.3(43):
14134 @quotation
14135 A @code{Size} clause should be supported for an object if the specified
14136 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
14137 to a size in storage elements that is a multiple of the object's
14138 @code{Alignment} (if the @code{Alignment} is nonzero).
14139 @end quotation
14141 @noindent
14142 An explicit size clause may be used to override the default size by
14143 increasing it.  For example, if we have:
14145 @smallexample @c ada
14146    type My_Boolean is new Boolean;
14147    for My_Boolean'Size use 32;
14148 @end smallexample
14150 @noindent
14151 then values of this type will always be 32 bits long.  In the case of
14152 discrete types, the size can be increased up to 64 bits, with the effect
14153 that the entire specified field is used to hold the value, sign- or
14154 zero-extended as appropriate.  If more than 64 bits is specified, then
14155 padding space is allocated after the value, and a warning is issued that
14156 there are unused bits.
14158 Similarly the size of records and arrays may be increased, and the effect
14159 is to add padding bits after the value.  This also causes a warning message
14160 to be generated.
14162 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
14163 Size in bits, this corresponds to an object of size 256 megabytes (minus
14164 one).  This limitation is true on all targets.  The reason for this
14165 limitation is that it improves the quality of the code in many cases
14166 if it is known that a Size value can be accommodated in an object of
14167 type Integer.
14169 @node Storage_Size Clauses
14170 @section Storage_Size Clauses
14171 @cindex Storage_Size Clause
14173 @noindent
14174 For tasks, the @code{Storage_Size} clause specifies the amount of space
14175 to be allocated for the task stack.  This cannot be extended, and if the
14176 stack is exhausted, then @code{Storage_Error} will be raised (if stack
14177 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
14178 or a @code{Storage_Size} pragma in the task definition to set the
14179 appropriate required size.  A useful technique is to include in every
14180 task definition a pragma of the form:
14182 @smallexample @c ada
14183    pragma Storage_Size (Default_Stack_Size);
14184 @end smallexample
14186 @noindent
14187 Then @code{Default_Stack_Size} can be defined in a global package, and
14188 modified as required. Any tasks requiring stack sizes different from the
14189 default can have an appropriate alternative reference in the pragma.
14191 You can also use the @option{-d} binder switch to modify the default stack
14192 size.
14194 For access types, the @code{Storage_Size} clause specifies the maximum
14195 space available for allocation of objects of the type.  If this space is
14196 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
14197 In the case where the access type is declared local to a subprogram, the
14198 use of a @code{Storage_Size} clause triggers automatic use of a special
14199 predefined storage pool (@code{System.Pool_Size}) that ensures that all
14200 space for the pool is automatically reclaimed on exit from the scope in
14201 which the type is declared.
14203 A special case recognized by the compiler is the specification of a
14204 @code{Storage_Size} of zero for an access type.  This means that no
14205 items can be allocated from the pool, and this is recognized at compile
14206 time, and all the overhead normally associated with maintaining a fixed
14207 size storage pool is eliminated.  Consider the following example:
14209 @smallexample @c ada
14210    procedure p is
14211       type R is array (Natural) of Character;
14212       type P is access all R;
14213       for P'Storage_Size use 0;
14214       --  Above access type intended only for interfacing purposes
14216       y : P;
14218       procedure g (m : P);
14219       pragma Import (C, g);
14221       --  @dots{}
14223    begin
14224       --  @dots{}
14225       y := new R;
14226    end;
14227 @end smallexample
14229 @noindent
14230 As indicated in this example, these dummy storage pools are often useful in
14231 connection with interfacing where no object will ever be allocated.  If you
14232 compile the above example, you get the warning:
14234 @smallexample
14235    p.adb:16:09: warning: allocation from empty storage pool
14236    p.adb:16:09: warning: Storage_Error will be raised at run time
14237 @end smallexample
14239 @noindent
14240 Of course in practice, there will not be any explicit allocators in the
14241 case of such an access declaration.
14243 @node Size of Variant Record Objects
14244 @section Size of Variant Record Objects
14245 @cindex Size, variant record objects
14246 @cindex Variant record objects, size
14248 @noindent
14249 In the case of variant record objects, there is a question whether Size gives
14250 information about a particular variant, or the maximum size required
14251 for any variant.  Consider the following program
14253 @smallexample @c ada
14254 with Text_IO; use Text_IO;
14255 procedure q is
14256    type R1 (A : Boolean := False) is record
14257      case A is
14258        when True  => X : Character;
14259        when False => null;
14260      end case;
14261    end record;
14263    V1 : R1 (False);
14264    V2 : R1;
14266 begin
14267    Put_Line (Integer'Image (V1'Size));
14268    Put_Line (Integer'Image (V2'Size));
14269 end q;
14270 @end smallexample
14272 @noindent
14273 Here we are dealing with a variant record, where the True variant
14274 requires 16 bits, and the False variant requires 8 bits.
14275 In the above example, both V1 and V2 contain the False variant,
14276 which is only 8 bits long.  However, the result of running the
14277 program is:
14279 @smallexample
14282 @end smallexample
14284 @noindent
14285 The reason for the difference here is that the discriminant value of
14286 V1 is fixed, and will always be False.  It is not possible to assign
14287 a True variant value to V1, therefore 8 bits is sufficient.  On the
14288 other hand, in the case of V2, the initial discriminant value is
14289 False (from the default), but it is possible to assign a True
14290 variant value to V2, therefore 16 bits must be allocated for V2
14291 in the general case, even fewer bits may be needed at any particular
14292 point during the program execution.
14294 As can be seen from the output of this program, the @code{'Size}
14295 attribute applied to such an object in GNAT gives the actual allocated
14296 size of the variable, which is the largest size of any of the variants.
14297 The Ada Reference Manual is not completely clear on what choice should
14298 be made here, but the GNAT behavior seems most consistent with the
14299 language in the RM@.
14301 In some cases, it may be desirable to obtain the size of the current
14302 variant, rather than the size of the largest variant.  This can be
14303 achieved in GNAT by making use of the fact that in the case of a
14304 subprogram parameter, GNAT does indeed return the size of the current
14305 variant (because a subprogram has no way of knowing how much space
14306 is actually allocated for the actual).
14308 Consider the following modified version of the above program:
14310 @smallexample @c ada
14311 with Text_IO; use Text_IO;
14312 procedure q is
14313    type R1 (A : Boolean := False) is record
14314      case A is
14315        when True  => X : Character;
14316        when False => null;
14317      end case;
14318    end record;
14320    V2 : R1;
14322    function Size (V : R1) return Integer is
14323    begin
14324       return V'Size;
14325    end Size;
14327 begin
14328    Put_Line (Integer'Image (V2'Size));
14329    Put_Line (Integer'IMage (Size (V2)));
14330    V2 := (True, 'x');
14331    Put_Line (Integer'Image (V2'Size));
14332    Put_Line (Integer'IMage (Size (V2)));
14333 end q;
14334 @end smallexample
14336 @noindent
14337 The output from this program is
14339 @smallexample
14344 @end smallexample
14346 @noindent
14347 Here we see that while the @code{'Size} attribute always returns
14348 the maximum size, regardless of the current variant value, the
14349 @code{Size} function does indeed return the size of the current
14350 variant value.
14352 @node Biased Representation
14353 @section Biased Representation
14354 @cindex Size for biased representation
14355 @cindex Biased representation
14357 @noindent
14358 In the case of scalars with a range starting at other than zero, it is
14359 possible in some cases to specify a size smaller than the default minimum
14360 value, and in such cases, GNAT uses an unsigned biased representation,
14361 in which zero is used to represent the lower bound, and successive values
14362 represent successive values of the type.
14364 For example, suppose we have the declaration:
14366 @smallexample @c ada
14367    type Small is range -7 .. -4;
14368    for Small'Size use 2;
14369 @end smallexample
14371 @noindent
14372 Although the default size of type @code{Small} is 4, the @code{Size}
14373 clause is accepted by GNAT and results in the following representation
14374 scheme:
14376 @smallexample
14377   -7 is represented as 2#00#
14378   -6 is represented as 2#01#
14379   -5 is represented as 2#10#
14380   -4 is represented as 2#11#
14381 @end smallexample
14383 @noindent
14384 Biased representation is only used if the specified @code{Size} clause
14385 cannot be accepted in any other manner.  These reduced sizes that force
14386 biased representation can be used for all discrete types except for
14387 enumeration types for which a representation clause is given.
14389 @node Value_Size and Object_Size Clauses
14390 @section Value_Size and Object_Size Clauses
14391 @findex Value_Size
14392 @findex Object_Size
14393 @cindex Size, of objects
14395 @noindent
14396 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
14397 number of bits required to hold values of type @code{T}.
14398 Although this interpretation was allowed in Ada 83, it was not required,
14399 and this requirement in practice can cause some significant difficulties.
14400 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
14401 However, in Ada 95 and Ada 2005,
14402 @code{Natural'Size} is
14403 typically 31.  This means that code may change in behavior when moving
14404 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
14406 @smallexample @c ada
14407    type Rec is record;
14408       A : Natural;
14409       B : Natural;
14410    end record;
14412    for Rec use record
14413       at 0  range 0 .. Natural'Size - 1;
14414       at 0  range Natural'Size .. 2 * Natural'Size - 1;
14415    end record;
14416 @end smallexample
14418 @noindent
14419 In the above code, since the typical size of @code{Natural} objects
14420 is 32 bits and @code{Natural'Size} is 31, the above code can cause
14421 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
14422 there are cases where the fact that the object size can exceed the
14423 size of the type causes surprises.
14425 To help get around this problem GNAT provides two implementation
14426 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
14427 applied to a type, these attributes yield the size of the type
14428 (corresponding to the RM defined size attribute), and the size of
14429 objects of the type respectively.
14431 The @code{Object_Size} is used for determining the default size of
14432 objects and components.  This size value can be referred to using the
14433 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
14434 the basis of the determination of the size.  The backend is free to
14435 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
14436 character might be stored in 32 bits on a machine with no efficient
14437 byte access instructions such as the Alpha.
14439 The default rules for the value of @code{Object_Size} for
14440 discrete types are as follows:
14442 @itemize @bullet
14443 @item
14444 The @code{Object_Size} for base subtypes reflect the natural hardware
14445 size in bits (run the compiler with @option{-gnatS} to find those values
14446 for numeric types). Enumeration types and fixed-point base subtypes have
14447 8, 16, 32 or 64 bits for this size, depending on the range of values
14448 to be stored.
14450 @item
14451 The @code{Object_Size} of a subtype is the same as the
14452 @code{Object_Size} of
14453 the type from which it is obtained.
14455 @item
14456 The @code{Object_Size} of a derived base type is copied from the parent
14457 base type, and the @code{Object_Size} of a derived first subtype is copied
14458 from the parent first subtype.
14459 @end itemize
14461 @noindent
14462 The @code{Value_Size} attribute
14463 is the (minimum) number of bits required to store a value
14464 of the type.
14465 This value is used to determine how tightly to pack
14466 records or arrays with components of this type, and also affects
14467 the semantics of unchecked conversion (unchecked conversions where
14468 the @code{Value_Size} values differ generate a warning, and are potentially
14469 target dependent).
14471 The default rules for the value of @code{Value_Size} are as follows:
14473 @itemize @bullet
14474 @item
14475 The @code{Value_Size} for a base subtype is the minimum number of bits
14476 required to store all values of the type (including the sign bit
14477 only if negative values are possible).
14479 @item
14480 If a subtype statically matches the first subtype of a given type, then it has
14481 by default the same @code{Value_Size} as the first subtype.  This is a
14482 consequence of RM 13.1(14) (``if two subtypes statically match,
14483 then their subtype-specific aspects are the same''.)
14485 @item
14486 All other subtypes have a @code{Value_Size} corresponding to the minimum
14487 number of bits required to store all values of the subtype.  For
14488 dynamic bounds, it is assumed that the value can range down or up
14489 to the corresponding bound of the ancestor
14490 @end itemize
14492 @noindent
14493 The RM defined attribute @code{Size} corresponds to the
14494 @code{Value_Size} attribute.
14496 The @code{Size} attribute may be defined for a first-named subtype.  This sets
14497 the @code{Value_Size} of
14498 the first-named subtype to the given value, and the
14499 @code{Object_Size} of this first-named subtype to the given value padded up
14500 to an appropriate boundary.  It is a consequence of the default rules
14501 above that this @code{Object_Size} will apply to all further subtypes.  On the
14502 other hand, @code{Value_Size} is affected only for the first subtype, any
14503 dynamic subtypes obtained from it directly, and any statically matching
14504 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
14506 @code{Value_Size} and
14507 @code{Object_Size} may be explicitly set for any subtype using
14508 an attribute definition clause.  Note that the use of these attributes
14509 can cause the RM 13.1(14) rule to be violated.  If two access types
14510 reference aliased objects whose subtypes have differing @code{Object_Size}
14511 values as a result of explicit attribute definition clauses, then it
14512 is illegal to convert from one access subtype to the other. For a more
14513 complete description of this additional legality rule, see the
14514 description of the @code{Object_Size} attribute.
14516 At the implementation level, Esize stores the Object_Size and the
14517 RM_Size field stores the @code{Value_Size} (and hence the value of the
14518 @code{Size} attribute,
14519 which, as noted above, is equivalent to @code{Value_Size}).
14521 To get a feel for the difference, consider the following examples (note
14522 that in each case the base is @code{Short_Short_Integer} with a size of 8):
14524 @smallexample
14525                                        Object_Size     Value_Size
14527 type x1 is range 0 .. 5;                    8               3
14529 type x2 is range 0 .. 5;
14530 for x2'size use 12;                        16              12
14532 subtype x3 is x2 range 0 .. 3;             16               2
14534 subtype x4 is x2'base range 0 .. 10;        8               4
14536 subtype x5 is x2 range 0 .. dynamic;       16               3*
14538 subtype x6 is x2'base range 0 .. dynamic;   8               3*
14540 @end smallexample
14542 @noindent
14543 Note: the entries marked ``3*'' are not actually specified by the Ada
14544 Reference Manual, but it seems in the spirit of the RM rules to allocate
14545 the minimum number of bits (here 3, given the range for @code{x2})
14546 known to be large enough to hold the given range of values.
14548 So far, so good, but GNAT has to obey the RM rules, so the question is
14549 under what conditions must the RM @code{Size} be used.
14550 The following is a list
14551 of the occasions on which the RM @code{Size} must be used:
14553 @itemize @bullet
14554 @item
14555 Component size for packed arrays or records
14557 @item
14558 Value of the attribute @code{Size} for a type
14560 @item
14561 Warning about sizes not matching for unchecked conversion
14562 @end itemize
14564 @noindent
14565 For record types, the @code{Object_Size} is always a multiple of the
14566 alignment of the type (this is true for all types). In some cases the
14567 @code{Value_Size} can be smaller. Consider:
14569 @smallexample
14570    type R is record
14571      X : Integer;
14572      Y : Character;
14573    end record;
14574 @end smallexample
14576 @noindent
14577 On a typical 32-bit architecture, the X component will be four bytes, and
14578 require four-byte alignment, and the Y component will be one byte. In this
14579 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
14580 required to store a value of this type, and for example, it is permissible
14581 to have a component of type R in an outer array whose component size is
14582 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
14583 since it must be rounded up so that this value is a multiple of the
14584 alignment (4 bytes = 32 bits).
14586 @noindent
14587 For all other types, the @code{Object_Size}
14588 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
14589 Only @code{Size} may be specified for such types.
14591 Note that @code{Value_Size} can be used to force biased representation
14592 for a particular subtype. Consider this example:
14594 @smallexample
14595    type R is (A, B, C, D, E, F);
14596    subtype RAB is R range A .. B;
14597    subtype REF is R range E .. F;
14598 @end smallexample
14600 @noindent
14601 By default, @code{RAB}
14602 has a size of 1 (sufficient to accommodate the representation
14603 of @code{A} and @code{B}, 0 and 1), and @code{REF}
14604 has a size of 3 (sufficient to accommodate the representation
14605 of @code{E} and @code{F}, 4 and 5). But if we add the
14606 following @code{Value_Size} attribute definition clause:
14608 @smallexample
14609    for REF'Value_Size use 1;
14610 @end smallexample
14612 @noindent
14613 then biased representation is forced for @code{REF},
14614 and 0 will represent @code{E} and 1 will represent @code{F}.
14615 A warning is issued when a @code{Value_Size} attribute
14616 definition clause forces biased representation. This
14617 warning can be turned off using @code{-gnatw.B}.
14619 @node Component_Size Clauses
14620 @section Component_Size Clauses
14621 @cindex Component_Size Clause
14623 @noindent
14624 Normally, the value specified in a component size clause must be consistent
14625 with the subtype of the array component with regard to size and alignment.
14626 In other words, the value specified must be at least equal to the size
14627 of this subtype, and must be a multiple of the alignment value.
14629 In addition, component size clauses are allowed which cause the array
14630 to be packed, by specifying a smaller value.  A first case is for
14631 component size values in the range 1 through 63.  The value specified
14632 must not be smaller than the Size of the subtype.  GNAT will accurately
14633 honor all packing requests in this range.  For example, if we have:
14635 @smallexample @c ada
14636 type r is array (1 .. 8) of Natural;
14637 for r'Component_Size use 31;
14638 @end smallexample
14640 @noindent
14641 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
14642 Of course access to the components of such an array is considerably
14643 less efficient than if the natural component size of 32 is used.
14644 A second case is when the subtype of the component is a record type
14645 padded because of its default alignment.  For example, if we have:
14647 @smallexample @c ada
14648 type r is record
14649   i : Integer;
14650   j : Integer;
14651   b : Boolean;
14652 end record;
14654 type a is array (1 .. 8) of r;
14655 for a'Component_Size use 72;
14656 @end smallexample
14658 @noindent
14659 then the resulting array has a length of 72 bytes, instead of 96 bytes
14660 if the alignment of the record (4) was obeyed.
14662 Note that there is no point in giving both a component size clause
14663 and a pragma Pack for the same array type. if such duplicate
14664 clauses are given, the pragma Pack will be ignored.
14666 @node Bit_Order Clauses
14667 @section Bit_Order Clauses
14668 @cindex Bit_Order Clause
14669 @cindex bit ordering
14670 @cindex ordering, of bits
14672 @noindent
14673 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
14674 attribute.  The specification may either correspond to the default bit
14675 order for the target, in which case the specification has no effect and
14676 places no additional restrictions, or it may be for the non-standard
14677 setting (that is the opposite of the default).
14679 In the case where the non-standard value is specified, the effect is
14680 to renumber bits within each byte, but the ordering of bytes is not
14681 affected.  There are certain
14682 restrictions placed on component clauses as follows:
14684 @itemize @bullet
14686 @item Components fitting within a single storage unit.
14687 @noindent
14688 These are unrestricted, and the effect is merely to renumber bits.  For
14689 example if we are on a little-endian machine with @code{Low_Order_First}
14690 being the default, then the following two declarations have exactly
14691 the same effect:
14693 @smallexample @c ada
14694    type R1 is record
14695       A : Boolean;
14696       B : Integer range 1 .. 120;
14697    end record;
14699    for R1 use record
14700       A at 0 range 0 .. 0;
14701       B at 0 range 1 .. 7;
14702    end record;
14704    type R2 is record
14705       A : Boolean;
14706       B : Integer range 1 .. 120;
14707    end record;
14709    for R2'Bit_Order use High_Order_First;
14711    for R2 use record
14712       A at 0 range 7 .. 7;
14713       B at 0 range 0 .. 6;
14714    end record;
14715 @end smallexample
14717 @noindent
14718 The useful application here is to write the second declaration with the
14719 @code{Bit_Order} attribute definition clause, and know that it will be treated
14720 the same, regardless of whether the target is little-endian or big-endian.
14722 @item Components occupying an integral number of bytes.
14723 @noindent
14724 These are components that exactly fit in two or more bytes.  Such component
14725 declarations are allowed, but have no effect, since it is important to realize
14726 that the @code{Bit_Order} specification does not affect the ordering of bytes.
14727 In particular, the following attempt at getting an endian-independent integer
14728 does not work:
14730 @smallexample @c ada
14731    type R2 is record
14732       A : Integer;
14733    end record;
14735    for R2'Bit_Order use High_Order_First;
14737    for R2 use record
14738       A at 0 range 0 .. 31;
14739    end record;
14740 @end smallexample
14742 @noindent
14743 This declaration will result in a little-endian integer on a
14744 little-endian machine, and a big-endian integer on a big-endian machine.
14745 If byte flipping is required for interoperability between big- and
14746 little-endian machines, this must be explicitly programmed.  This capability
14747 is not provided by @code{Bit_Order}.
14749 @item Components that are positioned across byte boundaries
14750 @noindent
14751 but do not occupy an integral number of bytes.  Given that bytes are not
14752 reordered, such fields would occupy a non-contiguous sequence of bits
14753 in memory, requiring non-trivial code to reassemble.  They are for this
14754 reason not permitted, and any component clause specifying such a layout
14755 will be flagged as illegal by GNAT@.
14757 @end itemize
14759 @noindent
14760 Since the misconception that Bit_Order automatically deals with all
14761 endian-related incompatibilities is a common one, the specification of
14762 a component field that is an integral number of bytes will always
14763 generate a warning.  This warning may be suppressed using @code{pragma
14764 Warnings (Off)} if desired.  The following section contains additional
14765 details regarding the issue of byte ordering.
14767 @node Effect of Bit_Order on Byte Ordering
14768 @section Effect of Bit_Order on Byte Ordering
14769 @cindex byte ordering
14770 @cindex ordering, of bytes
14772 @noindent
14773 In this section we will review the effect of the @code{Bit_Order} attribute
14774 definition clause on byte ordering.  Briefly, it has no effect at all, but
14775 a detailed example will be helpful.  Before giving this
14776 example, let us review the precise
14777 definition of the effect of defining @code{Bit_Order}.  The effect of a
14778 non-standard bit order is described in section 15.5.3 of the Ada
14779 Reference Manual:
14781 @quotation
14782 2   A bit ordering is a method of interpreting the meaning of
14783 the storage place attributes.
14784 @end quotation
14786 @noindent
14787 To understand the precise definition of storage place attributes in
14788 this context, we visit section 13.5.1 of the manual:
14790 @quotation
14791 13   A record_representation_clause (without the mod_clause)
14792 specifies the layout.  The storage place attributes (see 13.5.2)
14793 are taken from the values of the position, first_bit, and last_bit
14794 expressions after normalizing those values so that first_bit is
14795 less than Storage_Unit.
14796 @end quotation
14798 @noindent
14799 The critical point here is that storage places are taken from
14800 the values after normalization, not before.  So the @code{Bit_Order}
14801 interpretation applies to normalized values.  The interpretation
14802 is described in the later part of the 15.5.3 paragraph:
14804 @quotation
14805 2   A bit ordering is a method of interpreting the meaning of
14806 the storage place attributes.  High_Order_First (known in the
14807 vernacular as ``big endian'') means that the first bit of a
14808 storage element (bit 0) is the most significant bit (interpreting
14809 the sequence of bits that represent a component as an unsigned
14810 integer value).  Low_Order_First (known in the vernacular as
14811 ``little endian'') means the opposite: the first bit is the
14812 least significant.
14813 @end quotation
14815 @noindent
14816 Note that the numbering is with respect to the bits of a storage
14817 unit.  In other words, the specification affects only the numbering
14818 of bits within a single storage unit.
14820 We can make the effect clearer by giving an example.
14822 Suppose that we have an external device which presents two bytes, the first
14823 byte presented, which is the first (low addressed byte) of the two byte
14824 record is called Master, and the second byte is called Slave.
14826 The left most (most significant bit is called Control for each byte, and
14827 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
14828 (least significant) bit.
14830 On a big-endian machine, we can write the following representation clause
14832 @smallexample @c ada
14833    type Data is record
14834       Master_Control : Bit;
14835       Master_V1      : Bit;
14836       Master_V2      : Bit;
14837       Master_V3      : Bit;
14838       Master_V4      : Bit;
14839       Master_V5      : Bit;
14840       Master_V6      : Bit;
14841       Master_V7      : Bit;
14842       Slave_Control  : Bit;
14843       Slave_V1       : Bit;
14844       Slave_V2       : Bit;
14845       Slave_V3       : Bit;
14846       Slave_V4       : Bit;
14847       Slave_V5       : Bit;
14848       Slave_V6       : Bit;
14849       Slave_V7       : Bit;
14850    end record;
14852    for Data use record
14853       Master_Control at 0 range 0 .. 0;
14854       Master_V1      at 0 range 1 .. 1;
14855       Master_V2      at 0 range 2 .. 2;
14856       Master_V3      at 0 range 3 .. 3;
14857       Master_V4      at 0 range 4 .. 4;
14858       Master_V5      at 0 range 5 .. 5;
14859       Master_V6      at 0 range 6 .. 6;
14860       Master_V7      at 0 range 7 .. 7;
14861       Slave_Control  at 1 range 0 .. 0;
14862       Slave_V1       at 1 range 1 .. 1;
14863       Slave_V2       at 1 range 2 .. 2;
14864       Slave_V3       at 1 range 3 .. 3;
14865       Slave_V4       at 1 range 4 .. 4;
14866       Slave_V5       at 1 range 5 .. 5;
14867       Slave_V6       at 1 range 6 .. 6;
14868       Slave_V7       at 1 range 7 .. 7;
14869    end record;
14870 @end smallexample
14872 @noindent
14873 Now if we move this to a little endian machine, then the bit ordering within
14874 the byte is backwards, so we have to rewrite the record rep clause as:
14876 @smallexample @c ada
14877    for Data use record
14878       Master_Control at 0 range 7 .. 7;
14879       Master_V1      at 0 range 6 .. 6;
14880       Master_V2      at 0 range 5 .. 5;
14881       Master_V3      at 0 range 4 .. 4;
14882       Master_V4      at 0 range 3 .. 3;
14883       Master_V5      at 0 range 2 .. 2;
14884       Master_V6      at 0 range 1 .. 1;
14885       Master_V7      at 0 range 0 .. 0;
14886       Slave_Control  at 1 range 7 .. 7;
14887       Slave_V1       at 1 range 6 .. 6;
14888       Slave_V2       at 1 range 5 .. 5;
14889       Slave_V3       at 1 range 4 .. 4;
14890       Slave_V4       at 1 range 3 .. 3;
14891       Slave_V5       at 1 range 2 .. 2;
14892       Slave_V6       at 1 range 1 .. 1;
14893       Slave_V7       at 1 range 0 .. 0;
14894    end record;
14895 @end smallexample
14897 @noindent
14898 It is a nuisance to have to rewrite the clause, especially if
14899 the code has to be maintained on both machines.  However,
14900 this is a case that we can handle with the
14901 @code{Bit_Order} attribute if it is implemented.
14902 Note that the implementation is not required on byte addressed
14903 machines, but it is indeed implemented in GNAT.
14904 This means that we can simply use the
14905 first record clause, together with the declaration
14907 @smallexample @c ada
14908    for Data'Bit_Order use High_Order_First;
14909 @end smallexample
14911 @noindent
14912 and the effect is what is desired, namely the layout is exactly the same,
14913 independent of whether the code is compiled on a big-endian or little-endian
14914 machine.
14916 The important point to understand is that byte ordering is not affected.
14917 A @code{Bit_Order} attribute definition never affects which byte a field
14918 ends up in, only where it ends up in that byte.
14919 To make this clear, let us rewrite the record rep clause of the previous
14920 example as:
14922 @smallexample @c ada
14923    for Data'Bit_Order use High_Order_First;
14924    for Data use record
14925       Master_Control at 0 range  0 .. 0;
14926       Master_V1      at 0 range  1 .. 1;
14927       Master_V2      at 0 range  2 .. 2;
14928       Master_V3      at 0 range  3 .. 3;
14929       Master_V4      at 0 range  4 .. 4;
14930       Master_V5      at 0 range  5 .. 5;
14931       Master_V6      at 0 range  6 .. 6;
14932       Master_V7      at 0 range  7 .. 7;
14933       Slave_Control  at 0 range  8 .. 8;
14934       Slave_V1       at 0 range  9 .. 9;
14935       Slave_V2       at 0 range 10 .. 10;
14936       Slave_V3       at 0 range 11 .. 11;
14937       Slave_V4       at 0 range 12 .. 12;
14938       Slave_V5       at 0 range 13 .. 13;
14939       Slave_V6       at 0 range 14 .. 14;
14940       Slave_V7       at 0 range 15 .. 15;
14941    end record;
14942 @end smallexample
14944 @noindent
14945 This is exactly equivalent to saying (a repeat of the first example):
14947 @smallexample @c ada
14948    for Data'Bit_Order use High_Order_First;
14949    for Data use record
14950       Master_Control at 0 range 0 .. 0;
14951       Master_V1      at 0 range 1 .. 1;
14952       Master_V2      at 0 range 2 .. 2;
14953       Master_V3      at 0 range 3 .. 3;
14954       Master_V4      at 0 range 4 .. 4;
14955       Master_V5      at 0 range 5 .. 5;
14956       Master_V6      at 0 range 6 .. 6;
14957       Master_V7      at 0 range 7 .. 7;
14958       Slave_Control  at 1 range 0 .. 0;
14959       Slave_V1       at 1 range 1 .. 1;
14960       Slave_V2       at 1 range 2 .. 2;
14961       Slave_V3       at 1 range 3 .. 3;
14962       Slave_V4       at 1 range 4 .. 4;
14963       Slave_V5       at 1 range 5 .. 5;
14964       Slave_V6       at 1 range 6 .. 6;
14965       Slave_V7       at 1 range 7 .. 7;
14966    end record;
14967 @end smallexample
14969 @noindent
14970 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
14971 field.  The storage place attributes are obtained by normalizing the
14972 values given so that the @code{First_Bit} value is less than 8.  After
14973 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
14974 we specified in the other case.
14976 Now one might expect that the @code{Bit_Order} attribute might affect
14977 bit numbering within the entire record component (two bytes in this
14978 case, thus affecting which byte fields end up in), but that is not
14979 the way this feature is defined, it only affects numbering of bits,
14980 not which byte they end up in.
14982 Consequently it never makes sense to specify a starting bit number
14983 greater than 7 (for a byte addressable field) if an attribute
14984 definition for @code{Bit_Order} has been given, and indeed it
14985 may be actively confusing to specify such a value, so the compiler
14986 generates a warning for such usage.
14988 If you do need to control byte ordering then appropriate conditional
14989 values must be used.  If in our example, the slave byte came first on
14990 some machines we might write:
14992 @smallexample @c ada
14993    Master_Byte_First constant Boolean := @dots{};
14995    Master_Byte : constant Natural :=
14996                    1 - Boolean'Pos (Master_Byte_First);
14997    Slave_Byte  : constant Natural :=
14998                    Boolean'Pos (Master_Byte_First);
15000    for Data'Bit_Order use High_Order_First;
15001    for Data use record
15002       Master_Control at Master_Byte range 0 .. 0;
15003       Master_V1      at Master_Byte range 1 .. 1;
15004       Master_V2      at Master_Byte range 2 .. 2;
15005       Master_V3      at Master_Byte range 3 .. 3;
15006       Master_V4      at Master_Byte range 4 .. 4;
15007       Master_V5      at Master_Byte range 5 .. 5;
15008       Master_V6      at Master_Byte range 6 .. 6;
15009       Master_V7      at Master_Byte range 7 .. 7;
15010       Slave_Control  at Slave_Byte  range 0 .. 0;
15011       Slave_V1       at Slave_Byte  range 1 .. 1;
15012       Slave_V2       at Slave_Byte  range 2 .. 2;
15013       Slave_V3       at Slave_Byte  range 3 .. 3;
15014       Slave_V4       at Slave_Byte  range 4 .. 4;
15015       Slave_V5       at Slave_Byte  range 5 .. 5;
15016       Slave_V6       at Slave_Byte  range 6 .. 6;
15017       Slave_V7       at Slave_Byte  range 7 .. 7;
15018    end record;
15019 @end smallexample
15021 @noindent
15022 Now to switch between machines, all that is necessary is
15023 to set the boolean constant @code{Master_Byte_First} in
15024 an appropriate manner.
15026 @node Pragma Pack for Arrays
15027 @section Pragma Pack for Arrays
15028 @cindex Pragma Pack (for arrays)
15030 @noindent
15031 Pragma @code{Pack} applied to an array has no effect unless the component type
15032 is packable.  For a component type to be packable, it must be one of the
15033 following cases:
15035 @itemize @bullet
15036 @item
15037 Any scalar type
15038 @item
15039 Any type whose size is specified with a size clause
15040 @item
15041 Any packed array type with a static size
15042 @item
15043 Any record type padded because of its default alignment
15044 @end itemize
15046 @noindent
15047 For all these cases, if the component subtype size is in the range
15048 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
15049 component size were specified giving the component subtype size.
15050 For example if we have:
15052 @smallexample @c ada
15053    type r is range 0 .. 17;
15055    type ar is array (1 .. 8) of r;
15056    pragma Pack (ar);
15057 @end smallexample
15059 @noindent
15060 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
15061 and the size of the array @code{ar} will be exactly 40 bits.
15063 Note that in some cases this rather fierce approach to packing can produce
15064 unexpected effects.  For example, in Ada 95 and Ada 2005,
15065 subtype @code{Natural} typically has a size of 31, meaning that if you
15066 pack an array of @code{Natural}, you get 31-bit
15067 close packing, which saves a few bits, but results in far less efficient
15068 access.  Since many other Ada compilers will ignore such a packing request,
15069 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
15070 might not be what is intended.  You can easily remove this warning by
15071 using an explicit @code{Component_Size} setting instead, which never generates
15072 a warning, since the intention of the programmer is clear in this case.
15074 GNAT treats packed arrays in one of two ways.  If the size of the array is
15075 known at compile time and is less than 64 bits, then internally the array
15076 is represented as a single modular type, of exactly the appropriate number
15077 of bits.  If the length is greater than 63 bits, or is not known at compile
15078 time, then the packed array is represented as an array of bytes, and the
15079 length is always a multiple of 8 bits.
15081 Note that to represent a packed array as a modular type, the alignment must
15082 be suitable for the modular type involved. For example, on typical machines
15083 a 32-bit packed array will be represented by a 32-bit modular integer with
15084 an alignment of four bytes. If you explicitly override the default alignment
15085 with an alignment clause that is too small, the modular representation
15086 cannot be used. For example, consider the following set of declarations:
15088 @smallexample @c ada
15089    type R is range 1 .. 3;
15090    type S is array (1 .. 31) of R;
15091    for S'Component_Size use 2;
15092    for S'Size use 62;
15093    for S'Alignment use 1;
15094 @end smallexample
15096 @noindent
15097 If the alignment clause were not present, then a 62-bit modular
15098 representation would be chosen (typically with an alignment of 4 or 8
15099 bytes depending on the target). But the default alignment is overridden
15100 with the explicit alignment clause. This means that the modular
15101 representation cannot be used, and instead the array of bytes
15102 representation must be used, meaning that the length must be a multiple
15103 of 8. Thus the above set of declarations will result in a diagnostic
15104 rejecting the size clause and noting that the minimum size allowed is 64.
15106 @cindex Pragma Pack (for type Natural)
15107 @cindex Pragma Pack warning
15109 One special case that is worth noting occurs when the base type of the
15110 component size is 8/16/32 and the subtype is one bit less. Notably this
15111 occurs with subtype @code{Natural}. Consider:
15113 @smallexample @c ada
15114    type Arr is array (1 .. 32) of Natural;
15115    pragma Pack (Arr);
15116 @end smallexample
15118 @noindent
15119 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
15120 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
15121 Ada 83 compilers did not attempt 31 bit packing.
15123 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
15124 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
15125 substantial unintended performance penalty when porting legacy Ada 83 code.
15126 To help prevent this, GNAT generates a warning in such cases. If you really
15127 want 31 bit packing in a case like this, you can set the component size
15128 explicitly:
15130 @smallexample @c ada
15131    type Arr is array (1 .. 32) of Natural;
15132    for Arr'Component_Size use 31;
15133 @end smallexample
15135 @noindent
15136 Here 31-bit packing is achieved as required, and no warning is generated,
15137 since in this case the programmer intention is clear.
15139 @node Pragma Pack for Records
15140 @section Pragma Pack for Records
15141 @cindex Pragma Pack (for records)
15143 @noindent
15144 Pragma @code{Pack} applied to a record will pack the components to reduce
15145 wasted space from alignment gaps and by reducing the amount of space
15146 taken by components.  We distinguish between @emph{packable} components and
15147 @emph{non-packable} components.
15148 Components of the following types are considered packable:
15149 @itemize @bullet
15150 @item
15151 All primitive types are packable.
15153 @item
15154 Small packed arrays, whose size does not exceed 64 bits, and where the
15155 size is statically known at compile time, are represented internally
15156 as modular integers, and so they are also packable.
15158 @end itemize
15160 @noindent
15161 All packable components occupy the exact number of bits corresponding to
15162 their @code{Size} value, and are packed with no padding bits, i.e.@: they
15163 can start on an arbitrary bit boundary.
15165 All other types are non-packable, they occupy an integral number of
15166 storage units, and
15167 are placed at a boundary corresponding to their alignment requirements.
15169 For example, consider the record
15171 @smallexample @c ada
15172    type Rb1 is array (1 .. 13) of Boolean;
15173    pragma Pack (rb1);
15175    type Rb2 is array (1 .. 65) of Boolean;
15176    pragma Pack (rb2);
15178    type x2 is record
15179       l1 : Boolean;
15180       l2 : Duration;
15181       l3 : Float;
15182       l4 : Boolean;
15183       l5 : Rb1;
15184       l6 : Rb2;
15185    end record;
15186    pragma Pack (x2);
15187 @end smallexample
15189 @noindent
15190 The representation for the record x2 is as follows:
15192 @smallexample @c ada
15193 for x2'Size use 224;
15194 for x2 use record
15195    l1 at  0 range  0 .. 0;
15196    l2 at  0 range  1 .. 64;
15197    l3 at 12 range  0 .. 31;
15198    l4 at 16 range  0 .. 0;
15199    l5 at 16 range  1 .. 13;
15200    l6 at 18 range  0 .. 71;
15201 end record;
15202 @end smallexample
15204 @noindent
15205 Studying this example, we see that the packable fields @code{l1}
15206 and @code{l2} are
15207 of length equal to their sizes, and placed at specific bit boundaries (and
15208 not byte boundaries) to
15209 eliminate padding.  But @code{l3} is of a non-packable float type, so
15210 it is on the next appropriate alignment boundary.
15212 The next two fields are fully packable, so @code{l4} and @code{l5} are
15213 minimally packed with no gaps.  However, type @code{Rb2} is a packed
15214 array that is longer than 64 bits, so it is itself non-packable.  Thus
15215 the @code{l6} field is aligned to the next byte boundary, and takes an
15216 integral number of bytes, i.e.@: 72 bits.
15218 @node Record Representation Clauses
15219 @section Record Representation Clauses
15220 @cindex Record Representation Clause
15222 @noindent
15223 Record representation clauses may be given for all record types, including
15224 types obtained by record extension.  Component clauses are allowed for any
15225 static component.  The restrictions on component clauses depend on the type
15226 of the component.
15228 @cindex Component Clause
15229 For all components of an elementary type, the only restriction on component
15230 clauses is that the size must be at least the 'Size value of the type
15231 (actually the Value_Size).  There are no restrictions due to alignment,
15232 and such components may freely cross storage boundaries.
15234 Packed arrays with a size up to and including 64 bits are represented
15235 internally using a modular type with the appropriate number of bits, and
15236 thus the same lack of restriction applies.  For example, if you declare:
15238 @smallexample @c ada
15239    type R is array (1 .. 49) of Boolean;
15240    pragma Pack (R);
15241    for R'Size use 49;
15242 @end smallexample
15244 @noindent
15245 then a component clause for a component of type R may start on any
15246 specified bit boundary, and may specify a value of 49 bits or greater.
15248 For packed bit arrays that are longer than 64 bits, there are two
15249 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
15250 including the important case of single bits or boolean values, then
15251 there are no limitations on placement of such components, and they
15252 may start and end at arbitrary bit boundaries.
15254 If the component size is not a power of 2 (e.g.@: 3 or 5), then
15255 an array of this type longer than 64 bits must always be placed on
15256 on a storage unit (byte) boundary and occupy an integral number
15257 of storage units (bytes). Any component clause that does not
15258 meet this requirement will be rejected.
15260 Any aliased component, or component of an aliased type, must
15261 have its normal alignment and size. A component clause that
15262 does not meet this requirement will be rejected.
15264 The tag field of a tagged type always occupies an address sized field at
15265 the start of the record.  No component clause may attempt to overlay this
15266 tag. When a tagged type appears as a component, the tag field must have
15267 proper alignment
15269 In the case of a record extension T1, of a type T, no component clause applied
15270 to the type T1 can specify a storage location that would overlap the first
15271 T'Size bytes of the record.
15273 For all other component types, including non-bit-packed arrays,
15274 the component can be placed at an arbitrary bit boundary,
15275 so for example, the following is permitted:
15277 @smallexample @c ada
15278    type R is array (1 .. 10) of Boolean;
15279    for R'Size use 80;
15281    type Q is record
15282       G, H : Boolean;
15283       L, M : R;
15284    end record;
15286    for Q use record
15287       G at 0 range  0 ..   0;
15288       H at 0 range  1 ..   1;
15289       L at 0 range  2 ..  81;
15290       R at 0 range 82 .. 161;
15291    end record;
15292 @end smallexample
15294 @noindent
15295 Note: the above rules apply to recent releases of GNAT 5.
15296 In GNAT 3, there are more severe restrictions on larger components.
15297 For non-primitive types, including packed arrays with a size greater than
15298 64 bits, component clauses must respect the alignment requirement of the
15299 type, in particular, always starting on a byte boundary, and the length
15300 must be a multiple of the storage unit.
15302 @node Handling of Records with Holes
15303 @section Handling of Records with Holes
15304 @cindex Handling of Records with Holes
15306 As a result of alignment considerations, records may contain "holes"
15307 or gaps
15308 which do not correspond to the data bits of any of the components.
15309 Record representation clauses can also result in holes in records.
15311 GNAT does not attempt to clear these holes, so in record objects,
15312 they should be considered to hold undefined rubbish. The generated
15313 equality routine just tests components so does not access these
15314 undefined bits, and assignment and copy operations may or may not
15315 preserve the contents of these holes (for assignments, the holes
15316 in the target will in practice contain either the bits that are
15317 present in the holes in the source, or the bits that were present
15318 in the target before the assignment).
15320 If it is necessary to ensure that holes in records have all zero
15321 bits, then record objects for which this initialization is desired
15322 should be explicitly set to all zero values using Unchecked_Conversion
15323 or address overlays. For example
15325 @smallexample @c ada
15326 type HRec is record
15327    C : Character;
15328    I : Integer;
15329 end record;
15330 @end smallexample
15332 @noindent
15333 On typical machines, integers need to be aligned on a four-byte
15334 boundary, resulting in three bytes of undefined rubbish following
15335 the 8-bit field for C. To ensure that the hole in a variable of
15336 type HRec is set to all zero bits,
15337 you could for example do:
15339 @smallexample @c ada
15340 type Base is record
15341    Dummy1, Dummy2 : Integer := 0;
15342 end record;
15344 BaseVar : Base;
15345 RealVar : Hrec;
15346 for RealVar'Address use BaseVar'Address;
15347 @end smallexample
15349 @noindent
15350 Now the 8-bytes of the value of RealVar start out containing all zero
15351 bits. A safer approach is to just define dummy fields, avoiding the
15352 holes, as in:
15354 @smallexample @c ada
15355 type HRec is record
15356    C      : Character;
15357    Dummy1 : Short_Short_Integer := 0;
15358    Dummy2 : Short_Short_Integer := 0;
15359    Dummy3 : Short_Short_Integer := 0;
15360    I      : Integer;
15361 end record;
15362 @end smallexample
15364 @noindent
15365 And to make absolutely sure that the intent of this is followed, you
15366 can use representation clauses:
15368 @smallexample @c ada
15369 for Hrec use record
15370    C      at 0 range 0 .. 7;
15371    Dummy1 at 1 range 0 .. 7;
15372    Dummy2 at 2 range 0 .. 7;
15373    Dummy3 at 3 range 0 .. 7;
15374    I      at 4 range 0 .. 31;
15375 end record;
15376 for Hrec'Size use 64;
15377 @end smallexample
15379 @node Enumeration Clauses
15380 @section Enumeration Clauses
15382 The only restriction on enumeration clauses is that the range of values
15383 must be representable.  For the signed case, if one or more of the
15384 representation values are negative, all values must be in the range:
15386 @smallexample @c ada
15387    System.Min_Int .. System.Max_Int
15388 @end smallexample
15390 @noindent
15391 For the unsigned case, where all values are nonnegative, the values must
15392 be in the range:
15394 @smallexample @c ada
15395    0 .. System.Max_Binary_Modulus;
15396 @end smallexample
15398 @noindent
15399 A @emph{confirming} representation clause is one in which the values range
15400 from 0 in sequence, i.e.@: a clause that confirms the default representation
15401 for an enumeration type.
15402 Such a confirming representation
15403 is permitted by these rules, and is specially recognized by the compiler so
15404 that no extra overhead results from the use of such a clause.
15406 If an array has an index type which is an enumeration type to which an
15407 enumeration clause has been applied, then the array is stored in a compact
15408 manner.  Consider the declarations:
15410 @smallexample @c ada
15411    type r is (A, B, C);
15412    for r use (A => 1, B => 5, C => 10);
15413    type t is array (r) of Character;
15414 @end smallexample
15416 @noindent
15417 The array type t corresponds to a vector with exactly three elements and
15418 has a default size equal to @code{3*Character'Size}.  This ensures efficient
15419 use of space, but means that accesses to elements of the array will incur
15420 the overhead of converting representation values to the corresponding
15421 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
15423 @node Address Clauses
15424 @section Address Clauses
15425 @cindex Address Clause
15427 The reference manual allows a general restriction on representation clauses,
15428 as found in RM 13.1(22):
15430 @quotation
15431 An implementation need not support representation
15432 items containing nonstatic expressions, except that
15433 an implementation should support a representation item
15434 for a given entity if each nonstatic expression in the
15435 representation item is a name that statically denotes
15436 a constant declared before the entity.
15437 @end quotation
15439 @noindent
15440 In practice this is applicable only to address clauses, since this is the
15441 only case in which a non-static expression is permitted by the syntax.  As
15442 the AARM notes in sections 13.1 (22.a-22.h):
15444 @display
15445   22.a   Reason: This is to avoid the following sort of thing:
15447   22.b        X : Integer := F(@dots{});
15448               Y : Address := G(@dots{});
15449               for X'Address use Y;
15451   22.c   In the above, we have to evaluate the
15452          initialization expression for X before we
15453          know where to put the result.  This seems
15454          like an unreasonable implementation burden.
15456   22.d   The above code should instead be written
15457          like this:
15459   22.e        Y : constant Address := G(@dots{});
15460               X : Integer := F(@dots{});
15461               for X'Address use Y;
15463   22.f   This allows the expression ``Y'' to be safely
15464          evaluated before X is created.
15466   22.g   The constant could be a formal parameter of mode in.
15468   22.h   An implementation can support other nonstatic
15469          expressions if it wants to.  Expressions of type
15470          Address are hardly ever static, but their value
15471          might be known at compile time anyway in many
15472          cases.
15473 @end display
15475 @noindent
15476 GNAT does indeed permit many additional cases of non-static expressions.  In
15477 particular, if the type involved is elementary there are no restrictions
15478 (since in this case, holding a temporary copy of the initialization value,
15479 if one is present, is inexpensive).  In addition, if there is no implicit or
15480 explicit initialization, then there are no restrictions.  GNAT will reject
15481 only the case where all three of these conditions hold:
15483 @itemize @bullet
15485 @item
15486 The type of the item is non-elementary (e.g.@: a record or array).
15488 @item
15489 There is explicit or implicit initialization required for the object.
15490 Note that access values are always implicitly initialized.
15492 @item
15493 The address value is non-static.  Here GNAT is more permissive than the
15494 RM, and allows the address value to be the address of a previously declared
15495 stand-alone variable, as long as it does not itself have an address clause.
15497 @smallexample @c ada
15498            Anchor  : Some_Initialized_Type;
15499            Overlay : Some_Initialized_Type;
15500            for Overlay'Address use Anchor'Address;
15501 @end smallexample
15503 @noindent
15504 However, the prefix of the address clause cannot be an array component, or
15505 a component of a discriminated record.
15507 @end itemize
15509 @noindent
15510 As noted above in section 22.h, address values are typically non-static.  In
15511 particular the To_Address function, even if applied to a literal value, is
15512 a non-static function call.  To avoid this minor annoyance, GNAT provides
15513 the implementation defined attribute 'To_Address.  The following two
15514 expressions have identical values:
15516 @findex Attribute
15517 @findex To_Address
15518 @smallexample @c ada
15519    To_Address (16#1234_0000#)
15520    System'To_Address (16#1234_0000#);
15521 @end smallexample
15523 @noindent
15524 except that the second form is considered to be a static expression, and
15525 thus when used as an address clause value is always permitted.
15527 @noindent
15528 Additionally, GNAT treats as static an address clause that is an
15529 unchecked_conversion of a static integer value.  This simplifies the porting
15530 of legacy code, and provides a portable equivalent to the GNAT attribute
15531 @code{To_Address}.
15533 Another issue with address clauses is the interaction with alignment
15534 requirements.  When an address clause is given for an object, the address
15535 value must be consistent with the alignment of the object (which is usually
15536 the same as the alignment of the type of the object).  If an address clause
15537 is given that specifies an inappropriately aligned address value, then the
15538 program execution is erroneous.
15540 Since this source of erroneous behavior can have unfortunate effects, GNAT
15541 checks (at compile time if possible, generating a warning, or at execution
15542 time with a run-time check) that the alignment is appropriate.  If the
15543 run-time check fails, then @code{Program_Error} is raised.  This run-time
15544 check is suppressed if range checks are suppressed, or if the special GNAT
15545 check Alignment_Check is suppressed, or if
15546 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
15548 Finally, GNAT does not permit overlaying of objects of controlled types or
15549 composite types containing a controlled component. In most cases, the compiler
15550 can detect an attempt at such overlays and will generate a warning at compile
15551 time and a Program_Error exception at run time.
15553 @findex Export
15554 An address clause cannot be given for an exported object.  More
15555 understandably the real restriction is that objects with an address
15556 clause cannot be exported.  This is because such variables are not
15557 defined by the Ada program, so there is no external object to export.
15559 @findex Import
15560 It is permissible to give an address clause and a pragma Import for the
15561 same object.  In this case, the variable is not really defined by the
15562 Ada program, so there is no external symbol to be linked.  The link name
15563 and the external name are ignored in this case.  The reason that we allow this
15564 combination is that it provides a useful idiom to avoid unwanted
15565 initializations on objects with address clauses.
15567 When an address clause is given for an object that has implicit or
15568 explicit initialization, then by default initialization takes place.  This
15569 means that the effect of the object declaration is to overwrite the
15570 memory at the specified address.  This is almost always not what the
15571 programmer wants, so GNAT will output a warning:
15573 @smallexample
15574   with System;
15575   package G is
15576      type R is record
15577         M : Integer := 0;
15578      end record;
15580      Ext : R;
15581      for Ext'Address use System'To_Address (16#1234_1234#);
15582          |
15583   >>> warning: implicit initialization of "Ext" may
15584       modify overlaid storage
15585   >>> warning: use pragma Import for "Ext" to suppress
15586       initialization (RM B(24))
15588   end G;
15589 @end smallexample
15591 @noindent
15592 As indicated by the warning message, the solution is to use a (dummy) pragma
15593 Import to suppress this initialization.  The pragma tell the compiler that the
15594 object is declared and initialized elsewhere.  The following package compiles
15595 without warnings (and the initialization is suppressed):
15597 @smallexample @c ada
15598    with System;
15599    package G is
15600       type R is record
15601          M : Integer := 0;
15602       end record;
15604       Ext : R;
15605       for Ext'Address use System'To_Address (16#1234_1234#);
15606       pragma Import (Ada, Ext);
15607    end G;
15608 @end smallexample
15610 @noindent
15611 A final issue with address clauses involves their use for overlaying
15612 variables, as in the following example:
15613 @cindex Overlaying of objects
15615 @smallexample @c ada
15616   A : Integer;
15617   B : Integer;
15618   for B'Address use A'Address;
15619 @end smallexample
15621 @noindent
15622 or alternatively, using the form recommended by the RM:
15624 @smallexample @c ada
15625   A    : Integer;
15626   Addr : constant Address := A'Address;
15627   B    : Integer;
15628   for B'Address use Addr;
15629 @end smallexample
15631 @noindent
15632 In both of these cases, @code{A}
15633 and @code{B} become aliased to one another via the
15634 address clause. This use of address clauses to overlay
15635 variables, achieving an effect similar to unchecked
15636 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
15637 the effect is implementation defined. Furthermore, the
15638 Ada RM specifically recommends that in a situation
15639 like this, @code{B} should be subject to the following
15640 implementation advice (RM 13.3(19)):
15642 @quotation
15643 19  If the Address of an object is specified, or it is imported
15644     or exported, then the implementation should not perform
15645     optimizations based on assumptions of no aliases.
15646 @end quotation
15648 @noindent
15649 GNAT follows this recommendation, and goes further by also applying
15650 this recommendation to the overlaid variable (@code{A}
15651 in the above example) in this case. This means that the overlay
15652 works "as expected", in that a modification to one of the variables
15653 will affect the value of the other.
15655 Note that when address clause overlays are used in this way, there is an
15656 issue of unintentional initialization, as shown by this example:
15658 @smallexample @c ada
15659 package Overwrite_Record is
15660    type R is record
15661       A : Character := 'C';
15662       B : Character := 'A';
15663    end record;
15664    X : Short_Integer := 3;
15665    Y : R;
15666    for Y'Address use X'Address;
15667        |
15668 >>> warning: default initialization of "Y" may
15669     modify "X", use pragma Import for "Y" to
15670     suppress initialization (RM B.1(24))
15672 end Overwrite_Record;
15673 @end smallexample
15675 @noindent
15676 Here the default initialization of @code{Y} will clobber the value
15677 of @code{X}, which justifies the warning. The warning notes that
15678 this effect can be eliminated by adding a @code{pragma Import}
15679 which suppresses the initialization:
15681 @smallexample @c ada
15682 package Overwrite_Record is
15683    type R is record
15684       A : Character := 'C';
15685       B : Character := 'A';
15686    end record;
15687    X : Short_Integer := 3;
15688    Y : R;
15689    for Y'Address use X'Address;
15690    pragma Import (Ada, Y);
15691 end Overwrite_Record;
15692 @end smallexample
15694 @noindent
15695 Note that the use of @code{pragma Initialize_Scalars} may cause variables to
15696 be initialized when they would not otherwise have been in the absence
15697 of the use of this pragma. This may cause an overlay to have this
15698 unintended clobbering effect. The compiler avoids this for scalar
15699 types, but not for composite objects (where in general the effect
15700 of @code{Initialize_Scalars} is part of the initialization routine
15701 for the composite object:
15703 @smallexample @c ada
15704 pragma Initialize_Scalars;
15705 with Ada.Text_IO;  use Ada.Text_IO;
15706 procedure Overwrite_Array is
15707    type Arr is array (1 .. 5) of Integer;
15708    X : Arr := (others => 1);
15709    A : Arr;
15710    for A'Address use X'Address;
15711        |
15712 >>> warning: default initialization of "A" may
15713     modify "X", use pragma Import for "A" to
15714     suppress initialization (RM B.1(24))
15716 begin
15717    if X /= Arr'(others => 1) then
15718       Put_Line ("X was clobbered");
15719    else
15720       Put_Line ("X was not clobbered");
15721    end if;
15722 end Overwrite_Array;
15723 @end smallexample
15725 @noindent
15726 The above program generates the warning as shown, and at execution
15727 time, prints @code{X was clobbered}. If the @code{pragma Import} is
15728 added as suggested:
15730 @smallexample @c ada
15731 pragma Initialize_Scalars;
15732 with Ada.Text_IO;  use Ada.Text_IO;
15733 procedure Overwrite_Array is
15734    type Arr is array (1 .. 5) of Integer;
15735    X : Arr := (others => 1);
15736    A : Arr;
15737    for A'Address use X'Address;
15738    pragma Import (Ada, A);
15739 begin
15740    if X /= Arr'(others => 1) then
15741       Put_Line ("X was clobbered");
15742    else
15743       Put_Line ("X was not clobbered");
15744    end if;
15745 end Overwrite_Array;
15746 @end smallexample
15748 @noindent
15749 then the program compiles without the waraning and when run will generate
15750 the output @code{X was not clobbered}.
15752 @node Effect of Convention on Representation
15753 @section Effect of Convention on Representation
15754 @cindex Convention, effect on representation
15756 @noindent
15757 Normally the specification of a foreign language convention for a type or
15758 an object has no effect on the chosen representation.  In particular, the
15759 representation chosen for data in GNAT generally meets the standard system
15760 conventions, and for example records are laid out in a manner that is
15761 consistent with C@.  This means that specifying convention C (for example)
15762 has no effect.
15764 There are four exceptions to this general rule:
15766 @itemize @bullet
15768 @item Convention Fortran and array subtypes
15769 If pragma Convention Fortran is specified for an array subtype, then in
15770 accordance with the implementation advice in section 3.6.2(11) of the
15771 Ada Reference Manual, the array will be stored in a Fortran-compatible
15772 column-major manner, instead of the normal default row-major order.
15774 @item Convention C and enumeration types
15775 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
15776 to accommodate all values of the type.  For example, for the enumeration
15777 type declared by:
15779 @smallexample @c ada
15780    type Color is (Red, Green, Blue);
15781 @end smallexample
15783 @noindent
15784 8 bits is sufficient to store all values of the type, so by default, objects
15785 of type @code{Color} will be represented using 8 bits.  However, normal C
15786 convention is to use 32 bits for all enum values in C, since enum values
15787 are essentially of type int.  If pragma @code{Convention C} is specified for an
15788 Ada enumeration type, then the size is modified as necessary (usually to
15789 32 bits) to be consistent with the C convention for enum values.
15791 Note that this treatment applies only to types. If Convention C is given for
15792 an enumeration object, where the enumeration type is not Convention C, then
15793 Object_Size bits are allocated. For example, for a normal enumeration type,
15794 with less than 256 elements, only 8 bits will be allocated for the object.
15795 Since this may be a surprise in terms of what C expects, GNAT will issue a
15796 warning in this situation. The warning can be suppressed by giving an explicit
15797 size clause specifying the desired size.
15799 @item Convention C/Fortran and Boolean types
15800 In C, the usual convention for boolean values, that is values used for
15801 conditions, is that zero represents false, and nonzero values represent
15802 true.  In Ada, the normal convention is that two specific values, typically
15803 0/1, are used to represent false/true respectively.
15805 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
15806 value represents true).
15808 To accommodate the Fortran and C conventions, if a pragma Convention specifies
15809 C or Fortran convention for a derived Boolean, as in the following example:
15811 @smallexample @c ada
15812    type C_Switch is new Boolean;
15813    pragma Convention (C, C_Switch);
15814 @end smallexample
15816 @noindent
15817 then the GNAT generated code will treat any nonzero value as true.  For truth
15818 values generated by GNAT, the conventional value 1 will be used for True, but
15819 when one of these values is read, any nonzero value is treated as True.
15821 @item Access types on OpenVMS
15822 For 64-bit OpenVMS systems, access types (other than those for unconstrained
15823 arrays) are 64-bits long. An exception to this rule is for the case of
15824 C-convention access types where there is no explicit size clause present (or
15825 inherited for derived types). In this case, GNAT chooses to make these
15826 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
15827 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
15829 @end itemize
15831 @node Conventions and Anonymous Access Types
15832 @section Conventions and Anonymous Access Types
15833 @cindex Anonymous access types
15834 @cindex Convention for anonymous access types
15836 The RM is not entirely clear on convention handling in a number of cases,
15837 and in particular, it is not clear on the convention to be given to
15838 anonymous access types in general, and in particular what is to be
15839 done for the case of anonymous access-to-subprogram.
15841 In GNAT, we decide that if an explicit Convention is applied
15842 to an object or component, and its type is such an anonymous type,
15843 then the convention will apply to this anonymous type as well. This
15844 seems to make sense since it is anomolous in any case to have a
15845 different convention for an object and its type, and there is clearly
15846 no way to explicitly specify a convention for an anonymous type, since
15847 it doesn't have a name to specify!
15849 Furthermore, we decide that if a convention is applied to a record type,
15850 then this convention is inherited by any of its components that are of an
15851 anonymous access type which do not have an explicitly specified convention.
15853 The following program shows these conventions in action:
15855 @smallexample @c ada
15856 package ConvComp is
15857    type Foo is range 1 .. 10;
15858    type T1 is record
15859       A : access function (X : Foo) return Integer;
15860       B : Integer;
15861    end record;
15862    pragma Convention (C, T1);
15864    type T2 is record
15865       A : access function (X : Foo) return Integer;
15866       pragma Convention  (C, A);
15867       B : Integer;
15868    end record;
15869    pragma Convention (COBOL, T2);
15871    type T3 is record
15872       A : access function (X : Foo) return Integer;
15873       pragma Convention  (COBOL, A);
15874       B : Integer;
15875    end record;
15876    pragma Convention (C, T3);
15878    type T4 is record
15879       A : access function (X : Foo) return Integer;
15880       B : Integer;
15881    end record;
15882    pragma Convention (COBOL, T4);
15884    function F (X : Foo) return Integer;
15885    pragma Convention (C, F);
15887    function F (X : Foo) return Integer is (13);
15889    TV1 : T1 := (F'Access, 12);  -- OK
15890    TV2 : T2 := (F'Access, 13);  -- OK
15892    TV3 : T3 := (F'Access, 13);  -- ERROR
15893                 |
15894 >>> subprogram "F" has wrong convention
15895 >>> does not match access to subprogram declared at line 17
15896      38.    TV4 : T4 := (F'Access, 13);  -- ERROR
15897                 |
15898 >>> subprogram "F" has wrong convention
15899 >>> does not match access to subprogram declared at line 24
15900      39. end ConvComp;
15901 @end smallexample
15903 @node Determining the Representations chosen by GNAT
15904 @section Determining the Representations chosen by GNAT
15905 @cindex Representation, determination of
15906 @cindex @option{-gnatR} switch
15908 @noindent
15909 Although the descriptions in this section are intended to be complete, it is
15910 often easier to simply experiment to see what GNAT accepts and what the
15911 effect is on the layout of types and objects.
15913 As required by the Ada RM, if a representation clause is not accepted, then
15914 it must be rejected as illegal by the compiler.  However, when a
15915 representation clause or pragma is accepted, there can still be questions
15916 of what the compiler actually does.  For example, if a partial record
15917 representation clause specifies the location of some components and not
15918 others, then where are the non-specified components placed? Or if pragma
15919 @code{Pack} is used on a record, then exactly where are the resulting
15920 fields placed? The section on pragma @code{Pack} in this chapter can be
15921 used to answer the second question, but it is often easier to just see
15922 what the compiler does.
15924 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
15925 with this option, then the compiler will output information on the actual
15926 representations chosen, in a format similar to source representation
15927 clauses.  For example, if we compile the package:
15929 @smallexample @c ada
15930 package q is
15931    type r (x : boolean) is tagged record
15932       case x is
15933          when True => S : String (1 .. 100);
15934          when False => null;
15935       end case;
15936    end record;
15938    type r2 is new r (false) with record
15939       y2 : integer;
15940    end record;
15942    for r2 use record
15943       y2 at 16 range 0 .. 31;
15944    end record;
15946    type x is record
15947       y : character;
15948    end record;
15950    type x1 is array (1 .. 10) of x;
15951    for x1'component_size use 11;
15953    type ia is access integer;
15955    type Rb1 is array (1 .. 13) of Boolean;
15956    pragma Pack (rb1);
15958    type Rb2 is array (1 .. 65) of Boolean;
15959    pragma Pack (rb2);
15961    type x2 is record
15962       l1 : Boolean;
15963       l2 : Duration;
15964       l3 : Float;
15965       l4 : Boolean;
15966       l5 : Rb1;
15967       l6 : Rb2;
15968    end record;
15969    pragma Pack (x2);
15970 end q;
15971 @end smallexample
15973 @noindent
15974 using the switch @option{-gnatR} we obtain the following output:
15976 @smallexample
15977 Representation information for unit q
15978 -------------------------------------
15980 for r'Size use ??;
15981 for r'Alignment use 4;
15982 for r use record
15983    x    at 4 range  0 .. 7;
15984    _tag at 0 range  0 .. 31;
15985    s    at 5 range  0 .. 799;
15986 end record;
15988 for r2'Size use 160;
15989 for r2'Alignment use 4;
15990 for r2 use record
15991    x       at  4 range  0 .. 7;
15992    _tag    at  0 range  0 .. 31;
15993    _parent at  0 range  0 .. 63;
15994    y2      at 16 range  0 .. 31;
15995 end record;
15997 for x'Size use 8;
15998 for x'Alignment use 1;
15999 for x use record
16000    y at 0 range  0 .. 7;
16001 end record;
16003 for x1'Size use 112;
16004 for x1'Alignment use 1;
16005 for x1'Component_Size use 11;
16007 for rb1'Size use 13;
16008 for rb1'Alignment use 2;
16009 for rb1'Component_Size use 1;
16011 for rb2'Size use 72;
16012 for rb2'Alignment use 1;
16013 for rb2'Component_Size use 1;
16015 for x2'Size use 224;
16016 for x2'Alignment use 4;
16017 for x2 use record
16018    l1 at  0 range  0 .. 0;
16019    l2 at  0 range  1 .. 64;
16020    l3 at 12 range  0 .. 31;
16021    l4 at 16 range  0 .. 0;
16022    l5 at 16 range  1 .. 13;
16023    l6 at 18 range  0 .. 71;
16024 end record;
16025 @end smallexample
16027 @noindent
16028 The Size values are actually the Object_Size, i.e.@: the default size that
16029 will be allocated for objects of the type.
16030 The ?? size for type r indicates that we have a variant record, and the
16031 actual size of objects will depend on the discriminant value.
16033 The Alignment values show the actual alignment chosen by the compiler
16034 for each record or array type.
16036 The record representation clause for type r shows where all fields
16037 are placed, including the compiler generated tag field (whose location
16038 cannot be controlled by the programmer).
16040 The record representation clause for the type extension r2 shows all the
16041 fields present, including the parent field, which is a copy of the fields
16042 of the parent type of r2, i.e.@: r1.
16044 The component size and size clauses for types rb1 and rb2 show
16045 the exact effect of pragma @code{Pack} on these arrays, and the record
16046 representation clause for type x2 shows how pragma @code{Pack} affects
16047 this record type.
16049 In some cases, it may be useful to cut and paste the representation clauses
16050 generated by the compiler into the original source to fix and guarantee
16051 the actual representation to be used.
16053 @node Standard Library Routines
16054 @chapter Standard Library Routines
16056 @noindent
16057 The Ada Reference Manual contains in Annex A a full description of an
16058 extensive set of standard library routines that can be used in any Ada
16059 program, and which must be provided by all Ada compilers.  They are
16060 analogous to the standard C library used by C programs.
16062 GNAT implements all of the facilities described in annex A, and for most
16063 purposes the description in the Ada Reference Manual, or appropriate Ada
16064 text book, will be sufficient for making use of these facilities.
16066 In the case of the input-output facilities,
16067 @xref{The Implementation of Standard I/O},
16068 gives details on exactly how GNAT interfaces to the
16069 file system.  For the remaining packages, the Ada Reference Manual
16070 should be sufficient.  The following is a list of the packages included,
16071 together with a brief description of the functionality that is provided.
16073 For completeness, references are included to other predefined library
16074 routines defined in other sections of the Ada Reference Manual (these are
16075 cross-indexed from Annex A). For further details see the relevant
16076 package declarations in the run-time library. In particular, a few units
16077 are not implemented, as marked by the presence of pragma Unimplemented_Unit,
16078 and in this case the package declaration contains comments explaining why
16079 the unit is not implemented.
16081 @table @code
16082 @item Ada (A.2)
16083 This is a parent package for all the standard library packages.  It is
16084 usually included implicitly in your program, and itself contains no
16085 useful data or routines.
16087 @item Ada.Assertions (11.4.2)
16088 @code{Assertions} provides the @code{Assert} subprograms, and also
16089 the declaration of the @code{Assertion_Error} exception.
16091 @item Ada.Asynchronous_Task_Control (D.11)
16092 @code{Asynchronous_Task_Control} provides low level facilities for task
16093 synchronization. It is typically not implemented. See package spec for details.
16095 @item Ada.Calendar (9.6)
16096 @code{Calendar} provides time of day access, and routines for
16097 manipulating times and durations.
16099 @item Ada.Calendar.Arithmetic (9.6.1)
16100 This package provides additional arithmetic
16101 operations for @code{Calendar}.
16103 @item Ada.Calendar.Formatting (9.6.1)
16104 This package provides formatting operations for @code{Calendar}.
16106 @item Ada.Calendar.Time_Zones (9.6.1)
16107 This package provides additional @code{Calendar} facilities
16108 for handling time zones.
16110 @item Ada.Characters (A.3.1)
16111 This is a dummy parent package that contains no useful entities
16113 @item Ada.Characters.Conversions (A.3.2)
16114 This package provides character conversion functions.
16116 @item Ada.Characters.Handling (A.3.2)
16117 This package provides some basic character handling capabilities,
16118 including classification functions for classes of characters (e.g.@: test
16119 for letters, or digits).
16121 @item Ada.Characters.Latin_1 (A.3.3)
16122 This package includes a complete set of definitions of the characters
16123 that appear in type CHARACTER@.  It is useful for writing programs that
16124 will run in international environments.  For example, if you want an
16125 upper case E with an acute accent in a string, it is often better to use
16126 the definition of @code{UC_E_Acute} in this package.  Then your program
16127 will print in an understandable manner even if your environment does not
16128 support these extended characters.
16130 @item Ada.Command_Line (A.15)
16131 This package provides access to the command line parameters and the name
16132 of the current program (analogous to the use of @code{argc} and @code{argv}
16133 in C), and also allows the exit status for the program to be set in a
16134 system-independent manner.
16136 @item Ada.Complex_Text_IO (G.1.3)
16137 This package provides text input and output of complex numbers.
16139 @item Ada.Containers (A.18.1)
16140 A top level package providing a few basic definitions used by all the
16141 following specific child packages that provide specific kinds of
16142 containers.
16144 @item Ada.Containers.Bounded_Priority_Queues (A.18.31)
16146 @item Ada.Containers.Bounded_Synchronized_Queues (A.18.29)
16148 @item Ada.Containers.Doubly_Linked_Lists (A.18.3)
16150 @item Ada.Containers.Generic_Array_Sort (A.18.26)
16152 @item Ada.Containers.Generic_Constrained_Array_Sort (A.18.26)
16154 @item Ada.Containers.Generic_Sort (A.18.26)
16156 @item Ada.Containers.Hashed_Maps (A.18.5)
16158 @item Ada.Containers.Hashed_Sets (A.18.8)
16160 @item Ada.Containers.Indefinite_Doubly_Linked_Lists (A.18.12)
16162 @item Ada.Containers.Indefinite_Hashed_Maps (A.18.13)
16164 @item Ada.Containers.Indefinite_Hashed_Sets (A.18.15)
16166 @item Ada.Containers.Indefinite_Holders (A.18.18)
16168 @item Ada.Containers.Indefinite_Multiway_Trees (A.18.17)
16170 @item Ada.Containers.Indefinite_Ordered_Maps (A.18.14)
16172 @item Ada.Containers.Indefinite_Ordered_Sets (A.18.16)
16174 @item Ada.Containers.Indefinite_Vectors (A.18.11)
16176 @item Ada.Containers.Multiway_Trees (A.18.10)
16178 @item Ada.Containers.Ordered_Maps (A.18.6)
16180 @item Ada.Containers.Ordered_Sets (A.18.9)
16182 @item Ada.Containers.Synchronized_Queue_Interfaces (A.18.27)
16184 @item Ada.Containers.Unbounded_Priority_Queues (A.18.30)
16186 @item Ada.Containers.Unbounded_Synchronized_Queues (A.18.28)
16188 @item Ada.Containers.Vectors (A.18.2)
16190 @item Ada.Directories (A.16)
16191 This package provides operations on directories.
16193 @item Ada.Directories.Hierarchical_File_Names (A.16.1)
16194 This package provides additional directory operations handling
16195 hiearchical file names.
16197 @item Ada.Directories.Information (A.16)
16198 This is an implementation defined package for additional directory
16199 operations, which is not implemented in GNAT.
16201 @item Ada.Decimal (F.2)
16202 This package provides constants describing the range of decimal numbers
16203 implemented, and also a decimal divide routine (analogous to the COBOL
16204 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
16206 @item Ada.Direct_IO (A.8.4)
16207 This package provides input-output using a model of a set of records of
16208 fixed-length, containing an arbitrary definite Ada type, indexed by an
16209 integer record number.
16211 @item Ada.Dispatching (D.2.1)
16212 A parent package containing definitions for task dispatching operations.
16214 @item Ada.Dispatching.EDF (D.2.6)
16215 Not implemented in GNAT.
16217 @item Ada.Dispatching.Non_Preemptive (D.2.4)
16218 Not implemented in GNAT.
16220 @item Ada.Dispatching.Round_Robin (D.2.5)
16221 Not implemented in GNAT.
16223 @item Ada.Dynamic_Priorities (D.5)
16224 This package allows the priorities of a task to be adjusted dynamically
16225 as the task is running.
16227 @item Ada.Environment_Variables (A.17)
16228 This package provides facilities for accessing environment variables.
16230 @item Ada.Exceptions (11.4.1)
16231 This package provides additional information on exceptions, and also
16232 contains facilities for treating exceptions as data objects, and raising
16233 exceptions with associated messages.
16235 @item Ada.Execution_Time (D.14)
16236 Not implemented in GNAT.
16238 @item Ada.Execution_Time.Group_Budgets (D.14.2)
16239 Not implemented in GNAT.
16241 @item Ada.Execution_Time.Timers (D.14.1)'
16242 Not implemented in GNAT.
16244 @item Ada.Finalization (7.6)
16245 This package contains the declarations and subprograms to support the
16246 use of controlled types, providing for automatic initialization and
16247 finalization (analogous to the constructors and destructors of C++).
16249 @item Ada.Float_Text_IO (A.10.9)
16250 A library level instantiation of Text_IO.Float_IO for type Float.
16252 @item Ada.Float_Wide_Text_IO (A.10.9)
16253 A library level instantiation of Wide_Text_IO.Float_IO for type Float.
16255 @item Ada.Float_Wide_Wide_Text_IO (A.10.9)
16256 A library level instantiation of Wide_Wide_Text_IO.Float_IO for type Float.
16258 @item Ada.Integer_Text_IO (A.10.9)
16259 A library level instantiation of Text_IO.Integer_IO for type Integer.
16261 @item Ada.Integer_Wide_Text_IO (A.10.9)
16262 A library level instantiation of Wide_Text_IO.Integer_IO for type Integer.
16264 @item Ada.Integer_Wide_Wide_Text_IO (A.10.9)
16265 A library level instantiation of Wide_Wide_Text_IO.Integer_IO for type Integer.
16267 @item Ada.Interrupts (C.3.2)
16268 This package provides facilities for interfacing to interrupts, which
16269 includes the set of signals or conditions that can be raised and
16270 recognized as interrupts.
16272 @item Ada.Interrupts.Names (C.3.2)
16273 This package provides the set of interrupt names (actually signal
16274 or condition names) that can be handled by GNAT@.
16276 @item Ada.IO_Exceptions (A.13)
16277 This package defines the set of exceptions that can be raised by use of
16278 the standard IO packages.
16280 @item Ada.Iterator_Interfaces (5.5.1)
16281 This package provides a generic interface to generalized iterators.
16283 @item Ada.Locales (A.19)
16284 This package provides declarations providing information (Language
16285 and Country) about the current locale.
16287 @item Ada.Numerics
16288 This package contains some standard constants and exceptions used
16289 throughout the numerics packages.  Note that the constants pi and e are
16290 defined here, and it is better to use these definitions than rolling
16291 your own.
16293 @item Ada.Numerics.Complex_Arrays (G.3.2)
16294 Provides operations on arrays of complex numbers.
16296 @item Ada.Numerics.Complex_Elementary_Functions
16297 Provides the implementation of standard elementary functions (such as
16298 log and trigonometric functions) operating on complex numbers using the
16299 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
16300 created by the package @code{Numerics.Complex_Types}.
16302 @item Ada.Numerics.Complex_Types
16303 This is a predefined instantiation of
16304 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
16305 build the type @code{Complex} and @code{Imaginary}.
16307 @item Ada.Numerics.Discrete_Random
16308 This generic package provides a random number generator suitable for generating
16309 uniformly distributed values of a specified discrete subtype.
16311 @item Ada.Numerics.Float_Random
16312 This package provides a random number generator suitable for generating
16313 uniformly distributed floating point values in the unit interval.
16315 @item Ada.Numerics.Generic_Complex_Elementary_Functions
16316 This is a generic version of the package that provides the
16317 implementation of standard elementary functions (such as log and
16318 trigonometric functions) for an arbitrary complex type.
16320 The following predefined instantiations of this package are provided:
16322 @table @code
16323 @item Short_Float
16324 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
16325 @item Float
16326 @code{Ada.Numerics.Complex_Elementary_Functions}
16327 @item Long_Float
16328 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
16329 @end table
16331 @item Ada.Numerics.Generic_Complex_Types
16332 This is a generic package that allows the creation of complex types,
16333 with associated complex arithmetic operations.
16335 The following predefined instantiations of this package exist
16336 @table @code
16337 @item Short_Float
16338 @code{Ada.Numerics.Short_Complex_Complex_Types}
16339 @item Float
16340 @code{Ada.Numerics.Complex_Complex_Types}
16341 @item Long_Float
16342 @code{Ada.Numerics.Long_Complex_Complex_Types}
16343 @end table
16345 @item Ada.Numerics.Generic_Elementary_Functions
16346 This is a generic package that provides the implementation of standard
16347 elementary functions (such as log an trigonometric functions) for an
16348 arbitrary float type.
16350 The following predefined instantiations of this package exist
16352 @table @code
16353 @item Short_Float
16354 @code{Ada.Numerics.Short_Elementary_Functions}
16355 @item Float
16356 @code{Ada.Numerics.Elementary_Functions}
16357 @item Long_Float
16358 @code{Ada.Numerics.Long_Elementary_Functions}
16359 @end table
16361 @item Ada.Numerics.Generic_Real_Arrays (G.3.1)
16362 Generic operations on arrays of reals
16364 @item Ada.Numerics.Real_Arrays (G.3.1)
16365 Preinstantiation of Ada.Numerics.Generic_Real_Arrays (Float).
16367 @item Ada.Real_Time (D.8)
16368 This package provides facilities similar to those of @code{Calendar}, but
16369 operating with a finer clock suitable for real time control. Note that
16370 annex D requires that there be no backward clock jumps, and GNAT generally
16371 guarantees this behavior, but of course if the external clock on which
16372 the GNAT runtime depends is deliberately reset by some external event,
16373 then such a backward jump may occur.
16375 @item Ada.Real_Time.Timing_Events (D.15)
16376 Not implemented in GNAT.
16378 @item Ada.Sequential_IO (A.8.1)
16379 This package provides input-output facilities for sequential files,
16380 which can contain a sequence of values of a single type, which can be
16381 any Ada type, including indefinite (unconstrained) types.
16383 @item Ada.Storage_IO (A.9)
16384 This package provides a facility for mapping arbitrary Ada types to and
16385 from a storage buffer.  It is primarily intended for the creation of new
16386 IO packages.
16388 @item Ada.Streams (13.13.1)
16389 This is a generic package that provides the basic support for the
16390 concept of streams as used by the stream attributes (@code{Input},
16391 @code{Output}, @code{Read} and @code{Write}).
16393 @item Ada.Streams.Stream_IO (A.12.1)
16394 This package is a specialization of the type @code{Streams} defined in
16395 package @code{Streams} together with a set of operations providing
16396 Stream_IO capability.  The Stream_IO model permits both random and
16397 sequential access to a file which can contain an arbitrary set of values
16398 of one or more Ada types.
16400 @item Ada.Strings (A.4.1)
16401 This package provides some basic constants used by the string handling
16402 packages.
16404 @item Ada.Strings.Bounded (A.4.4)
16405 This package provides facilities for handling variable length
16406 strings.  The bounded model requires a maximum length.  It is thus
16407 somewhat more limited than the unbounded model, but avoids the use of
16408 dynamic allocation or finalization.
16410 @item Ada.Strings.Bounded.Equal_Case_Insensitive (A.4.10)
16411 Provides case-insensitive comparisons of bounded strings
16413 @item Ada.Strings.Bounded.Hash (A.4.9)
16414 This package provides a generic hash function for bounded strings
16416 @item Ada.Strings.Bounded.Hash_Case_Insensitive (A.4.9)
16417 This package provides a generic hash function for bounded strings that
16418 converts the string to be hashed to lower case.
16420 @item Ada.Strings.Bounded.Less_Case_Insensitive (A.4.10)
16421 This package provides a comparison function for bounded strings that works
16422 in a case insensitive manner by converting to lower case before the comparison.
16424 @item Ada.Strings.Fixed (A.4.3)
16425 This package provides facilities for handling fixed length strings.
16427 @item Ada.Strings.Fixed.Equal_Case_Insensitive (A.4.10)
16428 This package provides an equality function for fixed strings that compares
16429 the strings after converting both to lower case.
16431 @item Ada.Strings.Fixed.Hash_Case_Insensitive (A.4.9)
16432 This package provides a case insensitive hash function for fixed strings that
16433 converts the string to lower case before computing the hash.
16435 @item Ada.Strings.Fixed.Less_Case_Insensitive (A.4.10)
16436 This package provides a comparison function for fixed strings that works
16437 in a case insensitive manner by converting to lower case before the comparison.
16439 Ada.Strings.Hash (A.4.9)
16440 This package provides a hash function for strings.
16442 Ada.Strings.Hash_Case_Insensitive (A.4.9)
16443 This package provides a hash function for strings that is case insensitive.
16444 The string is converted to lower case before computing the hash.
16446 @item Ada.Strings.Less_Case_Insensitive (A.4.10)
16447 This package provides a comparison function for\strings that works
16448 in a case insensitive manner by converting to lower case before the comparison.
16450 @item Ada.Strings.Maps (A.4.2)
16451 This package provides facilities for handling character mappings and
16452 arbitrarily defined subsets of characters.  For instance it is useful in
16453 defining specialized translation tables.
16455 @item Ada.Strings.Maps.Constants (A.4.6)
16456 This package provides a standard set of predefined mappings and
16457 predefined character sets.  For example, the standard upper to lower case
16458 conversion table is found in this package.  Note that upper to lower case
16459 conversion is non-trivial if you want to take the entire set of
16460 characters, including extended characters like E with an acute accent,
16461 into account.  You should use the mappings in this package (rather than
16462 adding 32 yourself) to do case mappings.
16464 @item Ada.Strings.Unbounded (A.4.5)
16465 This package provides facilities for handling variable length
16466 strings.  The unbounded model allows arbitrary length strings, but
16467 requires the use of dynamic allocation and finalization.
16469 @item Ada.Strings.Unbounded.Equal_Case_Insensitive (A.4.10)
16470 Provides case-insensitive comparisons of unbounded strings
16472 @item Ada.Strings.Unbounded.Hash (A.4.9)
16473 This package provides a generic hash function for unbounded strings
16475 @item Ada.Strings.Unbounded.Hash_Case_Insensitive (A.4.9)
16476 This package provides a generic hash function for unbounded strings that
16477 converts the string to be hashed to lower case.
16479 @item Ada.Strings.Unbounded.Less_Case_Insensitive (A.4.10)
16480 This package provides a comparison function for unbounded strings that works
16481 in a case insensitive manner by converting to lower case before the comparison.
16483 @item Ada.Strings.UTF_Encoding (A.4.11)
16484 This package provides basic definitions for dealing with UTF-encoded strings.
16486 @item Ada.Strings.UTF_Encoding.Conversions (A.4.11)
16487 This package provides conversion functions for UTF-encoded strings.
16489 @item Ada.Strings.UTF_Encoding.Strings (A.4.11)
16490 @itemx Ada.Strings.UTF_Encoding.Wide_Strings (A.4.11)
16491 @itemx Ada.Strings.UTF_Encoding.Wide_Wide_Strings (A.4.11)
16492 These packages provide facilities for handling UTF encodings for
16493 Strings, Wide_Strings and Wide_Wide_Strings.
16495 @item Ada.Strings.Wide_Bounded (A.4.7)
16496 @itemx Ada.Strings.Wide_Fixed (A.4.7)
16497 @itemx Ada.Strings.Wide_Maps (A.4.7)
16498 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
16499 These packages provide analogous capabilities to the corresponding
16500 packages without @samp{Wide_} in the name, but operate with the types
16501 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
16502 and @code{Character}. Versions of all the child packages are available.
16504 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
16505 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
16506 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
16507 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
16508 These packages provide analogous capabilities to the corresponding
16509 packages without @samp{Wide_} in the name, but operate with the types
16510 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
16511 of @code{String} and @code{Character}.
16513 @item Ada.Synchronous_Barriers (D.10.1)
16514 This package provides facilities for synchronizing tasks at a low level
16515 with barriers.
16517 @item Ada.Synchronous_Task_Control (D.10)
16518 This package provides some standard facilities for controlling task
16519 communication in a synchronous manner.
16521 @item Ada.Synchronous_Task_Control.EDF (D.10)
16522 Not implemented in GNAT.
16524 @item Ada.Tags
16525 This package contains definitions for manipulation of the tags of tagged
16526 values.
16528 @item Ada.Tags.Generic_Dispatching_Constructor (3.9)
16529 This package provides a way of constructing tagged class-wide values given
16530 only the tag value.
16532 @item Ada.Task_Attributes (C.7.2)
16533 This package provides the capability of associating arbitrary
16534 task-specific data with separate tasks.
16536 @item Ada.Task_Identifification (C.7.1)
16537 This package provides capabilities for task identification.
16539 @item Ada.Task_Termination (C.7.3)
16540 This package provides control over task termination.
16542 @item Ada.Text_IO
16543 This package provides basic text input-output capabilities for
16544 character, string and numeric data.  The subpackages of this
16545 package are listed next. Note that although these are defined
16546 as subpackages in the RM, they are actually transparently
16547 implemented as child packages in GNAT, meaning that they
16548 are only loaded if needed.
16550 @item Ada.Text_IO.Decimal_IO
16551 Provides input-output facilities for decimal fixed-point types
16553 @item Ada.Text_IO.Enumeration_IO
16554 Provides input-output facilities for enumeration types.
16556 @item Ada.Text_IO.Fixed_IO
16557 Provides input-output facilities for ordinary fixed-point types.
16559 @item Ada.Text_IO.Float_IO
16560 Provides input-output facilities for float types.  The following
16561 predefined instantiations of this generic package are available:
16563 @table @code
16564 @item Short_Float
16565 @code{Short_Float_Text_IO}
16566 @item Float
16567 @code{Float_Text_IO}
16568 @item Long_Float
16569 @code{Long_Float_Text_IO}
16570 @end table
16572 @item Ada.Text_IO.Integer_IO
16573 Provides input-output facilities for integer types.  The following
16574 predefined instantiations of this generic package are available:
16576 @table @code
16577 @item Short_Short_Integer
16578 @code{Ada.Short_Short_Integer_Text_IO}
16579 @item Short_Integer
16580 @code{Ada.Short_Integer_Text_IO}
16581 @item Integer
16582 @code{Ada.Integer_Text_IO}
16583 @item Long_Integer
16584 @code{Ada.Long_Integer_Text_IO}
16585 @item Long_Long_Integer
16586 @code{Ada.Long_Long_Integer_Text_IO}
16587 @end table
16589 @item Ada.Text_IO.Modular_IO
16590 Provides input-output facilities for modular (unsigned) types.
16592 @item Ada.Text_IO.Bounded_IO (A.10.11)
16593 Provides input-output facilities for bounded strings.
16595 @item Ada.Text_IO.Complex_IO (G.1.3)
16596 This package provides basic text input-output capabilities for complex
16597 data.
16599 @item Ada.Text_IO.Editing (F.3.3)
16600 This package contains routines for edited output, analogous to the use
16601 of pictures in COBOL@.  The picture formats used by this package are a
16602 close copy of the facility in COBOL@.
16604 @item Ada.Text_IO.Text_Streams (A.12.2)
16605 This package provides a facility that allows Text_IO files to be treated
16606 as streams, so that the stream attributes can be used for writing
16607 arbitrary data, including binary data, to Text_IO files.
16609 @item Ada.Text_IO.Unbounded_IO (A.10.12)
16610 This package provides input-output facilities for unbounded strings.
16612 @item Ada.Unchecked_Conversion (13.9)
16613 This generic package allows arbitrary conversion from one type to
16614 another of the same size, providing for breaking the type safety in
16615 special circumstances.
16617 If the types have the same Size (more accurately the same Value_Size),
16618 then the effect is simply to transfer the bits from the source to the
16619 target type without any modification.  This usage is well defined, and
16620 for simple types whose representation is typically the same across
16621 all implementations, gives a portable method of performing such
16622 conversions.
16624 If the types do not have the same size, then the result is implementation
16625 defined, and thus may be non-portable.  The following describes how GNAT
16626 handles such unchecked conversion cases.
16628 If the types are of different sizes, and are both discrete types, then
16629 the effect is of a normal type conversion without any constraint checking.
16630 In particular if the result type has a larger size, the result will be
16631 zero or sign extended.  If the result type has a smaller size, the result
16632 will be truncated by ignoring high order bits.
16634 If the types are of different sizes, and are not both discrete types,
16635 then the conversion works as though pointers were created to the source
16636 and target, and the pointer value is converted.  The effect is that bits
16637 are copied from successive low order storage units and bits of the source
16638 up to the length of the target type.
16640 A warning is issued if the lengths differ, since the effect in this
16641 case is implementation dependent, and the above behavior may not match
16642 that of some other compiler.
16644 A pointer to one type may be converted to a pointer to another type using
16645 unchecked conversion.  The only case in which the effect is undefined is
16646 when one or both pointers are pointers to unconstrained array types.  In
16647 this case, the bounds information may get incorrectly transferred, and in
16648 particular, GNAT uses double size pointers for such types, and it is
16649 meaningless to convert between such pointer types.  GNAT will issue a
16650 warning if the alignment of the target designated type is more strict
16651 than the alignment of the source designated type (since the result may
16652 be unaligned in this case).
16654 A pointer other than a pointer to an unconstrained array type may be
16655 converted to and from System.Address.  Such usage is common in Ada 83
16656 programs, but note that Ada.Address_To_Access_Conversions is the
16657 preferred method of performing such conversions in Ada 95 and Ada 2005.
16658 Neither
16659 unchecked conversion nor Ada.Address_To_Access_Conversions should be
16660 used in conjunction with pointers to unconstrained objects, since
16661 the bounds information cannot be handled correctly in this case.
16663 @item Ada.Unchecked_Deallocation (13.11.2)
16664 This generic package allows explicit freeing of storage previously
16665 allocated by use of an allocator.
16667 @item Ada.Wide_Text_IO (A.11)
16668 This package is similar to @code{Ada.Text_IO}, except that the external
16669 file supports wide character representations, and the internal types are
16670 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
16671 and @code{String}. The corresponding set of nested packages and child
16672 packages are defined.
16674 @item Ada.Wide_Wide_Text_IO (A.11)
16675 This package is similar to @code{Ada.Text_IO}, except that the external
16676 file supports wide character representations, and the internal types are
16677 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
16678 and @code{String}. The corresponding set of nested packages and child
16679 packages are defined.
16681 @end table
16683 For packages in Interfaces and System, all the RM defined packages are
16684 available in GNAT, see the Ada 2012 RM for full details.
16686 @node The Implementation of Standard I/O
16687 @chapter The Implementation of Standard I/O
16689 @noindent
16690 GNAT implements all the required input-output facilities described in
16691 A.6 through A.14.  These sections of the Ada Reference Manual describe the
16692 required behavior of these packages from the Ada point of view, and if
16693 you are writing a portable Ada program that does not need to know the
16694 exact manner in which Ada maps to the outside world when it comes to
16695 reading or writing external files, then you do not need to read this
16696 chapter.  As long as your files are all regular files (not pipes or
16697 devices), and as long as you write and read the files only from Ada, the
16698 description in the Ada Reference Manual is sufficient.
16700 However, if you want to do input-output to pipes or other devices, such
16701 as the keyboard or screen, or if the files you are dealing with are
16702 either generated by some other language, or to be read by some other
16703 language, then you need to know more about the details of how the GNAT
16704 implementation of these input-output facilities behaves.
16706 In this chapter we give a detailed description of exactly how GNAT
16707 interfaces to the file system.  As always, the sources of the system are
16708 available to you for answering questions at an even more detailed level,
16709 but for most purposes the information in this chapter will suffice.
16711 Another reason that you may need to know more about how input-output is
16712 implemented arises when you have a program written in mixed languages
16713 where, for example, files are shared between the C and Ada sections of
16714 the same program.  GNAT provides some additional facilities, in the form
16715 of additional child library packages, that facilitate this sharing, and
16716 these additional facilities are also described in this chapter.
16718 @menu
16719 * Standard I/O Packages::
16720 * FORM Strings::
16721 * Direct_IO::
16722 * Sequential_IO::
16723 * Text_IO::
16724 * Wide_Text_IO::
16725 * Wide_Wide_Text_IO::
16726 * Stream_IO::
16727 * Text Translation::
16728 * Shared Files::
16729 * Filenames encoding::
16730 * Open Modes::
16731 * Operations on C Streams::
16732 * Interfacing to C Streams::
16733 @end menu
16735 @node Standard I/O Packages
16736 @section Standard I/O Packages
16738 @noindent
16739 The Standard I/O packages described in Annex A for
16741 @itemize @bullet
16742 @item
16743 Ada.Text_IO
16744 @item
16745 Ada.Text_IO.Complex_IO
16746 @item
16747 Ada.Text_IO.Text_Streams
16748 @item
16749 Ada.Wide_Text_IO
16750 @item
16751 Ada.Wide_Text_IO.Complex_IO
16752 @item
16753 Ada.Wide_Text_IO.Text_Streams
16754 @item
16755 Ada.Wide_Wide_Text_IO
16756 @item
16757 Ada.Wide_Wide_Text_IO.Complex_IO
16758 @item
16759 Ada.Wide_Wide_Text_IO.Text_Streams
16760 @item
16761 Ada.Stream_IO
16762 @item
16763 Ada.Sequential_IO
16764 @item
16765 Ada.Direct_IO
16766 @end itemize
16768 @noindent
16769 are implemented using the C
16770 library streams facility; where
16772 @itemize @bullet
16773 @item
16774 All files are opened using @code{fopen}.
16775 @item
16776 All input/output operations use @code{fread}/@code{fwrite}.
16777 @end itemize
16779 @noindent
16780 There is no internal buffering of any kind at the Ada library level. The only
16781 buffering is that provided at the system level in the implementation of the
16782 library routines that support streams. This facilitates shared use of these
16783 streams by mixed language programs. Note though that system level buffering is
16784 explicitly enabled at elaboration of the standard I/O packages and that can
16785 have an impact on mixed language programs, in particular those using I/O before
16786 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
16787 the Ada elaboration routine before performing any I/O or when impractical,
16788 flush the common I/O streams and in particular Standard_Output before
16789 elaborating the Ada code.
16791 @node FORM Strings
16792 @section FORM Strings
16794 @noindent
16795 The format of a FORM string in GNAT is:
16797 @smallexample
16798 "keyword=value,keyword=value,@dots{},keyword=value"
16799 @end smallexample
16801 @noindent
16802 where letters may be in upper or lower case, and there are no spaces
16803 between values.  The order of the entries is not important.  Currently
16804 the following keywords defined.
16806 @smallexample
16807 TEXT_TRANSLATION=[YES|NO]
16808 SHARED=[YES|NO]
16809 WCEM=[n|h|u|s|e|8|b]
16810 ENCODING=[UTF8|8BITS]
16811 @end smallexample
16813 @noindent
16814 The use of these parameters is described later in this section. If an
16815 unrecognized keyword appears in a form string, it is silently ignored
16816 and not considered invalid.
16818 @noindent
16819 For OpenVMS additional FORM string keywords are available for use with
16820 RMS services.  The syntax is:
16822 @smallexample
16823 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
16824 @end smallexample
16826 @noindent
16827 The following RMS keywords and values are currently defined:
16829 @smallexample
16830 Context=Force_Stream_Mode|Force_Record_Mode
16831 @end smallexample
16833 @noindent
16834 VMS RMS keys are silently ignored on non-VMS systems.  On OpenVMS
16835 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
16837 @node Direct_IO
16838 @section Direct_IO
16840 @noindent
16841 Direct_IO can only be instantiated for definite types.  This is a
16842 restriction of the Ada language, which means that the records are fixed
16843 length (the length being determined by @code{@var{type}'Size}, rounded
16844 up to the next storage unit boundary if necessary).
16846 The records of a Direct_IO file are simply written to the file in index
16847 sequence, with the first record starting at offset zero, and subsequent
16848 records following.  There is no control information of any kind.  For
16849 example, if 32-bit integers are being written, each record takes
16850 4-bytes, so the record at index @var{K} starts at offset
16851 (@var{K}@minus{}1)*4.
16853 There is no limit on the size of Direct_IO files, they are expanded as
16854 necessary to accommodate whatever records are written to the file.
16856 @node Sequential_IO
16857 @section Sequential_IO
16859 @noindent
16860 Sequential_IO may be instantiated with either a definite (constrained)
16861 or indefinite (unconstrained) type.
16863 For the definite type case, the elements written to the file are simply
16864 the memory images of the data values with no control information of any
16865 kind.  The resulting file should be read using the same type, no validity
16866 checking is performed on input.
16868 For the indefinite type case, the elements written consist of two
16869 parts.  First is the size of the data item, written as the memory image
16870 of a @code{Interfaces.C.size_t} value, followed by the memory image of
16871 the data value.  The resulting file can only be read using the same
16872 (unconstrained) type.  Normal assignment checks are performed on these
16873 read operations, and if these checks fail, @code{Data_Error} is
16874 raised.  In particular, in the array case, the lengths must match, and in
16875 the variant record case, if the variable for a particular read operation
16876 is constrained, the discriminants must match.
16878 Note that it is not possible to use Sequential_IO to write variable
16879 length array items, and then read the data back into different length
16880 arrays.  For example, the following will raise @code{Data_Error}:
16882 @smallexample @c ada
16883  package IO is new Sequential_IO (String);
16884  F : IO.File_Type;
16885  S : String (1..4);
16886  @dots{}
16887  IO.Create (F)
16888  IO.Write (F, "hello!")
16889  IO.Reset (F, Mode=>In_File);
16890  IO.Read (F, S);
16891  Put_Line (S);
16893 @end smallexample
16895 @noindent
16896 On some Ada implementations, this will print @code{hell}, but the program is
16897 clearly incorrect, since there is only one element in the file, and that
16898 element is the string @code{hello!}.
16900 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
16901 using Stream_IO, and this is the preferred mechanism.  In particular, the
16902 above program fragment rewritten to use Stream_IO will work correctly.
16904 @node Text_IO
16905 @section Text_IO
16907 @noindent
16908 Text_IO files consist of a stream of characters containing the following
16909 special control characters:
16911 @smallexample
16912 LF (line feed, 16#0A#) Line Mark
16913 FF (form feed, 16#0C#) Page Mark
16914 @end smallexample
16916 @noindent
16917 A canonical Text_IO file is defined as one in which the following
16918 conditions are met:
16920 @itemize @bullet
16921 @item
16922 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
16923 of the line.
16925 @item
16926 The character @code{FF} is used only as a page mark, i.e.@: to mark the
16927 end of a page and consequently can appear only immediately following a
16928 @code{LF} (line mark) character.
16930 @item
16931 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
16932 (line mark, page mark).  In the former case, the page mark is implicitly
16933 assumed to be present.
16934 @end itemize
16936 @noindent
16937 A file written using Text_IO will be in canonical form provided that no
16938 explicit @code{LF} or @code{FF} characters are written using @code{Put}
16939 or @code{Put_Line}.  There will be no @code{FF} character at the end of
16940 the file unless an explicit @code{New_Page} operation was performed
16941 before closing the file.
16943 A canonical Text_IO file that is a regular file (i.e., not a device or a
16944 pipe) can be read using any of the routines in Text_IO@.  The
16945 semantics in this case will be exactly as defined in the Ada Reference
16946 Manual, and all the routines in Text_IO are fully implemented.
16948 A text file that does not meet the requirements for a canonical Text_IO
16949 file has one of the following:
16951 @itemize @bullet
16952 @item
16953 The file contains @code{FF} characters not immediately following a
16954 @code{LF} character.
16956 @item
16957 The file contains @code{LF} or @code{FF} characters written by
16958 @code{Put} or @code{Put_Line}, which are not logically considered to be
16959 line marks or page marks.
16961 @item
16962 The file ends in a character other than @code{LF} or @code{FF},
16963 i.e.@: there is no explicit line mark or page mark at the end of the file.
16964 @end itemize
16966 @noindent
16967 Text_IO can be used to read such non-standard text files but subprograms
16968 to do with line or page numbers do not have defined meanings.  In
16969 particular, a @code{FF} character that does not follow a @code{LF}
16970 character may or may not be treated as a page mark from the point of
16971 view of page and line numbering.  Every @code{LF} character is considered
16972 to end a line, and there is an implied @code{LF} character at the end of
16973 the file.
16975 @menu
16976 * Text_IO Stream Pointer Positioning::
16977 * Text_IO Reading and Writing Non-Regular Files::
16978 * Get_Immediate::
16979 * Treating Text_IO Files as Streams::
16980 * Text_IO Extensions::
16981 * Text_IO Facilities for Unbounded Strings::
16982 @end menu
16984 @node Text_IO Stream Pointer Positioning
16985 @subsection Stream Pointer Positioning
16987 @noindent
16988 @code{Ada.Text_IO} has a definition of current position for a file that
16989 is being read.  No internal buffering occurs in Text_IO, and usually the
16990 physical position in the stream used to implement the file corresponds
16991 to this logical position defined by Text_IO@.  There are two exceptions:
16993 @itemize @bullet
16994 @item
16995 After a call to @code{End_Of_Page} that returns @code{True}, the stream
16996 is positioned past the @code{LF} (line mark) that precedes the page
16997 mark.  Text_IO maintains an internal flag so that subsequent read
16998 operations properly handle the logical position which is unchanged by
16999 the @code{End_Of_Page} call.
17001 @item
17002 After a call to @code{End_Of_File} that returns @code{True}, if the
17003 Text_IO file was positioned before the line mark at the end of file
17004 before the call, then the logical position is unchanged, but the stream
17005 is physically positioned right at the end of file (past the line mark,
17006 and past a possible page mark following the line mark.  Again Text_IO
17007 maintains internal flags so that subsequent read operations properly
17008 handle the logical position.
17009 @end itemize
17011 @noindent
17012 These discrepancies have no effect on the observable behavior of
17013 Text_IO, but if a single Ada stream is shared between a C program and
17014 Ada program, or shared (using @samp{shared=yes} in the form string)
17015 between two Ada files, then the difference may be observable in some
17016 situations.
17018 @node Text_IO Reading and Writing Non-Regular Files
17019 @subsection Reading and Writing Non-Regular Files
17021 @noindent
17022 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
17023 can be used for reading and writing.  Writing is not affected and the
17024 sequence of characters output is identical to the normal file case, but
17025 for reading, the behavior of Text_IO is modified to avoid undesirable
17026 look-ahead as follows:
17028 An input file that is not a regular file is considered to have no page
17029 marks.  Any @code{Ascii.FF} characters (the character normally used for a
17030 page mark) appearing in the file are considered to be data
17031 characters.  In particular:
17033 @itemize @bullet
17034 @item
17035 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
17036 following a line mark.  If a page mark appears, it will be treated as a
17037 data character.
17039 @item
17040 This avoids the need to wait for an extra character to be typed or
17041 entered from the pipe to complete one of these operations.
17043 @item
17044 @code{End_Of_Page} always returns @code{False}
17046 @item
17047 @code{End_Of_File} will return @code{False} if there is a page mark at
17048 the end of the file.
17049 @end itemize
17051 @noindent
17052 Output to non-regular files is the same as for regular files.  Page marks
17053 may be written to non-regular files using @code{New_Page}, but as noted
17054 above they will not be treated as page marks on input if the output is
17055 piped to another Ada program.
17057 Another important discrepancy when reading non-regular files is that the end
17058 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
17059 pressing the @key{EOT} key,
17060 then end of file
17061 is signaled once (i.e.@: the test @code{End_Of_File}
17062 will yield @code{True}, or a read will
17063 raise @code{End_Error}), but then reading can resume
17064 to read data past that end of
17065 file indication, until another end of file indication is entered.
17067 @node Get_Immediate
17068 @subsection Get_Immediate
17069 @cindex Get_Immediate
17071 @noindent
17072 Get_Immediate returns the next character (including control characters)
17073 from the input file.  In particular, Get_Immediate will return LF or FF
17074 characters used as line marks or page marks.  Such operations leave the
17075 file positioned past the control character, and it is thus not treated
17076 as having its normal function.  This means that page, line and column
17077 counts after this kind of Get_Immediate call are set as though the mark
17078 did not occur.  In the case where a Get_Immediate leaves the file
17079 positioned between the line mark and page mark (which is not normally
17080 possible), it is undefined whether the FF character will be treated as a
17081 page mark.
17083 @node Treating Text_IO Files as Streams
17084 @subsection Treating Text_IO Files as Streams
17085 @cindex Stream files
17087 @noindent
17088 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
17089 as a stream.  Data written to a Text_IO file in this stream mode is
17090 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
17091 16#0C# (@code{FF}), the resulting file may have non-standard
17092 format.  Similarly if read operations are used to read from a Text_IO
17093 file treated as a stream, then @code{LF} and @code{FF} characters may be
17094 skipped and the effect is similar to that described above for
17095 @code{Get_Immediate}.
17097 @node Text_IO Extensions
17098 @subsection Text_IO Extensions
17099 @cindex Text_IO extensions
17101 @noindent
17102 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
17103 to the standard @code{Text_IO} package:
17105 @itemize @bullet
17106 @item function File_Exists (Name : String) return Boolean;
17107 Determines if a file of the given name exists.
17109 @item function Get_Line return String;
17110 Reads a string from the standard input file.  The value returned is exactly
17111 the length of the line that was read.
17113 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
17114 Similar, except that the parameter File specifies the file from which
17115 the string is to be read.
17117 @end itemize
17119 @node Text_IO Facilities for Unbounded Strings
17120 @subsection Text_IO Facilities for Unbounded Strings
17121 @cindex Text_IO for unbounded strings
17122 @cindex Unbounded_String, Text_IO operations
17124 @noindent
17125 The package @code{Ada.Strings.Unbounded.Text_IO}
17126 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
17127 subprograms useful for Text_IO operations on unbounded strings:
17129 @itemize @bullet
17131 @item function Get_Line (File : File_Type) return Unbounded_String;
17132 Reads a line from the specified file
17133 and returns the result as an unbounded string.
17135 @item procedure Put (File : File_Type; U : Unbounded_String);
17136 Writes the value of the given unbounded string to the specified file
17137 Similar to the effect of
17138 @code{Put (To_String (U))} except that an extra copy is avoided.
17140 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
17141 Writes the value of the given unbounded string to the specified file,
17142 followed by a @code{New_Line}.
17143 Similar to the effect of @code{Put_Line (To_String (U))} except
17144 that an extra copy is avoided.
17145 @end itemize
17147 @noindent
17148 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
17149 and is optional.  If the parameter is omitted, then the standard input or
17150 output file is referenced as appropriate.
17152 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
17153 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
17154 @code{Wide_Text_IO} functionality for unbounded wide strings.
17156 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
17157 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
17158 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
17160 @node Wide_Text_IO
17161 @section Wide_Text_IO
17163 @noindent
17164 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
17165 both input and output files may contain special sequences that represent
17166 wide character values.  The encoding scheme for a given file may be
17167 specified using a FORM parameter:
17169 @smallexample
17170 WCEM=@var{x}
17171 @end smallexample
17173 @noindent
17174 as part of the FORM string (WCEM = wide character encoding method),
17175 where @var{x} is one of the following characters
17177 @table @samp
17178 @item h
17179 Hex ESC encoding
17180 @item u
17181 Upper half encoding
17182 @item s
17183 Shift-JIS encoding
17184 @item e
17185 EUC Encoding
17186 @item 8
17187 UTF-8 encoding
17188 @item b
17189 Brackets encoding
17190 @end table
17192 @noindent
17193 The encoding methods match those that
17194 can be used in a source
17195 program, but there is no requirement that the encoding method used for
17196 the source program be the same as the encoding method used for files,
17197 and different files may use different encoding methods.
17199 The default encoding method for the standard files, and for opened files
17200 for which no WCEM parameter is given in the FORM string matches the
17201 wide character encoding specified for the main program (the default
17202 being brackets encoding if no coding method was specified with -gnatW).
17204 @table @asis
17205 @item Hex Coding
17206 In this encoding, a wide character is represented by a five character
17207 sequence:
17209 @smallexample
17210 ESC a b c d
17211 @end smallexample
17213 @noindent
17214 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
17215 characters (using upper case letters) of the wide character code.  For
17216 example, ESC A345 is used to represent the wide character with code
17217 16#A345#.  This scheme is compatible with use of the full
17218 @code{Wide_Character} set.
17220 @item Upper Half Coding
17221 The wide character with encoding 16#abcd#, where the upper bit is on
17222 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
17223 16#cd#.  The second byte may never be a format control character, but is
17224 not required to be in the upper half.  This method can be also used for
17225 shift-JIS or EUC where the internal coding matches the external coding.
17227 @item Shift JIS Coding
17228 A wide character is represented by a two character sequence 16#ab# and
17229 16#cd#, with the restrictions described for upper half encoding as
17230 described above.  The internal character code is the corresponding JIS
17231 character according to the standard algorithm for Shift-JIS
17232 conversion.  Only characters defined in the JIS code set table can be
17233 used with this encoding method.
17235 @item EUC Coding
17236 A wide character is represented by a two character sequence 16#ab# and
17237 16#cd#, with both characters being in the upper half.  The internal
17238 character code is the corresponding JIS character according to the EUC
17239 encoding algorithm.  Only characters defined in the JIS code set table
17240 can be used with this encoding method.
17242 @item UTF-8 Coding
17243 A wide character is represented using
17244 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
17245 10646-1/Am.2.  Depending on the character value, the representation
17246 is a one, two, or three byte sequence:
17248 @smallexample
17249 16#0000#-16#007f#: 2#0xxxxxxx#
17250 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
17251 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
17252 @end smallexample
17254 @noindent
17255 where the @var{xxx} bits correspond to the left-padded bits of the
17256 16-bit character value.  Note that all lower half ASCII characters
17257 are represented as ASCII bytes and all upper half characters and
17258 other wide characters are represented as sequences of upper-half
17259 (The full UTF-8 scheme allows for encoding 31-bit characters as
17260 6-byte sequences, but in this implementation, all UTF-8 sequences
17261 of four or more bytes length will raise a Constraint_Error, as
17262 will all invalid UTF-8 sequences.)
17264 @item Brackets Coding
17265 In this encoding, a wide character is represented by the following eight
17266 character sequence:
17268 @smallexample
17269 [ " a b c d " ]
17270 @end smallexample
17272 @noindent
17273 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
17274 characters (using uppercase letters) of the wide character code.  For
17275 example, @code{["A345"]} is used to represent the wide character with code
17276 @code{16#A345#}.
17277 This scheme is compatible with use of the full Wide_Character set.
17278 On input, brackets coding can also be used for upper half characters,
17279 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
17280 is only used for wide characters with a code greater than @code{16#FF#}.
17282 Note that brackets coding is not normally used in the context of
17283 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
17284 a portable way of encoding source files. In the context of Wide_Text_IO
17285 or Wide_Wide_Text_IO, it can only be used if the file does not contain
17286 any instance of the left bracket character other than to encode wide
17287 character values using the brackets encoding method. In practice it is
17288 expected that some standard wide character encoding method such
17289 as UTF-8 will be used for text input output.
17291 If brackets notation is used, then any occurrence of a left bracket
17292 in the input file which is not the start of a valid wide character
17293 sequence will cause Constraint_Error to be raised. It is possible to
17294 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
17295 input will interpret this as a left bracket.
17297 However, when a left bracket is output, it will be output as a left bracket
17298 and not as ["5B"]. We make this decision because for normal use of
17299 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
17300 brackets. For example, if we write:
17302 @smallexample
17303    Put_Line ("Start of output [first run]");
17304 @end smallexample
17306 @noindent
17307 we really do not want to have the left bracket in this message clobbered so
17308 that the output reads:
17310 @smallexample
17311    Start of output ["5B"]first run]
17312 @end smallexample
17314 @noindent
17315 In practice brackets encoding is reasonably useful for normal Put_Line use
17316 since we won't get confused between left brackets and wide character
17317 sequences in the output. But for input, or when files are written out
17318 and read back in, it really makes better sense to use one of the standard
17319 encoding methods such as UTF-8.
17321 @end table
17323 @noindent
17324 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
17325 not all wide character
17326 values can be represented.  An attempt to output a character that cannot
17327 be represented using the encoding scheme for the file causes
17328 Constraint_Error to be raised.  An invalid wide character sequence on
17329 input also causes Constraint_Error to be raised.
17331 @menu
17332 * Wide_Text_IO Stream Pointer Positioning::
17333 * Wide_Text_IO Reading and Writing Non-Regular Files::
17334 @end menu
17336 @node Wide_Text_IO Stream Pointer Positioning
17337 @subsection Stream Pointer Positioning
17339 @noindent
17340 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
17341 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
17342 case:
17344 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
17345 normal lower ASCII set (i.e.@: a character in the range:
17347 @smallexample @c ada
17348 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
17349 @end smallexample
17351 @noindent
17352 then although the logical position of the file pointer is unchanged by
17353 the @code{Look_Ahead} call, the stream is physically positioned past the
17354 wide character sequence.  Again this is to avoid the need for buffering
17355 or backup, and all @code{Wide_Text_IO} routines check the internal
17356 indication that this situation has occurred so that this is not visible
17357 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
17358 can be observed if the wide text file shares a stream with another file.
17360 @node Wide_Text_IO Reading and Writing Non-Regular Files
17361 @subsection Reading and Writing Non-Regular Files
17363 @noindent
17364 As in the case of Text_IO, when a non-regular file is read, it is
17365 assumed that the file contains no page marks (any form characters are
17366 treated as data characters), and @code{End_Of_Page} always returns
17367 @code{False}.  Similarly, the end of file indication is not sticky, so
17368 it is possible to read beyond an end of file.
17370 @node Wide_Wide_Text_IO
17371 @section Wide_Wide_Text_IO
17373 @noindent
17374 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
17375 both input and output files may contain special sequences that represent
17376 wide wide character values.  The encoding scheme for a given file may be
17377 specified using a FORM parameter:
17379 @smallexample
17380 WCEM=@var{x}
17381 @end smallexample
17383 @noindent
17384 as part of the FORM string (WCEM = wide character encoding method),
17385 where @var{x} is one of the following characters
17387 @table @samp
17388 @item h
17389 Hex ESC encoding
17390 @item u
17391 Upper half encoding
17392 @item s
17393 Shift-JIS encoding
17394 @item e
17395 EUC Encoding
17396 @item 8
17397 UTF-8 encoding
17398 @item b
17399 Brackets encoding
17400 @end table
17402 @noindent
17403 The encoding methods match those that
17404 can be used in a source
17405 program, but there is no requirement that the encoding method used for
17406 the source program be the same as the encoding method used for files,
17407 and different files may use different encoding methods.
17409 The default encoding method for the standard files, and for opened files
17410 for which no WCEM parameter is given in the FORM string matches the
17411 wide character encoding specified for the main program (the default
17412 being brackets encoding if no coding method was specified with -gnatW).
17414 @table @asis
17416 @item UTF-8 Coding
17417 A wide character is represented using
17418 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
17419 10646-1/Am.2.  Depending on the character value, the representation
17420 is a one, two, three, or four byte sequence:
17422 @smallexample
17423 16#000000#-16#00007f#: 2#0xxxxxxx#
17424 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
17425 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
17426 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
17427 @end smallexample
17429 @noindent
17430 where the @var{xxx} bits correspond to the left-padded bits of the
17431 21-bit character value.  Note that all lower half ASCII characters
17432 are represented as ASCII bytes and all upper half characters and
17433 other wide characters are represented as sequences of upper-half
17434 characters.
17436 @item Brackets Coding
17437 In this encoding, a wide wide character is represented by the following eight
17438 character sequence if is in wide character range
17440 @smallexample
17441 [ " a b c d " ]
17442 @end smallexample
17444 and by the following ten character sequence if not
17446 @smallexample
17447 [ " a b c d e f " ]
17448 @end smallexample
17450 @noindent
17451 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
17452 are the four or six hexadecimal
17453 characters (using uppercase letters) of the wide wide character code.  For
17454 example, @code{["01A345"]} is used to represent the wide wide character
17455 with code @code{16#01A345#}.
17457 This scheme is compatible with use of the full Wide_Wide_Character set.
17458 On input, brackets coding can also be used for upper half characters,
17459 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
17460 is only used for wide characters with a code greater than @code{16#FF#}.
17462 @end table
17464 @noindent
17465 If is also possible to use the other Wide_Character encoding methods,
17466 such as Shift-JIS, but the other schemes cannot support the full range
17467 of wide wide characters.
17468 An attempt to output a character that cannot
17469 be represented using the encoding scheme for the file causes
17470 Constraint_Error to be raised.  An invalid wide character sequence on
17471 input also causes Constraint_Error to be raised.
17473 @menu
17474 * Wide_Wide_Text_IO Stream Pointer Positioning::
17475 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
17476 @end menu
17478 @node Wide_Wide_Text_IO Stream Pointer Positioning
17479 @subsection Stream Pointer Positioning
17481 @noindent
17482 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
17483 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
17484 case:
17486 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
17487 normal lower ASCII set (i.e.@: a character in the range:
17489 @smallexample @c ada
17490 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
17491 @end smallexample
17493 @noindent
17494 then although the logical position of the file pointer is unchanged by
17495 the @code{Look_Ahead} call, the stream is physically positioned past the
17496 wide character sequence.  Again this is to avoid the need for buffering
17497 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
17498 indication that this situation has occurred so that this is not visible
17499 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
17500 can be observed if the wide text file shares a stream with another file.
17502 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
17503 @subsection Reading and Writing Non-Regular Files
17505 @noindent
17506 As in the case of Text_IO, when a non-regular file is read, it is
17507 assumed that the file contains no page marks (any form characters are
17508 treated as data characters), and @code{End_Of_Page} always returns
17509 @code{False}.  Similarly, the end of file indication is not sticky, so
17510 it is possible to read beyond an end of file.
17512 @node Stream_IO
17513 @section Stream_IO
17515 @noindent
17516 A stream file is a sequence of bytes, where individual elements are
17517 written to the file as described in the Ada Reference Manual.  The type
17518 @code{Stream_Element} is simply a byte.  There are two ways to read or
17519 write a stream file.
17521 @itemize @bullet
17522 @item
17523 The operations @code{Read} and @code{Write} directly read or write a
17524 sequence of stream elements with no control information.
17526 @item
17527 The stream attributes applied to a stream file transfer data in the
17528 manner described for stream attributes.
17529 @end itemize
17531 @node Text Translation
17532 @section Text Translation
17534 @noindent
17535 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
17536 passed to Text_IO.Create and Text_IO.Open:
17537 @samp{Text_Translation=@var{Yes}} is the default, which means to
17538 translate LF to/from CR/LF on Windows systems.
17539 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
17540 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
17541 may be used to create Unix-style files on
17542 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
17543 systems.
17545 @node Shared Files
17546 @section Shared Files
17548 @noindent
17549 Section A.14 of the Ada Reference Manual allows implementations to
17550 provide a wide variety of behavior if an attempt is made to access the
17551 same external file with two or more internal files.
17553 To provide a full range of functionality, while at the same time
17554 minimizing the problems of portability caused by this implementation
17555 dependence, GNAT handles file sharing as follows:
17557 @itemize @bullet
17558 @item
17559 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
17560 to open two or more files with the same full name is considered an error
17561 and is not supported.  The exception @code{Use_Error} will be
17562 raised.  Note that a file that is not explicitly closed by the program
17563 remains open until the program terminates.
17565 @item
17566 If the form parameter @samp{shared=no} appears in the form string, the
17567 file can be opened or created with its own separate stream identifier,
17568 regardless of whether other files sharing the same external file are
17569 opened.  The exact effect depends on how the C stream routines handle
17570 multiple accesses to the same external files using separate streams.
17572 @item
17573 If the form parameter @samp{shared=yes} appears in the form string for
17574 each of two or more files opened using the same full name, the same
17575 stream is shared between these files, and the semantics are as described
17576 in Ada Reference Manual, Section A.14.
17577 @end itemize
17579 @noindent
17580 When a program that opens multiple files with the same name is ported
17581 from another Ada compiler to GNAT, the effect will be that
17582 @code{Use_Error} is raised.
17584 The documentation of the original compiler and the documentation of the
17585 program should then be examined to determine if file sharing was
17586 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
17587 and @code{Create} calls as required.
17589 When a program is ported from GNAT to some other Ada compiler, no
17590 special attention is required unless the @samp{shared=@var{xxx}} form
17591 parameter is used in the program.  In this case, you must examine the
17592 documentation of the new compiler to see if it supports the required
17593 file sharing semantics, and form strings modified appropriately.  Of
17594 course it may be the case that the program cannot be ported if the
17595 target compiler does not support the required functionality.  The best
17596 approach in writing portable code is to avoid file sharing (and hence
17597 the use of the @samp{shared=@var{xxx}} parameter in the form string)
17598 completely.
17600 One common use of file sharing in Ada 83 is the use of instantiations of
17601 Sequential_IO on the same file with different types, to achieve
17602 heterogeneous input-output.  Although this approach will work in GNAT if
17603 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
17604 for this purpose (using the stream attributes)
17606 @node Filenames encoding
17607 @section Filenames encoding
17609 @noindent
17610 An encoding form parameter can be used to specify the filename
17611 encoding @samp{encoding=@var{xxx}}.
17613 @itemize @bullet
17614 @item
17615 If the form parameter @samp{encoding=utf8} appears in the form string, the
17616 filename must be encoded in UTF-8.
17618 @item
17619 If the form parameter @samp{encoding=8bits} appears in the form
17620 string, the filename must be a standard 8bits string.
17621 @end itemize
17623 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
17624 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
17625 variable. And if not set @samp{utf8} is assumed.
17627 @table @samp
17628 @item CP_ACP
17629 The current system Windows ANSI code page.
17630 @item CP_UTF8
17631 UTF-8 encoding
17632 @end table
17634 This encoding form parameter is only supported on the Windows
17635 platform. On the other Operating Systems the run-time is supporting
17636 UTF-8 natively.
17638 @node Open Modes
17639 @section Open Modes
17641 @noindent
17642 @code{Open} and @code{Create} calls result in a call to @code{fopen}
17643 using the mode shown in the following table:
17645 @sp 2
17646 @center @code{Open} and @code{Create} Call Modes
17647 @smallexample
17648                                @b{OPEN }           @b{CREATE}
17649 Append_File                    "r+"             "w+"
17650 In_File                        "r"              "w+"
17651 Out_File (Direct_IO)           "r+"             "w"
17652 Out_File (all other cases)     "w"              "w"
17653 Inout_File                     "r+"             "w+"
17654 @end smallexample
17656 @noindent
17657 If text file translation is required, then either @samp{b} or @samp{t}
17658 is added to the mode, depending on the setting of Text.  Text file
17659 translation refers to the mapping of CR/LF sequences in an external file
17660 to LF characters internally.  This mapping only occurs in DOS and
17661 DOS-like systems, and is not relevant to other systems.
17663 A special case occurs with Stream_IO@.  As shown in the above table, the
17664 file is initially opened in @samp{r} or @samp{w} mode for the
17665 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
17666 subsequently requires switching from reading to writing or vice-versa,
17667 then the file is reopened in @samp{r+} mode to permit the required operation.
17669 @node Operations on C Streams
17670 @section Operations on C Streams
17671 The package @code{Interfaces.C_Streams} provides an Ada program with direct
17672 access to the C library functions for operations on C streams:
17674 @smallexample @c adanocomment
17675 package Interfaces.C_Streams is
17676   -- Note: the reason we do not use the types that are in
17677   -- Interfaces.C is that we want to avoid dragging in the
17678   -- code in this unit if possible.
17679   subtype chars is System.Address;
17680   -- Pointer to null-terminated array of characters
17681   subtype FILEs is System.Address;
17682   -- Corresponds to the C type FILE*
17683   subtype voids is System.Address;
17684   -- Corresponds to the C type void*
17685   subtype int is Integer;
17686   subtype long is Long_Integer;
17687   -- Note: the above types are subtypes deliberately, and it
17688   -- is part of this spec that the above correspondences are
17689   -- guaranteed.  This means that it is legitimate to, for
17690   -- example, use Integer instead of int.  We provide these
17691   -- synonyms for clarity, but in some cases it may be
17692   -- convenient to use the underlying types (for example to
17693   -- avoid an unnecessary dependency of a spec on the spec
17694   -- of this unit).
17695   type size_t is mod 2 ** Standard'Address_Size;
17696   NULL_Stream : constant FILEs;
17697   -- Value returned (NULL in C) to indicate an
17698   -- fdopen/fopen/tmpfile error
17699   ----------------------------------
17700   -- Constants Defined in stdio.h --
17701   ----------------------------------
17702   EOF : constant int;
17703   -- Used by a number of routines to indicate error or
17704   -- end of file
17705   IOFBF : constant int;
17706   IOLBF : constant int;
17707   IONBF : constant int;
17708   -- Used to indicate buffering mode for setvbuf call
17709   SEEK_CUR : constant int;
17710   SEEK_END : constant int;
17711   SEEK_SET : constant int;
17712   -- Used to indicate origin for fseek call
17713   function stdin return FILEs;
17714   function stdout return FILEs;
17715   function stderr return FILEs;
17716   -- Streams associated with standard files
17717   --------------------------
17718   -- Standard C functions --
17719   --------------------------
17720   -- The functions selected below are ones that are
17721   -- available in UNIX (but not necessarily in ANSI C).
17722   -- These are very thin interfaces
17723   -- which copy exactly the C headers.  For more
17724   -- documentation on these functions, see the Microsoft C
17725   -- "Run-Time Library Reference" (Microsoft Press, 1990,
17726   -- ISBN 1-55615-225-6), which includes useful information
17727   -- on system compatibility.
17728   procedure clearerr (stream : FILEs);
17729   function fclose (stream : FILEs) return int;
17730   function fdopen (handle : int; mode : chars) return FILEs;
17731   function feof (stream : FILEs) return int;
17732   function ferror (stream : FILEs) return int;
17733   function fflush (stream : FILEs) return int;
17734   function fgetc (stream : FILEs) return int;
17735   function fgets (strng : chars; n : int; stream : FILEs)
17736       return chars;
17737   function fileno (stream : FILEs) return int;
17738   function fopen (filename : chars; Mode : chars)
17739       return FILEs;
17740   -- Note: to maintain target independence, use
17741   -- text_translation_required, a boolean variable defined in
17742   -- a-sysdep.c to deal with the target dependent text
17743   -- translation requirement.  If this variable is set,
17744   -- then  b/t should be appended to the standard mode
17745   -- argument to set the text translation mode off or on
17746   -- as required.
17747   function fputc (C : int; stream : FILEs) return int;
17748   function fputs (Strng : chars; Stream : FILEs) return int;
17749   function fread
17750      (buffer : voids;
17751       size : size_t;
17752       count : size_t;
17753       stream : FILEs)
17754       return size_t;
17755   function freopen
17756      (filename : chars;
17757       mode : chars;
17758       stream : FILEs)
17759       return FILEs;
17760   function fseek
17761      (stream : FILEs;
17762       offset : long;
17763       origin : int)
17764       return int;
17765   function ftell (stream : FILEs) return long;
17766   function fwrite
17767      (buffer : voids;
17768       size : size_t;
17769       count : size_t;
17770       stream : FILEs)
17771       return size_t;
17772   function isatty (handle : int) return int;
17773   procedure mktemp (template : chars);
17774   -- The return value (which is just a pointer to template)
17775   -- is discarded
17776   procedure rewind (stream : FILEs);
17777   function rmtmp return int;
17778   function setvbuf
17779      (stream : FILEs;
17780       buffer : chars;
17781       mode : int;
17782       size : size_t)
17783       return int;
17785   function tmpfile return FILEs;
17786   function ungetc (c : int; stream : FILEs) return int;
17787   function unlink (filename : chars) return int;
17788   ---------------------
17789   -- Extra functions --
17790   ---------------------
17791   -- These functions supply slightly thicker bindings than
17792   -- those above.  They are derived from functions in the
17793   -- C Run-Time Library, but may do a bit more work than
17794   -- just directly calling one of the Library functions.
17795   function is_regular_file (handle : int) return int;
17796   -- Tests if given handle is for a regular file (result 1)
17797   -- or for a non-regular file (pipe or device, result 0).
17798   ---------------------------------
17799   -- Control of Text/Binary Mode --
17800   ---------------------------------
17801   -- If text_translation_required is true, then the following
17802   -- functions may be used to dynamically switch a file from
17803   -- binary to text mode or vice versa.  These functions have
17804   -- no effect if text_translation_required is false (i.e.@: in
17805   -- normal UNIX mode).  Use fileno to get a stream handle.
17806   procedure set_binary_mode (handle : int);
17807   procedure set_text_mode (handle : int);
17808   ----------------------------
17809   -- Full Path Name support --
17810   ----------------------------
17811   procedure full_name (nam : chars; buffer : chars);
17812   -- Given a NUL terminated string representing a file
17813   -- name, returns in buffer a NUL terminated string
17814   -- representing the full path name for the file name.
17815   -- On systems where it is relevant the   drive is also
17816   -- part of the full path name.  It is the responsibility
17817   -- of the caller to pass an actual parameter for buffer
17818   -- that is big enough for any full path name.  Use
17819   -- max_path_len given below as the size of buffer.
17820   max_path_len : integer;
17821   -- Maximum length of an allowable full path name on the
17822   -- system, including a terminating NUL character.
17823 end Interfaces.C_Streams;
17824 @end smallexample
17826 @node Interfacing to C Streams
17827 @section Interfacing to C Streams
17829 @noindent
17830 The packages in this section permit interfacing Ada files to C Stream
17831 operations.
17833 @smallexample @c ada
17834  with Interfaces.C_Streams;
17835  package Ada.Sequential_IO.C_Streams is
17836     function C_Stream (F : File_Type)
17837        return Interfaces.C_Streams.FILEs;
17838     procedure Open
17839       (File : in out File_Type;
17840        Mode : in File_Mode;
17841        C_Stream : in Interfaces.C_Streams.FILEs;
17842        Form : in String := "");
17843  end Ada.Sequential_IO.C_Streams;
17845   with Interfaces.C_Streams;
17846   package Ada.Direct_IO.C_Streams is
17847      function C_Stream (F : File_Type)
17848         return Interfaces.C_Streams.FILEs;
17849      procedure Open
17850        (File : in out File_Type;
17851         Mode : in File_Mode;
17852         C_Stream : in Interfaces.C_Streams.FILEs;
17853         Form : in String := "");
17854   end Ada.Direct_IO.C_Streams;
17856   with Interfaces.C_Streams;
17857   package Ada.Text_IO.C_Streams is
17858      function C_Stream (F : File_Type)
17859         return Interfaces.C_Streams.FILEs;
17860      procedure Open
17861        (File : in out File_Type;
17862         Mode : in File_Mode;
17863         C_Stream : in Interfaces.C_Streams.FILEs;
17864         Form : in String := "");
17865   end Ada.Text_IO.C_Streams;
17867   with Interfaces.C_Streams;
17868   package Ada.Wide_Text_IO.C_Streams is
17869      function C_Stream (F : File_Type)
17870         return Interfaces.C_Streams.FILEs;
17871      procedure Open
17872        (File : in out File_Type;
17873         Mode : in File_Mode;
17874         C_Stream : in Interfaces.C_Streams.FILEs;
17875         Form : in String := "");
17876  end Ada.Wide_Text_IO.C_Streams;
17878   with Interfaces.C_Streams;
17879   package Ada.Wide_Wide_Text_IO.C_Streams is
17880      function C_Stream (F : File_Type)
17881         return Interfaces.C_Streams.FILEs;
17882      procedure Open
17883        (File : in out File_Type;
17884         Mode : in File_Mode;
17885         C_Stream : in Interfaces.C_Streams.FILEs;
17886         Form : in String := "");
17887  end Ada.Wide_Wide_Text_IO.C_Streams;
17889  with Interfaces.C_Streams;
17890  package Ada.Stream_IO.C_Streams is
17891     function C_Stream (F : File_Type)
17892        return Interfaces.C_Streams.FILEs;
17893     procedure Open
17894       (File : in out File_Type;
17895        Mode : in File_Mode;
17896        C_Stream : in Interfaces.C_Streams.FILEs;
17897        Form : in String := "");
17898  end Ada.Stream_IO.C_Streams;
17899 @end smallexample
17901 @noindent
17902 In each of these six packages, the @code{C_Stream} function obtains the
17903 @code{FILE} pointer from a currently opened Ada file.  It is then
17904 possible to use the @code{Interfaces.C_Streams} package to operate on
17905 this stream, or the stream can be passed to a C program which can
17906 operate on it directly.  Of course the program is responsible for
17907 ensuring that only appropriate sequences of operations are executed.
17909 One particular use of relevance to an Ada program is that the
17910 @code{setvbuf} function can be used to control the buffering of the
17911 stream used by an Ada file.  In the absence of such a call the standard
17912 default buffering is used.
17914 The @code{Open} procedures in these packages open a file giving an
17915 existing C Stream instead of a file name.  Typically this stream is
17916 imported from a C program, allowing an Ada file to operate on an
17917 existing C file.
17919 @node The GNAT Library
17920 @chapter The GNAT Library
17922 @noindent
17923 The GNAT library contains a number of general and special purpose packages.
17924 It represents functionality that the GNAT developers have found useful, and
17925 which is made available to GNAT users.  The packages described here are fully
17926 supported, and upwards compatibility will be maintained in future releases,
17927 so you can use these facilities with the confidence that the same functionality
17928 will be available in future releases.
17930 The chapter here simply gives a brief summary of the facilities available.
17931 The full documentation is found in the spec file for the package.  The full
17932 sources of these library packages, including both spec and body, are provided
17933 with all GNAT releases.  For example, to find out the full specifications of
17934 the SPITBOL pattern matching capability, including a full tutorial and
17935 extensive examples, look in the @file{g-spipat.ads} file in the library.
17937 For each entry here, the package name (as it would appear in a @code{with}
17938 clause) is given, followed by the name of the corresponding spec file in
17939 parentheses.  The packages are children in four hierarchies, @code{Ada},
17940 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
17941 GNAT-specific hierarchy.
17943 Note that an application program should only use packages in one of these
17944 four hierarchies if the package is defined in the Ada Reference Manual,
17945 or is listed in this section of the GNAT Programmers Reference Manual.
17946 All other units should be considered internal implementation units and
17947 should not be directly @code{with}'ed by application code.  The use of
17948 a @code{with} statement that references one of these internal implementation
17949 units makes an application potentially dependent on changes in versions
17950 of GNAT, and will generate a warning message.
17952 @menu
17953 * Ada.Characters.Latin_9 (a-chlat9.ads)::
17954 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
17955 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
17956 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
17957 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
17958 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
17959 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
17960 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
17961 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
17962 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
17963 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
17964 * Ada.Command_Line.Environment (a-colien.ads)::
17965 * Ada.Command_Line.Remove (a-colire.ads)::
17966 * Ada.Command_Line.Response_File (a-clrefi.ads)::
17967 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
17968 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
17969 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
17970 * Ada.Exceptions.Traceback (a-exctra.ads)::
17971 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
17972 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
17973 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
17974 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
17975 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
17976 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
17977 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
17978 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
17979 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
17980 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
17981 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
17982 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
17983 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
17984 * GNAT.Altivec (g-altive.ads)::
17985 * GNAT.Altivec.Conversions (g-altcon.ads)::
17986 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
17987 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
17988 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
17989 * GNAT.Array_Split (g-arrspl.ads)::
17990 * GNAT.AWK (g-awk.ads)::
17991 * GNAT.Bounded_Buffers (g-boubuf.ads)::
17992 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
17993 * GNAT.Bubble_Sort (g-bubsor.ads)::
17994 * GNAT.Bubble_Sort_A (g-busora.ads)::
17995 * GNAT.Bubble_Sort_G (g-busorg.ads)::
17996 * GNAT.Byte_Order_Mark (g-byorma.ads)::
17997 * GNAT.Byte_Swapping (g-bytswa.ads)::
17998 * GNAT.Calendar (g-calend.ads)::
17999 * GNAT.Calendar.Time_IO (g-catiio.ads)::
18000 * GNAT.Case_Util (g-casuti.ads)::
18001 * GNAT.CGI (g-cgi.ads)::
18002 * GNAT.CGI.Cookie (g-cgicoo.ads)::
18003 * GNAT.CGI.Debug (g-cgideb.ads)::
18004 * GNAT.Command_Line (g-comlin.ads)::
18005 * GNAT.Compiler_Version (g-comver.ads)::
18006 * GNAT.Ctrl_C (g-ctrl_c.ads)::
18007 * GNAT.CRC32 (g-crc32.ads)::
18008 * GNAT.Current_Exception (g-curexc.ads)::
18009 * GNAT.Debug_Pools (g-debpoo.ads)::
18010 * GNAT.Debug_Utilities (g-debuti.ads)::
18011 * GNAT.Decode_String (g-decstr.ads)::
18012 * GNAT.Decode_UTF8_String (g-deutst.ads)::
18013 * GNAT.Directory_Operations (g-dirope.ads)::
18014 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
18015 * GNAT.Dynamic_HTables (g-dynhta.ads)::
18016 * GNAT.Dynamic_Tables (g-dyntab.ads)::
18017 * GNAT.Encode_String (g-encstr.ads)::
18018 * GNAT.Encode_UTF8_String (g-enutst.ads)::
18019 * GNAT.Exception_Actions (g-excact.ads)::
18020 * GNAT.Exception_Traces (g-exctra.ads)::
18021 * GNAT.Exceptions (g-except.ads)::
18022 * GNAT.Expect (g-expect.ads)::
18023 * GNAT.Expect.TTY (g-exptty.ads)::
18024 * GNAT.Float_Control (g-flocon.ads)::
18025 * GNAT.Heap_Sort (g-heasor.ads)::
18026 * GNAT.Heap_Sort_A (g-hesora.ads)::
18027 * GNAT.Heap_Sort_G (g-hesorg.ads)::
18028 * GNAT.HTable (g-htable.ads)::
18029 * GNAT.IO (g-io.ads)::
18030 * GNAT.IO_Aux (g-io_aux.ads)::
18031 * GNAT.Lock_Files (g-locfil.ads)::
18032 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
18033 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
18034 * GNAT.MD5 (g-md5.ads)::
18035 * GNAT.Memory_Dump (g-memdum.ads)::
18036 * GNAT.Most_Recent_Exception (g-moreex.ads)::
18037 * GNAT.OS_Lib (g-os_lib.ads)::
18038 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
18039 * GNAT.Random_Numbers (g-rannum.ads)::
18040 * GNAT.Regexp (g-regexp.ads)::
18041 * GNAT.Registry (g-regist.ads)::
18042 * GNAT.Regpat (g-regpat.ads)::
18043 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
18044 * GNAT.Semaphores (g-semaph.ads)::
18045 * GNAT.Serial_Communications (g-sercom.ads)::
18046 * GNAT.SHA1 (g-sha1.ads)::
18047 * GNAT.SHA224 (g-sha224.ads)::
18048 * GNAT.SHA256 (g-sha256.ads)::
18049 * GNAT.SHA384 (g-sha384.ads)::
18050 * GNAT.SHA512 (g-sha512.ads)::
18051 * GNAT.Signals (g-signal.ads)::
18052 * GNAT.Sockets (g-socket.ads)::
18053 * GNAT.Source_Info (g-souinf.ads)::
18054 * GNAT.Spelling_Checker (g-speche.ads)::
18055 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
18056 * GNAT.Spitbol.Patterns (g-spipat.ads)::
18057 * GNAT.Spitbol (g-spitbo.ads)::
18058 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
18059 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
18060 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
18061 * GNAT.SSE (g-sse.ads)::
18062 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
18063 * GNAT.Strings (g-string.ads)::
18064 * GNAT.String_Split (g-strspl.ads)::
18065 * GNAT.Table (g-table.ads)::
18066 * GNAT.Task_Lock (g-tasloc.ads)::
18067 * GNAT.Threads (g-thread.ads)::
18068 * GNAT.Time_Stamp (g-timsta.ads)::
18069 * GNAT.Traceback (g-traceb.ads)::
18070 * GNAT.Traceback.Symbolic (g-trasym.ads)::
18071 * GNAT.UTF_32 (g-utf_32.ads)::
18072 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
18073 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
18074 * GNAT.Wide_String_Split (g-wistsp.ads)::
18075 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
18076 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
18077 * Interfaces.C.Extensions (i-cexten.ads)::
18078 * Interfaces.C.Streams (i-cstrea.ads)::
18079 * Interfaces.CPP (i-cpp.ads)::
18080 * Interfaces.Packed_Decimal (i-pacdec.ads)::
18081 * Interfaces.VxWorks (i-vxwork.ads)::
18082 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
18083 * System.Address_Image (s-addima.ads)::
18084 * System.Assertions (s-assert.ads)::
18085 * System.Memory (s-memory.ads)::
18086 * System.Multiprocessors (s-multip.ads)::
18087 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
18088 * System.Partition_Interface (s-parint.ads)::
18089 * System.Pool_Global (s-pooglo.ads)::
18090 * System.Pool_Local (s-pooloc.ads)::
18091 * System.Restrictions (s-restri.ads)::
18092 * System.Rident (s-rident.ads)::
18093 * System.Strings.Stream_Ops (s-ststop.ads)::
18094 * System.Task_Info (s-tasinf.ads)::
18095 * System.Wch_Cnv (s-wchcnv.ads)::
18096 * System.Wch_Con (s-wchcon.ads)::
18097 @end menu
18099 @node Ada.Characters.Latin_9 (a-chlat9.ads)
18100 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
18101 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
18102 @cindex Latin_9 constants for Character
18104 @noindent
18105 This child of @code{Ada.Characters}
18106 provides a set of definitions corresponding to those in the
18107 RM-defined package @code{Ada.Characters.Latin_1} but with the
18108 few modifications required for @code{Latin-9}
18109 The provision of such a package
18110 is specifically authorized by the Ada Reference Manual
18111 (RM A.3.3(27)).
18113 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
18114 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
18115 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
18116 @cindex Latin_1 constants for Wide_Character
18118 @noindent
18119 This child of @code{Ada.Characters}
18120 provides a set of definitions corresponding to those in the
18121 RM-defined package @code{Ada.Characters.Latin_1} but with the
18122 types of the constants being @code{Wide_Character}
18123 instead of @code{Character}.  The provision of such a package
18124 is specifically authorized by the Ada Reference Manual
18125 (RM A.3.3(27)).
18127 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
18128 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
18129 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
18130 @cindex Latin_9 constants for Wide_Character
18132 @noindent
18133 This child of @code{Ada.Characters}
18134 provides a set of definitions corresponding to those in the
18135 GNAT defined package @code{Ada.Characters.Latin_9} but with the
18136 types of the constants being @code{Wide_Character}
18137 instead of @code{Character}.  The provision of such a package
18138 is specifically authorized by the Ada Reference Manual
18139 (RM A.3.3(27)).
18141 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
18142 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
18143 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
18144 @cindex Latin_1 constants for Wide_Wide_Character
18146 @noindent
18147 This child of @code{Ada.Characters}
18148 provides a set of definitions corresponding to those in the
18149 RM-defined package @code{Ada.Characters.Latin_1} but with the
18150 types of the constants being @code{Wide_Wide_Character}
18151 instead of @code{Character}.  The provision of such a package
18152 is specifically authorized by the Ada Reference Manual
18153 (RM A.3.3(27)).
18155 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
18156 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
18157 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
18158 @cindex Latin_9 constants for Wide_Wide_Character
18160 @noindent
18161 This child of @code{Ada.Characters}
18162 provides a set of definitions corresponding to those in the
18163 GNAT defined package @code{Ada.Characters.Latin_9} but with the
18164 types of the constants being @code{Wide_Wide_Character}
18165 instead of @code{Character}.  The provision of such a package
18166 is specifically authorized by the Ada Reference Manual
18167 (RM A.3.3(27)).
18169 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
18170 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
18171 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
18172 @cindex Formal container for doubly linked lists
18174 @noindent
18175 This child of @code{Ada.Containers} defines a modified version of the
18176 Ada 2005 container for doubly linked lists, meant to facilitate formal
18177 verification of code using such containers. The specification of this
18178 unit is compatible with SPARK 2014.
18180 Note that although this container was designed with formal verification
18181 in mind, it may well be generally useful in that it is a simplified more
18182 efficient version than the one defined in the standard. In particular it
18183 does not have the complex overhead required to detect cursor tampering.
18185 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
18186 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
18187 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
18188 @cindex Formal container for hashed maps
18190 @noindent
18191 This child of @code{Ada.Containers} defines a modified version of the
18192 Ada 2005 container for hashed maps, meant to facilitate formal
18193 verification of code using such containers. The specification of this
18194 unit is compatible with SPARK 2014.
18196 Note that although this container was designed with formal verification
18197 in mind, it may well be generally useful in that it is a simplified more
18198 efficient version than the one defined in the standard. In particular it
18199 does not have the complex overhead required to detect cursor tampering.
18201 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
18202 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
18203 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
18204 @cindex Formal container for hashed sets
18206 @noindent
18207 This child of @code{Ada.Containers} defines a modified version of the
18208 Ada 2005 container for hashed sets, meant to facilitate formal
18209 verification of code using such containers. The specification of this
18210 unit is compatible with SPARK 2014.
18212 Note that although this container was designed with formal verification
18213 in mind, it may well be generally useful in that it is a simplified more
18214 efficient version than the one defined in the standard. In particular it
18215 does not have the complex overhead required to detect cursor tampering.
18217 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
18218 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
18219 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
18220 @cindex Formal container for ordered maps
18222 @noindent
18223 This child of @code{Ada.Containers} defines a modified version of the
18224 Ada 2005 container for ordered maps, meant to facilitate formal
18225 verification of code using such containers. The specification of this
18226 unit is compatible with SPARK 2014.
18228 Note that although this container was designed with formal verification
18229 in mind, it may well be generally useful in that it is a simplified more
18230 efficient version than the one defined in the standard. In particular it
18231 does not have the complex overhead required to detect cursor tampering.
18233 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
18234 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
18235 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
18236 @cindex Formal container for ordered sets
18238 @noindent
18239 This child of @code{Ada.Containers} defines a modified version of the
18240 Ada 2005 container for ordered sets, meant to facilitate formal
18241 verification of code using such containers. The specification of this
18242 unit is compatible with SPARK 2014.
18244 Note that although this container was designed with formal verification
18245 in mind, it may well be generally useful in that it is a simplified more
18246 efficient version than the one defined in the standard. In particular it
18247 does not have the complex overhead required to detect cursor tampering.
18249 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
18250 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
18251 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
18252 @cindex Formal container for vectors
18254 @noindent
18255 This child of @code{Ada.Containers} defines a modified version of the
18256 Ada 2005 container for vectors, meant to facilitate formal
18257 verification of code using such containers. The specification of this
18258 unit is compatible with SPARK 2014.
18260 Note that although this container was designed with formal verification
18261 in mind, it may well be generally useful in that it is a simplified more
18262 efficient version than the one defined in the standard. In particular it
18263 does not have the complex overhead required to detect cursor tampering.
18265 @node Ada.Command_Line.Environment (a-colien.ads)
18266 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
18267 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
18268 @cindex Environment entries
18270 @noindent
18271 This child of @code{Ada.Command_Line}
18272 provides a mechanism for obtaining environment values on systems
18273 where this concept makes sense.
18275 @node Ada.Command_Line.Remove (a-colire.ads)
18276 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
18277 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
18278 @cindex Removing command line arguments
18279 @cindex Command line, argument removal
18281 @noindent
18282 This child of @code{Ada.Command_Line}
18283 provides a mechanism for logically removing
18284 arguments from the argument list.  Once removed, an argument is not visible
18285 to further calls on the subprograms in @code{Ada.Command_Line} will not
18286 see the removed argument.
18288 @node Ada.Command_Line.Response_File (a-clrefi.ads)
18289 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
18290 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
18291 @cindex Response file for command line
18292 @cindex Command line, response file
18293 @cindex Command line, handling long command lines
18295 @noindent
18296 This child of @code{Ada.Command_Line} provides a mechanism facilities for
18297 getting command line arguments from a text file, called a "response file".
18298 Using a response file allow passing a set of arguments to an executable longer
18299 than the maximum allowed by the system on the command line.
18301 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
18302 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
18303 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
18304 @cindex C Streams, Interfacing with Direct_IO
18306 @noindent
18307 This package provides subprograms that allow interfacing between
18308 C streams and @code{Direct_IO}.  The stream identifier can be
18309 extracted from a file opened on the Ada side, and an Ada file
18310 can be constructed from a stream opened on the C side.
18312 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
18313 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
18314 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
18315 @cindex Null_Occurrence, testing for
18317 @noindent
18318 This child subprogram provides a way of testing for the null
18319 exception occurrence (@code{Null_Occurrence}) without raising
18320 an exception.
18322 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
18323 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
18324 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
18325 @cindex Null_Occurrence, testing for
18327 @noindent
18328 This child subprogram is used for handling otherwise unhandled
18329 exceptions (hence the name last chance), and perform clean ups before
18330 terminating the program. Note that this subprogram never returns.
18332 @node Ada.Exceptions.Traceback (a-exctra.ads)
18333 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
18334 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
18335 @cindex Traceback for Exception Occurrence
18337 @noindent
18338 This child package provides the subprogram (@code{Tracebacks}) to
18339 give a traceback array of addresses based on an exception
18340 occurrence.
18342 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
18343 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
18344 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
18345 @cindex C Streams, Interfacing with Sequential_IO
18347 @noindent
18348 This package provides subprograms that allow interfacing between
18349 C streams and @code{Sequential_IO}.  The stream identifier can be
18350 extracted from a file opened on the Ada side, and an Ada file
18351 can be constructed from a stream opened on the C side.
18353 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
18354 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
18355 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
18356 @cindex C Streams, Interfacing with Stream_IO
18358 @noindent
18359 This package provides subprograms that allow interfacing between
18360 C streams and @code{Stream_IO}.  The stream identifier can be
18361 extracted from a file opened on the Ada side, and an Ada file
18362 can be constructed from a stream opened on the C side.
18364 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
18365 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
18366 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
18367 @cindex @code{Unbounded_String}, IO support
18368 @cindex @code{Text_IO}, extensions for unbounded strings
18370 @noindent
18371 This package provides subprograms for Text_IO for unbounded
18372 strings, avoiding the necessity for an intermediate operation
18373 with ordinary strings.
18375 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
18376 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
18377 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
18378 @cindex @code{Unbounded_Wide_String}, IO support
18379 @cindex @code{Text_IO}, extensions for unbounded wide strings
18381 @noindent
18382 This package provides subprograms for Text_IO for unbounded
18383 wide strings, avoiding the necessity for an intermediate operation
18384 with ordinary wide strings.
18386 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
18387 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
18388 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
18389 @cindex @code{Unbounded_Wide_Wide_String}, IO support
18390 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
18392 @noindent
18393 This package provides subprograms for Text_IO for unbounded
18394 wide wide strings, avoiding the necessity for an intermediate operation
18395 with ordinary wide wide strings.
18397 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
18398 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
18399 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
18400 @cindex C Streams, Interfacing with @code{Text_IO}
18402 @noindent
18403 This package provides subprograms that allow interfacing between
18404 C streams and @code{Text_IO}.  The stream identifier can be
18405 extracted from a file opened on the Ada side, and an Ada file
18406 can be constructed from a stream opened on the C side.
18408 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
18409 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
18410 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
18411 @cindex @code{Text_IO} resetting standard files
18413 @noindent
18414 This procedure is used to reset the status of the standard files used
18415 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
18416 embedded application) where the status of the files may change during
18417 execution (for example a standard input file may be redefined to be
18418 interactive).
18420 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
18421 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
18422 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
18423 @cindex Unicode categorization, Wide_Character
18425 @noindent
18426 This package provides subprograms that allow categorization of
18427 Wide_Character values according to Unicode categories.
18429 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
18430 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
18431 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
18432 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
18434 @noindent
18435 This package provides subprograms that allow interfacing between
18436 C streams and @code{Wide_Text_IO}.  The stream identifier can be
18437 extracted from a file opened on the Ada side, and an Ada file
18438 can be constructed from a stream opened on the C side.
18440 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
18441 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
18442 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
18443 @cindex @code{Wide_Text_IO} resetting standard files
18445 @noindent
18446 This procedure is used to reset the status of the standard files used
18447 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
18448 embedded application) where the status of the files may change during
18449 execution (for example a standard input file may be redefined to be
18450 interactive).
18452 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
18453 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
18454 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
18455 @cindex Unicode categorization, Wide_Wide_Character
18457 @noindent
18458 This package provides subprograms that allow categorization of
18459 Wide_Wide_Character values according to Unicode categories.
18461 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
18462 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
18463 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
18464 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
18466 @noindent
18467 This package provides subprograms that allow interfacing between
18468 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
18469 extracted from a file opened on the Ada side, and an Ada file
18470 can be constructed from a stream opened on the C side.
18472 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
18473 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
18474 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
18475 @cindex @code{Wide_Wide_Text_IO} resetting standard files
18477 @noindent
18478 This procedure is used to reset the status of the standard files used
18479 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
18480 restart in an embedded application) where the status of the files may
18481 change during execution (for example a standard input file may be
18482 redefined to be interactive).
18484 @node GNAT.Altivec (g-altive.ads)
18485 @section @code{GNAT.Altivec} (@file{g-altive.ads})
18486 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
18487 @cindex AltiVec
18489 @noindent
18490 This is the root package of the GNAT AltiVec binding. It provides
18491 definitions of constants and types common to all the versions of the
18492 binding.
18494 @node GNAT.Altivec.Conversions (g-altcon.ads)
18495 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
18496 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
18497 @cindex AltiVec
18499 @noindent
18500 This package provides the Vector/View conversion routines.
18502 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
18503 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
18504 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
18505 @cindex AltiVec
18507 @noindent
18508 This package exposes the Ada interface to the AltiVec operations on
18509 vector objects. A soft emulation is included by default in the GNAT
18510 library. The hard binding is provided as a separate package. This unit
18511 is common to both bindings.
18513 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
18514 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
18515 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
18516 @cindex AltiVec
18518 @noindent
18519 This package exposes the various vector types part of the Ada binding
18520 to AltiVec facilities.
18522 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
18523 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
18524 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
18525 @cindex AltiVec
18527 @noindent
18528 This package provides public 'View' data types from/to which private
18529 vector representations can be converted via
18530 GNAT.Altivec.Conversions. This allows convenient access to individual
18531 vector elements and provides a simple way to initialize vector
18532 objects.
18534 @node GNAT.Array_Split (g-arrspl.ads)
18535 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
18536 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
18537 @cindex Array splitter
18539 @noindent
18540 Useful array-manipulation routines: given a set of separators, split
18541 an array wherever the separators appear, and provide direct access
18542 to the resulting slices.
18544 @node GNAT.AWK (g-awk.ads)
18545 @section @code{GNAT.AWK} (@file{g-awk.ads})
18546 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
18547 @cindex Parsing
18548 @cindex AWK
18550 @noindent
18551 Provides AWK-like parsing functions, with an easy interface for parsing one
18552 or more files containing formatted data.  The file is viewed as a database
18553 where each record is a line and a field is a data element in this line.
18555 @node GNAT.Bounded_Buffers (g-boubuf.ads)
18556 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
18557 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
18558 @cindex Parsing
18559 @cindex Bounded Buffers
18561 @noindent
18562 Provides a concurrent generic bounded buffer abstraction.  Instances are
18563 useful directly or as parts of the implementations of other abstractions,
18564 such as mailboxes.
18566 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
18567 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
18568 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
18569 @cindex Parsing
18570 @cindex Mailboxes
18572 @noindent
18573 Provides a thread-safe asynchronous intertask mailbox communication facility.
18575 @node GNAT.Bubble_Sort (g-bubsor.ads)
18576 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
18577 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
18578 @cindex Sorting
18579 @cindex Bubble sort
18581 @noindent
18582 Provides a general implementation of bubble sort usable for sorting arbitrary
18583 data items.  Exchange and comparison procedures are provided by passing
18584 access-to-procedure values.
18586 @node GNAT.Bubble_Sort_A (g-busora.ads)
18587 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
18588 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
18589 @cindex Sorting
18590 @cindex Bubble sort
18592 @noindent
18593 Provides a general implementation of bubble sort usable for sorting arbitrary
18594 data items.  Move and comparison procedures are provided by passing
18595 access-to-procedure values. This is an older version, retained for
18596 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
18598 @node GNAT.Bubble_Sort_G (g-busorg.ads)
18599 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
18600 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
18601 @cindex Sorting
18602 @cindex Bubble sort
18604 @noindent
18605 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
18606 are provided as generic parameters, this improves efficiency, especially
18607 if the procedures can be inlined, at the expense of duplicating code for
18608 multiple instantiations.
18610 @node GNAT.Byte_Order_Mark (g-byorma.ads)
18611 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
18612 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
18613 @cindex UTF-8 representation
18614 @cindex Wide characte representations
18616 @noindent
18617 Provides a routine which given a string, reads the start of the string to
18618 see whether it is one of the standard byte order marks (BOM's) which signal
18619 the encoding of the string. The routine includes detection of special XML
18620 sequences for various UCS input formats.
18622 @node GNAT.Byte_Swapping (g-bytswa.ads)
18623 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
18624 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
18625 @cindex Byte swapping
18626 @cindex Endianness
18628 @noindent
18629 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
18630 Machine-specific implementations are available in some cases.
18632 @node GNAT.Calendar (g-calend.ads)
18633 @section @code{GNAT.Calendar} (@file{g-calend.ads})
18634 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
18635 @cindex @code{Calendar}
18637 @noindent
18638 Extends the facilities provided by @code{Ada.Calendar} to include handling
18639 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
18640 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
18641 C @code{timeval} format.
18643 @node GNAT.Calendar.Time_IO (g-catiio.ads)
18644 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
18645 @cindex @code{Calendar}
18646 @cindex Time
18647 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
18649 @node GNAT.CRC32 (g-crc32.ads)
18650 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
18651 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
18652 @cindex CRC32
18653 @cindex Cyclic Redundancy Check
18655 @noindent
18656 This package implements the CRC-32 algorithm.  For a full description
18657 of this algorithm see
18658 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
18659 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
18660 Aug.@: 1988.  Sarwate, D.V@.
18662 @node GNAT.Case_Util (g-casuti.ads)
18663 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
18664 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
18665 @cindex Casing utilities
18666 @cindex Character handling (@code{GNAT.Case_Util})
18668 @noindent
18669 A set of simple routines for handling upper and lower casing of strings
18670 without the overhead of the full casing tables
18671 in @code{Ada.Characters.Handling}.
18673 @node GNAT.CGI (g-cgi.ads)
18674 @section @code{GNAT.CGI} (@file{g-cgi.ads})
18675 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
18676 @cindex CGI (Common Gateway Interface)
18678 @noindent
18679 This is a package for interfacing a GNAT program with a Web server via the
18680 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
18681 parameters, which are a set of key/value pairs sent by the Web server.  It
18682 builds a table whose index is the key and provides some services to deal
18683 with this table.
18685 @node GNAT.CGI.Cookie (g-cgicoo.ads)
18686 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
18687 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
18688 @cindex CGI (Common Gateway Interface) cookie support
18689 @cindex Cookie support in CGI
18691 @noindent
18692 This is a package to interface a GNAT program with a Web server via the
18693 Common Gateway Interface (CGI).  It exports services to deal with Web
18694 cookies (piece of information kept in the Web client software).
18696 @node GNAT.CGI.Debug (g-cgideb.ads)
18697 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
18698 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
18699 @cindex CGI (Common Gateway Interface) debugging
18701 @noindent
18702 This is a package to help debugging CGI (Common Gateway Interface)
18703 programs written in Ada.
18705 @node GNAT.Command_Line (g-comlin.ads)
18706 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
18707 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
18708 @cindex Command line
18710 @noindent
18711 Provides a high level interface to @code{Ada.Command_Line} facilities,
18712 including the ability to scan for named switches with optional parameters
18713 and expand file names using wild card notations.
18715 @node GNAT.Compiler_Version (g-comver.ads)
18716 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
18717 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
18718 @cindex Compiler Version
18719 @cindex Version, of compiler
18721 @noindent
18722 Provides a routine for obtaining the version of the compiler used to
18723 compile the program. More accurately this is the version of the binder
18724 used to bind the program (this will normally be the same as the version
18725 of the compiler if a consistent tool set is used to compile all units
18726 of a partition).
18728 @node GNAT.Ctrl_C (g-ctrl_c.ads)
18729 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
18730 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
18731 @cindex Interrupt
18733 @noindent
18734 Provides a simple interface to handle Ctrl-C keyboard events.
18736 @node GNAT.Current_Exception (g-curexc.ads)
18737 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
18738 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
18739 @cindex Current exception
18740 @cindex Exception retrieval
18742 @noindent
18743 Provides access to information on the current exception that has been raised
18744 without the need for using the Ada 95 / Ada 2005 exception choice parameter
18745 specification syntax.
18746 This is particularly useful in simulating typical facilities for
18747 obtaining information about exceptions provided by Ada 83 compilers.
18749 @node GNAT.Debug_Pools (g-debpoo.ads)
18750 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
18751 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
18752 @cindex Debugging
18753 @cindex Debug pools
18754 @cindex Memory corruption debugging
18756 @noindent
18757 Provide a debugging storage pools that helps tracking memory corruption
18758 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
18759 @value{EDITION} User's Guide}.
18761 @node GNAT.Debug_Utilities (g-debuti.ads)
18762 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
18763 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
18764 @cindex Debugging
18766 @noindent
18767 Provides a few useful utilities for debugging purposes, including conversion
18768 to and from string images of address values. Supports both C and Ada formats
18769 for hexadecimal literals.
18771 @node GNAT.Decode_String (g-decstr.ads)
18772 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
18773 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
18774 @cindex Decoding strings
18775 @cindex String decoding
18776 @cindex Wide character encoding
18777 @cindex UTF-8
18778 @cindex Unicode
18780 @noindent
18781 A generic package providing routines for decoding wide character and wide wide
18782 character strings encoded as sequences of 8-bit characters using a specified
18783 encoding method. Includes validation routines, and also routines for stepping
18784 to next or previous encoded character in an encoded string.
18785 Useful in conjunction with Unicode character coding. Note there is a
18786 preinstantiation for UTF-8. See next entry.
18788 @node GNAT.Decode_UTF8_String (g-deutst.ads)
18789 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
18790 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
18791 @cindex Decoding strings
18792 @cindex Decoding UTF-8 strings
18793 @cindex UTF-8 string decoding
18794 @cindex Wide character decoding
18795 @cindex UTF-8
18796 @cindex Unicode
18798 @noindent
18799 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
18801 @node GNAT.Directory_Operations (g-dirope.ads)
18802 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
18803 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
18804 @cindex Directory operations
18806 @noindent
18807 Provides a set of routines for manipulating directories, including changing
18808 the current directory, making new directories, and scanning the files in a
18809 directory.
18811 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
18812 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
18813 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
18814 @cindex Directory operations iteration
18816 @noindent
18817 A child unit of GNAT.Directory_Operations providing additional operations
18818 for iterating through directories.
18820 @node GNAT.Dynamic_HTables (g-dynhta.ads)
18821 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
18822 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
18823 @cindex Hash tables
18825 @noindent
18826 A generic implementation of hash tables that can be used to hash arbitrary
18827 data.  Provided in two forms, a simple form with built in hash functions,
18828 and a more complex form in which the hash function is supplied.
18830 @noindent
18831 This package provides a facility similar to that of @code{GNAT.HTable},
18832 except that this package declares a type that can be used to define
18833 dynamic instances of the hash table, while an instantiation of
18834 @code{GNAT.HTable} creates a single instance of the hash table.
18836 @node GNAT.Dynamic_Tables (g-dyntab.ads)
18837 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
18838 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
18839 @cindex Table implementation
18840 @cindex Arrays, extendable
18842 @noindent
18843 A generic package providing a single dimension array abstraction where the
18844 length of the array can be dynamically modified.
18846 @noindent
18847 This package provides a facility similar to that of @code{GNAT.Table},
18848 except that this package declares a type that can be used to define
18849 dynamic instances of the table, while an instantiation of
18850 @code{GNAT.Table} creates a single instance of the table type.
18852 @node GNAT.Encode_String (g-encstr.ads)
18853 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
18854 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
18855 @cindex Encoding strings
18856 @cindex String encoding
18857 @cindex Wide character encoding
18858 @cindex UTF-8
18859 @cindex Unicode
18861 @noindent
18862 A generic package providing routines for encoding wide character and wide
18863 wide character strings as sequences of 8-bit characters using a specified
18864 encoding method. Useful in conjunction with Unicode character coding.
18865 Note there is a preinstantiation for UTF-8. See next entry.
18867 @node GNAT.Encode_UTF8_String (g-enutst.ads)
18868 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
18869 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
18870 @cindex Encoding strings
18871 @cindex Encoding UTF-8 strings
18872 @cindex UTF-8 string encoding
18873 @cindex Wide character encoding
18874 @cindex UTF-8
18875 @cindex Unicode
18877 @noindent
18878 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
18880 @node GNAT.Exception_Actions (g-excact.ads)
18881 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
18882 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
18883 @cindex Exception actions
18885 @noindent
18886 Provides callbacks when an exception is raised. Callbacks can be registered
18887 for specific exceptions, or when any exception is raised. This
18888 can be used for instance to force a core dump to ease debugging.
18890 @node GNAT.Exception_Traces (g-exctra.ads)
18891 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
18892 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
18893 @cindex Exception traces
18894 @cindex Debugging
18896 @noindent
18897 Provides an interface allowing to control automatic output upon exception
18898 occurrences.
18900 @node GNAT.Exceptions (g-except.ads)
18901 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
18902 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
18903 @cindex Exceptions, Pure
18904 @cindex Pure packages, exceptions
18906 @noindent
18907 Normally it is not possible to raise an exception with
18908 a message from a subprogram in a pure package, since the
18909 necessary types and subprograms are in @code{Ada.Exceptions}
18910 which is not a pure unit. @code{GNAT.Exceptions} provides a
18911 facility for getting around this limitation for a few
18912 predefined exceptions, and for example allow raising
18913 @code{Constraint_Error} with a message from a pure subprogram.
18915 @node GNAT.Expect (g-expect.ads)
18916 @section @code{GNAT.Expect} (@file{g-expect.ads})
18917 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
18919 @noindent
18920 Provides a set of subprograms similar to what is available
18921 with the standard Tcl Expect tool.
18922 It allows you to easily spawn and communicate with an external process.
18923 You can send commands or inputs to the process, and compare the output
18924 with some expected regular expression. Currently @code{GNAT.Expect}
18925 is implemented on all native GNAT ports except for OpenVMS@.
18926 It is not implemented for cross ports, and in particular is not
18927 implemented for VxWorks or LynxOS@.
18929 @node GNAT.Expect.TTY (g-exptty.ads)
18930 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
18931 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
18933 @noindent
18934 As GNAT.Expect but using pseudo-terminal.
18935 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
18936 ports except for OpenVMS@. It is not implemented for cross ports, and
18937 in particular is not implemented for VxWorks or LynxOS@.
18939 @node GNAT.Float_Control (g-flocon.ads)
18940 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
18941 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
18942 @cindex Floating-Point Processor
18944 @noindent
18945 Provides an interface for resetting the floating-point processor into the
18946 mode required for correct semantic operation in Ada.  Some third party
18947 library calls may cause this mode to be modified, and the Reset procedure
18948 in this package can be used to reestablish the required mode.
18950 @node GNAT.Heap_Sort (g-heasor.ads)
18951 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
18952 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
18953 @cindex Sorting
18955 @noindent
18956 Provides a general implementation of heap sort usable for sorting arbitrary
18957 data items. Exchange and comparison procedures are provided by passing
18958 access-to-procedure values.  The algorithm used is a modified heap sort
18959 that performs approximately N*log(N) comparisons in the worst case.
18961 @node GNAT.Heap_Sort_A (g-hesora.ads)
18962 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
18963 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
18964 @cindex Sorting
18966 @noindent
18967 Provides a general implementation of heap sort usable for sorting arbitrary
18968 data items. Move and comparison procedures are provided by passing
18969 access-to-procedure values.  The algorithm used is a modified heap sort
18970 that performs approximately N*log(N) comparisons in the worst case.
18971 This differs from @code{GNAT.Heap_Sort} in having a less convenient
18972 interface, but may be slightly more efficient.
18974 @node GNAT.Heap_Sort_G (g-hesorg.ads)
18975 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
18976 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
18977 @cindex Sorting
18979 @noindent
18980 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
18981 are provided as generic parameters, this improves efficiency, especially
18982 if the procedures can be inlined, at the expense of duplicating code for
18983 multiple instantiations.
18985 @node GNAT.HTable (g-htable.ads)
18986 @section @code{GNAT.HTable} (@file{g-htable.ads})
18987 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
18988 @cindex Hash tables
18990 @noindent
18991 A generic implementation of hash tables that can be used to hash arbitrary
18992 data.  Provides two approaches, one a simple static approach, and the other
18993 allowing arbitrary dynamic hash tables.
18995 @node GNAT.IO (g-io.ads)
18996 @section @code{GNAT.IO} (@file{g-io.ads})
18997 @cindex @code{GNAT.IO} (@file{g-io.ads})
18998 @cindex Simple I/O
18999 @cindex Input/Output facilities
19001 @noindent
19002 A simple preelaborable input-output package that provides a subset of
19003 simple Text_IO functions for reading characters and strings from
19004 Standard_Input, and writing characters, strings and integers to either
19005 Standard_Output or Standard_Error.
19007 @node GNAT.IO_Aux (g-io_aux.ads)
19008 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
19009 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
19010 @cindex Text_IO
19011 @cindex Input/Output facilities
19013 Provides some auxiliary functions for use with Text_IO, including a test
19014 for whether a file exists, and functions for reading a line of text.
19016 @node GNAT.Lock_Files (g-locfil.ads)
19017 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
19018 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
19019 @cindex File locking
19020 @cindex Locking using files
19022 @noindent
19023 Provides a general interface for using files as locks.  Can be used for
19024 providing program level synchronization.
19026 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
19027 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
19028 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
19029 @cindex Random number generation
19031 @noindent
19032 The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
19033 a modified version of the Blum-Blum-Shub generator.
19035 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
19036 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
19037 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
19038 @cindex Random number generation
19040 @noindent
19041 The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
19042 a modified version of the Blum-Blum-Shub generator.
19044 @node GNAT.MD5 (g-md5.ads)
19045 @section @code{GNAT.MD5} (@file{g-md5.ads})
19046 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
19047 @cindex Message Digest MD5
19049 @noindent
19050 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
19052 @node GNAT.Memory_Dump (g-memdum.ads)
19053 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
19054 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
19055 @cindex Dump Memory
19057 @noindent
19058 Provides a convenient routine for dumping raw memory to either the
19059 standard output or standard error files. Uses GNAT.IO for actual
19060 output.
19062 @node GNAT.Most_Recent_Exception (g-moreex.ads)
19063 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
19064 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
19065 @cindex Exception, obtaining most recent
19067 @noindent
19068 Provides access to the most recently raised exception.  Can be used for
19069 various logging purposes, including duplicating functionality of some
19070 Ada 83 implementation dependent extensions.
19072 @node GNAT.OS_Lib (g-os_lib.ads)
19073 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
19074 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
19075 @cindex Operating System interface
19076 @cindex Spawn capability
19078 @noindent
19079 Provides a range of target independent operating system interface functions,
19080 including time/date management, file operations, subprocess management,
19081 including a portable spawn procedure, and access to environment variables
19082 and error return codes.
19084 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
19085 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
19086 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
19087 @cindex Hash functions
19089 @noindent
19090 Provides a generator of static minimal perfect hash functions. No
19091 collisions occur and each item can be retrieved from the table in one
19092 probe (perfect property). The hash table size corresponds to the exact
19093 size of the key set and no larger (minimal property). The key set has to
19094 be know in advance (static property). The hash functions are also order
19095 preserving. If w2 is inserted after w1 in the generator, their
19096 hashcode are in the same order. These hashing functions are very
19097 convenient for use with realtime applications.
19099 @node GNAT.Random_Numbers (g-rannum.ads)
19100 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
19101 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
19102 @cindex Random number generation
19104 @noindent
19105 Provides random number capabilities which extend those available in the
19106 standard Ada library and are more convenient to use.
19108 @node GNAT.Regexp (g-regexp.ads)
19109 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
19110 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
19111 @cindex Regular expressions
19112 @cindex Pattern matching
19114 @noindent
19115 A simple implementation of regular expressions, using a subset of regular
19116 expression syntax copied from familiar Unix style utilities.  This is the
19117 simples of the three pattern matching packages provided, and is particularly
19118 suitable for ``file globbing'' applications.
19120 @node GNAT.Registry (g-regist.ads)
19121 @section @code{GNAT.Registry} (@file{g-regist.ads})
19122 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
19123 @cindex Windows Registry
19125 @noindent
19126 This is a high level binding to the Windows registry.  It is possible to
19127 do simple things like reading a key value, creating a new key.  For full
19128 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
19129 package provided with the Win32Ada binding
19131 @node GNAT.Regpat (g-regpat.ads)
19132 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
19133 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
19134 @cindex Regular expressions
19135 @cindex Pattern matching
19137 @noindent
19138 A complete implementation of Unix-style regular expression matching, copied
19139 from the original V7 style regular expression library written in C by
19140 Henry Spencer (and binary compatible with this C library).
19142 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
19143 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
19144 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
19145 @cindex Secondary Stack Info
19147 @noindent
19148 Provide the capability to query the high water mark of the current task's
19149 secondary stack.
19151 @node GNAT.Semaphores (g-semaph.ads)
19152 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
19153 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
19154 @cindex Semaphores
19156 @noindent
19157 Provides classic counting and binary semaphores using protected types.
19159 @node GNAT.Serial_Communications (g-sercom.ads)
19160 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
19161 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
19162 @cindex Serial_Communications
19164 @noindent
19165 Provides a simple interface to send and receive data over a serial
19166 port. This is only supported on GNU/Linux and Windows.
19168 @node GNAT.SHA1 (g-sha1.ads)
19169 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
19170 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
19171 @cindex Secure Hash Algorithm SHA-1
19173 @noindent
19174 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
19175 and RFC 3174.
19177 @node GNAT.SHA224 (g-sha224.ads)
19178 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
19179 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
19180 @cindex Secure Hash Algorithm SHA-224
19182 @noindent
19183 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
19185 @node GNAT.SHA256 (g-sha256.ads)
19186 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
19187 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
19188 @cindex Secure Hash Algorithm SHA-256
19190 @noindent
19191 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
19193 @node GNAT.SHA384 (g-sha384.ads)
19194 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
19195 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
19196 @cindex Secure Hash Algorithm SHA-384
19198 @noindent
19199 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
19201 @node GNAT.SHA512 (g-sha512.ads)
19202 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
19203 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
19204 @cindex Secure Hash Algorithm SHA-512
19206 @noindent
19207 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
19209 @node GNAT.Signals (g-signal.ads)
19210 @section @code{GNAT.Signals} (@file{g-signal.ads})
19211 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
19212 @cindex Signals
19214 @noindent
19215 Provides the ability to manipulate the blocked status of signals on supported
19216 targets.
19218 @node GNAT.Sockets (g-socket.ads)
19219 @section @code{GNAT.Sockets} (@file{g-socket.ads})
19220 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
19221 @cindex Sockets
19223 @noindent
19224 A high level and portable interface to develop sockets based applications.
19225 This package is based on the sockets thin binding found in
19226 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
19227 on all native GNAT ports except for OpenVMS@.  It is not implemented
19228 for the LynxOS@ cross port.
19230 @node GNAT.Source_Info (g-souinf.ads)
19231 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
19232 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
19233 @cindex Source Information
19235 @noindent
19236 Provides subprograms that give access to source code information known at
19237 compile time, such as the current file name and line number.
19239 @node GNAT.Spelling_Checker (g-speche.ads)
19240 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
19241 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
19242 @cindex Spell checking
19244 @noindent
19245 Provides a function for determining whether one string is a plausible
19246 near misspelling of another string.
19248 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
19249 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
19250 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
19251 @cindex Spell checking
19253 @noindent
19254 Provides a generic function that can be instantiated with a string type for
19255 determining whether one string is a plausible near misspelling of another
19256 string.
19258 @node GNAT.Spitbol.Patterns (g-spipat.ads)
19259 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
19260 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
19261 @cindex SPITBOL pattern matching
19262 @cindex Pattern matching
19264 @noindent
19265 A complete implementation of SNOBOL4 style pattern matching.  This is the
19266 most elaborate of the pattern matching packages provided.  It fully duplicates
19267 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
19268 efficient algorithm developed by Robert Dewar for the SPITBOL system.
19270 @node GNAT.Spitbol (g-spitbo.ads)
19271 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
19272 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
19273 @cindex SPITBOL interface
19275 @noindent
19276 The top level package of the collection of SPITBOL-style functionality, this
19277 package provides basic SNOBOL4 string manipulation functions, such as
19278 Pad, Reverse, Trim, Substr capability, as well as a generic table function
19279 useful for constructing arbitrary mappings from strings in the style of
19280 the SNOBOL4 TABLE function.
19282 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
19283 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
19284 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
19285 @cindex Sets of strings
19286 @cindex SPITBOL Tables
19288 @noindent
19289 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
19290 for type @code{Standard.Boolean}, giving an implementation of sets of
19291 string values.
19293 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
19294 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
19295 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
19296 @cindex Integer maps
19297 @cindex Maps
19298 @cindex SPITBOL Tables
19300 @noindent
19301 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
19302 for type @code{Standard.Integer}, giving an implementation of maps
19303 from string to integer values.
19305 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
19306 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
19307 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
19308 @cindex String maps
19309 @cindex Maps
19310 @cindex SPITBOL Tables
19312 @noindent
19313 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
19314 a variable length string type, giving an implementation of general
19315 maps from strings to strings.
19317 @node GNAT.SSE (g-sse.ads)
19318 @section @code{GNAT.SSE} (@file{g-sse.ads})
19319 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
19321 @noindent
19322 Root of a set of units aimed at offering Ada bindings to a subset of
19323 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
19324 targets.  It exposes vector component types together with a general
19325 introduction to the binding contents and use.
19327 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
19328 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
19329 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
19331 @noindent
19332 SSE vector types for use with SSE related intrinsics.
19334 @node GNAT.Strings (g-string.ads)
19335 @section @code{GNAT.Strings} (@file{g-string.ads})
19336 @cindex @code{GNAT.Strings} (@file{g-string.ads})
19338 @noindent
19339 Common String access types and related subprograms. Basically it
19340 defines a string access and an array of string access types.
19342 @node GNAT.String_Split (g-strspl.ads)
19343 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
19344 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
19345 @cindex String splitter
19347 @noindent
19348 Useful string manipulation routines: given a set of separators, split
19349 a string wherever the separators appear, and provide direct access
19350 to the resulting slices. This package is instantiated from
19351 @code{GNAT.Array_Split}.
19353 @node GNAT.Table (g-table.ads)
19354 @section @code{GNAT.Table} (@file{g-table.ads})
19355 @cindex @code{GNAT.Table} (@file{g-table.ads})
19356 @cindex Table implementation
19357 @cindex Arrays, extendable
19359 @noindent
19360 A generic package providing a single dimension array abstraction where the
19361 length of the array can be dynamically modified.
19363 @noindent
19364 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
19365 except that this package declares a single instance of the table type,
19366 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
19367 used to define dynamic instances of the table.
19369 @node GNAT.Task_Lock (g-tasloc.ads)
19370 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
19371 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
19372 @cindex Task synchronization
19373 @cindex Task locking
19374 @cindex Locking
19376 @noindent
19377 A very simple facility for locking and unlocking sections of code using a
19378 single global task lock.  Appropriate for use in situations where contention
19379 between tasks is very rarely expected.
19381 @node GNAT.Time_Stamp (g-timsta.ads)
19382 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
19383 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
19384 @cindex Time stamp
19385 @cindex Current time
19387 @noindent
19388 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
19389 represents the current date and time in ISO 8601 format. This is a very simple
19390 routine with minimal code and there are no dependencies on any other unit.
19392 @node GNAT.Threads (g-thread.ads)
19393 @section @code{GNAT.Threads} (@file{g-thread.ads})
19394 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
19395 @cindex Foreign threads
19396 @cindex Threads, foreign
19398 @noindent
19399 Provides facilities for dealing with foreign threads which need to be known
19400 by the GNAT run-time system. Consult the documentation of this package for
19401 further details if your program has threads that are created by a non-Ada
19402 environment which then accesses Ada code.
19404 @node GNAT.Traceback (g-traceb.ads)
19405 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
19406 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
19407 @cindex Trace back facilities
19409 @noindent
19410 Provides a facility for obtaining non-symbolic traceback information, useful
19411 in various debugging situations.
19413 @node GNAT.Traceback.Symbolic (g-trasym.ads)
19414 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
19415 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
19416 @cindex Trace back facilities
19418 @node GNAT.UTF_32 (g-utf_32.ads)
19419 @section @code{GNAT.UTF_32} (@file{g-table.ads})
19420 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
19421 @cindex Wide character codes
19423 @noindent
19424 This is a package intended to be used in conjunction with the
19425 @code{Wide_Character} type in Ada 95 and the
19426 @code{Wide_Wide_Character} type in Ada 2005 (available
19427 in @code{GNAT} in Ada 2005 mode). This package contains
19428 Unicode categorization routines, as well as lexical
19429 categorization routines corresponding to the Ada 2005
19430 lexical rules for identifiers and strings, and also a
19431 lower case to upper case fold routine corresponding to
19432 the Ada 2005 rules for identifier equivalence.
19434 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
19435 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
19436 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
19437 @cindex Spell checking
19439 @noindent
19440 Provides a function for determining whether one wide wide string is a plausible
19441 near misspelling of another wide wide string, where the strings are represented
19442 using the UTF_32_String type defined in System.Wch_Cnv.
19444 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
19445 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
19446 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
19447 @cindex Spell checking
19449 @noindent
19450 Provides a function for determining whether one wide string is a plausible
19451 near misspelling of another wide string.
19453 @node GNAT.Wide_String_Split (g-wistsp.ads)
19454 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
19455 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
19456 @cindex Wide_String splitter
19458 @noindent
19459 Useful wide string manipulation routines: given a set of separators, split
19460 a wide string wherever the separators appear, and provide direct access
19461 to the resulting slices. This package is instantiated from
19462 @code{GNAT.Array_Split}.
19464 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
19465 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
19466 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
19467 @cindex Spell checking
19469 @noindent
19470 Provides a function for determining whether one wide wide string is a plausible
19471 near misspelling of another wide wide string.
19473 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
19474 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
19475 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
19476 @cindex Wide_Wide_String splitter
19478 @noindent
19479 Useful wide wide string manipulation routines: given a set of separators, split
19480 a wide wide string wherever the separators appear, and provide direct access
19481 to the resulting slices. This package is instantiated from
19482 @code{GNAT.Array_Split}.
19484 @node Interfaces.C.Extensions (i-cexten.ads)
19485 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
19486 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
19488 @noindent
19489 This package contains additional C-related definitions, intended
19490 for use with either manually or automatically generated bindings
19491 to C libraries.
19493 @node Interfaces.C.Streams (i-cstrea.ads)
19494 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
19495 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
19496 @cindex  C streams, interfacing
19498 @noindent
19499 This package is a binding for the most commonly used operations
19500 on C streams.
19502 @node Interfaces.CPP (i-cpp.ads)
19503 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
19504 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
19505 @cindex  C++ interfacing
19506 @cindex  Interfacing, to C++
19508 @noindent
19509 This package provides facilities for use in interfacing to C++.  It
19510 is primarily intended to be used in connection with automated tools
19511 for the generation of C++ interfaces.
19513 @node Interfaces.Packed_Decimal (i-pacdec.ads)
19514 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
19515 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
19516 @cindex  IBM Packed Format
19517 @cindex  Packed Decimal
19519 @noindent
19520 This package provides a set of routines for conversions to and
19521 from a packed decimal format compatible with that used on IBM
19522 mainframes.
19524 @node Interfaces.VxWorks (i-vxwork.ads)
19525 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
19526 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
19527 @cindex Interfacing to VxWorks
19528 @cindex VxWorks, interfacing
19530 @noindent
19531 This package provides a limited binding to the VxWorks API.
19532 In particular, it interfaces with the
19533 VxWorks hardware interrupt facilities.
19535 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
19536 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
19537 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
19538 @cindex Interfacing to VxWorks' I/O
19539 @cindex VxWorks, I/O interfacing
19540 @cindex VxWorks, Get_Immediate
19541 @cindex Get_Immediate, VxWorks
19543 @noindent
19544 This package provides a binding to the ioctl (IO/Control)
19545 function of VxWorks, defining a set of option values and
19546 function codes. A particular use of this package is
19547 to enable the use of Get_Immediate under VxWorks.
19549 @node System.Address_Image (s-addima.ads)
19550 @section @code{System.Address_Image} (@file{s-addima.ads})
19551 @cindex @code{System.Address_Image} (@file{s-addima.ads})
19552 @cindex Address image
19553 @cindex Image, of an address
19555 @noindent
19556 This function provides a useful debugging
19557 function that gives an (implementation dependent)
19558 string which identifies an address.
19560 @node System.Assertions (s-assert.ads)
19561 @section @code{System.Assertions} (@file{s-assert.ads})
19562 @cindex @code{System.Assertions} (@file{s-assert.ads})
19563 @cindex Assertions
19564 @cindex Assert_Failure, exception
19566 @noindent
19567 This package provides the declaration of the exception raised
19568 by an run-time assertion failure, as well as the routine that
19569 is used internally to raise this assertion.
19571 @node System.Memory (s-memory.ads)
19572 @section @code{System.Memory} (@file{s-memory.ads})
19573 @cindex @code{System.Memory} (@file{s-memory.ads})
19574 @cindex Memory allocation
19576 @noindent
19577 This package provides the interface to the low level routines used
19578 by the generated code for allocation and freeing storage for the
19579 default storage pool (analogous to the C routines malloc and free.
19580 It also provides a reallocation interface analogous to the C routine
19581 realloc. The body of this unit may be modified to provide alternative
19582 allocation mechanisms for the default pool, and in addition, direct
19583 calls to this unit may be made for low level allocation uses (for
19584 example see the body of @code{GNAT.Tables}).
19586 @node System.Multiprocessors (s-multip.ads)
19587 @section @code{System.Multiprocessors} (@file{s-multip.ads})
19588 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
19589 @cindex Multiprocessor interface
19590 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
19591 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
19592 technically an implementation-defined addition).
19594 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
19595 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
19596 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
19597 @cindex Multiprocessor interface
19598 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
19599 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
19600 technically an implementation-defined addition).
19602 @node System.Partition_Interface (s-parint.ads)
19603 @section @code{System.Partition_Interface} (@file{s-parint.ads})
19604 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
19605 @cindex Partition interfacing functions
19607 @noindent
19608 This package provides facilities for partition interfacing.  It
19609 is used primarily in a distribution context when using Annex E
19610 with @code{GLADE}.
19612 @node System.Pool_Global (s-pooglo.ads)
19613 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
19614 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
19615 @cindex Storage pool, global
19616 @cindex Global storage pool
19618 @noindent
19619 This package provides a storage pool that is equivalent to the default
19620 storage pool used for access types for which no pool is specifically
19621 declared. It uses malloc/free to allocate/free and does not attempt to
19622 do any automatic reclamation.
19624 @node System.Pool_Local (s-pooloc.ads)
19625 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
19626 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
19627 @cindex Storage pool, local
19628 @cindex Local storage pool
19630 @noindent
19631 This package provides a storage pool that is intended for use with locally
19632 defined access types. It uses malloc/free for allocate/free, and maintains
19633 a list of allocated blocks, so that all storage allocated for the pool can
19634 be freed automatically when the pool is finalized.
19636 @node System.Restrictions (s-restri.ads)
19637 @section @code{System.Restrictions} (@file{s-restri.ads})
19638 @cindex @code{System.Restrictions} (@file{s-restri.ads})
19639 @cindex Run-time restrictions access
19641 @noindent
19642 This package provides facilities for accessing at run time
19643 the status of restrictions specified at compile time for
19644 the partition. Information is available both with regard
19645 to actual restrictions specified, and with regard to
19646 compiler determined information on which restrictions
19647 are violated by one or more packages in the partition.
19649 @node System.Rident (s-rident.ads)
19650 @section @code{System.Rident} (@file{s-rident.ads})
19651 @cindex @code{System.Rident} (@file{s-rident.ads})
19652 @cindex Restrictions definitions
19654 @noindent
19655 This package provides definitions of the restrictions
19656 identifiers supported by GNAT, and also the format of
19657 the restrictions provided in package System.Restrictions.
19658 It is not normally necessary to @code{with} this generic package
19659 since the necessary instantiation is included in
19660 package System.Restrictions.
19662 @node System.Strings.Stream_Ops (s-ststop.ads)
19663 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
19664 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
19665 @cindex Stream operations
19666 @cindex String stream operations
19668 @noindent
19669 This package provides a set of stream subprograms for standard string types.
19670 It is intended primarily to support implicit use of such subprograms when
19671 stream attributes are applied to string types, but the subprograms in this
19672 package can be used directly by application programs.
19674 @node System.Task_Info (s-tasinf.ads)
19675 @section @code{System.Task_Info} (@file{s-tasinf.ads})
19676 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
19677 @cindex Task_Info pragma
19679 @noindent
19680 This package provides target dependent functionality that is used
19681 to support the @code{Task_Info} pragma
19683 @node System.Wch_Cnv (s-wchcnv.ads)
19684 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
19685 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
19686 @cindex Wide Character, Representation
19687 @cindex Wide String, Conversion
19688 @cindex Representation of wide characters
19690 @noindent
19691 This package provides routines for converting between
19692 wide and wide wide characters and a representation as a value of type
19693 @code{Standard.String}, using a specified wide character
19694 encoding method.  It uses definitions in
19695 package @code{System.Wch_Con}.
19697 @node System.Wch_Con (s-wchcon.ads)
19698 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
19699 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
19701 @noindent
19702 This package provides definitions and descriptions of
19703 the various methods used for encoding wide characters
19704 in ordinary strings.  These definitions are used by
19705 the package @code{System.Wch_Cnv}.
19707 @node Interfacing to Other Languages
19708 @chapter Interfacing to Other Languages
19709 @noindent
19710 The facilities in annex B of the Ada Reference Manual are fully
19711 implemented in GNAT, and in addition, a full interface to C++ is
19712 provided.
19714 @menu
19715 * Interfacing to C::
19716 * Interfacing to C++::
19717 * Interfacing to COBOL::
19718 * Interfacing to Fortran::
19719 * Interfacing to non-GNAT Ada code::
19720 @end menu
19722 @node Interfacing to C
19723 @section Interfacing to C
19725 @noindent
19726 Interfacing to C with GNAT can use one of two approaches:
19728 @itemize @bullet
19729 @item
19730 The types in the package @code{Interfaces.C} may be used.
19731 @item
19732 Standard Ada types may be used directly.  This may be less portable to
19733 other compilers, but will work on all GNAT compilers, which guarantee
19734 correspondence between the C and Ada types.
19735 @end itemize
19737 @noindent
19738 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
19739 effect, since this is the default.  The following table shows the
19740 correspondence between Ada scalar types and the corresponding C types.
19742 @table @code
19743 @item Integer
19744 @code{int}
19745 @item Short_Integer
19746 @code{short}
19747 @item Short_Short_Integer
19748 @code{signed char}
19749 @item Long_Integer
19750 @code{long}
19751 @item Long_Long_Integer
19752 @code{long long}
19753 @item Short_Float
19754 @code{float}
19755 @item Float
19756 @code{float}
19757 @item Long_Float
19758 @code{double}
19759 @item Long_Long_Float
19760 This is the longest floating-point type supported by the hardware.
19761 @end table
19763 @noindent
19764 Additionally, there are the following general correspondences between Ada
19765 and C types:
19766 @itemize @bullet
19767 @item
19768 Ada enumeration types map to C enumeration types directly if pragma
19769 @code{Convention C} is specified, which causes them to have int
19770 length.  Without pragma @code{Convention C}, Ada enumeration types map to
19771 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
19772 @code{int}, respectively) depending on the number of values passed.
19773 This is the only case in which pragma @code{Convention C} affects the
19774 representation of an Ada type.
19776 @item
19777 Ada access types map to C pointers, except for the case of pointers to
19778 unconstrained types in Ada, which have no direct C equivalent.
19780 @item
19781 Ada arrays map directly to C arrays.
19783 @item
19784 Ada records map directly to C structures.
19786 @item
19787 Packed Ada records map to C structures where all members are bit fields
19788 of the length corresponding to the @code{@var{type}'Size} value in Ada.
19789 @end itemize
19791 @node Interfacing to C++
19792 @section Interfacing to C++
19794 @noindent
19795 The interface to C++ makes use of the following pragmas, which are
19796 primarily intended to be constructed automatically using a binding generator
19797 tool, although it is possible to construct them by hand.
19799 Using these pragmas it is possible to achieve complete
19800 inter-operability between Ada tagged types and C++ class definitions.
19801 See @ref{Implementation Defined Pragmas}, for more details.
19803 @table @code
19804 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
19805 The argument denotes an entity in the current declarative region that is
19806 declared as a tagged or untagged record type. It indicates that the type
19807 corresponds to an externally declared C++ class type, and is to be laid
19808 out the same way that C++ would lay out the type.
19810 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
19811 for backward compatibility but its functionality is available
19812 using pragma @code{Import} with @code{Convention} = @code{CPP}.
19814 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
19815 This pragma identifies an imported function (imported in the usual way
19816 with pragma @code{Import}) as corresponding to a C++ constructor.
19817 @end table
19819 A few restrictions are placed on the use of the @code{Access} attribute
19820 in conjunction with subprograms subject to convention @code{CPP}: the
19821 attribute may be used neither on primitive operations of a tagged
19822 record type with convention @code{CPP}, imported or not, nor on
19823 subprograms imported with pragma @code{CPP_Constructor}.
19825 In addition, C++ exceptions are propagated and can be handled in an
19826 @code{others} choice of an exception handler. The corresponding Ada
19827 occurrence has no message, and the simple name of the exception identity
19828 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
19829 tasks works properly when such foreign exceptions are propagated.
19831 It is also possible to import a C++ exception using the following syntax:
19833 @smallexample @c ada
19834 LOCAL_NAME : exception;
19835 pragma Import (Cpp,
19836   [Entity =>] LOCAL_NAME,
19837   [External_Name =>] static_string_EXPRESSION);
19838 @end smallexample
19840 @noindent
19841 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
19842 cover a specific C++ exception in an exception handler.
19844 @node Interfacing to COBOL
19845 @section Interfacing to COBOL
19847 @noindent
19848 Interfacing to COBOL is achieved as described in section B.4 of
19849 the Ada Reference Manual.
19851 @node Interfacing to Fortran
19852 @section Interfacing to Fortran
19854 @noindent
19855 Interfacing to Fortran is achieved as described in section B.5 of the
19856 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
19857 multi-dimensional array causes the array to be stored in column-major
19858 order as required for convenient interface to Fortran.
19860 @node Interfacing to non-GNAT Ada code
19861 @section Interfacing to non-GNAT Ada code
19863 It is possible to specify the convention @code{Ada} in a pragma
19864 @code{Import} or pragma @code{Export}.  However this refers to
19865 the calling conventions used by GNAT, which may or may not be
19866 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
19867 compiler to allow interoperation.
19869 If arguments types are kept simple, and if the foreign compiler generally
19870 follows system calling conventions, then it may be possible to integrate
19871 files compiled by other Ada compilers, provided that the elaboration
19872 issues are adequately addressed (for example by eliminating the
19873 need for any load time elaboration).
19875 In particular, GNAT running on VMS is designed to
19876 be highly compatible with the DEC Ada 83 compiler, so this is one
19877 case in which it is possible to import foreign units of this type,
19878 provided that the data items passed are restricted to simple scalar
19879 values or simple record types without variants, or simple array
19880 types with fixed bounds.
19882 @node Specialized Needs Annexes
19883 @chapter Specialized Needs Annexes
19885 @noindent
19886 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
19887 required in all implementations.  However, as described in this chapter,
19888 GNAT implements all of these annexes:
19890 @table @asis
19891 @item Systems Programming (Annex C)
19892 The Systems Programming Annex is fully implemented.
19894 @item Real-Time Systems (Annex D)
19895 The Real-Time Systems Annex is fully implemented.
19897 @item Distributed Systems (Annex E)
19898 Stub generation is fully implemented in the GNAT compiler.  In addition,
19899 a complete compatible PCS is available as part of the GLADE system,
19900 a separate product.  When the two
19901 products are used in conjunction, this annex is fully implemented.
19903 @item Information Systems (Annex F)
19904 The Information Systems annex is fully implemented.
19906 @item Numerics (Annex G)
19907 The Numerics Annex is fully implemented.
19909 @item Safety and Security / High-Integrity Systems (Annex H)
19910 The Safety and Security Annex (termed the High-Integrity Systems Annex
19911 in Ada 2005) is fully implemented.
19912 @end table
19914 @node Implementation of Specific Ada Features
19915 @chapter Implementation of Specific Ada Features
19917 @noindent
19918 This chapter describes the GNAT implementation of several Ada language
19919 facilities.
19921 @menu
19922 * Machine Code Insertions::
19923 * GNAT Implementation of Tasking::
19924 * GNAT Implementation of Shared Passive Packages::
19925 * Code Generation for Array Aggregates::
19926 * The Size of Discriminated Records with Default Discriminants::
19927 * Strict Conformance to the Ada Reference Manual::
19928 @end menu
19930 @node Machine Code Insertions
19931 @section Machine Code Insertions
19932 @cindex Machine Code insertions
19934 @noindent
19935 Package @code{Machine_Code} provides machine code support as described
19936 in the Ada Reference Manual in two separate forms:
19937 @itemize @bullet
19938 @item
19939 Machine code statements, consisting of qualified expressions that
19940 fit the requirements of RM section 13.8.
19941 @item
19942 An intrinsic callable procedure, providing an alternative mechanism of
19943 including machine instructions in a subprogram.
19944 @end itemize
19946 @noindent
19947 The two features are similar, and both are closely related to the mechanism
19948 provided by the asm instruction in the GNU C compiler.  Full understanding
19949 and use of the facilities in this package requires understanding the asm
19950 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
19951 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
19953 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
19954 semantic restrictions and effects as described below.  Both are provided so
19955 that the procedure call can be used as a statement, and the function call
19956 can be used to form a code_statement.
19958 The first example given in the GCC documentation is the C @code{asm}
19959 instruction:
19960 @smallexample
19961    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
19962 @end smallexample
19964 @noindent
19965 The equivalent can be written for GNAT as:
19967 @smallexample @c ada
19968 Asm ("fsinx %1 %0",
19969      My_Float'Asm_Output ("=f", result),
19970      My_Float'Asm_Input  ("f",  angle));
19971 @end smallexample
19973 @noindent
19974 The first argument to @code{Asm} is the assembler template, and is
19975 identical to what is used in GNU C@.  This string must be a static
19976 expression.  The second argument is the output operand list.  It is
19977 either a single @code{Asm_Output} attribute reference, or a list of such
19978 references enclosed in parentheses (technically an array aggregate of
19979 such references).
19981 The @code{Asm_Output} attribute denotes a function that takes two
19982 parameters.  The first is a string, the second is the name of a variable
19983 of the type designated by the attribute prefix.  The first (string)
19984 argument is required to be a static expression and designates the
19985 constraint for the parameter (e.g.@: what kind of register is
19986 required).  The second argument is the variable to be updated with the
19987 result.  The possible values for constraint are the same as those used in
19988 the RTL, and are dependent on the configuration file used to build the
19989 GCC back end.  If there are no output operands, then this argument may
19990 either be omitted, or explicitly given as @code{No_Output_Operands}.
19992 The second argument of @code{@var{my_float}'Asm_Output} functions as
19993 though it were an @code{out} parameter, which is a little curious, but
19994 all names have the form of expressions, so there is no syntactic
19995 irregularity, even though normally functions would not be permitted
19996 @code{out} parameters.  The third argument is the list of input
19997 operands.  It is either a single @code{Asm_Input} attribute reference, or
19998 a list of such references enclosed in parentheses (technically an array
19999 aggregate of such references).
20001 The @code{Asm_Input} attribute denotes a function that takes two
20002 parameters.  The first is a string, the second is an expression of the
20003 type designated by the prefix.  The first (string) argument is required
20004 to be a static expression, and is the constraint for the parameter,
20005 (e.g.@: what kind of register is required).  The second argument is the
20006 value to be used as the input argument.  The possible values for the
20007 constant are the same as those used in the RTL, and are dependent on
20008 the configuration file used to built the GCC back end.
20010 If there are no input operands, this argument may either be omitted, or
20011 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
20012 present in the above example, is a list of register names, called the
20013 @dfn{clobber} argument.  This argument, if given, must be a static string
20014 expression, and is a space or comma separated list of names of registers
20015 that must be considered destroyed as a result of the @code{Asm} call.  If
20016 this argument is the null string (the default value), then the code
20017 generator assumes that no additional registers are destroyed.
20019 The fifth argument, not present in the above example, called the
20020 @dfn{volatile} argument, is by default @code{False}.  It can be set to
20021 the literal value @code{True} to indicate to the code generator that all
20022 optimizations with respect to the instruction specified should be
20023 suppressed, and that in particular, for an instruction that has outputs,
20024 the instruction will still be generated, even if none of the outputs are
20025 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
20026 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
20027 Generally it is strongly advisable to use Volatile for any ASM statement
20028 that is missing either input or output operands, or when two or more ASM
20029 statements appear in sequence, to avoid unwanted optimizations. A warning
20030 is generated if this advice is not followed.
20032 The @code{Asm} subprograms may be used in two ways.  First the procedure
20033 forms can be used anywhere a procedure call would be valid, and
20034 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
20035 be used to intersperse machine instructions with other Ada statements.
20036 Second, the function forms, which return a dummy value of the limited
20037 private type @code{Asm_Insn}, can be used in code statements, and indeed
20038 this is the only context where such calls are allowed.  Code statements
20039 appear as aggregates of the form:
20041 @smallexample @c ada
20042 Asm_Insn'(Asm (@dots{}));
20043 Asm_Insn'(Asm_Volatile (@dots{}));
20044 @end smallexample
20046 @noindent
20047 In accordance with RM rules, such code statements are allowed only
20048 within subprograms whose entire body consists of such statements.  It is
20049 not permissible to intermix such statements with other Ada statements.
20051 Typically the form using intrinsic procedure calls is more convenient
20052 and more flexible.  The code statement form is provided to meet the RM
20053 suggestion that such a facility should be made available.  The following
20054 is the exact syntax of the call to @code{Asm}. As usual, if named notation
20055 is used, the arguments may be given in arbitrary order, following the
20056 normal rules for use of positional and named arguments)
20058 @smallexample
20059 ASM_CALL ::= Asm (
20060                  [Template =>] static_string_EXPRESSION
20061                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
20062                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
20063                [,[Clobber  =>] static_string_EXPRESSION ]
20064                [,[Volatile =>] static_boolean_EXPRESSION] )
20066 OUTPUT_OPERAND_LIST ::=
20067   [PREFIX.]No_Output_Operands
20068 | OUTPUT_OPERAND_ATTRIBUTE
20069 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
20071 OUTPUT_OPERAND_ATTRIBUTE ::=
20072   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
20074 INPUT_OPERAND_LIST ::=
20075   [PREFIX.]No_Input_Operands
20076 | INPUT_OPERAND_ATTRIBUTE
20077 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
20079 INPUT_OPERAND_ATTRIBUTE ::=
20080   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
20081 @end smallexample
20083 @noindent
20084 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
20085 are declared in the package @code{Machine_Code} and must be referenced
20086 according to normal visibility rules. In particular if there is no
20087 @code{use} clause for this package, then appropriate package name
20088 qualification is required.
20090 @node GNAT Implementation of Tasking
20091 @section GNAT Implementation of Tasking
20093 @noindent
20094 This chapter outlines the basic GNAT approach to tasking (in particular,
20095 a multi-layered library for portability) and discusses issues related
20096 to compliance with the Real-Time Systems Annex.
20098 @menu
20099 * Mapping Ada Tasks onto the Underlying Kernel Threads::
20100 * Ensuring Compliance with the Real-Time Annex::
20101 @end menu
20103 @node Mapping Ada Tasks onto the Underlying Kernel Threads
20104 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
20106 @noindent
20107 GNAT's run-time support comprises two layers:
20109 @itemize @bullet
20110 @item GNARL (GNAT Run-time Layer)
20111 @item GNULL (GNAT Low-level Library)
20112 @end itemize
20114 @noindent
20115 In GNAT, Ada's tasking services rely on a platform and OS independent
20116 layer known as GNARL@.  This code is responsible for implementing the
20117 correct semantics of Ada's task creation, rendezvous, protected
20118 operations etc.
20120 GNARL decomposes Ada's tasking semantics into simpler lower level
20121 operations such as create a thread, set the priority of a thread,
20122 yield, create a lock, lock/unlock, etc.  The spec for these low-level
20123 operations constitutes GNULLI, the GNULL Interface.  This interface is
20124 directly inspired from the POSIX real-time API@.
20126 If the underlying executive or OS implements the POSIX standard
20127 faithfully, the GNULL Interface maps as is to the services offered by
20128 the underlying kernel.  Otherwise, some target dependent glue code maps
20129 the services offered by the underlying kernel to the semantics expected
20130 by GNARL@.
20132 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
20133 key point is that each Ada task is mapped on a thread in the underlying
20134 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
20136 In addition Ada task priorities map onto the underlying thread priorities.
20137 Mapping Ada tasks onto the underlying kernel threads has several advantages:
20139 @itemize @bullet
20140 @item
20141 The underlying scheduler is used to schedule the Ada tasks.  This
20142 makes Ada tasks as efficient as kernel threads from a scheduling
20143 standpoint.
20145 @item
20146 Interaction with code written in C containing threads is eased
20147 since at the lowest level Ada tasks and C threads map onto the same
20148 underlying kernel concept.
20150 @item
20151 When an Ada task is blocked during I/O the remaining Ada tasks are
20152 able to proceed.
20154 @item
20155 On multiprocessor systems Ada tasks can execute in parallel.
20156 @end itemize
20158 @noindent
20159 Some threads libraries offer a mechanism to fork a new process, with the
20160 child process duplicating the threads from the parent.
20161 GNAT does not
20162 support this functionality when the parent contains more than one task.
20163 @cindex Forking a new process
20165 @node Ensuring Compliance with the Real-Time Annex
20166 @subsection Ensuring Compliance with the Real-Time Annex
20167 @cindex Real-Time Systems Annex compliance
20169 @noindent
20170 Although mapping Ada tasks onto
20171 the underlying threads has significant advantages, it does create some
20172 complications when it comes to respecting the scheduling semantics
20173 specified in the real-time annex (Annex D).
20175 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
20176 scheduling policy states:
20178 @quotation
20179 @emph{When the active priority of a ready task that is not running
20180 changes, or the setting of its base priority takes effect, the
20181 task is removed from the ready queue for its old active priority
20182 and is added at the tail of the ready queue for its new active
20183 priority, except in the case where the active priority is lowered
20184 due to the loss of inherited priority, in which case the task is
20185 added at the head of the ready queue for its new active priority.}
20186 @end quotation
20188 @noindent
20189 While most kernels do put tasks at the end of the priority queue when
20190 a task changes its priority, (which respects the main
20191 FIFO_Within_Priorities requirement), almost none keep a thread at the
20192 beginning of its priority queue when its priority drops from the loss
20193 of inherited priority.
20195 As a result most vendors have provided incomplete Annex D implementations.
20197 The GNAT run-time, has a nice cooperative solution to this problem
20198 which ensures that accurate FIFO_Within_Priorities semantics are
20199 respected.
20201 The principle is as follows.  When an Ada task T is about to start
20202 running, it checks whether some other Ada task R with the same
20203 priority as T has been suspended due to the loss of priority
20204 inheritance.  If this is the case, T yields and is placed at the end of
20205 its priority queue.  When R arrives at the front of the queue it
20206 executes.
20208 Note that this simple scheme preserves the relative order of the tasks
20209 that were ready to execute in the priority queue where R has been
20210 placed at the end.
20212 @node GNAT Implementation of Shared Passive Packages
20213 @section GNAT Implementation of Shared Passive Packages
20214 @cindex Shared passive packages
20216 @noindent
20217 GNAT fully implements the pragma @code{Shared_Passive} for
20218 @cindex pragma @code{Shared_Passive}
20219 the purpose of designating shared passive packages.
20220 This allows the use of passive partitions in the
20221 context described in the Ada Reference Manual; i.e., for communication
20222 between separate partitions of a distributed application using the
20223 features in Annex E.
20224 @cindex Annex E
20225 @cindex Distribution Systems Annex
20227 However, the implementation approach used by GNAT provides for more
20228 extensive usage as follows:
20230 @table @emph
20231 @item Communication between separate programs
20233 This allows separate programs to access the data in passive
20234 partitions, using protected objects for synchronization where
20235 needed. The only requirement is that the two programs have a
20236 common shared file system. It is even possible for programs
20237 running on different machines with different architectures
20238 (e.g.@: different endianness) to communicate via the data in
20239 a passive partition.
20241 @item Persistence between program runs
20243 The data in a passive package can persist from one run of a
20244 program to another, so that a later program sees the final
20245 values stored by a previous run of the same program.
20247 @end table
20249 @noindent
20250 The implementation approach used is to store the data in files. A
20251 separate stream file is created for each object in the package, and
20252 an access to an object causes the corresponding file to be read or
20253 written.
20255 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
20256 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
20257 set to the directory to be used for these files.
20258 The files in this directory
20259 have names that correspond to their fully qualified names. For
20260 example, if we have the package
20262 @smallexample @c ada
20263 package X is
20264   pragma Shared_Passive (X);
20265   Y : Integer;
20266   Z : Float;
20267 end X;
20268 @end smallexample
20270 @noindent
20271 and the environment variable is set to @code{/stemp/}, then the files created
20272 will have the names:
20274 @smallexample
20275 /stemp/x.y
20276 /stemp/x.z
20277 @end smallexample
20279 @noindent
20280 These files are created when a value is initially written to the object, and
20281 the files are retained until manually deleted. This provides the persistence
20282 semantics. If no file exists, it means that no partition has assigned a value
20283 to the variable; in this case the initial value declared in the package
20284 will be used. This model ensures that there are no issues in synchronizing
20285 the elaboration process, since elaboration of passive packages elaborates the
20286 initial values, but does not create the files.
20288 The files are written using normal @code{Stream_IO} access.
20289 If you want to be able
20290 to communicate between programs or partitions running on different
20291 architectures, then you should use the XDR versions of the stream attribute
20292 routines, since these are architecture independent.
20294 If active synchronization is required for access to the variables in the
20295 shared passive package, then as described in the Ada Reference Manual, the
20296 package may contain protected objects used for this purpose. In this case
20297 a lock file (whose name is @file{___lock} (three underscores)
20298 is created in the shared memory directory.
20299 @cindex @file{___lock} file (for shared passive packages)
20300 This is used to provide the required locking
20301 semantics for proper protected object synchronization.
20303 As of January 2003, GNAT supports shared passive packages on all platforms
20304 except for OpenVMS.
20306 @node Code Generation for Array Aggregates
20307 @section Code Generation for Array Aggregates
20309 @menu
20310 * Static constant aggregates with static bounds::
20311 * Constant aggregates with unconstrained nominal types::
20312 * Aggregates with static bounds::
20313 * Aggregates with non-static bounds::
20314 * Aggregates in assignment statements::
20315 @end menu
20317 @noindent
20318 Aggregates have a rich syntax and allow the user to specify the values of
20319 complex data structures by means of a single construct.  As a result, the
20320 code generated for aggregates can be quite complex and involve loops, case
20321 statements and multiple assignments.  In the simplest cases, however, the
20322 compiler will recognize aggregates whose components and constraints are
20323 fully static, and in those cases the compiler will generate little or no
20324 executable code.  The following is an outline of the code that GNAT generates
20325 for various aggregate constructs.  For further details, you will find it
20326 useful to examine the output produced by the -gnatG flag to see the expanded
20327 source that is input to the code generator.  You may also want to examine
20328 the assembly code generated at various levels of optimization.
20330 The code generated for aggregates depends on the context, the component values,
20331 and the type.  In the context of an object declaration the code generated is
20332 generally simpler than in the case of an assignment.  As a general rule, static
20333 component values and static subtypes also lead to simpler code.
20335 @node Static constant aggregates with static bounds
20336 @subsection Static constant aggregates with static bounds
20338 @noindent
20339 For the declarations:
20340 @smallexample @c ada
20341     type One_Dim is array (1..10) of integer;
20342     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
20343 @end smallexample
20345 @noindent
20346 GNAT generates no executable code: the constant ar0 is placed in static memory.
20347 The same is true for constant aggregates with named associations:
20349 @smallexample @c ada
20350     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
20351     Cr3 : constant One_Dim := (others => 7777);
20352 @end smallexample
20354 @noindent
20355 The same is true for multidimensional constant arrays such as:
20357 @smallexample @c ada
20358     type two_dim is array (1..3, 1..3) of integer;
20359     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
20360 @end smallexample
20362 @noindent
20363 The same is true for arrays of one-dimensional arrays: the following are
20364 static:
20366 @smallexample @c ada
20367 type ar1b  is array (1..3) of boolean;
20368 type ar_ar is array (1..3) of ar1b;
20369 None  : constant ar1b := (others => false);     --  fully static
20370 None2 : constant ar_ar := (1..3 => None);       --  fully static
20371 @end smallexample
20373 @noindent
20374 However, for multidimensional aggregates with named associations, GNAT will
20375 generate assignments and loops, even if all associations are static.  The
20376 following two declarations generate a loop for the first dimension, and
20377 individual component assignments for the second dimension:
20379 @smallexample @c ada
20380 Zero1: constant two_dim := (1..3 => (1..3 => 0));
20381 Zero2: constant two_dim := (others => (others => 0));
20382 @end smallexample
20384 @node Constant aggregates with unconstrained nominal types
20385 @subsection Constant aggregates with unconstrained nominal types
20387 @noindent
20388 In such cases the aggregate itself establishes the subtype, so that
20389 associations with @code{others} cannot be used.  GNAT determines the
20390 bounds for the actual subtype of the aggregate, and allocates the
20391 aggregate statically as well.  No code is generated for the following:
20393 @smallexample @c ada
20394     type One_Unc is array (natural range <>) of integer;
20395     Cr_Unc : constant One_Unc := (12,24,36);
20396 @end smallexample
20398 @node Aggregates with static bounds
20399 @subsection Aggregates with static bounds
20401 @noindent
20402 In all previous examples the aggregate was the initial (and immutable) value
20403 of a constant.  If the aggregate initializes a variable, then code is generated
20404 for it as a combination of individual assignments and loops over the target
20405 object.  The declarations
20407 @smallexample @c ada
20408        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
20409        Cr_Var2 : One_Dim := (others > -1);
20410 @end smallexample
20412 @noindent
20413 generate the equivalent of
20415 @smallexample @c ada
20416        Cr_Var1 (1) := 2;
20417        Cr_Var1 (2) := 3;
20418        Cr_Var1 (3) := 5;
20419        Cr_Var1 (4) := 11;
20421        for I in Cr_Var2'range loop
20422           Cr_Var2 (I) := -1;
20423        end loop;
20424 @end smallexample
20426 @node Aggregates with non-static bounds
20427 @subsection Aggregates with non-static bounds
20429 @noindent
20430 If the bounds of the aggregate are not statically compatible with the bounds
20431 of the nominal subtype  of the target, then constraint checks have to be
20432 generated on the bounds.  For a multidimensional array, constraint checks may
20433 have to be applied to sub-arrays individually, if they do not have statically
20434 compatible subtypes.
20436 @node Aggregates in assignment statements
20437 @subsection Aggregates in assignment statements
20439 @noindent
20440 In general, aggregate assignment requires the construction of a temporary,
20441 and a copy from the temporary to the target of the assignment.  This is because
20442 it is not always possible to convert the assignment into a series of individual
20443 component assignments.  For example, consider the simple case:
20445 @smallexample @c ada
20446         A := (A(2), A(1));
20447 @end smallexample
20449 @noindent
20450 This cannot be converted into:
20452 @smallexample @c ada
20453         A(1) := A(2);
20454         A(2) := A(1);
20455 @end smallexample
20457 @noindent
20458 So the aggregate has to be built first in a separate location, and then
20459 copied into the target.  GNAT recognizes simple cases where this intermediate
20460 step is not required, and the assignments can be performed in place, directly
20461 into the target.  The following sufficient criteria are applied:
20463 @itemize @bullet
20464 @item
20465 The bounds of the aggregate are static, and the associations are static.
20466 @item
20467 The components of the aggregate are static constants, names of
20468 simple variables that are not renamings, or expressions not involving
20469 indexed components whose operands obey these rules.
20470 @end itemize
20472 @noindent
20473 If any of these conditions are violated, the aggregate will be built in
20474 a temporary (created either by the front-end or the code generator) and then
20475 that temporary will be copied onto the target.
20477 @node The Size of Discriminated Records with Default Discriminants
20478 @section The Size of Discriminated Records with Default Discriminants
20480 @noindent
20481 If a discriminated type @code{T} has discriminants with default values, it is
20482 possible to declare an object of this type without providing an explicit
20483 constraint:
20485 @smallexample @c ada
20486 @group
20487 type Size is range 1..100;
20489 type Rec (D : Size := 15) is record
20490    Name : String (1..D);
20491 end T;
20493 Word : Rec;
20494 @end group
20495 @end smallexample
20497 @noindent
20498 Such an object is said to be @emph{unconstrained}.
20499 The discriminant of the object
20500 can be modified by a full assignment to the object, as long as it preserves the
20501 relation between the value of the discriminant, and the value of the components
20502 that depend on it:
20504 @smallexample @c ada
20505 @group
20506 Word := (3, "yes");
20508 Word := (5, "maybe");
20510 Word := (5, "no"); -- raises Constraint_Error
20511 @end group
20512 @end smallexample
20514 @noindent
20515 In order to support this behavior efficiently, an unconstrained object is
20516 given the maximum size that any value of the type requires. In the case
20517 above, @code{Word} has storage for the discriminant and for
20518 a @code{String} of length 100.
20519 It is important to note that unconstrained objects do not require dynamic
20520 allocation. It would be an improper implementation to place on the heap those
20521 components whose size depends on discriminants. (This improper implementation
20522 was used by some Ada83 compilers, where the @code{Name} component above
20523 would have
20524 been stored as a pointer to a dynamic string). Following the principle that
20525 dynamic storage management should never be introduced implicitly,
20526 an Ada compiler should reserve the full size for an unconstrained declared
20527 object, and place it on the stack.
20529 This maximum size approach
20530 has been a source of surprise to some users, who expect the default
20531 values of the discriminants to determine the size reserved for an
20532 unconstrained object: ``If the default is 15, why should the object occupy
20533 a larger size?''
20534 The answer, of course, is that the discriminant may be later modified,
20535 and its full range of values must be taken into account. This is why the
20536 declaration:
20538 @smallexample
20539 @group
20540 type Rec (D : Positive := 15) is record
20541    Name : String (1..D);
20542 end record;
20544 Too_Large : Rec;
20545 @end group
20546 @end smallexample
20548 @noindent
20549 is flagged by the compiler with a warning:
20550 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
20551 because the required size includes @code{Positive'Last}
20552 bytes. As the first example indicates, the proper approach is to declare an
20553 index type of ``reasonable'' range so that unconstrained objects are not too
20554 large.
20556 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
20557 created in the heap by means of an allocator, then it is @emph{not}
20558 unconstrained:
20559 it is constrained by the default values of the discriminants, and those values
20560 cannot be modified by full assignment. This is because in the presence of
20561 aliasing all views of the object (which may be manipulated by different tasks,
20562 say) must be consistent, so it is imperative that the object, once created,
20563 remain invariant.
20565 @node Strict Conformance to the Ada Reference Manual
20566 @section Strict Conformance to the Ada Reference Manual
20568 @noindent
20569 The dynamic semantics defined by the Ada Reference Manual impose a set of
20570 run-time checks to be generated. By default, the GNAT compiler will insert many
20571 run-time checks into the compiled code, including most of those required by the
20572 Ada Reference Manual. However, there are three checks that are not enabled
20573 in the default mode for efficiency reasons: arithmetic overflow checking for
20574 integer operations (including division by zero), checks for access before
20575 elaboration on subprogram calls, and stack overflow checking (most operating
20576 systems do not perform this check by default).
20578 Strict conformance to the Ada Reference Manual can be achieved by adding
20579 three compiler options for overflow checking for integer operations
20580 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
20581 calls and generic instantiations (@option{-gnatE}), and stack overflow
20582 checking (@option{-fstack-check}).
20584 Note that the result of a floating point arithmetic operation in overflow and
20585 invalid situations, when the @code{Machine_Overflows} attribute of the result
20586 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
20587 case for machines compliant with the IEEE floating-point standard, but on
20588 machines that are not fully compliant with this standard, such as Alpha, the
20589 @option{-mieee} compiler flag must be used for achieving IEEE confirming
20590 behavior (although at the cost of a significant performance penalty), so
20591 infinite and NaN values are properly generated.
20594 @node Implementation of Ada 2012 Features
20595 @chapter Implementation of Ada 2012 Features
20596 @cindex Ada 2012 implementation status
20598 This chapter contains a complete list of Ada 2012 features that have been
20599 implemented as of GNAT version 6.4. Generally, these features are only
20600 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
20601 @cindex @option{-gnat12} option
20602 or if the configuration pragma @code{Ada_2012} is used.
20603 @cindex pragma @code{Ada_2012}
20604 @cindex configuration pragma @code{Ada_2012}
20605 @cindex @code{Ada_2012} configuration pragma
20606 However, new pragmas, attributes, and restrictions are
20607 unconditionally available, since the Ada 95 standard allows the addition of
20608 new pragmas, attributes, and restrictions (there are exceptions, which are
20609 documented in the individual descriptions), and also certain packages
20610 were made available in earlier versions of Ada.
20612 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
20613 This date shows the implementation date of the feature. Any wavefront
20614 subsequent to this date will contain the indicated feature, as will any
20615 subsequent releases. A date of 0000-00-00 means that GNAT has always
20616 implemented the feature, or implemented it as soon as it appeared as a
20617 binding interpretation.
20619 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
20620 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
20621 The features are ordered based on the relevant sections of the Ada
20622 Reference Manual (``RM'').  When a given AI relates to multiple points
20623 in the RM, the earliest is used.
20625 A complete description of the AIs may be found in
20626 @url{www.ada-auth.org/ai05-summary.html}.
20628 @itemize @bullet
20630 @item
20631 @emph{AI-0176 Quantified expressions (2010-09-29)}
20632 @cindex AI-0176 (Ada 2012 feature)
20634 @noindent
20635   Both universally and existentially quantified expressions are implemented.
20636   They use the new syntax for iterators proposed in AI05-139-2, as well as
20637   the standard Ada loop syntax.
20639 @noindent
20640   RM References:  1.01.04 (12)   2.09 (2/2)   4.04 (7)   4.05.09 (0)
20642 @item
20643 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
20644 @cindex AI-0079 (Ada 2012 feature)
20646 @noindent
20647   Wide characters in the unicode category @i{other_format} are now allowed in
20648   source programs between tokens, but not within a token such as an identifier.
20650 @noindent
20651   RM References:  2.01 (4/2)   2.02 (7)
20653 @item
20654 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
20655 @cindex AI-0091 (Ada 2012 feature)
20657 @noindent
20658   Wide characters in the unicode category @i{other_format} are not permitted
20659   within  an identifier, since this can be a security problem. The error
20660   message for this case has been improved to be more specific, but GNAT has
20661   never allowed such characters to appear in identifiers.
20663 @noindent
20664   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)
20666 @item
20667 @emph{AI-0100 Placement of pragmas  (2010-07-01)}
20668 @cindex AI-0100 (Ada 2012 feature)
20670 @noindent
20671   This AI is an earlier version of AI-163. It simplifies the rules
20672   for legal placement of pragmas. In the case of lists that allow pragmas, if
20673   the list may have no elements, then the list may consist solely of pragmas.
20675 @noindent
20676   RM References:  2.08 (7)
20678 @item
20679 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
20680 @cindex AI-0163 (Ada 2012 feature)
20682 @noindent
20683   A statement sequence may be composed entirely of pragmas. It is no longer
20684   necessary to add a dummy @code{null} statement to make the sequence legal.
20686 @noindent
20687   RM References:  2.08 (7)   2.08 (16)
20690 @item
20691 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
20692 @cindex AI-0080 (Ada 2012 feature)
20694 @noindent
20695   This is an editorial change only, described as non-testable in the AI.
20697 @noindent
20698   RM References:  3.01 (7)
20701 @item
20702 @emph{AI-0183 Aspect specifications (2010-08-16)}
20703 @cindex AI-0183 (Ada 2012 feature)
20705 @noindent
20706   Aspect specifications have been fully implemented except for pre and post-
20707   conditions, and type invariants, which have their own separate AI's. All
20708   forms of declarations listed in the AI are supported. The following is a
20709   list of the aspects supported (with GNAT implementation aspects marked)
20711 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
20712 @item @code{Ada_2005} @tab                      -- GNAT
20713 @item @code{Ada_2012} @tab                      -- GNAT
20714 @item @code{Address} @tab
20715 @item @code{Alignment} @tab
20716 @item @code{Atomic} @tab
20717 @item @code{Atomic_Components} @tab
20718 @item @code{Bit_Order} @tab
20719 @item @code{Component_Size} @tab
20720 @item @code{Contract_Cases} @tab                -- GNAT
20721 @item @code{Discard_Names} @tab
20722 @item @code{External_Tag} @tab
20723 @item @code{Favor_Top_Level} @tab               -- GNAT
20724 @item @code{Inline} @tab
20725 @item @code{Inline_Always} @tab                 -- GNAT
20726 @item @code{Invariant} @tab                     -- GNAT
20727 @item @code{Machine_Radix} @tab
20728 @item @code{No_Return} @tab
20729 @item @code{Object_Size} @tab                   -- GNAT
20730 @item @code{Pack} @tab
20731 @item @code{Persistent_BSS} @tab                -- GNAT
20732 @item @code{Post} @tab
20733 @item @code{Pre} @tab
20734 @item @code{Predicate} @tab
20735 @item @code{Preelaborable_Initialization} @tab
20736 @item @code{Pure_Function} @tab                 -- GNAT
20737 @item @code{Remote_Access_Type} @tab            -- GNAT
20738 @item @code{Shared} @tab                        -- GNAT
20739 @item @code{Size} @tab
20740 @item @code{Storage_Pool} @tab
20741 @item @code{Storage_Size} @tab
20742 @item @code{Stream_Size} @tab
20743 @item @code{Suppress} @tab
20744 @item @code{Suppress_Debug_Info} @tab           -- GNAT
20745 @item @code{Test_Case} @tab                     -- GNAT
20746 @item @code{Type_Invariant} @tab
20747 @item @code{Unchecked_Union} @tab
20748 @item @code{Universal_Aliasing} @tab            -- GNAT
20749 @item @code{Unmodified} @tab                    -- GNAT
20750 @item @code{Unreferenced} @tab                  -- GNAT
20751 @item @code{Unreferenced_Objects} @tab          -- GNAT
20752 @item @code{Unsuppress} @tab
20753 @item @code{Value_Size} @tab                    -- GNAT
20754 @item @code{Volatile} @tab
20755 @item @code{Volatile_Components}
20756 @item @code{Warnings} @tab                      -- GNAT
20757 @end multitable
20759 @noindent
20760   Note that for aspects with an expression, e.g. @code{Size}, the expression is
20761   treated like a default expression (visibility is analyzed at the point of
20762   occurrence of the aspect, but evaluation of the expression occurs at the
20763   freeze point of the entity involved).
20765 @noindent
20766   RM References:  3.02.01 (3)   3.02.02 (2)   3.03.01 (2/2)   3.08 (6)
20767   3.09.03 (1.1/2)   6.01 (2/2)   6.07 (2/2)   9.05.02 (2/2)   7.01 (3)   7.03
20768   (2)   7.03 (3)   9.01 (2/2)   9.01 (3/2)   9.04 (2/2)   9.04 (3/2)
20769   9.05.02 (2/2)   11.01 (2)   12.01 (3)   12.03 (2/2)   12.04 (2/2)   12.05 (2)
20770   12.06 (2.1/2)   12.06 (2.2/2)   12.07 (2)   13.01 (0.1/2)   13.03 (5/1)
20771   13.03.01 (0)
20774 @item
20775 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
20776 @cindex AI-0128 (Ada 2012 feature)
20778 @noindent
20779   If an equality operator ("=") is declared for a type, then the implicitly
20780   declared inequality operator ("/=") is a primitive operation of the type.
20781   This is the only reasonable interpretation, and is the one always implemented
20782   by GNAT, but the RM was not entirely clear in making this point.
20784 @noindent
20785   RM References:  3.02.03 (6)   6.06 (6)
20787 @item
20788 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
20789 @cindex AI-0003 (Ada 2012 feature)
20791 @noindent
20792    In Ada 2012, a qualified expression is considered to be syntactically a name,
20793    meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
20794    useful in disambiguating some cases of overloading.
20796 @noindent
20797   RM References:  3.03 (11)   3.03 (21)   4.01 (2)   4.04 (7)   4.07 (3)
20798   5.04 (7)
20800 @item
20801 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
20802 @cindex AI-0120 (Ada 2012 feature)
20804 @noindent
20805   This is an RM editorial change only. The section that lists objects that are
20806   constant failed to include the current instance of a protected object
20807   within a protected function. This has always been treated as a constant
20808   in GNAT.
20810 @noindent
20811   RM References:  3.03 (21)
20813 @item
20814 @emph{AI-0008 General access to constrained objects (0000-00-00)}
20815 @cindex AI-0008 (Ada 2012 feature)
20817 @noindent
20818   The wording in the RM implied that if you have a general access to a
20819   constrained object, it could be used to modify the discriminants. This was
20820   obviously not intended. @code{Constraint_Error} should be raised, and GNAT
20821   has always done so in this situation.
20823 @noindent
20824   RM References:  3.03 (23)   3.10.02 (26/2)   4.01 (9)   6.04.01 (17)   8.05.01 (5/2)
20827 @item
20828 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
20829 @cindex AI-0093 (Ada 2012 feature)
20831 @noindent
20832   This is an editorial change only, to make more widespread use of the Ada 2012
20833   ``immutably limited''.
20835 @noindent
20836   RM References:  3.03 (23.4/3)
20840 @item
20841 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
20842 @cindex AI-0096 (Ada 2012 feature)
20844 @noindent
20845   In general it is illegal for a type derived from a formal limited type to be
20846   nonlimited.  This AI makes an exception to this rule: derivation is legal
20847   if it appears in the private part of the generic, and the formal type is not
20848   tagged. If the type is tagged, the legality check must be applied to the
20849   private part of the package.
20851 @noindent
20852   RM References:  3.04 (5.1/2)   6.02 (7)
20855 @item
20856 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
20857 @cindex AI-0181 (Ada 2012 feature)
20859 @noindent
20860   From Ada 2005 on, soft hyphen is considered a non-graphic character, which
20861   means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
20862   @code{Image} and @code{Value} attributes for the character types. Strictly
20863   speaking this is an inconsistency with Ada 95, but in practice the use of
20864   these attributes is so obscure that it will not cause problems.
20866 @noindent
20867   RM References:  3.05.02 (2/2)   A.01 (35/2)   A.03.03 (21)
20870 @item
20871 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
20872 @cindex AI-0182 (Ada 2012 feature)
20874 @noindent
20875   This AI allows @code{Character'Value} to accept the string @code{'?'} where
20876   @code{?} is any character including non-graphic control characters. GNAT has
20877   always accepted such strings. It also allows strings such as
20878   @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
20879   permission and raises @code{Constraint_Error}, as is certainly still
20880   permitted.
20882 @noindent
20883   RM References:  3.05 (56/2)
20886 @item
20887 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
20888 @cindex AI-0214 (Ada 2012 feature)
20890 @noindent
20891   Ada 2012 relaxes the restriction that forbids discriminants of tagged types
20892   to have default expressions by allowing them when the type is limited. It
20893   is often useful to define a default value for a discriminant even though
20894   it can't be changed by assignment.
20896 @noindent
20897   RM References:  3.07 (9.1/2)   3.07.02 (3)
20900 @item
20901 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
20902 @cindex AI-0102 (Ada 2012 feature)
20904 @noindent
20905   It is illegal to assign an anonymous access constant to an anonymous access
20906   variable. The RM did not have a clear rule to prevent this, but GNAT has
20907   always generated an error for this usage.
20909 @noindent
20910   RM References:  3.07 (16)   3.07.01 (9)   6.04.01 (6)   8.06 (27/2)
20913 @item
20914 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
20915 @cindex AI-0158 (Ada 2012 feature)
20917 @noindent
20918   This AI extends the syntax of membership tests to simplify complex conditions
20919   that can be expressed as membership in a subset of values of any type. It
20920   introduces syntax for a list of expressions that may be used in loop contexts
20921   as well.
20923 @noindent
20924   RM References:  3.08.01 (5)   4.04 (3)   4.05.02 (3)   4.05.02 (5)   4.05.02 (27)
20927 @item
20928 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
20929 @cindex AI-0173 (Ada 2012 feature)
20931 @noindent
20932   The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
20933   with the tag of an abstract type, and @code{False} otherwise.
20935 @noindent
20936   RM References:  3.09 (7.4/2)   3.09 (12.4/2)
20940 @item
20941 @emph{AI-0076 function with controlling result (0000-00-00)}
20942 @cindex AI-0076 (Ada 2012 feature)
20944 @noindent
20945   This is an editorial change only. The RM defines calls with controlling
20946   results, but uses the term ``function with controlling result'' without an
20947   explicit definition.
20949 @noindent
20950   RM References:  3.09.02 (2/2)
20953 @item
20954 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
20955 @cindex AI-0126 (Ada 2012 feature)
20957 @noindent
20958   This AI clarifies dispatching rules, and simply confirms that dispatching
20959   executes the operation of the parent type when there is no explicitly or
20960   implicitly declared operation for the descendant type. This has always been
20961   the case in all versions of GNAT.
20963 @noindent
20964   RM References:  3.09.02 (20/2)   3.09.02 (20.1/2)   3.09.02 (20.2/2)
20967 @item
20968 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
20969 @cindex AI-0097 (Ada 2012 feature)
20971 @noindent
20972   The RM as written implied that in some cases it was possible to create an
20973   object of an abstract type, by having an abstract extension inherit a non-
20974   abstract constructor from its parent type. This mistake has been corrected
20975   in GNAT and in the RM, and this construct is now illegal.
20977 @noindent
20978   RM References:  3.09.03 (4/2)
20981 @item
20982 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
20983 @cindex AI-0203 (Ada 2012 feature)
20985 @noindent
20986   A return_subtype_indication cannot denote an abstract subtype. GNAT has never
20987   permitted such usage.
20989 @noindent
20990   RM References:  3.09.03 (8/3)
20993 @item
20994 @emph{AI-0198 Inheriting abstract operators  (0000-00-00)}
20995 @cindex AI-0198 (Ada 2012 feature)
20997 @noindent
20998   This AI resolves a conflict between two rules involving inherited abstract
20999   operations and predefined operators. If a derived numeric type inherits
21000   an abstract operator, it overrides the predefined one. This interpretation
21001   was always the one implemented in GNAT.
21003 @noindent
21004   RM References:  3.09.03 (4/3)
21006 @item
21007 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
21008 @cindex AI-0073 (Ada 2012 feature)
21010 @noindent
21011   This AI covers a number of issues regarding returning abstract types. In
21012   particular generic functions cannot have abstract result types or access
21013   result types designated an abstract type. There are some other cases which
21014   are detailed in the AI. Note that this binding interpretation has not been
21015   retrofitted to operate before Ada 2012 mode, since it caused a significant
21016   number of regressions.
21018 @noindent
21019   RM References:  3.09.03 (8)   3.09.03 (10)   6.05 (8/2)
21022 @item
21023 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
21024 @cindex AI-0070 (Ada 2012 feature)
21026 @noindent
21027   This is an editorial change only, there are no testable consequences short of
21028   checking for the absence of generated code for an interface declaration.
21030 @noindent
21031   RM References:  3.09.04 (18/2)
21034 @item
21035 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
21036 @cindex AI-0208 (Ada 2012 feature)
21038 @noindent
21039   The wording in the Ada 2005 RM concerning characteristics of incomplete views
21040   was incorrect and implied that some programs intended to be legal were now
21041   illegal. GNAT had never considered such programs illegal, so it has always
21042   implemented the intent of this AI.
21044 @noindent
21045   RM References:  3.10.01 (2.4/2)   3.10.01 (2.6/2)
21048 @item
21049 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
21050 @cindex AI-0162 (Ada 2012 feature)
21052 @noindent
21053   Incomplete types are made more useful by allowing them to be completed by
21054   private types and private extensions.
21056 @noindent
21057   RM References:  3.10.01 (2.5/2)   3.10.01 (2.6/2)   3.10.01 (3)   3.10.01 (4/2)
21061 @item
21062 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
21063 @cindex AI-0098 (Ada 2012 feature)
21065 @noindent
21066   An unintentional omission in the RM implied some inconsistent restrictions on
21067   the use of anonymous access to subprogram values. These restrictions were not
21068   intentional, and have never been enforced by GNAT.
21070 @noindent
21071   RM References:  3.10.01 (6)   3.10.01 (9.2/2)
21074 @item
21075 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
21076 @cindex AI-0199 (Ada 2012 feature)
21078 @noindent
21079   A choice list in a record aggregate can include several components of
21080   (distinct) anonymous access types as long as they have matching designated
21081   subtypes.
21083 @noindent
21084   RM References:  4.03.01 (16)
21087 @item
21088 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
21089 @cindex AI-0220 (Ada 2012 feature)
21091 @noindent
21092   This AI addresses a wording problem in the RM that appears to permit some
21093   complex cases of aggregates with non-static discriminants. GNAT has always
21094   implemented the intended semantics.
21096 @noindent
21097   RM References:  4.03.01 (17)
21099 @item
21100 @emph{AI-0147 Conditional expressions (2009-03-29)}
21101 @cindex AI-0147 (Ada 2012 feature)
21103 @noindent
21104   Conditional expressions are permitted. The form of such an expression is:
21106 @smallexample
21107     (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
21108 @end smallexample
21110   The parentheses can be omitted in contexts where parentheses are present
21111   anyway, such as subprogram arguments and pragma arguments. If the @b{else}
21112   clause is omitted, @b{else True} is assumed;
21113   thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
21114   @emph{(A implies B)} in standard logic.
21116 @noindent
21117   RM References:  4.03.03 (15)   4.04 (1)   4.04 (7)   4.05.07 (0)   4.07 (2)
21118   4.07 (3)   4.09 (12)   4.09 (33)   5.03 (3)   5.03 (4)   7.05 (2.1/2)
21121 @item
21122 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
21123 @cindex AI-0037 (Ada 2012 feature)
21125 @noindent
21126   This AI confirms that an association of the form @code{Indx => <>} in an
21127   array aggregate must raise @code{Constraint_Error} if @code{Indx}
21128   is out of range. The RM specified a range check on other associations, but
21129   not when the value of the association was defaulted. GNAT has always inserted
21130   a constraint check on the index value.
21132 @noindent
21133   RM References:  4.03.03 (29)
21136 @item
21137 @emph{AI-0123 Composability of equality (2010-04-13)}
21138 @cindex AI-0123 (Ada 2012 feature)
21140 @noindent
21141   Equality of untagged record composes, so that the predefined equality for a
21142   composite type that includes a component of some untagged record type
21143   @code{R} uses the equality operation of @code{R} (which may be user-defined
21144   or predefined). This makes the behavior of untagged records identical to that
21145   of tagged types in this respect.
21147   This change is an incompatibility with previous versions of Ada, but it
21148   corrects a non-uniformity that was often a source of confusion. Analysis of
21149   a large number of industrial programs indicates that in those rare cases
21150   where a composite type had an untagged record component with a user-defined
21151   equality, either there was no use of the composite equality, or else the code
21152   expected the same composability as for tagged types, and thus had a bug that
21153   would be fixed by this change.
21155 @noindent
21156   RM References:  4.05.02 (9.7/2)   4.05.02 (14)   4.05.02 (15)   4.05.02 (24)
21157   8.05.04 (8)
21160 @item
21161 @emph{AI-0088 The value of exponentiation (0000-00-00)}
21162 @cindex AI-0088 (Ada 2012 feature)
21164 @noindent
21165   This AI clarifies the equivalence rule given for the dynamic semantics of
21166   exponentiation: the value of the operation can be obtained by repeated
21167   multiplication, but the operation can be implemented otherwise (for example
21168   using the familiar divide-by-two-and-square algorithm, even if this is less
21169   accurate), and does not imply repeated reads of a volatile base.
21171 @noindent
21172   RM References:  4.05.06 (11)
21174 @item
21175 @emph{AI-0188 Case expressions (2010-01-09)}
21176 @cindex AI-0188 (Ada 2012 feature)
21178 @noindent
21179   Case expressions are permitted. This allows use of constructs such as:
21180 @smallexample
21181   X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
21182 @end smallexample
21184 @noindent
21185   RM References:  4.05.07 (0)   4.05.08 (0)   4.09 (12)   4.09 (33)
21187 @item
21188 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
21189 @cindex AI-0104 (Ada 2012 feature)
21191 @noindent
21192   The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
21193   @code{Constraint_Error} because the default value of the allocated object is
21194   @b{null}. This useless construct is illegal in Ada 2012.
21196 @noindent
21197   RM References:  4.08 (2)
21199 @item
21200 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
21201 @cindex AI-0157 (Ada 2012 feature)
21203 @noindent
21204   Allocation and Deallocation from an empty storage pool (i.e. allocation or
21205   deallocation of a pointer for which a static storage size clause of zero
21206   has been given) is now illegal and is detected as such. GNAT
21207   previously gave a warning but not an error.
21209 @noindent
21210   RM References:  4.08 (5.3/2)   13.11.02 (4)   13.11.02 (17)
21212 @item
21213 @emph{AI-0179 Statement not required after label (2010-04-10)}
21214 @cindex AI-0179 (Ada 2012 feature)
21216 @noindent
21217   It is not necessary to have a statement following a label, so a label
21218   can appear at the end of a statement sequence without the need for putting a
21219   null statement afterwards, but it is not allowable to have only labels and
21220   no real statements in a statement sequence.
21222 @noindent
21223   RM References:  5.01 (2)
21226 @item
21227 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
21228 @cindex AI-139-2 (Ada 2012 feature)
21230 @noindent
21231   The new syntax for iterating over arrays and containers is now implemented.
21232   Iteration over containers is for now limited to read-only iterators. Only
21233   default iterators are supported, with the syntax:  @code{@b{for} Elem @b{of} C}.
21235 @noindent
21236   RM References:  5.05
21238 @item
21239 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
21240 @cindex AI-0134 (Ada 2012 feature)
21242 @noindent
21243   For full conformance, the profiles of anonymous-access-to-subprogram
21244   parameters must match. GNAT has always enforced this rule.
21246 @noindent
21247   RM References:  6.03.01 (18)
21249 @item
21250 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
21251 @cindex AI-0207 (Ada 2012 feature)
21253 @noindent
21254   This AI confirms that access_to_constant indication must match for mode
21255   conformance. This was implemented in GNAT when the qualifier was originally
21256   introduced in Ada 2005.
21258 @noindent
21259   RM References:  6.03.01 (16/2)
21262 @item
21263 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
21264 @cindex AI-0046 (Ada 2012 feature)
21266 @noindent
21267   For full conformance, in the case of access parameters, the null exclusion
21268   must match (either both or neither must have @code{@b{not null}}).
21270 @noindent
21271   RM References:  6.03.02 (18)
21274 @item
21275 @emph{AI-0118 The association of parameter associations (0000-00-00)}
21276 @cindex AI-0118 (Ada 2012 feature)
21278 @noindent
21279   This AI clarifies the rules for named associations in subprogram calls and
21280   generic instantiations. The rules have been in place since Ada 83.
21282 @noindent
21283   RM References:  6.04.01 (2)   12.03 (9)
21286 @item
21287 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
21288 @cindex AI-0196 (Ada 2012 feature)
21290 @noindent
21291   Null exclusion checks are not made for @code{@b{out}} parameters when
21292   evaluating the actual parameters. GNAT has never generated these checks.
21294 @noindent
21295   RM References:  6.04.01 (13)
21297 @item
21298 @emph{AI-0015 Constant return objects (0000-00-00)}
21299 @cindex AI-0015 (Ada 2012 feature)
21301 @noindent
21302   The return object declared in an @i{extended_return_statement} may be
21303   declared constant. This was always intended, and GNAT has always allowed it.
21305 @noindent
21306   RM References:  6.05 (2.1/2)   3.03 (10/2)   3.03 (21)   6.05 (5/2)
21307   6.05 (5.7/2)
21310 @item
21311 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
21312 @cindex AI-0032 (Ada 2012 feature)
21314 @noindent
21315   If a function returns a class-wide type, the object of an extended return
21316   statement can be declared with a specific type that is covered by the class-
21317   wide type. This has been implemented in GNAT since the introduction of
21318   extended returns. Note AI-0103 complements this AI by imposing matching
21319   rules for constrained return types.
21321 @noindent
21322   RM References:  6.05 (5.2/2)   6.05 (5.3/2)   6.05 (5.6/2)   6.05 (5.8/2)
21323   6.05 (8/2)
21325 @item
21326 @emph{AI-0103 Static matching for extended return (2010-07-23)}
21327 @cindex AI-0103 (Ada 2012 feature)
21329 @noindent
21330   If the return subtype of a function is an elementary type or a constrained
21331   type, the subtype indication in an extended return statement must match
21332   statically this return subtype.
21334 @noindent
21335   RM References:  6.05 (5.2/2)
21338 @item
21339 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
21340 @cindex AI-0058 (Ada 2012 feature)
21342 @noindent
21343   The RM had some incorrect wording implying wrong treatment of abnormal
21344   completion in an extended return. GNAT has always implemented the intended
21345   correct semantics as described by this AI.
21347 @noindent
21348   RM References:  6.05 (22/2)
21351 @item
21352 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
21353 @cindex AI-0050 (Ada 2012 feature)
21355 @noindent
21356   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
21357   not take advantage of these incorrect permissions in any case.
21359 @noindent
21360   RM References:  6.05 (24/2)
21363 @item
21364 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
21365 @cindex AI-0125 (Ada 2012 feature)
21367 @noindent
21368   In Ada 2012, the declaration of a primitive operation of a type extension
21369   or private extension can also override an inherited primitive that is not
21370   visible at the point of this declaration.
21372 @noindent
21373   RM References:  7.03.01 (6)   8.03 (23)   8.03.01 (5/2)   8.03.01 (6/2)
21375 @item
21376 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
21377 @cindex AI-0062 (Ada 2012 feature)
21379 @noindent
21380   A full constant may have a null exclusion even if its associated deferred
21381   constant does not. GNAT has always allowed this.
21383 @noindent
21384   RM References:  7.04 (6/2)   7.04 (7.1/2)
21387 @item
21388 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
21389 @cindex AI-0178 (Ada 2012 feature)
21391 @noindent
21392   This AI clarifies the role of incomplete views and plugs an omission in the
21393   RM. GNAT always correctly restricted the use of incomplete views and types.
21395 @noindent
21396   RM References:  7.05 (3/2)   7.05 (6/2)
21398 @item
21399 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
21400 @cindex AI-0087 (Ada 2012 feature)
21402 @noindent
21403   The actual for a formal nonlimited derived type cannot be limited. In
21404   particular, a formal derived type that extends a limited interface but which
21405   is not explicitly limited cannot be instantiated with a limited type.
21407 @noindent
21408   RM References:  7.05 (5/2)   12.05.01 (5.1/2)
21410 @item
21411 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
21412 @cindex AI-0099 (Ada 2012 feature)
21414 @noindent
21415   This AI clarifies that ``needs finalization'' is part of dynamic semantics,
21416   and therefore depends on the run-time characteristics of an object (i.e. its
21417   tag) and not on its nominal type. As the AI indicates: ``we do not expect
21418   this to affect any implementation''.
21420 @noindent
21421   RM References:  7.06.01 (6)   7.06.01 (7)   7.06.01 (8)   7.06.01 (9/2)
21425 @item
21426 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
21427 @cindex AI-0064 (Ada 2012 feature)
21429 @noindent
21430   This is an editorial change only. The intended behavior is already checked
21431   by an existing ACATS test, which GNAT has always executed correctly.
21433 @noindent
21434   RM References:  7.06.01 (17.1/1)
21436 @item
21437 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
21438 @cindex AI-0026 (Ada 2012 feature)
21440 @noindent
21441   Record representation clauses concerning Unchecked_Union types cannot mention
21442   the discriminant of the type. The type of a component declared in the variant
21443   part of an Unchecked_Union cannot be controlled, have controlled components,
21444   nor have protected or task parts. If an Unchecked_Union type is declared
21445   within the body of a generic unit or its descendants, then the type of a
21446   component declared in the variant part cannot be a formal private type or a
21447   formal private extension declared within the same generic unit.
21449 @noindent
21450   RM References:  7.06 (9.4/2)   B.03.03 (9/2)   B.03.03 (10/2)
21453 @item
21454 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
21455 @cindex AI-0205 (Ada 2012 feature)
21457 @noindent
21458   This AI corrects a simple omission in the RM. Return objects have always
21459   been visible within an extended return statement.
21461 @noindent
21462   RM References:  8.03 (17)
21465 @item
21466 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
21467 @cindex AI-0042 (Ada 2012 feature)
21469 @noindent
21470   This AI fixes a wording gap in the RM. An operation of a synchronized
21471   interface can be implemented by a protected or task entry, but the abstract
21472   operation is not being overridden in the usual sense, and it must be stated
21473   separately that this implementation is legal. This has always been the case
21474   in GNAT.
21476 @noindent
21477   RM References:  9.01 (9.2/2)   9.04 (11.1/2)
21479 @item
21480 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
21481 @cindex AI-0030 (Ada 2012 feature)
21483 @noindent
21484   Requeue is permitted to a protected, synchronized or task interface primitive
21485   providing it is known that the overriding operation is an entry. Otherwise
21486   the requeue statement has the same effect as a procedure call. Use of pragma
21487   @code{Implemented} provides a way to impose a static requirement on the
21488   overriding operation by adhering to one of the implementation kinds: entry,
21489   protected procedure or any of the above.
21491 @noindent
21492   RM References:  9.05 (9)   9.05.04 (2)   9.05.04 (3)   9.05.04 (5)
21493   9.05.04 (6)   9.05.04 (7)   9.05.04 (12)
21496 @item
21497 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
21498 @cindex AI-0201 (Ada 2012 feature)
21500 @noindent
21501   If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
21502   attribute, then individual components may not be addressable by independent
21503   tasks. However, if the representation clause has no effect (is confirming),
21504   then independence is not compromised. Furthermore, in GNAT, specification of
21505   other appropriately addressable component sizes (e.g. 16 for 8-bit
21506   characters) also preserves independence. GNAT now gives very clear warnings
21507   both for the declaration of such a type, and for any assignment to its components.
21509 @noindent
21510   RM References:  9.10 (1/3)   C.06 (22/2)   C.06 (23/2)
21512 @item
21513 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
21514 @cindex AI-0009 (Ada 2012 feature)
21516 @noindent
21517   This AI introduces the new pragmas @code{Independent} and
21518   @code{Independent_Components},
21519   which control guaranteeing independence of access to objects and components.
21520   The AI also requires independence not unaffected by confirming rep clauses.
21522 @noindent
21523   RM References:  9.10 (1)   13.01 (15/1)   13.02 (9)   13.03 (13)   C.06 (2)
21524   C.06 (4)   C.06 (6)   C.06 (9)   C.06 (13)   C.06 (14)
21527 @item
21528 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
21529 @cindex AI-0072 (Ada 2012 feature)
21531 @noindent
21532   This AI clarifies that task signalling for reading @code{'Terminated} only
21533   occurs if the result is True. GNAT semantics has always been consistent with
21534   this notion of task signalling.
21536 @noindent
21537   RM References:  9.10 (6.1/1)
21539 @item
21540 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
21541 @cindex AI-0108 (Ada 2012 feature)
21543 @noindent
21544   This AI confirms that an incomplete type from a limited view does not have
21545   discriminants. This has always been the case in GNAT.
21547 @noindent
21548   RM References:  10.01.01 (12.3/2)
21550 @item
21551 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
21552 @cindex AI-0129 (Ada 2012 feature)
21554 @noindent
21555   This AI clarifies the description of limited views: a limited view of a
21556   package includes only one view of a type that has an incomplete declaration
21557   and a full declaration (there is no possible ambiguity in a client package).
21558   This AI also fixes an omission: a nested package in the private part has no
21559   limited view. GNAT always implemented this correctly.
21561 @noindent
21562   RM References:  10.01.01 (12.2/2)   10.01.01 (12.3/2)
21566 @item
21567 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
21568 @cindex AI-0077 (Ada 2012 feature)
21570 @noindent
21571   This AI clarifies that a declaration does not include a context clause,
21572   and confirms that it is illegal to have a context in which both a limited
21573   and a nonlimited view of a package are accessible. Such double visibility
21574   was always rejected by GNAT.
21576 @noindent
21577   RM References:  10.01.02 (12/2)   10.01.02 (21/2)   10.01.02 (22/2)
21579 @item
21580 @emph{AI-0122 Private with and children of generics (0000-00-00)}
21581 @cindex AI-0122 (Ada 2012 feature)
21583 @noindent
21584   This AI clarifies the visibility of private children of generic units within
21585   instantiations of a parent. GNAT has always handled this correctly.
21587 @noindent
21588   RM References:  10.01.02 (12/2)
21592 @item
21593 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
21594 @cindex AI-0040 (Ada 2012 feature)
21596 @noindent
21597   This AI confirms that a limited with clause in a child unit cannot name
21598   an ancestor of the unit. This has always been checked in GNAT.
21600 @noindent
21601   RM References:  10.01.02 (20/2)
21603 @item
21604 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
21605 @cindex AI-0132 (Ada 2012 feature)
21607 @noindent
21608   This AI fills a gap in the description of library unit pragmas. The pragma
21609   clearly must apply to a library unit, even if it does not carry the name
21610   of the enclosing unit. GNAT has always enforced the required check.
21612 @noindent
21613   RM References:  10.01.05 (7)
21616 @item
21617 @emph{AI-0034 Categorization of limited views (0000-00-00)}
21618 @cindex AI-0034 (Ada 2012 feature)
21620 @noindent
21621   The RM makes certain limited with clauses illegal because of categorization
21622   considerations, when the corresponding normal with would be legal. This is
21623   not intended, and GNAT has always implemented the recommended behavior.
21625 @noindent
21626   RM References:  10.02.01 (11/1)   10.02.01 (17/2)
21629 @item
21630 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
21631 @cindex AI-0035 (Ada 2012 feature)
21633 @noindent
21634   This AI remedies some inconsistencies in the legality rules for Pure units.
21635   Derived access types are legal in a pure unit (on the assumption that the
21636   rule for a zero storage pool size has been enforced on the ancestor type).
21637   The rules are enforced in generic instances and in subunits. GNAT has always
21638   implemented the recommended behavior.
21640 @noindent
21641   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)
21644 @item
21645 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
21646 @cindex AI-0219 (Ada 2012 feature)
21648 @noindent
21649   This AI refines the rules for the cases with limited parameters which do not
21650   allow the implementations to omit ``redundant''. GNAT now properly conforms
21651   to the requirements of this binding interpretation.
21653 @noindent
21654   RM References:  10.02.01 (18/2)
21656 @item
21657 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
21658 @cindex AI-0043 (Ada 2012 feature)
21660 @noindent
21661   This AI covers various omissions in the RM regarding the raising of
21662   exceptions. GNAT has always implemented the intended semantics.
21664 @noindent
21665   RM References:  11.04.01 (10.1/2)   11 (2)
21668 @item
21669 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
21670 @cindex AI-0200 (Ada 2012 feature)
21672 @noindent
21673   This AI plugs a gap in the RM which appeared to allow some obviously intended
21674   illegal instantiations. GNAT has never allowed these instantiations.
21676 @noindent
21677   RM References:  12.07 (16)
21680 @item
21681 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
21682 @cindex AI-0112 (Ada 2012 feature)
21684 @noindent
21685   This AI concerns giving names to various representation aspects, but the
21686   practical effect is simply to make the use of duplicate
21687   @code{Atomic}[@code{_Components}],
21688   @code{Volatile}[@code{_Components}] and
21689   @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
21690   now performs this required check.
21692 @noindent
21693   RM References:  13.01 (8)
21695 @item
21696 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
21697 @cindex AI-0106 (Ada 2012 feature)
21699 @noindent
21700   The RM appeared to allow representation pragmas on generic formal parameters,
21701   but this was not intended, and GNAT has never permitted this usage.
21703 @noindent
21704   RM References:  13.01 (9.1/1)
21707 @item
21708 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
21709 @cindex AI-0012 (Ada 2012 feature)
21711 @noindent
21712   It is now illegal to give an inappropriate component size or a pragma
21713   @code{Pack} that attempts to change the component size in the case of atomic
21714   or aliased components. Previously GNAT ignored such an attempt with a
21715   warning.
21717 @noindent
21718   RM References:  13.02 (6.1/2)   13.02 (7)   C.06 (10)   C.06 (11)   C.06 (21)
21721 @item
21722 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
21723 @cindex AI-0039 (Ada 2012 feature)
21725 @noindent
21726   The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
21727   for stream attributes, but these were never useful and are now illegal. GNAT
21728   has always regarded such expressions as illegal.
21730 @noindent
21731   RM References:  13.03 (4)   13.03 (6)   13.13.02 (38/2)
21734 @item
21735 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
21736 @cindex AI-0095 (Ada 2012 feature)
21738 @noindent
21739   The prefix of @code{'Address} cannot statically denote a subprogram with
21740   convention @code{Intrinsic}. The use of the @code{Address} attribute raises
21741   @code{Program_Error} if the prefix denotes a subprogram with convention
21742   @code{Intrinsic}.
21744 @noindent
21745   RM References:  13.03 (11/1)
21748 @item
21749 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
21750 @cindex AI-0116 (Ada 2012 feature)
21752 @noindent
21753   This AI requires that the alignment of a class-wide object be no greater
21754   than the alignment of any type in the class. GNAT has always followed this
21755   recommendation.
21757 @noindent
21758   RM References:  13.03 (29)   13.11 (16)
21761 @item
21762 @emph{AI-0146 Type invariants (2009-09-21)}
21763 @cindex AI-0146 (Ada 2012 feature)
21765 @noindent
21766   Type invariants may be specified for private types using the aspect notation.
21767   Aspect @code{Type_Invariant} may be specified for any private type,
21768   @code{Type_Invariant'Class} can
21769   only be specified for tagged types, and is inherited by any descendent of the
21770   tagged types. The invariant is a boolean expression that is tested for being
21771   true in the following situations: conversions to the private type, object
21772   declarations for the private type that are default initialized, and
21773   [@b{in}] @b{out}
21774   parameters and returned result on return from any primitive operation for
21775   the type that is visible to a client.
21776   GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
21777   @code{Invariant'Class} for @code{Type_Invariant'Class}.
21779 @noindent
21780   RM References:  13.03.03 (00)
21782 @item
21783 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
21784 @cindex AI-0078 (Ada 2012 feature)
21786 @noindent
21787   In Ada 2012, compilers are required to support unchecked conversion where the
21788   target alignment is a multiple of the source alignment. GNAT always supported
21789   this case (and indeed all cases of differing alignments, doing copies where
21790   required if the alignment was reduced).
21792 @noindent
21793   RM References:  13.09 (7)
21796 @item
21797 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
21798 @cindex AI-0195 (Ada 2012 feature)
21800 @noindent
21801   The handling of invalid values is now designated to be implementation
21802   defined. This is a documentation change only, requiring Annex M in the GNAT
21803   Reference Manual to document this handling.
21804   In GNAT, checks for invalid values are made
21805   only when necessary to avoid erroneous behavior. Operations like assignments
21806   which cannot cause erroneous behavior ignore the possibility of invalid
21807   values and do not do a check. The date given above applies only to the
21808   documentation change, this behavior has always been implemented by GNAT.
21810 @noindent
21811   RM References:  13.09.01 (10)
21813 @item
21814 @emph{AI-0193 Alignment of allocators (2010-09-16)}
21815 @cindex AI-0193 (Ada 2012 feature)
21817 @noindent
21818   This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
21819   analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
21820   of size.
21822 @noindent
21823   RM References:  13.11 (16)   13.11 (21)   13.11.01 (0)   13.11.01 (1)
21824   13.11.01 (2)   13.11.01 (3)
21827 @item
21828 @emph{AI-0177 Parameterized expressions (2010-07-10)}
21829 @cindex AI-0177 (Ada 2012 feature)
21831 @noindent
21832   The new Ada 2012 notion of parameterized expressions is implemented. The form
21833   is:
21834 @smallexample
21835   @i{function specification} @b{is} (@i{expression})
21836 @end smallexample
21838 @noindent
21839   This is exactly equivalent to the
21840   corresponding function body that returns the expression, but it can appear
21841   in a package spec. Note that the expression must be parenthesized.
21843 @noindent
21844   RM References:  13.11.01 (3/2)
21846 @item
21847 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
21848 @cindex AI-0033 (Ada 2012 feature)
21850 @noindent
21851   Neither of these two pragmas may appear within a generic template, because
21852   the generic might be instantiated at other than the library level.
21854 @noindent
21855   RM References:  13.11.02 (16)   C.03.01 (7/2)   C.03.01 (8/2)
21858 @item
21859 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
21860 @cindex AI-0161 (Ada 2012 feature)
21862 @noindent
21863   A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
21864   of the default stream attributes for elementary types. If this restriction is
21865   in force, then it is necessary to provide explicit subprograms for any
21866   stream attributes used.
21868 @noindent
21869   RM References:  13.12.01 (4/2)   13.13.02 (40/2)   13.13.02 (52/2)
21871 @item
21872 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
21873 @cindex AI-0194 (Ada 2012 feature)
21875 @noindent
21876   The @code{Stream_Size} attribute returns the default number of bits in the
21877   stream representation of the given type.
21878   This value is not affected by the presence
21879   of stream subprogram attributes for the type. GNAT has always implemented
21880   this interpretation.
21882 @noindent
21883   RM References:  13.13.02 (1.2/2)
21885 @item
21886 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
21887 @cindex AI-0109 (Ada 2012 feature)
21889 @noindent
21890   This AI is an editorial change only. It removes the need for a tag check
21891   that can never fail.
21893 @noindent
21894   RM References:  13.13.02 (34/2)
21896 @item
21897 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
21898 @cindex AI-0007 (Ada 2012 feature)
21900 @noindent
21901   The RM as written appeared to limit the possibilities of declaring read
21902   attribute procedures for private scalar types. This limitation was not
21903   intended, and has never been enforced by GNAT.
21905 @noindent
21906   RM References:  13.13.02 (50/2)   13.13.02 (51/2)
21909 @item
21910 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
21911 @cindex AI-0065 (Ada 2012 feature)
21913 @noindent
21914   This AI clarifies the fact that all remote access types support external
21915   streaming. This fixes an obvious oversight in the definition of the
21916   language, and GNAT always implemented the intended correct rules.
21918 @noindent
21919   RM References:  13.13.02 (52/2)
21921 @item
21922 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
21923 @cindex AI-0019 (Ada 2012 feature)
21925 @noindent
21926   The RM suggests that primitive subprograms of a specific tagged type are
21927   frozen when the tagged type is frozen. This would be an incompatible change
21928   and is not intended. GNAT has never attempted this kind of freezing and its
21929   behavior is consistent with the recommendation of this AI.
21931 @noindent
21932   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)
21934 @item
21935 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
21936 @cindex AI-0017 (Ada 2012 feature)
21938 @noindent
21939   So-called ``Taft-amendment types'' (i.e., types that are completed in package
21940   bodies) are not frozen by the occurrence of bodies in the
21941   enclosing declarative part. GNAT always implemented this properly.
21943 @noindent
21944   RM References:  13.14 (3/1)
21947 @item
21948 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
21949 @cindex AI-0060 (Ada 2012 feature)
21951 @noindent
21952   This AI extends the definition of remote access types to include access
21953   to limited, synchronized, protected or task class-wide interface types.
21954   GNAT already implemented this extension.
21956 @noindent
21957   RM References:  A (4)   E.02.02 (9/1)   E.02.02 (9.2/1)   E.02.02 (14/2)   E.02.02 (18)
21959 @item
21960 @emph{AI-0114 Classification of letters (0000-00-00)}
21961 @cindex AI-0114 (Ada 2012 feature)
21963 @noindent
21964   The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
21965   181 (@code{MICRO SIGN}), and
21966   186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
21967   lower case letters by Unicode.
21968   However, they are not allowed in identifiers, and they
21969   return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
21970   This behavior is consistent with that defined in Ada 95.
21972 @noindent
21973   RM References:  A.03.02 (59)   A.04.06 (7)
21976 @item
21977 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
21978 @cindex AI-0185 (Ada 2012 feature)
21980 @noindent
21981   Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
21982   classification functions for @code{Wide_Character} and
21983   @code{Wide_Wide_Character}, as well as providing
21984   case folding routines for @code{Wide_[Wide_]Character} and
21985   @code{Wide_[Wide_]String}.
21987 @noindent
21988   RM References:  A.03.05 (0)   A.03.06 (0)
21991 @item
21992 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
21993 @cindex AI-0031 (Ada 2012 feature)
21995 @noindent
21996   A new version of @code{Find_Token} is added to all relevant string packages,
21997   with an extra parameter @code{From}. Instead of starting at the first
21998   character of the string, the search for a matching Token starts at the
21999   character indexed by the value of @code{From}.
22000   These procedures are available in all versions of Ada
22001   but if used in versions earlier than Ada 2012 they will generate a warning
22002   that an Ada 2012 subprogram is being used.
22004 @noindent
22005   RM References:  A.04.03 (16)   A.04.03 (67)   A.04.03 (68/1)   A.04.04 (51)
22006   A.04.05 (46)
22009 @item
22010 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
22011 @cindex AI-0056 (Ada 2012 feature)
22013 @noindent
22014   The wording in the Ada 2005 RM implied an incompatible handling of the
22015   @code{Index} functions, resulting in raising an exception instead of
22016   returning zero in some situations.
22017   This was not intended and has been corrected.
22018   GNAT always returned zero, and is thus consistent with this AI.
22020 @noindent
22021   RM References:  A.04.03 (56.2/2)   A.04.03 (58.5/2)
22024 @item
22025 @emph{AI-0137 String encoding package (2010-03-25)}
22026 @cindex AI-0137 (Ada 2012 feature)
22028 @noindent
22029   The packages @code{Ada.Strings.UTF_Encoding}, together with its child
22030   packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
22031   and @code{Wide_Wide_Strings} have been
22032   implemented. These packages (whose documentation can be found in the spec
22033   files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
22034   @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
22035   @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
22036   values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
22037   UTF-16), as well as conversions between the different UTF encodings. With
22038   the exception of @code{Wide_Wide_Strings}, these packages are available in
22039   Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
22040   The @code{Wide_Wide_Strings package}
22041   is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
22042   mode since it uses @code{Wide_Wide_Character}).
22044 @noindent
22045   RM References:  A.04.11
22047 @item
22048 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
22049 @cindex AI-0038 (Ada 2012 feature)
22051 @noindent
22052   These are minor errors in the description on three points. The intent on
22053   all these points has always been clear, and GNAT has always implemented the
22054   correct intended semantics.
22056 @noindent
22057   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)
22059 @item
22060 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
22061 @cindex AI-0044 (Ada 2012 feature)
22063 @noindent
22064   This AI places restrictions on allowed instantiations of generic containers.
22065   These restrictions are not checked by the compiler, so there is nothing to
22066   change in the implementation. This affects only the RM documentation.
22068 @noindent
22069   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)
22071 @item
22072 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
22073 @cindex AI-0127 (Ada 2012 feature)
22075 @noindent
22076   This package provides an interface for identifying the current locale.
22078 @noindent
22079   RM References:  A.19    A.19.01    A.19.02    A.19.03    A.19.05    A.19.06
22080   A.19.07    A.19.08    A.19.09    A.19.10    A.19.11    A.19.12    A.19.13
22084 @item
22085 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
22086 @cindex AI-0002 (Ada 2012 feature)
22088 @noindent
22089   The compiler is not required to support exporting an Ada subprogram with
22090   convention C if there are parameters or a return type of an unconstrained
22091   array type (such as @code{String}). GNAT allows such declarations but
22092   generates warnings. It is possible, but complicated, to write the
22093   corresponding C code and certainly such code would be specific to GNAT and
22094   non-portable.
22096 @noindent
22097   RM References:  B.01 (17)   B.03 (62)   B.03 (71.1/2)
22100 @item
22101 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
22102 @cindex AI05-0216 (Ada 2012 feature)
22104 @noindent
22105   It is clearly the intention that @code{No_Task_Hierarchy} is intended to
22106   forbid tasks declared locally within subprograms, or functions returning task
22107   objects, and that is the implementation that GNAT has always provided.
22108   However the language in the RM was not sufficiently clear on this point.
22109   Thus this is a documentation change in the RM only.
22111 @noindent
22112   RM References:  D.07 (3/3)
22114 @item
22115 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
22116 @cindex AI-0211 (Ada 2012 feature)
22118 @noindent
22119   The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
22120   @code{Ada.Real_Time.Timing_Events.Set_Handler}.
22122 @noindent
22123   RM References:  D.07 (5)   D.07 (10/2)   D.07 (10.4/2)   D.07 (10.7/2)
22125 @item
22126 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
22127 @cindex AI-0190 (Ada 2012 feature)
22129 @noindent
22130   This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
22131   used to control storage pools globally.
22132   In particular, you can force every access
22133   type that is used for allocation (@b{new}) to have an explicit storage pool,
22134   or you can declare a pool globally to be used for all access types that lack
22135   an explicit one.
22137 @noindent
22138   RM References:  D.07 (8)
22140 @item
22141 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
22142 @cindex AI-0189 (Ada 2012 feature)
22144 @noindent
22145   This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
22146   which says that no dynamic allocation will occur once elaboration is
22147   completed.
22148   In general this requires a run-time check, which is not required, and which
22149   GNAT does not attempt. But the static cases of allocators in a task body or
22150   in the body of the main program are detected and flagged at compile or bind
22151   time.
22153 @noindent
22154   RM References:  D.07 (19.1/2)   H.04 (23.3/2)
22156 @item
22157 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
22158 @cindex AI-0171 (Ada 2012 feature)
22160 @noindent
22161   A new package @code{System.Multiprocessors} is added, together with the
22162   definition of pragma @code{CPU} for controlling task affinity. A new no
22163   dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
22164   is added to the Ravenscar profile.
22166 @noindent
22167   RM References:  D.13.01 (4/2)   D.16
22170 @item
22171 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
22172 @cindex AI-0210 (Ada 2012 feature)
22174 @noindent
22175   This is a documentation only issue regarding wording of metric requirements,
22176   that does not affect the implementation of the compiler.
22178 @noindent
22179   RM References:  D.15 (24/2)
22182 @item
22183 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
22184 @cindex AI-0206 (Ada 2012 feature)
22186 @noindent
22187   Remote types packages are now allowed to depend on preelaborated packages.
22188   This was formerly considered illegal.
22190 @noindent
22191   RM References:  E.02.02 (6)
22195 @item
22196 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
22197 @cindex AI-0152 (Ada 2012 feature)
22199 @noindent
22200   Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
22201   where the type of the returned value is an anonymous access type.
22203 @noindent
22204   RM References:  H.04 (8/1)
22205 @end itemize
22208 @node Obsolescent Features
22209 @chapter Obsolescent Features
22211 @noindent
22212 This chapter describes features that are provided by GNAT, but are
22213 considered obsolescent since there are preferred ways of achieving
22214 the same effect. These features are provided solely for historical
22215 compatibility purposes.
22217 @menu
22218 * pragma No_Run_Time::
22219 * pragma Ravenscar::
22220 * pragma Restricted_Run_Time::
22221 @end menu
22223 @node pragma No_Run_Time
22224 @section pragma No_Run_Time
22226 The pragma @code{No_Run_Time} is used to achieve an affect similar
22227 to the use of the "Zero Foot Print" configurable run time, but without
22228 requiring a specially configured run time. The result of using this
22229 pragma, which must be used for all units in a partition, is to restrict
22230 the use of any language features requiring run-time support code. The
22231 preferred usage is to use an appropriately configured run-time that
22232 includes just those features that are to be made accessible.
22234 @node pragma Ravenscar
22235 @section pragma Ravenscar
22237 The pragma @code{Ravenscar} has exactly the same effect as pragma
22238 @code{Profile (Ravenscar)}. The latter usage is preferred since it
22239 is part of the new Ada 2005 standard.
22241 @node pragma Restricted_Run_Time
22242 @section pragma Restricted_Run_Time
22244 The pragma @code{Restricted_Run_Time} has exactly the same effect as
22245 pragma @code{Profile (Restricted)}. The latter usage is
22246 preferred since the Ada 2005 pragma @code{Profile} is intended for
22247 this kind of implementation dependent addition.
22249 @include fdl.texi
22250 @c GNU Free Documentation License
22252 @node Index,,GNU Free Documentation License, Top
22253 @unnumbered Index
22255 @printindex cp
22257 @contents
22259 @bye
22260 tablishes the following set of restrictions:
22261 Pragma Shared