PR target/58115
[official-gcc.git] / gcc / ada / gnat_rm.texi
blob5dcfbe8663424f559d19342e34164e4461084398
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
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
32 @settitle GNAT Reference Manual
34 @setchapternewpage odd
35 @syncodeindex fn cp
37 @include gcc-common.texi
39 @dircategory GNU Ada tools
40 @direntry
41 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
42 @end direntry
44 @titlepage
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
47 @versionsubtitle
48 @author AdaCore
49 @page
50 @vskip 0pt plus 1filll
52 @insertcopying
54 @end titlepage
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
60 @noindent
61 GNAT Reference Manual
63 @noindent
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
67 @noindent
68 AdaCore
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Aspects::
74 * Implementation Defined Attributes::
75 * Standard and Implementation Defined Restrictions::
76 * Implementation Advice::
77 * Implementation Defined Characteristics::
78 * Intrinsic Subprograms::
79 * Representation Clauses and Pragmas::
80 * Standard Library Routines::
81 * The Implementation of Standard I/O::
82 * The GNAT Library::
83 * Interfacing to Other Languages::
84 * Specialized Needs Annexes::
85 * Implementation of Specific Ada Features::
86 * Implementation of Ada 2012 Features::
87 * Obsolescent Features::
88 * GNU Free Documentation License::
89 * Index::
91  --- The Detailed Node Listing ---
93 About This Guide
95 * What This Reference Manual Contains::
96 * Related Information::
98 Implementation Defined Pragmas
100 * Pragma Abort_Defer::
101 * Pragma Ada_83::
102 * Pragma Ada_95::
103 * Pragma Ada_05::
104 * Pragma Ada_2005::
105 * Pragma Ada_12::
106 * Pragma Ada_2012::
107 * Pragma 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 Complete_Representation::
127 * Pragma Complex_Representation::
128 * Pragma Component_Alignment::
129 * Pragma Contract_Cases::
130 * Pragma Convention_Identifier::
131 * Pragma CPP_Class::
132 * Pragma CPP_Constructor::
133 * Pragma CPP_Virtual::
134 * Pragma CPP_Vtable::
135 * Pragma CPU::
136 * Pragma Debug::
137 * Pragma Debug_Policy::
138 * Pragma Default_Storage_Pool::
139 * Pragma Detect_Blocking::
140 * Pragma Disable_Atomic_Synchronization::
141 * Pragma Dispatching_Domain::
142 * Pragma Elaboration_Checks::
143 * Pragma Eliminate::
144 * Pragma Enable_Atomic_Synchronization::
145 * Pragma Export_Exception::
146 * Pragma Export_Function::
147 * Pragma Export_Object::
148 * Pragma Export_Procedure::
149 * Pragma Export_Value::
150 * Pragma Export_Valued_Procedure::
151 * Pragma Extend_System::
152 * Pragma Extensions_Allowed::
153 * Pragma External::
154 * Pragma External_Name_Casing::
155 * Pragma Fast_Math::
156 * Pragma Favor_Top_Level::
157 * Pragma Finalize_Storage_Only::
158 * Pragma Float_Representation::
159 * Pragma Ident::
160 * Pragma Implementation_Defined::
161 * Pragma Implemented::
162 * Pragma Implicit_Packing::
163 * Pragma Import_Exception::
164 * Pragma Import_Function::
165 * Pragma Import_Object::
166 * Pragma Import_Procedure::
167 * Pragma Import_Valued_Procedure::
168 * Pragma Independent::
169 * Pragma Independent_Components::
170 * Pragma Initialize_Scalars::
171 * Pragma Inline_Always::
172 * Pragma Inline_Generic::
173 * Pragma Interface::
174 * Pragma Interface_Name::
175 * Pragma Interrupt_Handler::
176 * Pragma Interrupt_State::
177 * Pragma Invariant::
178 * Pragma Java_Constructor::
179 * Pragma Java_Interface::
180 * Pragma Keep_Names::
181 * Pragma License::
182 * Pragma Link_With::
183 * Pragma Linker_Alias::
184 * Pragma Linker_Constructor::
185 * Pragma Linker_Destructor::
186 * Pragma Linker_Section::
187 * Pragma Long_Float::
188 * Pragma Loop_Invariant::
189 * Pragma Loop_Optimize::
190 * Pragma Loop_Variant::
191 * Pragma Machine_Attribute::
192 * Pragma Main::
193 * Pragma Main_Storage::
194 * Pragma No_Body::
195 * Pragma No_Inline::
196 * Pragma No_Return::
197 * Pragma No_Run_Time::
198 * Pragma No_Strict_Aliasing ::
199 * Pragma Normalize_Scalars::
200 * Pragma Obsolescent::
201 * Pragma Optimize_Alignment::
202 * Pragma Ordered::
203 * Pragma Overflow_Mode::
204 * Pragma Overriding_Renamings::
205 * Pragma Partition_Elaboration_Policy::
206 * Pragma Passive::
207 * Pragma Persistent_BSS::
208 * Pragma Polling::
209 * Pragma Post::
210 * Pragma Postcondition::
211 * Pragma Post_Class::
212 * Pragma Pre::
213 * Pragma Precondition::
214 * Pragma Predicate::
215 * Pragma Preelaborable_Initialization::
216 * Pragma Preelaborate_05::
217 * Pragma Pre_Class::
218 * Pragma Priority_Specific_Dispatching::
219 * Pragma Profile::
220 * Pragma Profile_Warnings::
221 * Pragma Propagate_Exceptions::
222 * Pragma Psect_Object::
223 * Pragma Pure_05::
224 * Pragma Pure_12::
225 * Pragma Pure_Function::
226 * Pragma Ravenscar::
227 * Pragma Relative_Deadline::
228 * Pragma Remote_Access_Type::
229 * Pragma Restricted_Run_Time::
230 * Pragma Restriction_Warnings::
231 * Pragma Share_Generic::
232 * Pragma Shared::
233 * Pragma Short_Circuit_And_Or::
234 * Pragma Short_Descriptors::
235 * Pragma Simple_Storage_Pool_Type::
236 * Pragma Source_File_Name::
237 * Pragma Source_File_Name_Project::
238 * Pragma Source_Reference::
239 * Pragma SPARK_Mode::
240 * Pragma Static_Elaboration_Desired::
241 * Pragma Stream_Convert::
242 * Pragma Style_Checks::
243 * Pragma Subtitle::
244 * Pragma Suppress::
245 * Pragma Suppress_All::
246 * Pragma Suppress_Debug_Info::
247 * Pragma Suppress_Exception_Locations::
248 * Pragma Suppress_Initialization::
249 * Pragma Task_Info::
250 * Pragma Task_Name::
251 * Pragma Task_Storage::
252 * Pragma Test_Case::
253 * Pragma Thread_Local_Storage::
254 * Pragma Time_Slice::
255 * Pragma Title::
256 * Pragma Type_Invariant::
257 * Pragma Type_Invariant_Class::
258 * Pragma Unchecked_Union::
259 * Pragma Unimplemented_Unit::
260 * Pragma Universal_Aliasing ::
261 * Pragma Universal_Data::
262 * Pragma Unmodified::
263 * Pragma Unreferenced::
264 * Pragma Unreferenced_Objects::
265 * Pragma Unreserve_All_Interrupts::
266 * Pragma Unsuppress::
267 * Pragma Use_VADS_Size::
268 * Pragma Validity_Checks::
269 * Pragma Volatile::
270 * Pragma Warnings::
271 * Pragma Weak_External::
272 * Pragma Wide_Character_Encoding::
274 Implementation Defined Aspects
276 * Aspect Abstract_State::
277 * Aspect Ada_2005::
278 * Aspect Ada_2012::
279 * Aspect Compiler_Unit::
280 * Aspect Contract_Cases::
281 * Aspect Depends::
282 * Aspect Dimension::
283 * Aspect Dimension_System::
284 * Aspect Favor_Top_Level::
285 * Aspect Global::
286 * Aspect Inline_Always::
287 * Aspect Invariant::
288 * Aspect Object_Size::
289 * Aspect Persistent_BSS::
290 * Aspect Predicate::
291 * Aspect Preelaborate_05::
292 * Aspect Pure_05::
293 * Aspect Pure_12::
294 * Aspect Pure_Function::
295 * Aspect Remote_Access_Type::
296 * Aspect Scalar_Storage_Order::
297 * Aspect Shared::
298 * Aspect Simple_Storage_Pool::
299 * Aspect Simple_Storage_Pool_Type::
300 * Aspect SPARK_Mode::
301 * Aspect Suppress_Debug_Info::
302 * Aspect Test_Case::
303 * Aspect Universal_Aliasing::
304 * Aspect Universal_Data::
305 * Aspect Unmodified::
306 * Aspect Unreferenced::
307 * Aspect Unreferenced_Objects::
308 * Aspect Value_Size::
309 * Aspect Warnings::
311 Implementation Defined Attributes
313 * Attribute Abort_Signal::
314 * Attribute Address_Size::
315 * Attribute Asm_Input::
316 * Attribute Asm_Output::
317 * Attribute AST_Entry::
318 * Attribute Bit::
319 * Attribute Bit_Position::
320 * Attribute Compiler_Version::
321 * Attribute Code_Address::
322 * Attribute Default_Bit_Order::
323 * Attribute Descriptor_Size::
324 * Attribute Elaborated::
325 * Attribute Elab_Body::
326 * Attribute Elab_Spec::
327 * Attribute Elab_Subp_Body::
328 * Attribute Emax::
329 * Attribute Enabled::
330 * Attribute Enum_Rep::
331 * Attribute Enum_Val::
332 * Attribute Epsilon::
333 * Attribute Fixed_Value::
334 * Attribute Has_Access_Values::
335 * Attribute Has_Discriminants::
336 * Attribute Img::
337 * Attribute Integer_Value::
338 * Attribute Invalid_Value::
339 * Attribute Large::
340 * Attribute Library_Level::
341 * Attribute Loop_Entry::
342 * Attribute Machine_Size::
343 * Attribute Mantissa::
344 * Attribute Max_Interrupt_Priority::
345 * Attribute Max_Priority::
346 * Attribute Maximum_Alignment::
347 * Attribute Mechanism_Code::
348 * Attribute Null_Parameter::
349 * Attribute Object_Size::
350 * Attribute Passed_By_Reference::
351 * Attribute Pool_Address::
352 * Attribute Range_Length::
353 * Attribute Ref::
354 * Attribute Restriction_Set::
355 * Attribute Result::
356 * Attribute Safe_Emax::
357 * Attribute Safe_Large::
358 * Attribute Scalar_Storage_Order::
359 * Attribute Simple_Storage_Pool::
360 * Attribute Small::
361 * Attribute Storage_Unit::
362 * Attribute Stub_Type::
363 * Attribute System_Allocator_Alignment::
364 * Attribute Target_Name::
365 * Attribute Tick::
366 * Attribute To_Address::
367 * Attribute Type_Class::
368 * Attribute UET_Address::
369 * Attribute Unconstrained_Array::
370 * Attribute Universal_Literal_String::
371 * Attribute Unrestricted_Access::
372 * Attribute Update::
373 * Attribute Valid_Scalars::
374 * Attribute VADS_Size::
375 * Attribute Value_Size::
376 * Attribute Wchar_T_Size::
377 * Attribute Word_Size::
379 Standard and Implementation Defined Restrictions
381 * Partition-Wide Restrictions::
382 * Program Unit Level Restrictions::
384 Partition-Wide Restrictions
386 * Immediate_Reclamation::
387 * Max_Asynchronous_Select_Nesting::
388 * Max_Entry_Queue_Length::
389 * Max_Protected_Entries::
390 * Max_Select_Alternatives::
391 * Max_Storage_At_Blocking::
392 * Max_Task_Entries::
393 * Max_Tasks::
394 * No_Abort_Statements::
395 * No_Access_Parameter_Allocators::
396 * No_Access_Subprograms::
397 * No_Allocators::
398 * No_Anonymous_Allocators::
399 * No_Calendar::
400 * No_Coextensions::
401 * No_Default_Initialization::
402 * No_Delay::
403 * No_Dependence::
404 * No_Direct_Boolean_Operators::
405 * No_Dispatch::
406 * No_Dispatching_Calls::
407 * No_Dynamic_Attachment::
408 * No_Dynamic_Priorities::
409 * No_Entry_Calls_In_Elaboration_Code::
410 * No_Enumeration_Maps::
411 * No_Exception_Handlers::
412 * No_Exception_Propagation::
413 * No_Exception_Registration::
414 * No_Exceptions::
415 * No_Finalization::
416 * No_Fixed_Point::
417 * No_Floating_Point::
418 * No_Implicit_Conditionals::
419 * No_Implicit_Dynamic_Code::
420 * No_Implicit_Heap_Allocations::
421 * No_Implicit_Loops::
422 * No_Initialize_Scalars::
423 * No_IO::
424 * No_Local_Allocators::
425 * No_Local_Protected_Objects::
426 * No_Local_Timing_Events::
427 * No_Nested_Finalization::
428 * No_Protected_Type_Allocators::
429 * No_Protected_Types::
430 * No_Recursion::
431 * No_Reentrancy::
432 * No_Relative_Delay::
433 * No_Requeue_Statements::
434 * No_Secondary_Stack::
435 * No_Select_Statements::
436 * No_Specific_Termination_Handlers::
437 * No_Specification_of_Aspect::
438 * No_Standard_Allocators_After_Elaboration::
439 * No_Standard_Storage_Pools::
440 * No_Stream_Optimizations::
441 * No_Streams::
442 * No_Task_Allocators::
443 * No_Task_Attributes_Package::
444 * No_Task_Hierarchy::
445 * No_Task_Termination::
446 * No_Tasking::
447 * No_Terminate_Alternatives::
448 * No_Unchecked_Access::
449 * Simple_Barriers::
450 * Static_Priorities::
451 * Static_Storage_Size::
453 Program Unit Level Restrictions
455 * No_Elaboration_Code::
456 * No_Entry_Queue::
457 * No_Implementation_Aspect_Specifications::
458 * No_Implementation_Attributes::
459 * No_Implementation_Identifiers::
460 * No_Implementation_Pragmas::
461 * No_Implementation_Restrictions::
462 * No_Implementation_Units::
463 * No_Implicit_Aliasing::
464 * No_Obsolescent_Features::
465 * No_Wide_Characters::
466 * SPARK_05::
468 The Implementation of Standard I/O
470 * Standard I/O Packages::
471 * FORM Strings::
472 * Direct_IO::
473 * Sequential_IO::
474 * Text_IO::
475 * Wide_Text_IO::
476 * Wide_Wide_Text_IO::
477 * Stream_IO::
478 * Text Translation::
479 * Shared Files::
480 * Filenames encoding::
481 * Open Modes::
482 * Operations on C Streams::
483 * Interfacing to C Streams::
485 The GNAT Library
487 * Ada.Characters.Latin_9 (a-chlat9.ads)::
488 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
489 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
490 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
491 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
492 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
493 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
494 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
495 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
496 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
497 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
498 * Ada.Command_Line.Environment (a-colien.ads)::
499 * Ada.Command_Line.Remove (a-colire.ads)::
500 * Ada.Command_Line.Response_File (a-clrefi.ads)::
501 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
502 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
503 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
504 * Ada.Exceptions.Traceback (a-exctra.ads)::
505 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
506 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
507 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
508 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
509 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
510 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
511 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
512 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
513 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
514 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
515 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
516 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
517 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
518 * GNAT.Altivec (g-altive.ads)::
519 * GNAT.Altivec.Conversions (g-altcon.ads)::
520 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
521 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
522 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
523 * GNAT.Array_Split (g-arrspl.ads)::
524 * GNAT.AWK (g-awk.ads)::
525 * GNAT.Bounded_Buffers (g-boubuf.ads)::
526 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
527 * GNAT.Bubble_Sort (g-bubsor.ads)::
528 * GNAT.Bubble_Sort_A (g-busora.ads)::
529 * GNAT.Bubble_Sort_G (g-busorg.ads)::
530 * GNAT.Byte_Order_Mark (g-byorma.ads)::
531 * GNAT.Byte_Swapping (g-bytswa.ads)::
532 * GNAT.Calendar (g-calend.ads)::
533 * GNAT.Calendar.Time_IO (g-catiio.ads)::
534 * GNAT.Case_Util (g-casuti.ads)::
535 * GNAT.CGI (g-cgi.ads)::
536 * GNAT.CGI.Cookie (g-cgicoo.ads)::
537 * GNAT.CGI.Debug (g-cgideb.ads)::
538 * GNAT.Command_Line (g-comlin.ads)::
539 * GNAT.Compiler_Version (g-comver.ads)::
540 * GNAT.Ctrl_C (g-ctrl_c.ads)::
541 * GNAT.CRC32 (g-crc32.ads)::
542 * GNAT.Current_Exception (g-curexc.ads)::
543 * GNAT.Debug_Pools (g-debpoo.ads)::
544 * GNAT.Debug_Utilities (g-debuti.ads)::
545 * GNAT.Decode_String (g-decstr.ads)::
546 * GNAT.Decode_UTF8_String (g-deutst.ads)::
547 * GNAT.Directory_Operations (g-dirope.ads)::
548 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
549 * GNAT.Dynamic_HTables (g-dynhta.ads)::
550 * GNAT.Dynamic_Tables (g-dyntab.ads)::
551 * GNAT.Encode_String (g-encstr.ads)::
552 * GNAT.Encode_UTF8_String (g-enutst.ads)::
553 * GNAT.Exception_Actions (g-excact.ads)::
554 * GNAT.Exception_Traces (g-exctra.ads)::
555 * GNAT.Exceptions (g-except.ads)::
556 * GNAT.Expect (g-expect.ads)::
557 * GNAT.Expect.TTY (g-exptty.ads)::
558 * GNAT.Float_Control (g-flocon.ads)::
559 * GNAT.Heap_Sort (g-heasor.ads)::
560 * GNAT.Heap_Sort_A (g-hesora.ads)::
561 * GNAT.Heap_Sort_G (g-hesorg.ads)::
562 * GNAT.HTable (g-htable.ads)::
563 * GNAT.IO (g-io.ads)::
564 * GNAT.IO_Aux (g-io_aux.ads)::
565 * GNAT.Lock_Files (g-locfil.ads)::
566 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
567 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
568 * GNAT.MD5 (g-md5.ads)::
569 * GNAT.Memory_Dump (g-memdum.ads)::
570 * GNAT.Most_Recent_Exception (g-moreex.ads)::
571 * GNAT.OS_Lib (g-os_lib.ads)::
572 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
573 * GNAT.Random_Numbers (g-rannum.ads)::
574 * GNAT.Regexp (g-regexp.ads)::
575 * GNAT.Registry (g-regist.ads)::
576 * GNAT.Regpat (g-regpat.ads)::
577 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
578 * GNAT.Semaphores (g-semaph.ads)::
579 * GNAT.Serial_Communications (g-sercom.ads)::
580 * GNAT.SHA1 (g-sha1.ads)::
581 * GNAT.SHA224 (g-sha224.ads)::
582 * GNAT.SHA256 (g-sha256.ads)::
583 * GNAT.SHA384 (g-sha384.ads)::
584 * GNAT.SHA512 (g-sha512.ads)::
585 * GNAT.Signals (g-signal.ads)::
586 * GNAT.Sockets (g-socket.ads)::
587 * GNAT.Source_Info (g-souinf.ads)::
588 * GNAT.Spelling_Checker (g-speche.ads)::
589 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
590 * GNAT.Spitbol.Patterns (g-spipat.ads)::
591 * GNAT.Spitbol (g-spitbo.ads)::
592 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
593 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
594 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
595 * GNAT.SSE (g-sse.ads)::
596 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
597 * GNAT.Strings (g-string.ads)::
598 * GNAT.String_Split (g-strspl.ads)::
599 * GNAT.Table (g-table.ads)::
600 * GNAT.Task_Lock (g-tasloc.ads)::
601 * GNAT.Threads (g-thread.ads)::
602 * GNAT.Time_Stamp (g-timsta.ads)::
603 * GNAT.Traceback (g-traceb.ads)::
604 * GNAT.Traceback.Symbolic (g-trasym.ads)::
605 * GNAT.UTF_32 (g-utf_32.ads)::
606 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
607 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
608 * GNAT.Wide_String_Split (g-wistsp.ads)::
609 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
610 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
611 * Interfaces.C.Extensions (i-cexten.ads)::
612 * Interfaces.C.Streams (i-cstrea.ads)::
613 * Interfaces.CPP (i-cpp.ads)::
614 * Interfaces.Packed_Decimal (i-pacdec.ads)::
615 * Interfaces.VxWorks (i-vxwork.ads)::
616 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
617 * System.Address_Image (s-addima.ads)::
618 * System.Assertions (s-assert.ads)::
619 * System.Memory (s-memory.ads)::
620 * System.Multiprocessors (s-multip.ads)::
621 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
622 * System.Partition_Interface (s-parint.ads)::
623 * System.Pool_Global (s-pooglo.ads)::
624 * System.Pool_Local (s-pooloc.ads)::
625 * System.Restrictions (s-restri.ads)::
626 * System.Rident (s-rident.ads)::
627 * System.Strings.Stream_Ops (s-ststop.ads)::
628 * System.Task_Info (s-tasinf.ads)::
629 * System.Wch_Cnv (s-wchcnv.ads)::
630 * System.Wch_Con (s-wchcon.ads)::
632 Text_IO
634 * Text_IO Stream Pointer Positioning::
635 * Text_IO Reading and Writing Non-Regular Files::
636 * Get_Immediate::
637 * Treating Text_IO Files as Streams::
638 * Text_IO Extensions::
639 * Text_IO Facilities for Unbounded Strings::
641 Wide_Text_IO
643 * Wide_Text_IO Stream Pointer Positioning::
644 * Wide_Text_IO Reading and Writing Non-Regular Files::
646 Wide_Wide_Text_IO
648 * Wide_Wide_Text_IO Stream Pointer Positioning::
649 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
651 Interfacing to Other Languages
653 * Interfacing to C::
654 * Interfacing to C++::
655 * Interfacing to COBOL::
656 * Interfacing to Fortran::
657 * Interfacing to non-GNAT Ada code::
659 Specialized Needs Annexes
661 Implementation of Specific Ada Features
662 * Machine Code Insertions::
663 * GNAT Implementation of Tasking::
664 * GNAT Implementation of Shared Passive Packages::
665 * Code Generation for Array Aggregates::
666 * The Size of Discriminated Records with Default Discriminants::
667 * Strict Conformance to the Ada Reference Manual::
669 Implementation of Ada 2012 Features
671 Obsolescent Features
673 GNU Free Documentation License
675 Index
676 @end menu
678 @end ifnottex
680 @node About This Guide
681 @unnumbered About This Guide
683 @noindent
684 This manual contains useful information in writing programs using the
685 @value{EDITION} compiler.  It includes information on implementation dependent
686 characteristics of @value{EDITION}, including all the information required by
687 Annex M of the Ada language standard.
689 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
690 Ada 83 compatibility mode.
691 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
692 but you can override with a compiler switch
693 to explicitly specify the language version.
694 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
695 @value{EDITION} User's Guide}, for details on these switches.)
696 Throughout this manual, references to ``Ada'' without a year suffix
697 apply to both the Ada 95 and Ada 2005 versions of the language.
699 Ada is designed to be highly portable.
700 In general, a program will have the same effect even when compiled by
701 different compilers on different platforms.
702 However, since Ada is designed to be used in a
703 wide variety of applications, it also contains a number of system
704 dependent features to be used in interfacing to the external world.
705 @cindex Implementation-dependent features
706 @cindex Portability
708 Note: Any program that makes use of implementation-dependent features
709 may be non-portable.  You should follow good programming practice and
710 isolate and clearly document any sections of your program that make use
711 of these features in a non-portable manner.
713 @ifset PROEDITION
714 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
715 ``GNAT'' in the remainder of this document.
716 @end ifset
718 @menu
719 * What This Reference Manual Contains::
720 * Conventions::
721 * Related Information::
722 @end menu
724 @node What This Reference Manual Contains
725 @unnumberedsec What This Reference Manual Contains
727 @noindent
728 This reference manual contains the following chapters:
730 @itemize @bullet
731 @item
732 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
733 pragmas, which can be used to extend and enhance the functionality of the
734 compiler.
736 @item
737 @ref{Implementation Defined Attributes}, lists GNAT
738 implementation-dependent attributes, which can be used to extend and
739 enhance the functionality of the compiler.
741 @item
742 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
743 implementation-dependent restrictions, which can be used to extend and
744 enhance the functionality of the compiler.
746 @item
747 @ref{Implementation Advice}, provides information on generally
748 desirable behavior which are not requirements that all compilers must
749 follow since it cannot be provided on all systems, or which may be
750 undesirable on some systems.
752 @item
753 @ref{Implementation Defined Characteristics}, provides a guide to
754 minimizing implementation dependent features.
756 @item
757 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
758 implemented by GNAT, and how they can be imported into user
759 application programs.
761 @item
762 @ref{Representation Clauses and Pragmas}, describes in detail the
763 way that GNAT represents data, and in particular the exact set
764 of representation clauses and pragmas that is accepted.
766 @item
767 @ref{Standard Library Routines}, provides a listing of packages and a
768 brief description of the functionality that is provided by Ada's
769 extensive set of standard library routines as implemented by GNAT@.
771 @item
772 @ref{The Implementation of Standard I/O}, details how the GNAT
773 implementation of the input-output facilities.
775 @item
776 @ref{The GNAT Library}, is a catalog of packages that complement
777 the Ada predefined library.
779 @item
780 @ref{Interfacing to Other Languages}, describes how programs
781 written in Ada using GNAT can be interfaced to other programming
782 languages.
784 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
785 of the specialized needs annexes.
787 @item
788 @ref{Implementation of Specific Ada Features}, discusses issues related
789 to GNAT's implementation of machine code insertions, tasking, and several
790 other features.
792 @item
793 @ref{Implementation of Ada 2012 Features}, describes the status of the
794 GNAT implementation of the Ada 2012 language standard.
796 @item
797 @ref{Obsolescent Features} documents implementation dependent features,
798 including pragmas and attributes, which are considered obsolescent, since
799 there are other preferred ways of achieving the same results. These
800 obsolescent forms are retained for backwards compatibility.
802 @end itemize
804 @cindex Ada 95 Language Reference Manual
805 @cindex Ada 2005 Language Reference Manual
806 @noindent
807 This reference manual assumes a basic familiarity with the Ada 95 language, as
808 described in the International Standard ANSI/ISO/IEC-8652:1995,
809 January 1995.
810 It does not require knowledge of the new features introduced by Ada 2005,
811 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
812 and Amendment 1).
813 Both reference manuals are included in the GNAT documentation
814 package.
816 @node Conventions
817 @unnumberedsec Conventions
818 @cindex Conventions, typographical
819 @cindex Typographical conventions
821 @noindent
822 Following are examples of the typographical and graphic conventions used
823 in this guide:
825 @itemize @bullet
826 @item
827 @code{Functions}, @code{utility program names}, @code{standard names},
828 and @code{classes}.
830 @item
831 @code{Option flags}
833 @item
834 @file{File names}, @samp{button names}, and @samp{field names}.
836 @item
837 @code{Variables}, @env{environment variables}, and @var{metasyntactic
838 variables}.
840 @item
841 @emph{Emphasis}.
843 @item
844 [optional information or parameters]
846 @item
847 Examples are described by text
848 @smallexample
849 and then shown this way.
850 @end smallexample
851 @end itemize
853 @noindent
854 Commands that are entered by the user are preceded in this manual by the
855 characters @samp{$ } (dollar sign followed by space).  If your system uses this
856 sequence as a prompt, then the commands will appear exactly as you see them
857 in the manual.  If your system uses some other prompt, then the command will
858 appear with the @samp{$} replaced by whatever prompt character you are using.
860 @node Related Information
861 @unnumberedsec Related Information
862 @noindent
863 See the following documents for further information on GNAT:
865 @itemize @bullet
866 @item
867 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
868 @value{EDITION} User's Guide}, which provides information on how to use the
869 GNAT compiler system.
871 @item
872 @cite{Ada 95 Reference Manual}, which contains all reference
873 material for the Ada 95 programming language.
875 @item
876 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
877 of the Ada 95 standard.  The annotations describe
878 detailed aspects of the design decision, and in particular contain useful
879 sections on Ada 83 compatibility.
881 @item
882 @cite{Ada 2005 Reference Manual}, which contains all reference
883 material for the Ada 2005 programming language.
885 @item
886 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
887 of the Ada 2005 standard.  The annotations describe
888 detailed aspects of the design decision, and in particular contain useful
889 sections on Ada 83 and Ada 95 compatibility.
891 @item
892 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
893 which contains specific information on compatibility between GNAT and
894 DEC Ada 83 systems.
896 @item
897 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
898 describes in detail the pragmas and attributes provided by the DEC Ada 83
899 compiler system.
901 @end itemize
903 @node Implementation Defined Pragmas
904 @chapter Implementation Defined Pragmas
906 @noindent
907 Ada defines a set of pragmas that can be used to supply additional
908 information to the compiler.  These language defined pragmas are
909 implemented in GNAT and work as described in the Ada Reference Manual.
911 In addition, Ada allows implementations to define additional pragmas
912 whose meaning is defined by the implementation.  GNAT provides a number
913 of these implementation-defined pragmas, which can be used to extend
914 and enhance the functionality of the compiler.  This section of the GNAT
915 Reference Manual describes these additional pragmas.
917 Note that any program using these pragmas might not be portable to other
918 compilers (although GNAT implements this set of pragmas on all
919 platforms).  Therefore if portability to other compilers is an important
920 consideration, the use of these pragmas should be minimized.
922 @menu
923 * Pragma Abort_Defer::
924 * Pragma Ada_83::
925 * Pragma Ada_95::
926 * Pragma Ada_05::
927 * Pragma Ada_2005::
928 * Pragma Ada_12::
929 * Pragma Ada_2012::
930 * Pragma Annotate::
931 * Pragma Assert::
932 * Pragma Assert_And_Cut::
933 * Pragma Assertion_Policy::
934 * Pragma Assume::
935 * Pragma Assume_No_Invalid_Values::
936 * Pragma Attribute_Definition::
937 * Pragma Ast_Entry::
938 * Pragma C_Pass_By_Copy::
939 * Pragma Check::
940 * Pragma Check_Float_Overflow::
941 * Pragma Check_Name::
942 * Pragma Check_Policy::
943 * Pragma CIL_Constructor::
944 * Pragma Comment::
945 * Pragma Common_Object::
946 * Pragma Compile_Time_Error::
947 * Pragma Compile_Time_Warning::
948 * Pragma Compiler_Unit::
949 * Pragma Complete_Representation::
950 * Pragma Complex_Representation::
951 * Pragma Component_Alignment::
952 * Pragma Contract_Cases::
953 * Pragma Convention_Identifier::
954 * Pragma CPP_Class::
955 * Pragma CPP_Constructor::
956 * Pragma CPP_Virtual::
957 * Pragma CPP_Vtable::
958 * Pragma CPU::
959 * Pragma Debug::
960 * Pragma Debug_Policy::
961 * Pragma Default_Storage_Pool::
962 * Pragma Detect_Blocking::
963 * Pragma Disable_Atomic_Synchronization::
964 * Pragma Dispatching_Domain::
965 * Pragma Elaboration_Checks::
966 * Pragma Eliminate::
967 * Pragma Enable_Atomic_Synchronization::
968 * Pragma Export_Exception::
969 * Pragma Export_Function::
970 * Pragma Export_Object::
971 * Pragma Export_Procedure::
972 * Pragma Export_Value::
973 * Pragma Export_Valued_Procedure::
974 * Pragma Extend_System::
975 * Pragma Extensions_Allowed::
976 * Pragma External::
977 * Pragma External_Name_Casing::
978 * Pragma Fast_Math::
979 * Pragma Favor_Top_Level::
980 * Pragma Finalize_Storage_Only::
981 * Pragma Float_Representation::
982 * Pragma Ident::
983 * Pragma Implementation_Defined::
984 * Pragma Implemented::
985 * Pragma Implicit_Packing::
986 * Pragma Import_Exception::
987 * Pragma Import_Function::
988 * Pragma Import_Object::
989 * Pragma Import_Procedure::
990 * Pragma Import_Valued_Procedure::
991 * Pragma Independent::
992 * Pragma Independent_Components::
993 * Pragma Initialize_Scalars::
994 * Pragma Inline_Always::
995 * Pragma Inline_Generic::
996 * Pragma Interface::
997 * Pragma Interface_Name::
998 * Pragma Interrupt_Handler::
999 * Pragma Interrupt_State::
1000 * Pragma Invariant::
1001 * Pragma Java_Constructor::
1002 * Pragma Java_Interface::
1003 * Pragma Keep_Names::
1004 * Pragma License::
1005 * Pragma Link_With::
1006 * Pragma Linker_Alias::
1007 * Pragma Linker_Constructor::
1008 * Pragma Linker_Destructor::
1009 * Pragma Linker_Section::
1010 * Pragma Long_Float::
1011 * Pragma Loop_Invariant::
1012 * Pragma Loop_Optimize::
1013 * Pragma Loop_Variant::
1014 * Pragma Machine_Attribute::
1015 * Pragma Main::
1016 * Pragma Main_Storage::
1017 * Pragma No_Body::
1018 * Pragma No_Inline::
1019 * Pragma No_Return::
1020 * Pragma No_Run_Time::
1021 * Pragma No_Strict_Aliasing::
1022 * Pragma Normalize_Scalars::
1023 * Pragma Obsolescent::
1024 * Pragma Optimize_Alignment::
1025 * Pragma Ordered::
1026 * Pragma Overflow_Mode::
1027 * Pragma Overriding_Renamings::
1028 * Pragma Partition_Elaboration_Policy::
1029 * Pragma Passive::
1030 * Pragma Persistent_BSS::
1031 * Pragma Polling::
1032 * Pragma Post::
1033 * Pragma Postcondition::
1034 * Pragma Post_Class::
1035 * Pragma Pre::
1036 * Pragma Precondition::
1037 * Pragma Predicate::
1038 * Pragma Preelaborable_Initialization::
1039 * Pragma Preelaborate_05::
1040 * Pragma Pre_Class::
1041 * Pragma Priority_Specific_Dispatching::
1042 * Pragma Profile::
1043 * Pragma Profile_Warnings::
1044 * Pragma Propagate_Exceptions::
1045 * Pragma Psect_Object::
1046 * Pragma Pure_05::
1047 * Pragma Pure_12::
1048 * Pragma Pure_Function::
1049 * Pragma Ravenscar::
1050 * Pragma Relative_Deadline::
1051 * Pragma Remote_Access_Type::
1052 * Pragma Restricted_Run_Time::
1053 * Pragma Restriction_Warnings::
1054 * Pragma Share_Generic::
1055 * Pragma Shared::
1056 * Pragma Short_Circuit_And_Or::
1057 * Pragma Short_Descriptors::
1058 * Pragma Simple_Storage_Pool_Type::
1059 * Pragma Source_File_Name::
1060 * Pragma Source_File_Name_Project::
1061 * Pragma Source_Reference::
1062 * Pragma SPARK_Mode::
1063 * Pragma Static_Elaboration_Desired::
1064 * Pragma Stream_Convert::
1065 * Pragma Style_Checks::
1066 * Pragma Subtitle::
1067 * Pragma Suppress::
1068 * Pragma Suppress_All::
1069 * Pragma Suppress_Debug_Info::
1070 * Pragma Suppress_Exception_Locations::
1071 * Pragma Suppress_Initialization::
1072 * Pragma Task_Info::
1073 * Pragma Task_Name::
1074 * Pragma Task_Storage::
1075 * Pragma Test_Case::
1076 * Pragma Thread_Local_Storage::
1077 * Pragma Time_Slice::
1078 * Pragma Title::
1079 * Pragma Type_Invariant::
1080 * Pragma Type_Invariant_Class::
1081 * Pragma Unchecked_Union::
1082 * Pragma Unimplemented_Unit::
1083 * Pragma Universal_Aliasing ::
1084 * Pragma Universal_Data::
1085 * Pragma Unmodified::
1086 * Pragma Unreferenced::
1087 * Pragma Unreferenced_Objects::
1088 * Pragma Unreserve_All_Interrupts::
1089 * Pragma Unsuppress::
1090 * Pragma Use_VADS_Size::
1091 * Pragma Validity_Checks::
1092 * Pragma Volatile::
1093 * Pragma Warnings::
1094 * Pragma Weak_External::
1095 * Pragma Wide_Character_Encoding::
1096 @end menu
1098 @node Pragma Abort_Defer
1099 @unnumberedsec Pragma Abort_Defer
1100 @findex Abort_Defer
1101 @cindex Deferring aborts
1102 @noindent
1103 Syntax:
1104 @smallexample
1105 pragma Abort_Defer;
1106 @end smallexample
1108 @noindent
1109 This pragma must appear at the start of the statement sequence of a
1110 handled sequence of statements (right after the @code{begin}).  It has
1111 the effect of deferring aborts for the sequence of statements (but not
1112 for the declarations or handlers, if any, associated with this statement
1113 sequence).
1115 @node Pragma Ada_83
1116 @unnumberedsec Pragma Ada_83
1117 @findex Ada_83
1118 @noindent
1119 Syntax:
1120 @smallexample @c ada
1121 pragma Ada_83;
1122 @end smallexample
1124 @noindent
1125 A configuration pragma that establishes Ada 83 mode for the unit to
1126 which it applies, regardless of the mode set by the command line
1127 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
1128 the syntax and semantics of Ada 83, as defined in the original Ada
1129 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
1130 and Ada 2005 are not recognized, optional package bodies are allowed,
1131 and generics may name types with unknown discriminants without using
1132 the @code{(<>)} notation.  In addition, some but not all of the additional
1133 restrictions of Ada 83 are enforced.
1135 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
1136 Ada 83 code to be compiled and adapted to GNAT with less effort.
1137 Secondly, it aids in keeping code backwards compatible with Ada 83.
1138 However, there is no guarantee that code that is processed correctly
1139 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1140 83 compiler, since GNAT does not enforce all the additional checks
1141 required by Ada 83.
1143 @node Pragma Ada_95
1144 @unnumberedsec Pragma Ada_95
1145 @findex Ada_95
1146 @noindent
1147 Syntax:
1148 @smallexample @c ada
1149 pragma Ada_95;
1150 @end smallexample
1152 @noindent
1153 A configuration pragma that establishes Ada 95 mode for the unit to which
1154 it applies, regardless of the mode set by the command line switches.
1155 This mode is set automatically for the @code{Ada} and @code{System}
1156 packages and their children, so you need not specify it in these
1157 contexts.  This pragma is useful when writing a reusable component that
1158 itself uses Ada 95 features, but which is intended to be usable from
1159 either Ada 83 or Ada 95 programs.
1161 @node Pragma Ada_05
1162 @unnumberedsec Pragma Ada_05
1163 @findex Ada_05
1164 @noindent
1165 Syntax:
1166 @smallexample @c ada
1167 pragma Ada_05;
1168 @end smallexample
1170 @noindent
1171 A configuration pragma that establishes Ada 2005 mode for the unit to which
1172 it applies, regardless of the mode set by the command line switches.
1173 This pragma is useful when writing a reusable component that
1174 itself uses Ada 2005 features, but which is intended to be usable from
1175 either Ada 83 or Ada 95 programs.
1177 @node Pragma Ada_2005
1178 @unnumberedsec Pragma Ada_2005
1179 @findex Ada_2005
1180 @noindent
1181 Syntax:
1182 @smallexample @c ada
1183 pragma Ada_2005;
1184 @end smallexample
1186 @noindent
1187 This configuration pragma is a synonym for pragma Ada_05 and has the
1188 same syntax and effect.
1190 @node Pragma Ada_12
1191 @unnumberedsec Pragma Ada_12
1192 @findex Ada_12
1193 @noindent
1194 Syntax:
1195 @smallexample @c ada
1196 pragma Ada_12;
1197 @end smallexample
1199 @noindent
1200 A configuration pragma that establishes Ada 2012 mode for the unit to which
1201 it applies, regardless of the mode set by the command line switches.
1202 This mode is set automatically for the @code{Ada} and @code{System}
1203 packages and their children, so you need not specify it in these
1204 contexts.  This pragma is useful when writing a reusable component that
1205 itself uses Ada 2012 features, but which is intended to be usable from
1206 Ada 83, Ada 95, or Ada 2005 programs.
1208 @node Pragma Ada_2012
1209 @unnumberedsec Pragma Ada_2012
1210 @findex Ada_2005
1211 @noindent
1212 Syntax:
1213 @smallexample @c ada
1214 pragma Ada_2012;
1215 @end smallexample
1217 @noindent
1218 This configuration pragma is a synonym for pragma Ada_12 and has the
1219 same syntax and effect.
1221 @node Pragma Annotate
1222 @unnumberedsec Pragma Annotate
1223 @findex Annotate
1224 @noindent
1225 Syntax:
1226 @smallexample @c ada
1227 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1229 ARG ::= NAME | EXPRESSION
1230 @end smallexample
1232 @noindent
1233 This pragma is used to annotate programs.  @var{identifier} identifies
1234 the type of annotation.  GNAT verifies that it is an identifier, but does
1235 not otherwise analyze it. The second optional identifier is also left
1236 unanalyzed, and by convention is used to control the action of the tool to
1237 which the annotation is addressed.  The remaining @var{arg} arguments
1238 can be either string literals or more generally expressions.
1239 String literals are assumed to be either of type
1240 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1241 depending on the character literals they contain.
1242 All other kinds of arguments are analyzed as expressions, and must be
1243 unambiguous.
1245 The analyzed pragma is retained in the tree, but not otherwise processed
1246 by any part of the GNAT compiler, except to generate corresponding note
1247 lines in the generated ALI file. For the format of these note lines, see
1248 the compiler source file lib-writ.ads. This pragma is intended for use by
1249 external tools, including ASIS@. The use of pragma Annotate does not
1250 affect the compilation process in any way. This pragma may be used as
1251 a configuration pragma.
1253 @node Pragma Assert
1254 @unnumberedsec Pragma Assert
1255 @findex Assert
1256 @noindent
1257 Syntax:
1258 @smallexample @c ada
1259 pragma Assert (
1260   boolean_EXPRESSION
1261   [, string_EXPRESSION]);
1262 @end smallexample
1264 @noindent
1265 The effect of this pragma depends on whether the corresponding command
1266 line switch is set to activate assertions.  The pragma expands into code
1267 equivalent to the following:
1269 @smallexample @c ada
1270 if assertions-enabled then
1271    if not boolean_EXPRESSION then
1272       System.Assertions.Raise_Assert_Failure
1273         (string_EXPRESSION);
1274    end if;
1275 end if;
1276 @end smallexample
1278 @noindent
1279 The string argument, if given, is the message that will be associated
1280 with the exception occurrence if the exception is raised.  If no second
1281 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1282 where @var{file} is the name of the source file containing the assert,
1283 and @var{nnn} is the line number of the assert.  A pragma is not a
1284 statement, so if a statement sequence contains nothing but a pragma
1285 assert, then a null statement is required in addition, as in:
1287 @smallexample @c ada
1288 @dots{}
1289 if J > 3 then
1290    pragma Assert (K > 3, "Bad value for K");
1291    null;
1292 end if;
1293 @end smallexample
1295 @noindent
1296 Note that, as with the @code{if} statement to which it is equivalent, the
1297 type of the expression is either @code{Standard.Boolean}, or any type derived
1298 from this standard type.
1300 Assert checks can be either checked or ignored. By default they are ignored.
1301 They will be checked if either the command line switch @option{-gnata} is
1302 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1303 to enable @code{Assert_Checks}.
1305 If assertions are ignored, then there
1306 is no run-time effect (and in particular, any side effects from the
1307 expression will not occur at run time).  (The expression is still
1308 analyzed at compile time, and may cause types to be frozen if they are
1309 mentioned here for the first time).
1311 If assertions are checked, then the given expression is tested, and if
1312 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1313 which results in the raising of @code{Assert_Failure} with the given message.
1315 You should generally avoid side effects in the expression arguments of
1316 this pragma, because these side effects will turn on and off with the
1317 setting of the assertions mode, resulting in assertions that have an
1318 effect on the program.  However, the expressions are analyzed for
1319 semantic correctness whether or not assertions are enabled, so turning
1320 assertions on and off cannot affect the legality of a program.
1322 Note that the implementation defined policy @code{DISABLE}, given in a
1323 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1325 Note: this is a standard language-defined pragma in versions
1326 of Ada from 2005 on. In GNAT, it is implemented in all versions
1327 of Ada, and the DISABLE policy is an implementation-defined
1328 addition.
1330 @node Pragma Assert_And_Cut
1331 @unnumberedsec Pragma Assert_And_Cut
1332 @findex Assert_And_Cut
1333 @noindent
1334 Syntax:
1335 @smallexample @c ada
1336 pragma Assert_And_Cut (
1337   boolean_EXPRESSION
1338   [, string_EXPRESSION]);
1339 @end smallexample
1341 @noindent
1342 The effect of this pragma is identical to that of pragma @code{Assert},
1343 except that in an @code{Assertion_Policy} pragma, the identifier
1344 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1345 (or disabled).
1347 The intention is that this be used within a subprogram when the
1348 given test expresion sums up all the work done so far in the
1349 subprogram, so that the rest of the subprogram can be verified
1350 (informally or formally) using only the entry preconditions,
1351 and the expression in this pragma. This allows dividing up
1352 a subprogram into sections for the purposes of testing or
1353 formal verification. The pragma also serves as useful
1354 documentation.
1356 @node Pragma Assertion_Policy
1357 @unnumberedsec Pragma Assertion_Policy
1358 @findex Assertion_Policy
1359 @noindent
1360 Syntax:
1361 @smallexample @c ada
1362 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1364 pragma Assertion_Policy (
1365     ASSERTION_KIND => POLICY_IDENTIFIER
1366  @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1368 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1370 RM_ASSERTION_KIND ::= Assert               |
1371                       Static_Predicate     |
1372                       Dynamic_Predicate    |
1373                       Pre                  |
1374                       Pre'Class            |
1375                       Post                 |
1376                       Post'Class           |
1377                       Type_Invariant       |
1378                       Type_Invariant'Class
1380 ID_ASSERTION_KIND ::= Assertions           |
1381                       Assert_And_Cut       |
1382                       Assume               |
1383                       Contract_Cases       |
1384                       Debug                |
1385                       Invariant            |
1386                       Invariant'Class      |
1387                       Loop_Invariant       |
1388                       Loop_Variant         |
1389                       Postcondition        |
1390                       Precondition         |
1391                       Predicate            |
1392                       Refined_Post         |
1393                       Refined_Pre          |
1394                       Statement_Assertions
1396 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1397 @end smallexample
1399 @noindent
1400 This is a standard Ada 2012 pragma that is available as an
1401 implementation-defined pragma in earlier versions of Ada.
1402 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1403 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1404 are implementation defined additions recognized by the GNAT compiler.
1406 The pragma applies in both cases to pragmas and aspects with matching
1407 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1408 applies to both the @code{Precondition} pragma
1409 and the aspect @code{Precondition}. Note that the identifiers for
1410 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
1411 Pre_Class and Post_Class), since these pragmas are intended to be
1412 identical to the corresponding aspects).
1414 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1415 the corresponding pragma or aspect is activated.
1416 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1417 the corresponding pragma or aspect is deactivated.
1418 This pragma overrides the effect of the @option{-gnata} switch on the
1419 command line.
1421 The implementation defined policy @code{DISABLE} is like
1422 @code{IGNORE} except that it completely disables semantic
1423 checking of the corresponding pragma or aspect. This is
1424 useful when the pragma or aspect argument references subprograms
1425 in a with'ed package which is replaced by a dummy package
1426 for the final build.
1428 The implementation defined policy @code{Assertions} applies to all
1429 assertion kinds. The form with no assertion kind given implies this
1430 choice, so it applies to all assertion kinds (RM defined, and
1431 implementation defined).
1433 The implementation defined policy @code{Statement_Assertions}
1434 applies to @code{Assert}, @code{Assert_And_Cut},
1435 @code{Assume}, and @code{Loop_Invariant}.
1437 @node Pragma Assume
1438 @unnumberedsec Pragma Assume
1439 @findex Assume
1440 @noindent
1441 Syntax:
1442 @smallexample @c ada
1443 pragma Assume (
1444   boolean_EXPRESSION
1445   [, string_EXPRESSION]);
1446 @end smallexample
1448 @noindent
1449 The effect of this pragma is identical to that of pragma @code{Assert},
1450 except that in an @code{Assertion_Policy} pragma, the identifier
1451 @code{Assume} is used to control whether it is ignored or checked
1452 (or disabled).
1454 The intention is that this be used for assumptions about the
1455 external environment. So you cannot expect to verify formally
1456 or informally that the condition is met, this must be
1457 established by examining things outside the program itself.
1458 For example, we may have code that depends on the size of
1459 @code{Long_Long_Integer} being at least 64. So we could write:
1461 @smallexample @c ada
1462 pragma Assume (Long_Long_Integer'Size >= 64);
1463 @end smallexample
1465 @noindent
1466 This assumption cannot be proved from the program itself,
1467 but it acts as a useful run-time check that the assumption
1468 is met, and documents the need to ensure that it is met by
1469 reference to information outside the program.
1471 @node Pragma Assume_No_Invalid_Values
1472 @unnumberedsec Pragma Assume_No_Invalid_Values
1473 @findex Assume_No_Invalid_Values
1474 @cindex Invalid representations
1475 @cindex Invalid values
1476 @noindent
1477 Syntax:
1478 @smallexample @c ada
1479 pragma Assume_No_Invalid_Values (On | Off);
1480 @end smallexample
1482 @noindent
1483 This is a configuration pragma that controls the assumptions made by the
1484 compiler about the occurrence of invalid representations (invalid values)
1485 in the code.
1487 The default behavior (corresponding to an Off argument for this pragma), is
1488 to assume that values may in general be invalid unless the compiler can
1489 prove they are valid. Consider the following example:
1491 @smallexample @c ada
1492 V1 : Integer range 1 .. 10;
1493 V2 : Integer range 11 .. 20;
1495 for J in V2 .. V1 loop
1496    ...
1497 end loop;
1498 @end smallexample
1500 @noindent
1501 if V1 and V2 have valid values, then the loop is known at compile
1502 time not to execute since the lower bound must be greater than the
1503 upper bound. However in default mode, no such assumption is made,
1504 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1505 is given, the compiler will assume that any occurrence of a variable
1506 other than in an explicit @code{'Valid} test always has a valid
1507 value, and the loop above will be optimized away.
1509 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1510 you know your code is free of uninitialized variables and other
1511 possible sources of invalid representations, and may result in
1512 more efficient code. A program that accesses an invalid representation
1513 with this pragma in effect is erroneous, so no guarantees can be made
1514 about its behavior.
1516 It is peculiar though permissible to use this pragma in conjunction
1517 with validity checking (-gnatVa). In such cases, accessing invalid
1518 values will generally give an exception, though formally the program
1519 is erroneous so there are no guarantees that this will always be the
1520 case, and it is recommended that these two options not be used together.
1522 @node Pragma Ast_Entry
1523 @unnumberedsec Pragma Ast_Entry
1524 @cindex OpenVMS
1525 @findex Ast_Entry
1526 @noindent
1527 Syntax:
1528 @smallexample @c ada
1529 pragma AST_Entry (entry_IDENTIFIER);
1530 @end smallexample
1532 @noindent
1533 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1534 argument is the simple name of a single entry; at most one @code{AST_Entry}
1535 pragma is allowed for any given entry.  This pragma must be used in
1536 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1537 the entry declaration and in the same task type specification or single task
1538 as the entry to which it applies.  This pragma specifies that the given entry
1539 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1540 resulting from an OpenVMS system service call.  The pragma does not affect
1541 normal use of the entry.  For further details on this pragma, see the
1542 DEC Ada Language Reference Manual, section 9.12a.
1544 @node Pragma Attribute_Definition
1545 @unnumberedsec Pragma Attribute_Definition
1546 @findex Attribute_Definition
1547 @noindent
1548 Syntax:
1549 @smallexample @c ada
1550 pragma Attribute_Definition
1551   ([Attribute  =>] ATTRIBUTE_DESIGNATOR,
1552    [Entity     =>] LOCAL_NAME,
1553    [Expression =>] EXPRESSION | NAME);
1554 @end smallexample
1556 @noindent
1557 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1558 the attribute definition clause:
1560 @smallexample @c ada
1561   for Entity'Attribute use Expression;
1562 @end smallexample
1564 If @code{Attribute} is not a recognized attribute name, the pragma is
1565 ignored, and a warning is emitted. This allows source
1566 code to be written that takes advantage of some new attribute, while remaining
1567 compilable with earlier compilers.
1569 @node Pragma C_Pass_By_Copy
1570 @unnumberedsec Pragma C_Pass_By_Copy
1571 @cindex Passing by copy
1572 @findex C_Pass_By_Copy
1573 @noindent
1574 Syntax:
1575 @smallexample @c ada
1576 pragma C_Pass_By_Copy
1577   ([Max_Size =>] static_integer_EXPRESSION);
1578 @end smallexample
1580 @noindent
1581 Normally the default mechanism for passing C convention records to C
1582 convention subprograms is to pass them by reference, as suggested by RM
1583 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1584 this default, by requiring that record formal parameters be passed by
1585 copy if all of the following conditions are met:
1587 @itemize @bullet
1588 @item
1589 The size of the record type does not exceed the value specified for
1590 @code{Max_Size}.
1591 @item
1592 The record type has @code{Convention C}.
1593 @item
1594 The formal parameter has this record type, and the subprogram has a
1595 foreign (non-Ada) convention.
1596 @end itemize
1598 @noindent
1599 If these conditions are met the argument is passed by copy, i.e.@: in a
1600 manner consistent with what C expects if the corresponding formal in the
1601 C prototype is a struct (rather than a pointer to a struct).
1603 You can also pass records by copy by specifying the convention
1604 @code{C_Pass_By_Copy} for the record type, or by using the extended
1605 @code{Import} and @code{Export} pragmas, which allow specification of
1606 passing mechanisms on a parameter by parameter basis.
1608 @node Pragma Check
1609 @unnumberedsec Pragma Check
1610 @cindex Assertions
1611 @cindex Named assertions
1612 @findex Check
1613 @noindent
1614 Syntax:
1615 @smallexample @c ada
1616 pragma Check (
1617      [Name    =>] CHECK_KIND,
1618      [Check   =>] Boolean_EXPRESSION
1619   [, [Message =>] string_EXPRESSION] );
1621 CHECK_KIND ::= IDENTIFIER           |
1622                Pre'Class            |
1623                Post'Class           |
1624                Type_Invariant'Class |
1625                Invariant'Class
1626 @end smallexample
1628 @noindent
1629 This pragma is similar to the predefined pragma @code{Assert} except that an
1630 extra identifier argument is present. In conjunction with pragma
1631 @code{Check_Policy}, this can be used to define groups of assertions that can
1632 be independently controlled. The identifier @code{Assertion} is special, it
1633 refers to the normal set of pragma @code{Assert} statements.
1635 Checks introduced by this pragma are normally deactivated by default. They can
1636 be activated either by the command line option @option{-gnata}, which turns on
1637 all checks, or individually controlled using pragma @code{Check_Policy}.
1639 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1640 permitted as check kinds, since this would cause confusion with the use
1641 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1642 pragmas, where they are used to refer to sets of assertions.
1644 @node Pragma Check_Float_Overflow
1645 @unnumberedsec Pragma Check_Float_Overflow
1646 @cindex Floating-point overflow
1647 @findex Check_Float_Overflow
1648 @noindent
1649 Syntax:
1650 @smallexample @c ada
1651 pragma Check_Float_Overflow;
1652 @end smallexample
1654 @noindent
1655 In Ada, the predefined floating-point types (@code{Short_Float},
1656 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1657 defined to be @emph{unconstrained}. This means that even though each
1658 has a well-defined base range, an operation that delivers a result
1659 outside this base range is not required to raise an exception.
1660 This implementation permission accommodates the notion
1661 of infinities in IEEE floating-point, and corresponds to the
1662 efficient execution mode on most machines. GNAT will not raise
1663 overflow exceptions on these machines; instead it will generate
1664 infinities and NaN's as defined in the IEEE standard.
1666 Generating infinities, although efficient, is not always desirable.
1667 Often the preferable approach is to check for overflow, even at the
1668 (perhaps considerable) expense of run-time performance.
1669 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1670 range constraints -- and indeed such a subtype
1671 can have the same base range as its base type. For example:
1673 @smallexample @c ada
1674 subtype My_Float is Float range Float'Range;
1675 @end smallexample
1677 @noindent
1678 Here @code{My_Float} has the same range as
1679 @code{Float} but is constrained, so operations on
1680 @code{My_Float} values will be checked for overflow
1681 against this range.
1683 This style will achieve the desired goal, but
1684 it is often more convenient to be able to simply use
1685 the standard predefined floating-point types as long
1686 as overflow checking could be guaranteed.
1687 The @code{Check_Float_Overflow}
1688 configuration pragma achieves this effect. If a unit is compiled
1689 subject to this configuration pragma, then all operations
1690 on predefined floating-point types will be treated as
1691 though those types were constrained, and overflow checks
1692 will be generated. The @code{Constraint_Error}
1693 exception is raised if the result is out of range.
1695 This mode can also be set by use of the compiler
1696 switch @option{-gnateF}.
1698 @node Pragma Check_Name
1699 @unnumberedsec Pragma Check_Name
1700 @cindex Defining check names
1701 @cindex Check names, defining
1702 @findex Check_Name
1703 @noindent
1704 Syntax:
1705 @smallexample @c ada
1706 pragma Check_Name (check_name_IDENTIFIER);
1707 @end smallexample
1709 @noindent
1710 This is a configuration pragma that defines a new implementation
1711 defined check name (unless IDENTIFIER matches one of the predefined
1712 check names, in which case the pragma has no effect). Check names
1713 are global to a partition, so if two or more configuration pragmas
1714 are present in a partition mentioning the same name, only one new
1715 check name is introduced.
1717 An implementation defined check name introduced with this pragma may
1718 be used in only three contexts: @code{pragma Suppress},
1719 @code{pragma Unsuppress},
1720 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1721 any of these three cases, the check name must be visible. A check
1722 name is visible if it is in the configuration pragmas applying to
1723 the current unit, or if it appears at the start of any unit that
1724 is part of the dependency set of the current unit (e.g., units that
1725 are mentioned in @code{with} clauses).
1727 Check names introduced by this pragma are subject to control by compiler
1728 switches (in particular -gnatp) in the usual manner.
1730 @node Pragma Check_Policy
1731 @unnumberedsec Pragma Check_Policy
1732 @cindex Controlling assertions
1733 @cindex Assertions, control
1734 @cindex Check pragma control
1735 @cindex Named assertions
1736 @findex Check
1737 @noindent
1738 Syntax:
1739 @smallexample @c ada
1740 pragma Check_Policy
1741  ([Name   =>] CHECK_KIND,
1742   [Policy =>] POLICY_IDENTIFIER);
1744 pragma Check_Policy (
1745     CHECK_KIND => POLICY_IDENTIFIER
1746  @{, CHECK_KIND => POLICY_IDENTIFIER@});
1748 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1750 CHECK_KIND ::= IDENTIFIER           |
1751                Pre'Class            |
1752                Post'Class           |
1753                Type_Invariant'Class |
1754                Invariant'Class
1756 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1757 avoids confusion between the two possible syntax forms for this pragma.
1759 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1760 @end smallexample
1762 @noindent
1763 This pragma is used to set the checking policy for assertions (specified
1764 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1765 to be checked using the @code{Check} pragma. It may appear either as
1766 a configuration pragma, or within a declarative part of package. In the
1767 latter case, it applies from the point where it appears to the end of
1768 the declarative region (like pragma @code{Suppress}).
1770 The @code{Check_Policy} pragma is similar to the
1771 predefined @code{Assertion_Policy} pragma,
1772 and if the check kind corresponds to one of the assertion kinds that
1773 are allowed by @code{Assertion_Policy}, then the effect is identical.
1775 If the first argument is Debug, then the policy applies to Debug pragmas,
1776 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1777 @code{IGNORE}, and allowing them to execute with normal semantics if
1778 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1779 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1780 be totally ignored and not analyzed semantically.
1782 Finally the first argument may be some other identifier than the above
1783 possibilities, in which case it controls a set of named assertions
1784 that can be checked using pragma @code{Check}. For example, if the pragma:
1786 @smallexample @c ada
1787 pragma Check_Policy (Critical_Error, OFF);
1788 @end smallexample
1790 @noindent
1791 is given, then subsequent @code{Check} pragmas whose first argument is also
1792 @code{Critical_Error} will be disabled.
1794 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1795 to turn on corresponding checks. The default for a set of checks for which no
1796 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1797 @option{-gnata} is given, which turns on all checks by default.
1799 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1800 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1801 compatibility with the standard @code{Assertion_Policy} pragma. The check
1802 policy setting @code{DISABLE} causes the second argument of a corresponding
1803 @code{Check} pragma to be completely ignored and not analyzed.
1805 @node Pragma CIL_Constructor
1806 @unnumberedsec Pragma CIL_Constructor
1807 @findex CIL_Constructor
1808 @noindent
1809 Syntax:
1811 @smallexample @c ada
1812 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1813 @end smallexample
1815 @noindent
1816 This pragma is used to assert that the specified Ada function should be
1817 mapped to the .NET constructor for some Ada tagged record type.
1819 See section 4.1 of the
1820 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1821 for related information.
1823 @node Pragma Comment
1824 @unnumberedsec Pragma Comment
1825 @findex Comment
1826 @noindent
1827 Syntax:
1829 @smallexample @c ada
1830 pragma Comment (static_string_EXPRESSION);
1831 @end smallexample
1833 @noindent
1834 This is almost identical in effect to pragma @code{Ident}.  It allows the
1835 placement of a comment into the object file and hence into the
1836 executable file if the operating system permits such usage.  The
1837 difference is that @code{Comment}, unlike @code{Ident}, has
1838 no limitations on placement of the pragma (it can be placed
1839 anywhere in the main source unit), and if more than one pragma
1840 is used, all comments are retained.
1842 @node Pragma Common_Object
1843 @unnumberedsec Pragma Common_Object
1844 @findex Common_Object
1845 @noindent
1846 Syntax:
1848 @smallexample @c ada
1849 pragma Common_Object (
1850      [Internal =>] LOCAL_NAME
1851   [, [External =>] EXTERNAL_SYMBOL]
1852   [, [Size     =>] EXTERNAL_SYMBOL] );
1854 EXTERNAL_SYMBOL ::=
1855   IDENTIFIER
1856 | static_string_EXPRESSION
1857 @end smallexample
1859 @noindent
1860 This pragma enables the shared use of variables stored in overlaid
1861 linker areas corresponding to the use of @code{COMMON}
1862 in Fortran.  The single
1863 object @var{LOCAL_NAME} is assigned to the area designated by
1864 the @var{External} argument.
1865 You may define a record to correspond to a series
1866 of fields.  The @var{Size} argument
1867 is syntax checked in GNAT, but otherwise ignored.
1869 @code{Common_Object} is not supported on all platforms.  If no
1870 support is available, then the code generator will issue a message
1871 indicating that the necessary attribute for implementation of this
1872 pragma is not available.
1874 @node Pragma Compile_Time_Error
1875 @unnumberedsec Pragma Compile_Time_Error
1876 @findex Compile_Time_Error
1877 @noindent
1878 Syntax:
1880 @smallexample @c ada
1881 pragma Compile_Time_Error
1882          (boolean_EXPRESSION, static_string_EXPRESSION);
1883 @end smallexample
1885 @noindent
1886 This pragma can be used to generate additional compile time
1887 error messages. It
1888 is particularly useful in generics, where errors can be issued for
1889 specific problematic instantiations. The first parameter is a boolean
1890 expression. The pragma is effective only if the value of this expression
1891 is known at compile time, and has the value True. The set of expressions
1892 whose values are known at compile time includes all static boolean
1893 expressions, and also other values which the compiler can determine
1894 at compile time (e.g., the size of a record type set by an explicit
1895 size representation clause, or the value of a variable which was
1896 initialized to a constant and is known not to have been modified).
1897 If these conditions are met, an error message is generated using
1898 the value given as the second argument. This string value may contain
1899 embedded ASCII.LF characters to break the message into multiple lines.
1901 @node Pragma Compile_Time_Warning
1902 @unnumberedsec Pragma Compile_Time_Warning
1903 @findex Compile_Time_Warning
1904 @noindent
1905 Syntax:
1907 @smallexample @c ada
1908 pragma Compile_Time_Warning
1909          (boolean_EXPRESSION, static_string_EXPRESSION);
1910 @end smallexample
1912 @noindent
1913 Same as pragma Compile_Time_Error, except a warning is issued instead
1914 of an error message. Note that if this pragma is used in a package that
1915 is with'ed by a client, the client will get the warning even though it
1916 is issued by a with'ed package (normally warnings in with'ed units are
1917 suppressed, but this is a special exception to that rule).
1919 One typical use is within a generic where compile time known characteristics
1920 of formal parameters are tested, and warnings given appropriately. Another use
1921 with a first parameter of True is to warn a client about use of a package,
1922 for example that it is not fully implemented.
1924 @node Pragma Compiler_Unit
1925 @unnumberedsec Pragma Compiler_Unit
1926 @findex Compiler_Unit
1927 @noindent
1928 Syntax:
1930 @smallexample @c ada
1931 pragma Compiler_Unit;
1932 @end smallexample
1934 @noindent
1935 This pragma is intended only for internal use in the GNAT run-time library.
1936 It indicates that the unit is used as part of the compiler build. The effect
1937 is to disallow constructs (raise with message, conditional expressions etc)
1938 that would cause trouble when bootstrapping using an older version of GNAT.
1939 For the exact list of restrictions, see the compiler sources and references
1940 to Is_Compiler_Unit.
1942 @node Pragma Complete_Representation
1943 @unnumberedsec Pragma Complete_Representation
1944 @findex Complete_Representation
1945 @noindent
1946 Syntax:
1948 @smallexample @c ada
1949 pragma Complete_Representation;
1950 @end smallexample
1952 @noindent
1953 This pragma must appear immediately within a record representation
1954 clause. Typical placements are before the first component clause
1955 or after the last component clause. The effect is to give an error
1956 message if any component is missing a component clause. This pragma
1957 may be used to ensure that a record representation clause is
1958 complete, and that this invariant is maintained if fields are
1959 added to the record in the future.
1961 @node Pragma Complex_Representation
1962 @unnumberedsec Pragma Complex_Representation
1963 @findex Complex_Representation
1964 @noindent
1965 Syntax:
1967 @smallexample @c ada
1968 pragma Complex_Representation
1969         ([Entity =>] LOCAL_NAME);
1970 @end smallexample
1972 @noindent
1973 The @var{Entity} argument must be the name of a record type which has
1974 two fields of the same floating-point type.  The effect of this pragma is
1975 to force gcc to use the special internal complex representation form for
1976 this record, which may be more efficient.  Note that this may result in
1977 the code for this type not conforming to standard ABI (application
1978 binary interface) requirements for the handling of record types.  For
1979 example, in some environments, there is a requirement for passing
1980 records by pointer, and the use of this pragma may result in passing
1981 this type in floating-point registers.
1983 @node Pragma Component_Alignment
1984 @unnumberedsec Pragma Component_Alignment
1985 @cindex Alignments of components
1986 @findex Component_Alignment
1987 @noindent
1988 Syntax:
1990 @smallexample @c ada
1991 pragma Component_Alignment (
1992      [Form =>] ALIGNMENT_CHOICE
1993   [, [Name =>] type_LOCAL_NAME]);
1995 ALIGNMENT_CHOICE ::=
1996   Component_Size
1997 | Component_Size_4
1998 | Storage_Unit
1999 | Default
2000 @end smallexample
2002 @noindent
2003 Specifies the alignment of components in array or record types.
2004 The meaning of the @var{Form} argument is as follows:
2006 @table @code
2007 @findex Component_Size
2008 @item Component_Size
2009 Aligns scalar components and subcomponents of the array or record type
2010 on boundaries appropriate to their inherent size (naturally
2011 aligned).  For example, 1-byte components are aligned on byte boundaries,
2012 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2013 integer components are aligned on 4-byte boundaries and so on.  These
2014 alignment rules correspond to the normal rules for C compilers on all
2015 machines except the VAX@.
2017 @findex Component_Size_4
2018 @item Component_Size_4
2019 Naturally aligns components with a size of four or fewer
2020 bytes.  Components that are larger than 4 bytes are placed on the next
2021 4-byte boundary.
2023 @findex Storage_Unit
2024 @item Storage_Unit
2025 Specifies that array or record components are byte aligned, i.e.@:
2026 aligned on boundaries determined by the value of the constant
2027 @code{System.Storage_Unit}.
2029 @cindex OpenVMS
2030 @item Default
2031 Specifies that array or record components are aligned on default
2032 boundaries, appropriate to the underlying hardware or operating system or
2033 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
2034 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
2035 the @code{Default} choice is the same as @code{Component_Size} (natural
2036 alignment).
2037 @end table
2039 @noindent
2040 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2041 refer to a local record or array type, and the specified alignment
2042 choice applies to the specified type.  The use of
2043 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2044 @code{Component_Alignment} pragma to be ignored.  The use of
2045 @code{Component_Alignment} together with a record representation clause
2046 is only effective for fields not specified by the representation clause.
2048 If the @code{Name} parameter is absent, the pragma can be used as either
2049 a configuration pragma, in which case it applies to one or more units in
2050 accordance with the normal rules for configuration pragmas, or it can be
2051 used within a declarative part, in which case it applies to types that
2052 are declared within this declarative part, or within any nested scope
2053 within this declarative part.  In either case it specifies the alignment
2054 to be applied to any record or array type which has otherwise standard
2055 representation.
2057 If the alignment for a record or array type is not specified (using
2058 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2059 clause), the GNAT uses the default alignment as described previously.
2061 @node Pragma Contract_Cases
2062 @unnumberedsec Pragma Contract_Cases
2063 @cindex Contract cases
2064 @findex Contract_Cases
2065 @noindent
2066 Syntax:
2068 @smallexample @c ada
2069 pragma Contract_Cases (
2070    Condition => Consequence
2071  @{,Condition => Consequence@});
2072 @end smallexample
2074 @noindent
2075 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2076 that can complement or replace the contract given by a precondition and a
2077 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2078 by testing and formal verification tools. The compiler checks its validity and,
2079 depending on the assertion policy at the point of declaration of the pragma,
2080 it may insert a check in the executable. For code generation, the contract
2081 cases
2083 @smallexample @c ada
2084 pragma Contract_Cases (
2085   Cond1 => Pred1,
2086   Cond2 => Pred2);
2087 @end smallexample
2089 @noindent
2090 are equivalent to
2092 @smallexample @c ada
2093 C1 : constant Boolean := Cond1;  --  evaluated at subprogram entry
2094 C2 : constant Boolean := Cond2;  --  evaluated at subprogram entry
2095 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2096 pragma Postcondition (if C1 then Pred1);
2097 pragma Postcondition (if C2 then Pred2);
2098 @end smallexample
2100 @noindent
2101 The precondition ensures that one and only one of the conditions is
2102 satisfied on entry to the subprogram.
2103 The postcondition ensures that for the condition that was True on entry,
2104 the corrresponding consequence is True on exit. Other consequence expressions
2105 are not evaluated.
2107 A precondition @code{P} and postcondition @code{Q} can also be
2108 expressed as contract cases:
2110 @smallexample @c ada
2111 pragma Contract_Cases (P => Q);
2112 @end smallexample
2114 The placement and visibility rules for @code{Contract_Cases} pragmas are
2115 identical to those described for preconditions and postconditions.
2117 The compiler checks that boolean expressions given in conditions and
2118 consequences are valid, where the rules for conditions are the same as
2119 the rule for an expression in @code{Precondition} and the rules for
2120 consequences are the same as the rule for an expression in
2121 @code{Postcondition}. In particular, attributes @code{'Old} and
2122 @code{'Result} can only be used within consequence expressions.
2123 The condition for the last contract case may be @code{others}, to denote
2124 any case not captured by the previous cases. The
2125 following is an example of use within a package spec:
2127 @smallexample @c ada
2128 package Math_Functions is
2129    ...
2130    function Sqrt (Arg : Float) return Float;
2131    pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2132                           Arg >= 100       => Sqrt'Result >= 10,
2133                           others           => Sqrt'Result = 0);
2134    ...
2135 end Math_Functions;
2136 @end smallexample
2138 @noindent
2139 The meaning of contract cases is that only one case should apply at each
2140 call, as determined by the corresponding condition evaluating to True,
2141 and that the consequence for this case should hold when the subprogram
2142 returns.
2144 @node Pragma Convention_Identifier
2145 @unnumberedsec Pragma Convention_Identifier
2146 @findex Convention_Identifier
2147 @cindex Conventions, synonyms
2148 @noindent
2149 Syntax:
2151 @smallexample @c ada
2152 pragma Convention_Identifier (
2153          [Name =>]       IDENTIFIER,
2154          [Convention =>] convention_IDENTIFIER);
2155 @end smallexample
2157 @noindent
2158 This pragma provides a mechanism for supplying synonyms for existing
2159 convention identifiers. The @code{Name} identifier can subsequently
2160 be used as a synonym for the given convention in other pragmas (including
2161 for example pragma @code{Import} or another @code{Convention_Identifier}
2162 pragma). As an example of the use of this, suppose you had legacy code
2163 which used Fortran77 as the identifier for Fortran. Then the pragma:
2165 @smallexample @c ada
2166 pragma Convention_Identifier (Fortran77, Fortran);
2167 @end smallexample
2169 @noindent
2170 would allow the use of the convention identifier @code{Fortran77} in
2171 subsequent code, avoiding the need to modify the sources. As another
2172 example, you could use this to parameterize convention requirements
2173 according to systems. Suppose you needed to use @code{Stdcall} on
2174 windows systems, and @code{C} on some other system, then you could
2175 define a convention identifier @code{Library} and use a single
2176 @code{Convention_Identifier} pragma to specify which convention
2177 would be used system-wide.
2179 @node Pragma CPP_Class
2180 @unnumberedsec Pragma CPP_Class
2181 @findex CPP_Class
2182 @cindex Interfacing with C++
2183 @noindent
2184 Syntax:
2186 @smallexample @c ada
2187 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2188 @end smallexample
2190 @noindent
2191 The argument denotes an entity in the current declarative region that is
2192 declared as a record type. It indicates that the type corresponds to an
2193 externally declared C++ class type, and is to be laid out the same way
2194 that C++ would lay out the type. If the C++ class has virtual primitives
2195 then the record must be declared as a tagged record type.
2197 Types for which @code{CPP_Class} is specified do not have assignment or
2198 equality operators defined (such operations can be imported or declared
2199 as subprograms as required). Initialization is allowed only by constructor
2200 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2201 limited if not explicitly declared as limited or derived from a limited
2202 type, and an error is issued in that case.
2204 See @ref{Interfacing to C++} for related information.
2206 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2207 for backward compatibility but its functionality is available
2208 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2210 @node Pragma CPP_Constructor
2211 @unnumberedsec Pragma CPP_Constructor
2212 @cindex Interfacing with C++
2213 @findex CPP_Constructor
2214 @noindent
2215 Syntax:
2217 @smallexample @c ada
2218 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2219   [, [External_Name =>] static_string_EXPRESSION ]
2220   [, [Link_Name     =>] static_string_EXPRESSION ]);
2221 @end smallexample
2223 @noindent
2224 This pragma identifies an imported function (imported in the usual way
2225 with pragma @code{Import}) as corresponding to a C++ constructor. If
2226 @code{External_Name} and @code{Link_Name} are not specified then the
2227 @code{Entity} argument is a name that must have been previously mentioned
2228 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2229 must be of one of the following forms:
2231 @itemize @bullet
2232 @item
2233 @code{function @var{Fname} return @var{T}}
2235 @itemize @bullet
2236 @item
2237 @code{function @var{Fname} return @var{T}'Class}
2239 @item
2240 @code{function @var{Fname} (@dots{}) return @var{T}}
2241 @end itemize
2243 @item
2244 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2245 @end itemize
2247 @noindent
2248 where @var{T} is a limited record type imported from C++ with pragma
2249 @code{Import} and @code{Convention} = @code{CPP}.
2251 The first two forms import the default constructor, used when an object
2252 of type @var{T} is created on the Ada side with no explicit constructor.
2253 The latter two forms cover all the non-default constructors of the type.
2254 See the @value{EDITION} User's Guide for details.
2256 If no constructors are imported, it is impossible to create any objects
2257 on the Ada side and the type is implicitly declared abstract.
2259 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2260 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2261 GCC switch).
2262 See @ref{Interfacing to C++} for more related information.
2264 Note: The use of functions returning class-wide types for constructors is
2265 currently obsolete. They are supported for backward compatibility. The
2266 use of functions returning the type T leave the Ada sources more clear
2267 because the imported C++ constructors always return an object of type T;
2268 that is, they never return an object whose type is a descendant of type T.
2270 @node Pragma CPP_Virtual
2271 @unnumberedsec Pragma CPP_Virtual
2272 @cindex Interfacing to C++
2273 @findex CPP_Virtual
2274 @noindent
2275 This pragma is now obsolete and, other than generating a warning if warnings
2276 on obsolescent features are enabled, is completely ignored.
2277 It is retained for compatibility
2278 purposes. It used to be required to ensure compoatibility with C++, but
2279 is no longer required for that purpose because GNAT generates
2280 the same object layout as the G++ compiler by default.
2282 See @ref{Interfacing to C++} for related information.
2284 @node Pragma CPP_Vtable
2285 @unnumberedsec Pragma CPP_Vtable
2286 @cindex Interfacing with C++
2287 @findex CPP_Vtable
2288 @noindent
2289 This pragma is now obsolete and, other than generating a warning if warnings
2290 on obsolescent features are enabled, is completely ignored.
2291 It used to be required to ensure compatibility with C++, but
2292 is no longer required for that purpose because GNAT generates
2293 the same object layout than the G++ compiler by default.
2295 See @ref{Interfacing to C++} for related information.
2297 @node Pragma CPU
2298 @unnumberedsec Pragma CPU
2299 @findex CPU
2300 @noindent
2301 Syntax:
2303 @smallexample @c ada
2304 pragma CPU (EXPRESSSION);
2305 @end smallexample
2307 @noindent
2308 This pragma is standard in Ada 2012, but is available in all earlier
2309 versions of Ada as an implementation-defined pragma.
2310 See Ada 2012 Reference Manual for details.
2312 @node Pragma Debug
2313 @unnumberedsec Pragma Debug
2314 @findex Debug
2315 @noindent
2316 Syntax:
2318 @smallexample @c ada
2319 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2321 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2322   PROCEDURE_NAME
2323 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2324 @end smallexample
2326 @noindent
2327 The procedure call argument has the syntactic form of an expression, meeting
2328 the syntactic requirements for pragmas.
2330 If debug pragmas are not enabled or if the condition is present and evaluates
2331 to False, this pragma has no effect. If debug pragmas are enabled, the
2332 semantics of the pragma is exactly equivalent to the procedure call statement
2333 corresponding to the argument with a terminating semicolon. Pragmas are
2334 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2335 intersperse calls to debug procedures in the middle of declarations. Debug
2336 pragmas can be enabled either by use of the command line switch @option{-gnata}
2337 or by use of the pragma @code{Check_Policy} with a first argument of
2338 @code{Debug}.
2340 @node Pragma Debug_Policy
2341 @unnumberedsec Pragma Debug_Policy
2342 @findex Debug_Policy
2343 @noindent
2344 Syntax:
2346 @smallexample @c ada
2347 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2348 @end smallexample
2350 @noindent
2351 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2352 with a first argument of @code{Debug}. It is retained for historical
2353 compatibility reasons.
2355 @node Pragma Default_Storage_Pool
2356 @unnumberedsec Pragma Default_Storage_Pool
2357 @findex Default_Storage_Pool
2358 @noindent
2359 Syntax:
2361 @smallexample @c ada
2362 pragma Default_Storage_Pool (storage_pool_NAME | null);
2363 @end smallexample
2365 @noindent
2366 This pragma is standard in Ada 2012, but is available in all earlier
2367 versions of Ada as an implementation-defined pragma.
2368 See Ada 2012 Reference Manual for details.
2370 @node Pragma Detect_Blocking
2371 @unnumberedsec Pragma Detect_Blocking
2372 @findex Detect_Blocking
2373 @noindent
2374 Syntax:
2376 @smallexample @c ada
2377 pragma Detect_Blocking;
2378 @end smallexample
2380 @noindent
2381 This is a standard pragma in Ada 2005, that is available in all earlier
2382 versions of Ada as an implementation-defined pragma.
2384 This is a configuration pragma that forces the detection of potentially
2385 blocking operations within a protected operation, and to raise Program_Error
2386 if that happens.
2388 @node Pragma Disable_Atomic_Synchronization
2389 @unnumberedsec Pragma Disable_Atomic_Synchronization
2390 @cindex Atomic Synchronization
2391 @findex Disable_Atomic_Synchronization
2392 @noindent
2393 Syntax:
2395 @smallexample @c ada
2396 pragma Disable_Atomic_Synchronization [(Entity)];
2397 @end smallexample
2399 @noindent
2400 Ada requires that accesses (reads or writes) of an atomic variable be
2401 regarded as synchronization points in the case of multiple tasks.
2402 Particularly in the case of multi-processors this may require special
2403 handling, e.g. the generation of memory barriers. This capability may
2404 be turned off using this pragma in cases where it is known not to be
2405 required.
2407 The placement and scope rules for this pragma are the same as those
2408 for @code{pragma Suppress}. In particular it can be used as a
2409 configuration  pragma, or in a declaration sequence where it applies
2410 till the end of the scope. If an @code{Entity} argument is present,
2411 the action applies only to that entity.
2413 @node Pragma Dispatching_Domain
2414 @unnumberedsec Pragma Dispatching_Domain
2415 @findex Dispatching_Domain
2416 @noindent
2417 Syntax:
2419 @smallexample @c ada
2420 pragma Dispatching_Domain (EXPRESSION);
2421 @end smallexample
2423 @noindent
2424 This pragma is standard in Ada 2012, but is available in all earlier
2425 versions of Ada as an implementation-defined pragma.
2426 See Ada 2012 Reference Manual for details.
2428 @node Pragma Elaboration_Checks
2429 @unnumberedsec Pragma Elaboration_Checks
2430 @cindex Elaboration control
2431 @findex Elaboration_Checks
2432 @noindent
2433 Syntax:
2435 @smallexample @c ada
2436 pragma Elaboration_Checks (Dynamic | Static);
2437 @end smallexample
2439 @noindent
2440 This is a configuration pragma that provides control over the
2441 elaboration model used by the compilation affected by the
2442 pragma.  If the parameter is @code{Dynamic},
2443 then the dynamic elaboration
2444 model described in the Ada Reference Manual is used, as though
2445 the @option{-gnatE} switch had been specified on the command
2446 line.  If the parameter is @code{Static}, then the default GNAT static
2447 model is used.  This configuration pragma overrides the setting
2448 of the command line.  For full details on the elaboration models
2449 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2450 gnat_ugn, @value{EDITION} User's Guide}.
2452 @node Pragma Eliminate
2453 @unnumberedsec Pragma Eliminate
2454 @cindex Elimination of unused subprograms
2455 @findex Eliminate
2456 @noindent
2457 Syntax:
2459 @smallexample @c ada
2460 pragma Eliminate ([Entity          =>] DEFINING_DESIGNATOR,
2461                   [Source_Location =>] STRING_LITERAL);
2462 @end smallexample
2464 @noindent
2465 The string literal given for the source location is a string which
2466 specifies the line number of the occurrence of the entity, using
2467 the syntax for SOURCE_TRACE given below:
2469 @smallexample @c ada
2470  SOURCE_TRACE     ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2472  LBRACKET         ::= [
2473  RBRACKET         ::= ]
2475  SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2477  LINE_NUMBER      ::= DIGIT @{DIGIT@}
2478 @end smallexample
2480 @noindent
2481 Spaces around the colon in a @code{Source_Reference} are optional.
2483 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2484 explicit subprogram declaration, where the @code{entity} name in this
2485 designator appears on the source line specified by the source location.
2487 The source trace that is given as the @code{Source_Location} shall obey the
2488 following rules. The @code{FILE_NAME} is the short name (with no directory
2489 information) of an Ada source file, given using exactly the required syntax
2490 for the underlying file system (e.g. case is important if the underlying
2491 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2492 number of the occurrence of the @code{entity}
2493 as a decimal literal without an exponent or point. If an @code{entity} is not
2494 declared in a generic instantiation (this includes generic subprogram
2495 instances), the source trace includes only one source reference. If an entity
2496 is declared inside a generic instantiation, its source trace (when parsing
2497 from left to right) starts with the source location of the declaration of the
2498 entity in the generic unit and ends with the source location of the
2499 instantiation (it is given in square brackets). This approach is recursively
2500 used in case of nested instantiations: the rightmost (nested most deeply in
2501 square brackets) element of the source trace is the location of the outermost
2502 instantiation, the next to left element is the location of the next (first
2503 nested) instantiation in the code of the corresponding generic unit, and so
2504 on, and the leftmost element (that is out of any square brackets) is the
2505 location of the declaration of the entity to eliminate in a generic unit.
2507 Note that the @code{Source_Location} argument specifies which of a set of
2508 similarly named entities is being eliminated, dealing both with overloading,
2509 and also appearance of the same entity name in different scopes.
2511 This pragma indicates that the given entity is not used in the program to be
2512 compiled and built. The effect of the pragma is to allow the compiler to
2513 eliminate the code or data associated with the named entity. Any reference to
2514 an eliminated entity causes a compile-time or link-time error.
2516 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2517 in a system-independent manner, with unused entities eliminated, without
2518 needing to modify the source text. Normally the required set of
2519 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2521 Any source file change that removes, splits, or
2522 adds lines may make the set of Eliminate pragmas invalid because their
2523 @code{Source_Location} argument values may get out of date.
2525 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2526 operation. In this case all the subprograms to which the given operation can
2527 dispatch are considered to be unused (are never called as a result of a direct
2528 or a dispatching call).
2530 @node Pragma Enable_Atomic_Synchronization
2531 @unnumberedsec Pragma Enable_Atomic_Synchronization
2532 @cindex Atomic Synchronization
2533 @findex Enable_Atomic_Synchronization
2534 @noindent
2535 Syntax:
2537 @smallexample @c ada
2538 pragma Enable_Atomic_Synchronization [(Entity)];
2539 @end smallexample
2541 @noindent
2542 Ada requires that accesses (reads or writes) of an atomic variable be
2543 regarded as synchronization points in the case of multiple tasks.
2544 Particularly in the case of multi-processors this may require special
2545 handling, e.g. the generation of memory barriers. This synchronization
2546 is performed by default, but can be turned off using
2547 @code{pragma Disable_Atomic_Synchronization}. The
2548 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2549 it back on.
2551 The placement and scope rules for this pragma are the same as those
2552 for @code{pragma Unsuppress}. In particular it can be used as a
2553 configuration  pragma, or in a declaration sequence where it applies
2554 till the end of the scope. If an @code{Entity} argument is present,
2555 the action applies only to that entity.
2557 @node Pragma Export_Exception
2558 @unnumberedsec Pragma Export_Exception
2559 @cindex OpenVMS
2560 @findex Export_Exception
2561 @noindent
2562 Syntax:
2564 @smallexample @c ada
2565 pragma Export_Exception (
2566      [Internal =>] LOCAL_NAME
2567   [, [External =>] EXTERNAL_SYMBOL]
2568   [, [Form     =>] Ada | VMS]
2569   [, [Code     =>] static_integer_EXPRESSION]);
2571 EXTERNAL_SYMBOL ::=
2572   IDENTIFIER
2573 | static_string_EXPRESSION
2574 @end smallexample
2576 @noindent
2577 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
2578 causes the specified exception to be propagated outside of the Ada program,
2579 so that it can be handled by programs written in other OpenVMS languages.
2580 This pragma establishes an external name for an Ada exception and makes the
2581 name available to the OpenVMS Linker as a global symbol.  For further details
2582 on this pragma, see the
2583 DEC Ada Language Reference Manual, section 13.9a3.2.
2585 @node Pragma Export_Function
2586 @unnumberedsec Pragma Export_Function
2587 @cindex Argument passing mechanisms
2588 @findex Export_Function
2590 @noindent
2591 Syntax:
2593 @smallexample @c ada
2594 pragma Export_Function (
2595      [Internal         =>] LOCAL_NAME
2596   [, [External         =>] EXTERNAL_SYMBOL]
2597   [, [Parameter_Types  =>] PARAMETER_TYPES]
2598   [, [Result_Type      =>] result_SUBTYPE_MARK]
2599   [, [Mechanism        =>] MECHANISM]
2600   [, [Result_Mechanism =>] MECHANISM_NAME]);
2602 EXTERNAL_SYMBOL ::=
2603   IDENTIFIER
2604 | static_string_EXPRESSION
2605 | ""
2607 PARAMETER_TYPES ::=
2608   null
2609 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2611 TYPE_DESIGNATOR ::=
2612   subtype_NAME
2613 | subtype_Name ' Access
2615 MECHANISM ::=
2616   MECHANISM_NAME
2617 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2619 MECHANISM_ASSOCIATION ::=
2620   [formal_parameter_NAME =>] MECHANISM_NAME
2622 MECHANISM_NAME ::=
2623   Value
2624 | Reference
2625 | Descriptor [([Class =>] CLASS_NAME)]
2626 | Short_Descriptor [([Class =>] CLASS_NAME)]
2628 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2629 @end smallexample
2631 @noindent
2632 Use this pragma to make a function externally callable and optionally
2633 provide information on mechanisms to be used for passing parameter and
2634 result values.  We recommend, for the purposes of improving portability,
2635 this pragma always be used in conjunction with a separate pragma
2636 @code{Export}, which must precede the pragma @code{Export_Function}.
2637 GNAT does not require a separate pragma @code{Export}, but if none is
2638 present, @code{Convention Ada} is assumed, which is usually
2639 not what is wanted, so it is usually appropriate to use this
2640 pragma in conjunction with a @code{Export} or @code{Convention}
2641 pragma that specifies the desired foreign convention.
2642 Pragma @code{Export_Function}
2643 (and @code{Export}, if present) must appear in the same declarative
2644 region as the function to which they apply.
2646 @var{internal_name} must uniquely designate the function to which the
2647 pragma applies.  If more than one function name exists of this name in
2648 the declarative part you must use the @code{Parameter_Types} and
2649 @code{Result_Type} parameters is mandatory to achieve the required
2650 unique designation.  @var{subtype_mark}s in these parameters must
2651 exactly match the subtypes in the corresponding function specification,
2652 using positional notation to match parameters with subtype marks.
2653 The form with an @code{'Access} attribute can be used to match an
2654 anonymous access parameter.
2656 @cindex OpenVMS
2657 @cindex Passing by descriptor
2658 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2659 The default behavior for Export_Function is to accept either 64bit or
2660 32bit descriptors unless short_descriptor is specified, then only 32bit
2661 descriptors are accepted.
2663 @cindex Suppressing external name
2664 Special treatment is given if the EXTERNAL is an explicit null
2665 string or a static string expressions that evaluates to the null
2666 string. In this case, no external name is generated. This form
2667 still allows the specification of parameter mechanisms.
2669 @node Pragma Export_Object
2670 @unnumberedsec Pragma Export_Object
2671 @findex Export_Object
2672 @noindent
2673 Syntax:
2675 @smallexample @c ada
2676 pragma Export_Object
2677       [Internal =>] LOCAL_NAME
2678    [, [External =>] EXTERNAL_SYMBOL]
2679    [, [Size     =>] EXTERNAL_SYMBOL]
2681 EXTERNAL_SYMBOL ::=
2682   IDENTIFIER
2683 | static_string_EXPRESSION
2684 @end smallexample
2686 @noindent
2687 This pragma designates an object as exported, and apart from the
2688 extended rules for external symbols, is identical in effect to the use of
2689 the normal @code{Export} pragma applied to an object.  You may use a
2690 separate Export pragma (and you probably should from the point of view
2691 of portability), but it is not required.  @var{Size} is syntax checked,
2692 but otherwise ignored by GNAT@.
2694 @node Pragma Export_Procedure
2695 @unnumberedsec Pragma Export_Procedure
2696 @findex Export_Procedure
2697 @noindent
2698 Syntax:
2700 @smallexample @c ada
2701 pragma Export_Procedure (
2702      [Internal        =>] LOCAL_NAME
2703   [, [External        =>] EXTERNAL_SYMBOL]
2704   [, [Parameter_Types =>] PARAMETER_TYPES]
2705   [, [Mechanism       =>] MECHANISM]);
2707 EXTERNAL_SYMBOL ::=
2708   IDENTIFIER
2709 | static_string_EXPRESSION
2710 | ""
2712 PARAMETER_TYPES ::=
2713   null
2714 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2716 TYPE_DESIGNATOR ::=
2717   subtype_NAME
2718 | subtype_Name ' Access
2720 MECHANISM ::=
2721   MECHANISM_NAME
2722 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2724 MECHANISM_ASSOCIATION ::=
2725   [formal_parameter_NAME =>] MECHANISM_NAME
2727 MECHANISM_NAME ::=
2728   Value
2729 | Reference
2730 | Descriptor [([Class =>] CLASS_NAME)]
2731 | Short_Descriptor [([Class =>] CLASS_NAME)]
2733 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2734 @end smallexample
2736 @noindent
2737 This pragma is identical to @code{Export_Function} except that it
2738 applies to a procedure rather than a function and the parameters
2739 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2740 GNAT does not require a separate pragma @code{Export}, but if none is
2741 present, @code{Convention Ada} is assumed, which is usually
2742 not what is wanted, so it is usually appropriate to use this
2743 pragma in conjunction with a @code{Export} or @code{Convention}
2744 pragma that specifies the desired foreign convention.
2746 @cindex OpenVMS
2747 @cindex Passing by descriptor
2748 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2749 The default behavior for Export_Procedure is to accept either 64bit or
2750 32bit descriptors unless short_descriptor is specified, then only 32bit
2751 descriptors are accepted.
2753 @cindex Suppressing external name
2754 Special treatment is given if the EXTERNAL is an explicit null
2755 string or a static string expressions that evaluates to the null
2756 string. In this case, no external name is generated. This form
2757 still allows the specification of parameter mechanisms.
2759 @node Pragma Export_Value
2760 @unnumberedsec Pragma Export_Value
2761 @findex Export_Value
2762 @noindent
2763 Syntax:
2765 @smallexample @c ada
2766 pragma Export_Value (
2767   [Value     =>] static_integer_EXPRESSION,
2768   [Link_Name =>] static_string_EXPRESSION);
2769 @end smallexample
2771 @noindent
2772 This pragma serves to export a static integer value for external use.
2773 The first argument specifies the value to be exported. The Link_Name
2774 argument specifies the symbolic name to be associated with the integer
2775 value. This pragma is useful for defining a named static value in Ada
2776 that can be referenced in assembly language units to be linked with
2777 the application. This pragma is currently supported only for the
2778 AAMP target and is ignored for other targets.
2780 @node Pragma Export_Valued_Procedure
2781 @unnumberedsec Pragma Export_Valued_Procedure
2782 @findex Export_Valued_Procedure
2783 @noindent
2784 Syntax:
2786 @smallexample @c ada
2787 pragma Export_Valued_Procedure (
2788      [Internal        =>] LOCAL_NAME
2789   [, [External        =>] EXTERNAL_SYMBOL]
2790   [, [Parameter_Types =>] PARAMETER_TYPES]
2791   [, [Mechanism       =>] MECHANISM]);
2793 EXTERNAL_SYMBOL ::=
2794   IDENTIFIER
2795 | static_string_EXPRESSION
2796 | ""
2798 PARAMETER_TYPES ::=
2799   null
2800 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2802 TYPE_DESIGNATOR ::=
2803   subtype_NAME
2804 | subtype_Name ' Access
2806 MECHANISM ::=
2807   MECHANISM_NAME
2808 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2810 MECHANISM_ASSOCIATION ::=
2811   [formal_parameter_NAME =>] MECHANISM_NAME
2813 MECHANISM_NAME ::=
2814   Value
2815 | Reference
2816 | Descriptor [([Class =>] CLASS_NAME)]
2817 | Short_Descriptor [([Class =>] CLASS_NAME)]
2819 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2820 @end smallexample
2822 @noindent
2823 This pragma is identical to @code{Export_Procedure} except that the
2824 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2825 mode @code{OUT}, and externally the subprogram is treated as a function
2826 with this parameter as the result of the function.  GNAT provides for
2827 this capability to allow the use of @code{OUT} and @code{IN OUT}
2828 parameters in interfacing to external functions (which are not permitted
2829 in Ada functions).
2830 GNAT does not require a separate pragma @code{Export}, but if none is
2831 present, @code{Convention Ada} is assumed, which is almost certainly
2832 not what is wanted since the whole point of this pragma is to interface
2833 with foreign language functions, so it is usually appropriate to use this
2834 pragma in conjunction with a @code{Export} or @code{Convention}
2835 pragma that specifies the desired foreign convention.
2837 @cindex OpenVMS
2838 @cindex Passing by descriptor
2839 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2840 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2841 32bit descriptors unless short_descriptor is specified, then only 32bit
2842 descriptors are accepted.
2844 @cindex Suppressing external name
2845 Special treatment is given if the EXTERNAL is an explicit null
2846 string or a static string expressions that evaluates to the null
2847 string. In this case, no external name is generated. This form
2848 still allows the specification of parameter mechanisms.
2850 @node Pragma Extend_System
2851 @unnumberedsec Pragma Extend_System
2852 @cindex @code{system}, extending
2853 @cindex Dec Ada 83
2854 @findex Extend_System
2855 @noindent
2856 Syntax:
2858 @smallexample @c ada
2859 pragma Extend_System ([Name =>] IDENTIFIER);
2860 @end smallexample
2862 @noindent
2863 This pragma is used to provide backwards compatibility with other
2864 implementations that extend the facilities of package @code{System}.  In
2865 GNAT, @code{System} contains only the definitions that are present in
2866 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2867 implementation, provide many extensions to package @code{System}.
2869 For each such implementation accommodated by this pragma, GNAT provides a
2870 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2871 implementation, which provides the required additional definitions.  You
2872 can use this package in two ways.  You can @code{with} it in the normal
2873 way and access entities either by selection or using a @code{use}
2874 clause.  In this case no special processing is required.
2876 However, if existing code contains references such as
2877 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2878 definitions provided in package @code{System}, you may use this pragma
2879 to extend visibility in @code{System} in a non-standard way that
2880 provides greater compatibility with the existing code.  Pragma
2881 @code{Extend_System} is a configuration pragma whose single argument is
2882 the name of the package containing the extended definition
2883 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2884 control of this pragma will be processed using special visibility
2885 processing that looks in package @code{System.Aux_@var{xxx}} where
2886 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2887 package @code{System}, but not found in package @code{System}.
2889 You can use this pragma either to access a predefined @code{System}
2890 extension supplied with the compiler, for example @code{Aux_DEC} or
2891 you can construct your own extension unit following the above
2892 definition.  Note that such a package is a child of @code{System}
2893 and thus is considered part of the implementation.  To compile
2894 it you will have to use the appropriate switch for compiling
2895 system units.
2896 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2897 for details.
2899 @node Pragma Extensions_Allowed
2900 @unnumberedsec Pragma Extensions_Allowed
2901 @cindex Ada Extensions
2902 @cindex GNAT Extensions
2903 @findex Extensions_Allowed
2904 @noindent
2905 Syntax:
2907 @smallexample @c ada
2908 pragma Extensions_Allowed (On | Off);
2909 @end smallexample
2911 @noindent
2912 This configuration pragma enables or disables the implementation
2913 extension mode (the use of Off as a parameter cancels the effect
2914 of the @option{-gnatX} command switch).
2916 In extension mode, the latest version of the Ada language is
2917 implemented (currently Ada 2012), and in addition a small number
2918 of GNAT specific extensions are recognized as follows:
2920 @table @asis
2921 @item Constrained attribute for generic objects
2922 The @code{Constrained} attribute is permitted for objects of
2923 generic types. The result indicates if the corresponding actual
2924 is constrained.
2926 @end table
2928 @node Pragma External
2929 @unnumberedsec Pragma External
2930 @findex External
2931 @noindent
2932 Syntax:
2934 @smallexample @c ada
2935 pragma External (
2936   [   Convention    =>] convention_IDENTIFIER,
2937   [   Entity        =>] LOCAL_NAME
2938   [, [External_Name =>] static_string_EXPRESSION ]
2939   [, [Link_Name     =>] static_string_EXPRESSION ]);
2940 @end smallexample
2942 @noindent
2943 This pragma is identical in syntax and semantics to pragma
2944 @code{Export} as defined in the Ada Reference Manual.  It is
2945 provided for compatibility with some Ada 83 compilers that
2946 used this pragma for exactly the same purposes as pragma
2947 @code{Export} before the latter was standardized.
2949 @node Pragma External_Name_Casing
2950 @unnumberedsec Pragma External_Name_Casing
2951 @cindex Dec Ada 83 casing compatibility
2952 @cindex External Names, casing
2953 @cindex Casing of External names
2954 @findex External_Name_Casing
2955 @noindent
2956 Syntax:
2958 @smallexample @c ada
2959 pragma External_Name_Casing (
2960   Uppercase | Lowercase
2961   [, Uppercase | Lowercase | As_Is]);
2962 @end smallexample
2964 @noindent
2965 This pragma provides control over the casing of external names associated
2966 with Import and Export pragmas.  There are two cases to consider:
2968 @table @asis
2969 @item Implicit external names
2970 Implicit external names are derived from identifiers.  The most common case
2971 arises when a standard Ada Import or Export pragma is used with only two
2972 arguments, as in:
2974 @smallexample @c ada
2975    pragma Import (C, C_Routine);
2976 @end smallexample
2978 @noindent
2979 Since Ada is a case-insensitive language, the spelling of the identifier in
2980 the Ada source program does not provide any information on the desired
2981 casing of the external name, and so a convention is needed.  In GNAT the
2982 default treatment is that such names are converted to all lower case
2983 letters.  This corresponds to the normal C style in many environments.
2984 The first argument of pragma @code{External_Name_Casing} can be used to
2985 control this treatment.  If @code{Uppercase} is specified, then the name
2986 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2987 then the normal default of all lower case letters will be used.
2989 This same implicit treatment is also used in the case of extended DEC Ada 83
2990 compatible Import and Export pragmas where an external name is explicitly
2991 specified using an identifier rather than a string.
2993 @item Explicit external names
2994 Explicit external names are given as string literals.  The most common case
2995 arises when a standard Ada Import or Export pragma is used with three
2996 arguments, as in:
2998 @smallexample @c ada
2999 pragma Import (C, C_Routine, "C_routine");
3000 @end smallexample
3002 @noindent
3003 In this case, the string literal normally provides the exact casing required
3004 for the external name.  The second argument of pragma
3005 @code{External_Name_Casing} may be used to modify this behavior.
3006 If @code{Uppercase} is specified, then the name
3007 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3008 then the name will be forced to all lowercase letters.  A specification of
3009 @code{As_Is} provides the normal default behavior in which the casing is
3010 taken from the string provided.
3011 @end table
3013 @noindent
3014 This pragma may appear anywhere that a pragma is valid.  In particular, it
3015 can be used as a configuration pragma in the @file{gnat.adc} file, in which
3016 case it applies to all subsequent compilations, or it can be used as a program
3017 unit pragma, in which case it only applies to the current unit, or it can
3018 be used more locally to control individual Import/Export pragmas.
3020 It is primarily intended for use with OpenVMS systems, where many
3021 compilers convert all symbols to upper case by default.  For interfacing to
3022 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3023 the pragma:
3025 @smallexample @c ada
3026 pragma External_Name_Casing (Uppercase, Uppercase);
3027 @end smallexample
3029 @noindent
3030 to enforce the upper casing of all external symbols.
3032 @node Pragma Fast_Math
3033 @unnumberedsec Pragma Fast_Math
3034 @findex Fast_Math
3035 @noindent
3036 Syntax:
3038 @smallexample @c ada
3039 pragma Fast_Math;
3040 @end smallexample
3042 @noindent
3043 This is a configuration pragma which activates a mode in which speed is
3044 considered more important for floating-point operations than absolutely
3045 accurate adherence to the requirements of the standard. Currently the
3046 following operations are affected:
3048 @table @asis
3049 @item Complex Multiplication
3050 The normal simple formula for complex multiplication can result in intermediate
3051 overflows for numbers near the end of the range. The Ada standard requires that
3052 this situation be detected and corrected by scaling, but in Fast_Math mode such
3053 cases will simply result in overflow. Note that to take advantage of this you
3054 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3055 under control of the pragma, rather than use the preinstantiated versions.
3056 @end table
3058 @node Pragma Favor_Top_Level
3059 @unnumberedsec Pragma Favor_Top_Level
3060 @findex Favor_Top_Level
3061 @noindent
3062 Syntax:
3064 @smallexample @c ada
3065 pragma Favor_Top_Level (type_NAME);
3066 @end smallexample
3068 @noindent
3069 The named type must be an access-to-subprogram type. This pragma is an
3070 efficiency hint to the compiler, regarding the use of 'Access or
3071 'Unrestricted_Access on nested (non-library-level) subprograms. The
3072 pragma means that nested subprograms are not used with this type, or
3073 are rare, so that the generated code should be efficient in the
3074 top-level case. When this pragma is used, dynamically generated
3075 trampolines may be used on some targets for nested subprograms.
3076 See also the No_Implicit_Dynamic_Code restriction.
3078 @node Pragma Finalize_Storage_Only
3079 @unnumberedsec Pragma Finalize_Storage_Only
3080 @findex Finalize_Storage_Only
3081 @noindent
3082 Syntax:
3084 @smallexample @c ada
3085 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3086 @end smallexample
3088 @noindent
3089 This pragma allows the compiler not to emit a Finalize call for objects
3090 defined at the library level.  This is mostly useful for types where
3091 finalization is only used to deal with storage reclamation since in most
3092 environments it is not necessary to reclaim memory just before terminating
3093 execution, hence the name.
3095 @node Pragma Float_Representation
3096 @unnumberedsec Pragma Float_Representation
3097 @cindex OpenVMS
3098 @findex Float_Representation
3099 @noindent
3100 Syntax:
3102 @smallexample @c ada
3103 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3105 FLOAT_REP ::= VAX_Float | IEEE_Float
3106 @end smallexample
3108 @noindent
3109 In the one argument form, this pragma is a configuration pragma which
3110 allows control over the internal representation chosen for the predefined
3111 floating point types declared in the packages @code{Standard} and
3112 @code{System}. On all systems other than OpenVMS, the argument must
3113 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3114 argument may be @code{VAX_Float} to specify the use of the VAX float
3115 format for the floating-point types in Standard. This requires that
3116 the standard runtime libraries be recompiled.
3118 The two argument form specifies the representation to be used for
3119 the specified floating-point type. On all systems other than OpenVMS,
3120 the argument must
3121 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3123 @itemize @bullet
3124 @item
3125 For a digits value of 6, 32-bit IEEE short format will be used.
3126 @item
3127 For a digits value of 15, 64-bit IEEE long format will be used.
3128 @item
3129 No other value of digits is permitted.
3130 @end itemize
3132 On OpenVMS, the
3133 argument may be @code{VAX_Float} to specify the use of the VAX float
3134 format, as follows:
3136 @itemize @bullet
3137 @item
3138 For digits values up to 6, F float format will be used.
3139 @item
3140 For digits values from 7 to 9, D float format will be used.
3141 @item
3142 For digits values from 10 to 15, G float format will be used.
3143 @item
3144 Digits values above 15 are not allowed.
3145 @end itemize
3147 @node Pragma Ident
3148 @unnumberedsec Pragma Ident
3149 @findex Ident
3150 @noindent
3151 Syntax:
3153 @smallexample @c ada
3154 pragma Ident (static_string_EXPRESSION);
3155 @end smallexample
3157 @noindent
3158 This pragma provides a string identification in the generated object file,
3159 if the system supports the concept of this kind of identification string.
3160 This pragma is allowed only in the outermost declarative part or
3161 declarative items of a compilation unit. If more than one @code{Ident}
3162 pragma is given, only the last one processed is effective.
3163 @cindex OpenVMS
3164 On OpenVMS systems, the effect of the pragma is identical to the effect of
3165 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
3166 maximum allowed length is 31 characters, so if it is important to
3167 maintain compatibility with this compiler, you should obey this length
3168 limit.
3170 @node Pragma Implementation_Defined
3171 @unnumberedsec Pragma Implementation_Defined
3172 @findex Implementation_Defined
3173 @noindent
3174 Syntax:
3176 @smallexample @c ada
3177 pragma Implementation_Defined (local_NAME);
3178 @end smallexample
3180 @noindent
3181 This pragma marks a previously declared entioty as implementation-defined.
3182 For an overloaded entity, applies to the most recent homonym.
3184 @smallexample @c ada
3185 pragma Implementation_Defined;
3186 @end smallexample
3188 @noindent
3189 The form with no arguments appears anywhere within a scope, most
3190 typically a package spec, and indicates that all entities that are
3191 defined within the package spec are Implementation_Defined.
3193 This pragma is used within the GNAT runtime library to identify
3194 implementation-defined entities introduced in language-defined units,
3195 for the purpose of implementing the No_Implementation_Identifiers
3196 restriction.
3198 @node Pragma Implemented
3199 @unnumberedsec Pragma Implemented
3200 @findex Implemented
3201 @noindent
3202 Syntax:
3204 @smallexample @c ada
3205 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3207 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3208 @end smallexample
3210 @noindent
3211 This is an Ada 2012 representation pragma which applies to protected, task
3212 and synchronized interface primitives. The use of pragma Implemented provides
3213 a way to impose a static requirement on the overriding operation by adhering
3214 to one of the three implementation kinds: entry, protected procedure or any of
3215 the above. This pragma is available in all earlier versions of Ada as an
3216 implementation-defined pragma.
3218 @smallexample @c ada
3219 type Synch_Iface is synchronized interface;
3220 procedure Prim_Op (Obj : in out Iface) is abstract;
3221 pragma Implemented (Prim_Op, By_Protected_Procedure);
3223 protected type Prot_1 is new Synch_Iface with
3224    procedure Prim_Op;  --  Legal
3225 end Prot_1;
3227 protected type Prot_2 is new Synch_Iface with
3228    entry Prim_Op;      --  Illegal
3229 end Prot_2;
3231 task type Task_Typ is new Synch_Iface with
3232    entry Prim_Op;      --  Illegal
3233 end Task_Typ;
3234 @end smallexample
3236 @noindent
3237 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3238 Implemented determines the runtime behavior of the requeue. Implementation kind
3239 By_Entry guarantees that the action of requeueing will proceed from an entry to
3240 another entry. Implementation kind By_Protected_Procedure transforms the
3241 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3242 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3243 the target's overriding subprogram kind.
3245 @node Pragma Implicit_Packing
3246 @unnumberedsec Pragma Implicit_Packing
3247 @findex Implicit_Packing
3248 @cindex Rational Profile
3249 @noindent
3250 Syntax:
3252 @smallexample @c ada
3253 pragma Implicit_Packing;
3254 @end smallexample
3256 @noindent
3257 This is a configuration pragma that requests implicit packing for packed
3258 arrays for which a size clause is given but no explicit pragma Pack or
3259 specification of Component_Size is present. It also applies to records
3260 where no record representation clause is present. Consider this example:
3262 @smallexample @c ada
3263 type R is array (0 .. 7) of Boolean;
3264 for R'Size use 8;
3265 @end smallexample
3267 @noindent
3268 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3269 does not change the layout of a composite object. So the Size clause in the
3270 above example is normally rejected, since the default layout of the array uses
3271 8-bit components, and thus the array requires a minimum of 64 bits.
3273 If this declaration is compiled in a region of code covered by an occurrence
3274 of the configuration pragma Implicit_Packing, then the Size clause in this
3275 and similar examples will cause implicit packing and thus be accepted. For
3276 this implicit packing to occur, the type in question must be an array of small
3277 components whose size is known at compile time, and the Size clause must
3278 specify the exact size that corresponds to the number of elements in the array
3279 multiplied by the size in bits of the component type (both single and
3280 multi-dimensioned arrays can be controlled with this pragma).
3282 @cindex Array packing
3284 Similarly, the following example shows the use in the record case
3286 @smallexample @c ada
3287 type r is record
3288    a, b, c, d, e, f, g, h : boolean;
3289    chr                    : character;
3290 end record;
3291 for r'size use 16;
3292 @end smallexample
3294 @noindent
3295 Without a pragma Pack, each Boolean field requires 8 bits, so the
3296 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3297 sufficient. The use of pragma Implicit_Packing allows this record
3298 declaration to compile without an explicit pragma Pack.
3299 @node Pragma Import_Exception
3300 @unnumberedsec Pragma Import_Exception
3301 @cindex OpenVMS
3302 @findex Import_Exception
3303 @noindent
3304 Syntax:
3306 @smallexample @c ada
3307 pragma Import_Exception (
3308      [Internal =>] LOCAL_NAME
3309   [, [External =>] EXTERNAL_SYMBOL]
3310   [, [Form     =>] Ada | VMS]
3311   [, [Code     =>] static_integer_EXPRESSION]);
3313 EXTERNAL_SYMBOL ::=
3314   IDENTIFIER
3315 | static_string_EXPRESSION
3316 @end smallexample
3318 @noindent
3319 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3320 It allows OpenVMS conditions (for example, from OpenVMS system services or
3321 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3322 The pragma specifies that the exception associated with an exception
3323 declaration in an Ada program be defined externally (in non-Ada code).
3324 For further details on this pragma, see the
3325 DEC Ada Language Reference Manual, section 13.9a.3.1.
3327 @node Pragma Import_Function
3328 @unnumberedsec Pragma Import_Function
3329 @findex Import_Function
3330 @noindent
3331 Syntax:
3333 @smallexample @c ada
3334 pragma Import_Function (
3335      [Internal                 =>] LOCAL_NAME,
3336   [, [External                 =>] EXTERNAL_SYMBOL]
3337   [, [Parameter_Types          =>] PARAMETER_TYPES]
3338   [, [Result_Type              =>] SUBTYPE_MARK]
3339   [, [Mechanism                =>] MECHANISM]
3340   [, [Result_Mechanism         =>] MECHANISM_NAME]
3341   [, [First_Optional_Parameter =>] IDENTIFIER]);
3343 EXTERNAL_SYMBOL ::=
3344   IDENTIFIER
3345 | static_string_EXPRESSION
3347 PARAMETER_TYPES ::=
3348   null
3349 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3351 TYPE_DESIGNATOR ::=
3352   subtype_NAME
3353 | subtype_Name ' Access
3355 MECHANISM ::=
3356   MECHANISM_NAME
3357 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3359 MECHANISM_ASSOCIATION ::=
3360   [formal_parameter_NAME =>] MECHANISM_NAME
3362 MECHANISM_NAME ::=
3363   Value
3364 | Reference
3365 | Descriptor [([Class =>] CLASS_NAME)]
3366 | Short_Descriptor [([Class =>] CLASS_NAME)]
3368 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3369 @end smallexample
3371 @noindent
3372 This pragma is used in conjunction with a pragma @code{Import} to
3373 specify additional information for an imported function.  The pragma
3374 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3375 @code{Import_Function} pragma and both must appear in the same
3376 declarative part as the function specification.
3378 The @var{Internal} argument must uniquely designate
3379 the function to which the
3380 pragma applies.  If more than one function name exists of this name in
3381 the declarative part you must use the @code{Parameter_Types} and
3382 @var{Result_Type} parameters to achieve the required unique
3383 designation.  Subtype marks in these parameters must exactly match the
3384 subtypes in the corresponding function specification, using positional
3385 notation to match parameters with subtype marks.
3386 The form with an @code{'Access} attribute can be used to match an
3387 anonymous access parameter.
3389 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3390 parameters to specify passing mechanisms for the
3391 parameters and result.  If you specify a single mechanism name, it
3392 applies to all parameters.  Otherwise you may specify a mechanism on a
3393 parameter by parameter basis using either positional or named
3394 notation.  If the mechanism is not specified, the default mechanism
3395 is used.
3397 @cindex OpenVMS
3398 @cindex Passing by descriptor
3399 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3400 The default behavior for Import_Function is to pass a 64bit descriptor
3401 unless short_descriptor is specified, then a 32bit descriptor is passed.
3403 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3404 It specifies that the designated parameter and all following parameters
3405 are optional, meaning that they are not passed at the generated code
3406 level (this is distinct from the notion of optional parameters in Ada
3407 where the parameters are passed anyway with the designated optional
3408 parameters).  All optional parameters must be of mode @code{IN} and have
3409 default parameter values that are either known at compile time
3410 expressions, or uses of the @code{'Null_Parameter} attribute.
3412 @node Pragma Import_Object
3413 @unnumberedsec Pragma Import_Object
3414 @findex Import_Object
3415 @noindent
3416 Syntax:
3418 @smallexample @c ada
3419 pragma Import_Object
3420      [Internal =>] LOCAL_NAME
3421   [, [External =>] EXTERNAL_SYMBOL]
3422   [, [Size     =>] EXTERNAL_SYMBOL]);
3424 EXTERNAL_SYMBOL ::=
3425   IDENTIFIER
3426 | static_string_EXPRESSION
3427 @end smallexample
3429 @noindent
3430 This pragma designates an object as imported, and apart from the
3431 extended rules for external symbols, is identical in effect to the use of
3432 the normal @code{Import} pragma applied to an object.  Unlike the
3433 subprogram case, you need not use a separate @code{Import} pragma,
3434 although you may do so (and probably should do so from a portability
3435 point of view).  @var{size} is syntax checked, but otherwise ignored by
3436 GNAT@.
3438 @node Pragma Import_Procedure
3439 @unnumberedsec Pragma Import_Procedure
3440 @findex Import_Procedure
3441 @noindent
3442 Syntax:
3444 @smallexample @c ada
3445 pragma Import_Procedure (
3446      [Internal                 =>] LOCAL_NAME
3447   [, [External                 =>] EXTERNAL_SYMBOL]
3448   [, [Parameter_Types          =>] PARAMETER_TYPES]
3449   [, [Mechanism                =>] MECHANISM]
3450   [, [First_Optional_Parameter =>] IDENTIFIER]);
3452 EXTERNAL_SYMBOL ::=
3453   IDENTIFIER
3454 | static_string_EXPRESSION
3456 PARAMETER_TYPES ::=
3457   null
3458 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3460 TYPE_DESIGNATOR ::=
3461   subtype_NAME
3462 | subtype_Name ' Access
3464 MECHANISM ::=
3465   MECHANISM_NAME
3466 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3468 MECHANISM_ASSOCIATION ::=
3469   [formal_parameter_NAME =>] MECHANISM_NAME
3471 MECHANISM_NAME ::=
3472   Value
3473 | Reference
3474 | Descriptor [([Class =>] CLASS_NAME)]
3475 | Short_Descriptor [([Class =>] CLASS_NAME)]
3477 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3478 @end smallexample
3480 @noindent
3481 This pragma is identical to @code{Import_Function} except that it
3482 applies to a procedure rather than a function and the parameters
3483 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3485 @node Pragma Import_Valued_Procedure
3486 @unnumberedsec Pragma Import_Valued_Procedure
3487 @findex Import_Valued_Procedure
3488 @noindent
3489 Syntax:
3491 @smallexample @c ada
3492 pragma Import_Valued_Procedure (
3493      [Internal                 =>] LOCAL_NAME
3494   [, [External                 =>] EXTERNAL_SYMBOL]
3495   [, [Parameter_Types          =>] PARAMETER_TYPES]
3496   [, [Mechanism                =>] MECHANISM]
3497   [, [First_Optional_Parameter =>] IDENTIFIER]);
3499 EXTERNAL_SYMBOL ::=
3500   IDENTIFIER
3501 | static_string_EXPRESSION
3503 PARAMETER_TYPES ::=
3504   null
3505 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3507 TYPE_DESIGNATOR ::=
3508   subtype_NAME
3509 | subtype_Name ' Access
3511 MECHANISM ::=
3512   MECHANISM_NAME
3513 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3515 MECHANISM_ASSOCIATION ::=
3516   [formal_parameter_NAME =>] MECHANISM_NAME
3518 MECHANISM_NAME ::=
3519   Value
3520 | Reference
3521 | Descriptor [([Class =>] CLASS_NAME)]
3522 | Short_Descriptor [([Class =>] CLASS_NAME)]
3524 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3525 @end smallexample
3527 @noindent
3528 This pragma is identical to @code{Import_Procedure} except that the
3529 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3530 mode @code{OUT}, and externally the subprogram is treated as a function
3531 with this parameter as the result of the function.  The purpose of this
3532 capability is to allow the use of @code{OUT} and @code{IN OUT}
3533 parameters in interfacing to external functions (which are not permitted
3534 in Ada functions).  You may optionally use the @code{Mechanism}
3535 parameters to specify passing mechanisms for the parameters.
3536 If you specify a single mechanism name, it applies to all parameters.
3537 Otherwise you may specify a mechanism on a parameter by parameter
3538 basis using either positional or named notation.  If the mechanism is not
3539 specified, the default mechanism is used.
3541 Note that it is important to use this pragma in conjunction with a separate
3542 pragma Import that specifies the desired convention, since otherwise the
3543 default convention is Ada, which is almost certainly not what is required.
3545 @node Pragma Independent
3546 @unnumberedsec Pragma Independent
3547 @findex Independent
3548 @noindent
3549 Syntax:
3551 @smallexample @c ada
3552 pragma Independent (Local_NAME);
3553 @end smallexample
3555 @noindent
3556 This pragma is standard in Ada 2012 mode (which also provides an aspect
3557 of the same name). It is also available as an implementation-defined
3558 pragma in all earlier versions. It specifies that the
3559 designated object or all objects of the designated type must be
3560 independently addressable. This means that separate tasks can safely
3561 manipulate such objects. For example, if two components of a record are
3562 independent, then two separate tasks may access these two components.
3563 This may place
3564 constraints on the representation of the object (for instance prohibiting
3565 tight packing).
3567 @node Pragma Independent_Components
3568 @unnumberedsec Pragma Independent_Components
3569 @findex Independent_Components
3570 @noindent
3571 Syntax:
3573 @smallexample @c ada
3574 pragma Independent_Components (Local_NAME);
3575 @end smallexample
3577 @noindent
3578 This pragma is standard in Ada 2012 mode (which also provides an aspect
3579 of the same name). It is also available as an implementation-defined
3580 pragma in all earlier versions. It specifies that the components of the
3581 designated object, or the components of each object of the designated
3582 type, must be
3583 independently addressable. This means that separate tasks can safely
3584 manipulate separate components in the composite object. This may place
3585 constraints on the representation of the object (for instance prohibiting
3586 tight packing).
3588 @node Pragma Initialize_Scalars
3589 @unnumberedsec Pragma Initialize_Scalars
3590 @findex Initialize_Scalars
3591 @cindex debugging with Initialize_Scalars
3592 @noindent
3593 Syntax:
3595 @smallexample @c ada
3596 pragma Initialize_Scalars;
3597 @end smallexample
3599 @noindent
3600 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3601 two important differences.  First, there is no requirement for the pragma
3602 to be used uniformly in all units of a partition, in particular, it is fine
3603 to use this just for some or all of the application units of a partition,
3604 without needing to recompile the run-time library.
3606 In the case where some units are compiled with the pragma, and some without,
3607 then a declaration of a variable where the type is defined in package
3608 Standard or is locally declared will always be subject to initialization,
3609 as will any declaration of a scalar variable.  For composite variables,
3610 whether the variable is initialized may also depend on whether the package
3611 in which the type of the variable is declared is compiled with the pragma.
3613 The other important difference is that you can control the value used
3614 for initializing scalar objects.  At bind time, you can select several
3615 options for initialization. You can
3616 initialize with invalid values (similar to Normalize_Scalars, though for
3617 Initialize_Scalars it is not always possible to determine the invalid
3618 values in complex cases like signed component fields with non-standard
3619 sizes). You can also initialize with high or
3620 low values, or with a specified bit pattern.  See the @value{EDITION}
3621 User's Guide for binder options for specifying these cases.
3623 This means that you can compile a program, and then without having to
3624 recompile the program, you can run it with different values being used
3625 for initializing otherwise uninitialized values, to test if your program
3626 behavior depends on the choice.  Of course the behavior should not change,
3627 and if it does, then most likely you have an erroneous reference to an
3628 uninitialized value.
3630 It is even possible to change the value at execution time eliminating even
3631 the need to rebind with a different switch using an environment variable.
3632 See the @value{EDITION} User's Guide for details.
3634 Note that pragma @code{Initialize_Scalars} is particularly useful in
3635 conjunction with the enhanced validity checking that is now provided
3636 in GNAT, which checks for invalid values under more conditions.
3637 Using this feature (see description of the @option{-gnatV} flag in the
3638 @value{EDITION} User's Guide) in conjunction with
3639 pragma @code{Initialize_Scalars}
3640 provides a powerful new tool to assist in the detection of problems
3641 caused by uninitialized variables.
3643 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3644 effect on the generated code. This may cause your code to be
3645 substantially larger. It may also cause an increase in the amount
3646 of stack required, so it is probably a good idea to turn on stack
3647 checking (see description of stack checking in the @value{EDITION}
3648 User's Guide) when using this pragma.
3650 @node Pragma Inline_Always
3651 @unnumberedsec Pragma Inline_Always
3652 @findex Inline_Always
3653 @noindent
3654 Syntax:
3656 @smallexample @c ada
3657 pragma Inline_Always (NAME [, NAME]);
3658 @end smallexample
3660 @noindent
3661 Similar to pragma @code{Inline} except that inlining is not subject to
3662 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3663 happens regardless of whether these options are used.
3665 @node Pragma Inline_Generic
3666 @unnumberedsec Pragma Inline_Generic
3667 @findex Inline_Generic
3668 @noindent
3669 Syntax:
3671 @smallexample @c ada
3672 pragma Inline_Generic (GNAME @{, GNAME@});
3674 GNAME ::= generic_unit_NAME | generic_instance_NAME
3675 @end smallexample
3677 @noindent
3678 This pragma is provided for compatibility with Dec Ada 83. It has
3679 no effect in @code{GNAT} (which always inlines generics), other
3680 than to check that the given names are all names of generic units or
3681 generic instances.
3683 @node Pragma Interface
3684 @unnumberedsec Pragma Interface
3685 @findex Interface
3686 @noindent
3687 Syntax:
3689 @smallexample @c ada
3690 pragma Interface (
3691      [Convention    =>] convention_identifier,
3692      [Entity        =>] local_NAME
3693   [, [External_Name =>] static_string_expression]
3694   [, [Link_Name     =>] static_string_expression]);
3695 @end smallexample
3697 @noindent
3698 This pragma is identical in syntax and semantics to
3699 the standard Ada pragma @code{Import}.  It is provided for compatibility
3700 with Ada 83.  The definition is upwards compatible both with pragma
3701 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3702 with some extended implementations of this pragma in certain Ada 83
3703 implementations.  The only difference between pragma @code{Interface}
3704 and pragma @code{Import} is that there is special circuitry to allow
3705 both pragmas to appear for the same subprogram entity (normally it
3706 is illegal to have multiple @code{Import} pragmas. This is useful in
3707 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3708 Ada 83 compilers.
3710 @node Pragma Interface_Name
3711 @unnumberedsec Pragma Interface_Name
3712 @findex Interface_Name
3713 @noindent
3714 Syntax:
3716 @smallexample @c ada
3717 pragma Interface_Name (
3718      [Entity        =>] LOCAL_NAME
3719   [, [External_Name =>] static_string_EXPRESSION]
3720   [, [Link_Name     =>] static_string_EXPRESSION]);
3721 @end smallexample
3723 @noindent
3724 This pragma provides an alternative way of specifying the interface name
3725 for an interfaced subprogram, and is provided for compatibility with Ada
3726 83 compilers that use the pragma for this purpose.  You must provide at
3727 least one of @var{External_Name} or @var{Link_Name}.
3729 @node Pragma Interrupt_Handler
3730 @unnumberedsec Pragma Interrupt_Handler
3731 @findex Interrupt_Handler
3732 @noindent
3733 Syntax:
3735 @smallexample @c ada
3736 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3737 @end smallexample
3739 @noindent
3740 This program unit pragma is supported for parameterless protected procedures
3741 as described in Annex C of the Ada Reference Manual. On the AAMP target
3742 the pragma can also be specified for nonprotected parameterless procedures
3743 that are declared at the library level (which includes procedures
3744 declared at the top level of a library package). In the case of AAMP,
3745 when this pragma is applied to a nonprotected procedure, the instruction
3746 @code{IERET} is generated for returns from the procedure, enabling
3747 maskable interrupts, in place of the normal return instruction.
3749 @node Pragma Interrupt_State
3750 @unnumberedsec Pragma Interrupt_State
3751 @findex Interrupt_State
3752 @noindent
3753 Syntax:
3755 @smallexample @c ada
3756 pragma Interrupt_State
3757  ([Name  =>] value,
3758   [State =>] SYSTEM | RUNTIME | USER);
3759 @end smallexample
3761 @noindent
3762 Normally certain interrupts are reserved to the implementation.  Any attempt
3763 to attach an interrupt causes Program_Error to be raised, as described in
3764 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3765 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3766 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3767 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
3768 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3769 Ada exceptions, or used to implement run-time functions such as the
3770 @code{abort} statement and stack overflow checking.
3772 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3773 such uses of interrupts.  It subsumes the functionality of pragma
3774 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
3775 available on Windows or VMS.  On all other platforms than VxWorks,
3776 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3777 and may be used to mark interrupts required by the board support package
3778 as reserved.
3780 Interrupts can be in one of three states:
3781 @itemize @bullet
3782 @item System
3784 The interrupt is reserved (no Ada handler can be installed), and the
3785 Ada run-time may not install a handler. As a result you are guaranteed
3786 standard system default action if this interrupt is raised.
3788 @item Runtime
3790 The interrupt is reserved (no Ada handler can be installed). The run time
3791 is allowed to install a handler for internal control purposes, but is
3792 not required to do so.
3794 @item User
3796 The interrupt is unreserved.  The user may install a handler to provide
3797 some other action.
3798 @end itemize
3800 @noindent
3801 These states are the allowed values of the @code{State} parameter of the
3802 pragma.  The @code{Name} parameter is a value of the type
3803 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
3804 @code{Ada.Interrupts.Names}.
3806 This is a configuration pragma, and the binder will check that there
3807 are no inconsistencies between different units in a partition in how a
3808 given interrupt is specified. It may appear anywhere a pragma is legal.
3810 The effect is to move the interrupt to the specified state.
3812 By declaring interrupts to be SYSTEM, you guarantee the standard system
3813 action, such as a core dump.
3815 By declaring interrupts to be USER, you guarantee that you can install
3816 a handler.
3818 Note that certain signals on many operating systems cannot be caught and
3819 handled by applications.  In such cases, the pragma is ignored.  See the
3820 operating system documentation, or the value of the array @code{Reserved}
3821 declared in the spec of package @code{System.OS_Interface}.
3823 Overriding the default state of signals used by the Ada runtime may interfere
3824 with an application's runtime behavior in the cases of the synchronous signals,
3825 and in the case of the signal used to implement the @code{abort} statement.
3827 @node Pragma Invariant
3828 @unnumberedsec Pragma Invariant
3829 @findex Invariant
3830 @noindent
3831 Syntax:
3833 @smallexample @c ada
3834 pragma Invariant
3835   ([Entity =>]    private_type_LOCAL_NAME,
3836    [Check  =>]    EXPRESSION
3837    [,[Message =>] String_Expression]);
3838 @end smallexample
3840 @noindent
3841 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3842 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3843 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3844 requires the use of the aspect syntax, which is not available except in 2012
3845 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3846 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3847 note that the aspect Invariant is a synonym in GNAT for the aspect
3848 Type_Invariant, but there is no pragma Type_Invariant.
3850 The pragma must appear within the visible part of the package specification,
3851 after the type to which its Entity argument appears. As with the Invariant
3852 aspect, the Check expression is not analyzed until the end of the visible
3853 part of the package, so it may contain forward references. The Message
3854 argument, if present, provides the exception message used if the invariant
3855 is violated. If no Message parameter is provided, a default message that
3856 identifies the line on which the pragma appears is used.
3858 It is permissible to have multiple Invariants for the same type entity, in
3859 which case they are and'ed together. It is permissible to use this pragma
3860 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3861 invariant pragma for the same entity.
3863 For further details on the use of this pragma, see the Ada 2012 documentation
3864 of the Type_Invariant aspect.
3866 @node Pragma Java_Constructor
3867 @unnumberedsec Pragma Java_Constructor
3868 @findex Java_Constructor
3869 @noindent
3870 Syntax:
3872 @smallexample @c ada
3873 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
3874 @end smallexample
3876 @noindent
3877 This pragma is used to assert that the specified Ada function should be
3878 mapped to the Java constructor for some Ada tagged record type.
3880 See section 7.3.2 of the
3881 @code{GNAT User's Guide: Supplement for the JVM Platform.}
3882 for related information.
3884 @node Pragma Java_Interface
3885 @unnumberedsec Pragma Java_Interface
3886 @findex Java_Interface
3887 @noindent
3888 Syntax:
3890 @smallexample @c ada
3891 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
3892 @end smallexample
3894 @noindent
3895 This pragma is used to assert that the specified Ada abstract tagged type
3896 is to be mapped to a Java interface name.
3898 See sections 7.1 and 7.2 of the
3899 @code{GNAT User's Guide: Supplement for the JVM Platform.}
3900 for related information.
3902 @node Pragma Keep_Names
3903 @unnumberedsec Pragma Keep_Names
3904 @findex Keep_Names
3905 @noindent
3906 Syntax:
3908 @smallexample @c ada
3909 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3910 @end smallexample
3912 @noindent
3913 The @var{LOCAL_NAME} argument
3914 must refer to an enumeration first subtype
3915 in the current declarative part. The effect is to retain the enumeration
3916 literal names for use by @code{Image} and @code{Value} even if a global
3917 @code{Discard_Names} pragma applies. This is useful when you want to
3918 generally suppress enumeration literal names and for example you therefore
3919 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3920 want to retain the names for specific enumeration types.
3922 @node Pragma License
3923 @unnumberedsec Pragma License
3924 @findex License
3925 @cindex License checking
3926 @noindent
3927 Syntax:
3929 @smallexample @c ada
3930 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3931 @end smallexample
3933 @noindent
3934 This pragma is provided to allow automated checking for appropriate license
3935 conditions with respect to the standard and modified GPL@.  A pragma
3936 @code{License}, which is a configuration pragma that typically appears at
3937 the start of a source file or in a separate @file{gnat.adc} file, specifies
3938 the licensing conditions of a unit as follows:
3940 @itemize @bullet
3941 @item Unrestricted
3942 This is used for a unit that can be freely used with no license restrictions.
3943 Examples of such units are public domain units, and units from the Ada
3944 Reference Manual.
3946 @item GPL
3947 This is used for a unit that is licensed under the unmodified GPL, and which
3948 therefore cannot be @code{with}'ed by a restricted unit.
3950 @item Modified_GPL
3951 This is used for a unit licensed under the GNAT modified GPL that includes
3952 a special exception paragraph that specifically permits the inclusion of
3953 the unit in programs without requiring the entire program to be released
3954 under the GPL@.
3956 @item Restricted
3957 This is used for a unit that is restricted in that it is not permitted to
3958 depend on units that are licensed under the GPL@.  Typical examples are
3959 proprietary code that is to be released under more restrictive license
3960 conditions.  Note that restricted units are permitted to @code{with} units
3961 which are licensed under the modified GPL (this is the whole point of the
3962 modified GPL).
3964 @end itemize
3966 @noindent
3967 Normally a unit with no @code{License} pragma is considered to have an
3968 unknown license, and no checking is done.  However, standard GNAT headers
3969 are recognized, and license information is derived from them as follows.
3971 @itemize @bullet
3973 A GNAT license header starts with a line containing 78 hyphens.  The following
3974 comment text is searched for the appearance of any of the following strings.
3976 If the string ``GNU General Public License'' is found, then the unit is assumed
3977 to have GPL license, unless the string ``As a special exception'' follows, in
3978 which case the license is assumed to be modified GPL@.
3980 If one of the strings
3981 ``This specification is adapted from the Ada Semantic Interface'' or
3982 ``This specification is derived from the Ada Reference Manual'' is found
3983 then the unit is assumed to be unrestricted.
3984 @end itemize
3986 @noindent
3987 These default actions means that a program with a restricted license pragma
3988 will automatically get warnings if a GPL unit is inappropriately
3989 @code{with}'ed.  For example, the program:
3991 @smallexample @c ada
3992 with Sem_Ch3;
3993 with GNAT.Sockets;
3994 procedure Secret_Stuff is
3995   @dots{}
3996 end Secret_Stuff
3997 @end smallexample
3999 @noindent
4000 if compiled with pragma @code{License} (@code{Restricted}) in a
4001 @file{gnat.adc} file will generate the warning:
4003 @smallexample
4004 1.  with Sem_Ch3;
4005         |
4006    >>> license of withed unit "Sem_Ch3" is incompatible
4008 2.  with GNAT.Sockets;
4009 3.  procedure Secret_Stuff is
4010 @end smallexample
4012 @noindent
4013 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4014 compiler and is licensed under the
4015 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4016 run time, and is therefore licensed under the modified GPL@.
4018 @node Pragma Link_With
4019 @unnumberedsec Pragma Link_With
4020 @findex Link_With
4021 @noindent
4022 Syntax:
4024 @smallexample @c ada
4025 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4026 @end smallexample
4028 @noindent
4029 This pragma is provided for compatibility with certain Ada 83 compilers.
4030 It has exactly the same effect as pragma @code{Linker_Options} except
4031 that spaces occurring within one of the string expressions are treated
4032 as separators. For example, in the following case:
4034 @smallexample @c ada
4035 pragma Link_With ("-labc -ldef");
4036 @end smallexample
4038 @noindent
4039 results in passing the strings @code{-labc} and @code{-ldef} as two
4040 separate arguments to the linker. In addition pragma Link_With allows
4041 multiple arguments, with the same effect as successive pragmas.
4043 @node Pragma Linker_Alias
4044 @unnumberedsec Pragma Linker_Alias
4045 @findex Linker_Alias
4046 @noindent
4047 Syntax:
4049 @smallexample @c ada
4050 pragma Linker_Alias (
4051   [Entity =>] LOCAL_NAME,
4052   [Target =>] static_string_EXPRESSION);
4053 @end smallexample
4055 @noindent
4056 @var{LOCAL_NAME} must refer to an object that is declared at the library
4057 level. This pragma establishes the given entity as a linker alias for the
4058 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4059 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4060 @var{static_string_EXPRESSION} in the object file, that is to say no space
4061 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4062 to the same address as @var{static_string_EXPRESSION} by the linker.
4064 The actual linker name for the target must be used (e.g.@: the fully
4065 encoded name with qualification in Ada, or the mangled name in C++),
4066 or it must be declared using the C convention with @code{pragma Import}
4067 or @code{pragma Export}.
4069 Not all target machines support this pragma. On some of them it is accepted
4070 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4072 @smallexample @c ada
4073 --  Example of the use of pragma Linker_Alias
4075 package p is
4076   i : Integer := 1;
4077   pragma Export (C, i);
4079   new_name_for_i : Integer;
4080   pragma Linker_Alias (new_name_for_i, "i");
4081 end p;
4082 @end smallexample
4084 @node Pragma Linker_Constructor
4085 @unnumberedsec Pragma Linker_Constructor
4086 @findex Linker_Constructor
4087 @noindent
4088 Syntax:
4090 @smallexample @c ada
4091 pragma Linker_Constructor (procedure_LOCAL_NAME);
4092 @end smallexample
4094 @noindent
4095 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4096 is declared at the library level. A procedure to which this pragma is
4097 applied will be treated as an initialization routine by the linker.
4098 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4099 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4100 of the executable is called (or immediately after the shared library is
4101 loaded if the procedure is linked in a shared library), in particular
4102 before the Ada run-time environment is set up.
4104 Because of these specific contexts, the set of operations such a procedure
4105 can perform is very limited and the type of objects it can manipulate is
4106 essentially restricted to the elementary types. In particular, it must only
4107 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4109 This pragma is used by GNAT to implement auto-initialization of shared Stand
4110 Alone Libraries, which provides a related capability without the restrictions
4111 listed above. Where possible, the use of Stand Alone Libraries is preferable
4112 to the use of this pragma.
4114 @node Pragma Linker_Destructor
4115 @unnumberedsec Pragma Linker_Destructor
4116 @findex Linker_Destructor
4117 @noindent
4118 Syntax:
4120 @smallexample @c ada
4121 pragma Linker_Destructor (procedure_LOCAL_NAME);
4122 @end smallexample
4124 @noindent
4125 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4126 is declared at the library level. A procedure to which this pragma is
4127 applied will be treated as a finalization routine by the linker.
4128 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4129 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4130 of the executable has exited (or immediately before the shared library
4131 is unloaded if the procedure is linked in a shared library), in particular
4132 after the Ada run-time environment is shut down.
4134 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4135 because of these specific contexts.
4137 @node Pragma Linker_Section
4138 @unnumberedsec Pragma Linker_Section
4139 @findex Linker_Section
4140 @noindent
4141 Syntax:
4143 @smallexample @c ada
4144 pragma Linker_Section (
4145   [Entity  =>] LOCAL_NAME,
4146   [Section =>] static_string_EXPRESSION);
4147 @end smallexample
4149 @noindent
4150 @var{LOCAL_NAME} must refer to an object that is declared at the library
4151 level. This pragma specifies the name of the linker section for the given
4152 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
4153 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
4154 section of the executable (assuming the linker doesn't rename the section).
4156 The compiler normally places library-level objects in standard sections
4157 depending on their type: procedures and functions generally go in the
4158 @code{.text} section, initialized variables in the @code{.data} section
4159 and uninitialized variables in the @code{.bss} section.
4161 Other, special sections may exist on given target machines to map special
4162 hardware, for example I/O ports or flash memory. This pragma is a means to
4163 defer the final layout of the executable to the linker, thus fully working
4164 at the symbolic level with the compiler.
4166 Some file formats do not support arbitrary sections so not all target
4167 machines support this pragma. The use of this pragma may cause a program
4168 execution to be erroneous if it is used to place an entity into an
4169 inappropriate section (e.g.@: a modified variable into the @code{.text}
4170 section). See also @code{pragma Persistent_BSS}.
4172 @smallexample @c ada
4173 --  Example of the use of pragma Linker_Section
4175 package IO_Card is
4176   Port_A : Integer;
4177   pragma Volatile (Port_A);
4178   pragma Linker_Section (Port_A, ".bss.port_a");
4180   Port_B : Integer;
4181   pragma Volatile (Port_B);
4182   pragma Linker_Section (Port_B, ".bss.port_b");
4183 end IO_Card;
4184 @end smallexample
4186 @node Pragma Long_Float
4187 @unnumberedsec Pragma Long_Float
4188 @cindex OpenVMS
4189 @findex Long_Float
4190 @noindent
4191 Syntax:
4193 @smallexample @c ada
4194 pragma Long_Float (FLOAT_FORMAT);
4196 FLOAT_FORMAT ::= D_Float | G_Float
4197 @end smallexample
4199 @noindent
4200 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4201 It allows control over the internal representation chosen for the predefined
4202 type @code{Long_Float} and for floating point type representations with
4203 @code{digits} specified in the range 7 through 15.
4204 For further details on this pragma, see the
4205 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
4206 this pragma, the standard runtime libraries must be recompiled.
4208 @node Pragma Loop_Invariant
4209 @unnumberedsec Pragma Loop_Invariant
4210 @findex Loop_Invariant
4211 @noindent
4212 Syntax:
4214 @smallexample @c ada
4215 pragma Loop_Invariant ( boolean_EXPRESSION );
4216 @end smallexample
4218 @noindent
4219 The effect of this pragma is similar to that of pragma @code{Assert},
4220 except that in an @code{Assertion_Policy} pragma, the identifier
4221 @code{Loop_Invariant} is used to control whether it is ignored or checked
4222 (or disabled).
4224 @code{Loop_Invariant} can only appear as one of the items in the sequence
4225 of statements of a loop body. The intention is that it be used to
4226 represent a "loop invariant" assertion, i.e. something that is true each
4227 time through the loop, and which can be used to show that the loop is
4228 achieving its purpose.
4230 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4231 may be used to refer to the value of an expression on entry to the loop. This
4232 attribute can only be used within the expression of a @code{Loop_Invariant}
4233 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4235 @node Pragma Loop_Optimize
4236 @unnumberedsec Pragma Loop_Optimize
4237 @findex Loop_Optimize
4238 @noindent
4239 Syntax:
4241 @smallexample @c ada
4242 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4244 OPTIMIZATION_HINT ::= No_Unroll | Unroll | No_Vector | Vector
4245 @end smallexample
4247 @noindent
4248 This pragma must appear immediately within a loop statement.  It allows the
4249 programmer to specify optimization hints for the enclosing loop.  The hints
4250 are not mutually exclusive and can be freely mixed, but not all combinations
4251 will yield a sensible outcome.
4253 There are four supported optimization hints for a loop:
4254 @itemize @bullet
4255 @item No_Unroll
4257 The loop must not be unrolled.  This is a strong hint: the compiler will not
4258 unroll a loop marked with this hint.
4260 @item Unroll
4262 The loop should be unrolled.  This is a weak hint: the compiler will try to
4263 apply unrolling to this loop preferably to other optimizations, notably
4264 vectorization, but there is no guarantee that the loop will be unrolled.
4266 @item No_Vector
4268 The loop must not be vectorized.  This is a strong hint: the compiler will not
4269 vectorize a loop marked with this hint.
4271 @item Vector
4273 The loop should be vectorized.  This is a weak hint: the compiler will try to
4274 apply vectorization to this loop preferably to other optimizations, notably
4275 unrolling, but there is no guarantee that the loop will be vectorized.
4277 @end itemize
4279 These hints do not void the need to pass the appropriate switches to the
4280 compiler in order to enable the relevant optimizations, that is to say
4281 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4282 vectorization.
4284 @node Pragma Loop_Variant
4285 @unnumberedsec Pragma Loop_Variant
4286 @findex Loop_Variant
4287 @noindent
4288 Syntax:
4290 @smallexample @c ada
4291 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4292 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4293 CHANGE_DIRECTION ::= Increases | Decreases
4294 @end smallexample
4296 @noindent
4297 This pragma must appear immediately within the sequence of statements of a
4298 loop statement. It allows the specification of quantities which must always
4299 decrease or increase in successive iterations of the loop. In its simplest
4300 form, just one expression is specified, whose value must increase or decrease
4301 on each iteration of the loop.
4303 In a more complex form, multiple arguments can be given which are intepreted
4304 in a nesting lexicographic manner. For example:
4306 @smallexample @c ada
4307 pragma Loop_Variant (Increases => X, Decreases => Y);
4308 @end smallexample
4310 @noindent
4311 specifies that each time through the loop either X increases, or X stays
4312 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4313 loop is making progress. It can be useful in helping to show informally
4314 or prove formally that the loop always terminates.
4316 @code{Loop_Variant} is an assertion whose effect can be controlled using
4317 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4318 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4319 to ignore the check (in which case the pragma has no effect on the program),
4320 or @code{Disable} in which case the pragma is not even checked for correct
4321 syntax.
4323 The @code{Loop_Entry} attribute may be used within the expressions of the
4324 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4326 @node Pragma Machine_Attribute
4327 @unnumberedsec Pragma Machine_Attribute
4328 @findex Machine_Attribute
4329 @noindent
4330 Syntax:
4332 @smallexample @c ada
4333 pragma Machine_Attribute (
4334      [Entity         =>] LOCAL_NAME,
4335      [Attribute_Name =>] static_string_EXPRESSION
4336   [, [Info           =>] static_EXPRESSION] );
4337 @end smallexample
4339 @noindent
4340 Machine-dependent attributes can be specified for types and/or
4341 declarations.  This pragma is semantically equivalent to
4342 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4343 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4344 in GNU C, where @code{@var{attribute_name}} is recognized by the
4345 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4346 specific macro.  A string literal for the optional parameter @var{info}
4347 is transformed into an identifier, which may make this pragma unusable
4348 for some attributes.  @xref{Target Attributes,, Defining target-specific
4349 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4350 Internals}, further information.
4352 @node Pragma Main
4353 @unnumberedsec Pragma Main
4354 @cindex OpenVMS
4355 @findex Main
4356 @noindent
4357 Syntax:
4359 @smallexample @c ada
4360 pragma Main
4361  (MAIN_OPTION [, MAIN_OPTION]);
4363 MAIN_OPTION ::=
4364   [Stack_Size              =>] static_integer_EXPRESSION
4365 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4366 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
4367 @end smallexample
4369 @noindent
4370 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4371 no effect in GNAT, other than being syntax checked.
4373 @node Pragma Main_Storage
4374 @unnumberedsec Pragma Main_Storage
4375 @cindex OpenVMS
4376 @findex Main_Storage
4377 @noindent
4378 Syntax:
4380 @smallexample @c ada
4381 pragma Main_Storage
4382   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4384 MAIN_STORAGE_OPTION ::=
4385   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4386 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
4387 @end smallexample
4389 @noindent
4390 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4391 no effect in GNAT, other than being syntax checked.  Note that the pragma
4392 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4394 @node Pragma No_Body
4395 @unnumberedsec Pragma No_Body
4396 @findex No_Body
4397 @noindent
4398 Syntax:
4400 @smallexample @c ada
4401 pragma No_Body;
4402 @end smallexample
4404 @noindent
4405 There are a number of cases in which a package spec does not require a body,
4406 and in fact a body is not permitted. GNAT will not permit the spec to be
4407 compiled if there is a body around. The pragma No_Body allows you to provide
4408 a body file, even in a case where no body is allowed. The body file must
4409 contain only comments and a single No_Body pragma. This is recognized by
4410 the compiler as indicating that no body is logically present.
4412 This is particularly useful during maintenance when a package is modified in
4413 such a way that a body needed before is no longer needed. The provision of a
4414 dummy body with a No_Body pragma ensures that there is no interference from
4415 earlier versions of the package body.
4417 @node Pragma No_Inline
4418 @unnumberedsec Pragma No_Inline
4419 @findex No_Inline
4420 @noindent
4421 Syntax:
4423 @smallexample @c ada
4424 pragma No_Inline (NAME @{, NAME@});
4425 @end smallexample
4427 @noindent
4428 This pragma suppresses inlining for the callable entity or the instances of
4429 the generic subprogram designated by @var{NAME}, including inlining that
4430 results from the use of pragma @code{Inline}.  This pragma is always active,
4431 in particular it is not subject to the use of option @option{-gnatn} or
4432 @option{-gnatN}.  It is illegal to specify both pragma @code{No_Inline} and
4433 pragma @code{Inline_Always} for the same @var{NAME}.
4435 @node Pragma No_Return
4436 @unnumberedsec Pragma No_Return
4437 @findex No_Return
4438 @noindent
4439 Syntax:
4441 @smallexample @c ada
4442 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4443 @end smallexample
4445 @noindent
4446 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4447 declarations in the current declarative part.  A procedure to which this
4448 pragma is applied may not contain any explicit @code{return} statements.
4449 In addition, if the procedure contains any implicit returns from falling
4450 off the end of a statement sequence, then execution of that implicit
4451 return will cause Program_Error to be raised.
4453 One use of this pragma is to identify procedures whose only purpose is to raise
4454 an exception. Another use of this pragma is to suppress incorrect warnings
4455 about missing returns in functions, where the last statement of a function
4456 statement sequence is a call to such a procedure.
4458 Note that in Ada 2005 mode, this pragma is part of the language. It is
4459 available in all earlier versions of Ada as an implementation-defined
4460 pragma.
4462 @node Pragma No_Run_Time
4463 @unnumberedsec Pragma No_Run_Time
4464 @findex No_Run_Time
4465 @noindent
4466 Syntax:
4468 @smallexample @c ada
4469 pragma No_Run_Time;
4470 @end smallexample
4472 @noindent
4473 This is an obsolete configuration pragma that historically was used to
4474 setup what is now called the "zero footprint" library. It causes any
4475 library units outside this basic library to be ignored. The use of
4476 this pragma has been superseded by the general configurable run-time
4477 capability of @code{GNAT} where the compiler takes into account whatever
4478 units happen to be accessible in the library.
4480 @node Pragma No_Strict_Aliasing
4481 @unnumberedsec Pragma No_Strict_Aliasing
4482 @findex No_Strict_Aliasing
4483 @noindent
4484 Syntax:
4486 @smallexample @c ada
4487 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4488 @end smallexample
4490 @noindent
4491 @var{type_LOCAL_NAME} must refer to an access type
4492 declaration in the current declarative part.  The effect is to inhibit
4493 strict aliasing optimization for the given type.  The form with no
4494 arguments is a configuration pragma which applies to all access types
4495 declared in units to which the pragma applies. For a detailed
4496 description of the strict aliasing optimization, and the situations
4497 in which it must be suppressed, see @ref{Optimization and Strict
4498 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4500 This pragma currently has no effects on access to unconstrained array types.
4502 @node Pragma Normalize_Scalars
4503 @unnumberedsec Pragma Normalize_Scalars
4504 @findex Normalize_Scalars
4505 @noindent
4506 Syntax:
4508 @smallexample @c ada
4509 pragma Normalize_Scalars;
4510 @end smallexample
4512 @noindent
4513 This is a language defined pragma which is fully implemented in GNAT@.  The
4514 effect is to cause all scalar objects that are not otherwise initialized
4515 to be initialized.  The initial values are implementation dependent and
4516 are as follows:
4518 @table @code
4519 @item Standard.Character
4520 @noindent
4521 Objects whose root type is Standard.Character are initialized to
4522 Character'Last unless the subtype range excludes NUL (in which case
4523 NUL is used). This choice will always generate an invalid value if
4524 one exists.
4526 @item Standard.Wide_Character
4527 @noindent
4528 Objects whose root type is Standard.Wide_Character are initialized to
4529 Wide_Character'Last unless the subtype range excludes NUL (in which case
4530 NUL is used). This choice will always generate an invalid value if
4531 one exists.
4533 @item Standard.Wide_Wide_Character
4534 @noindent
4535 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4536 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4537 which case NUL is used). This choice will always generate an invalid value if
4538 one exists.
4540 @item Integer types
4541 @noindent
4542 Objects of an integer type are treated differently depending on whether
4543 negative values are present in the subtype. If no negative values are
4544 present, then all one bits is used as the initial value except in the
4545 special case where zero is excluded from the subtype, in which case
4546 all zero bits are used. This choice will always generate an invalid
4547 value if one exists.
4549 For subtypes with negative values present, the largest negative number
4550 is used, except in the unusual case where this largest negative number
4551 is in the subtype, and the largest positive number is not, in which case
4552 the largest positive value is used. This choice will always generate
4553 an invalid value if one exists.
4555 @item Floating-Point Types
4556 Objects of all floating-point types are initialized to all 1-bits. For
4557 standard IEEE format, this corresponds to a NaN (not a number) which is
4558 indeed an invalid value.
4560 @item Fixed-Point Types
4561 Objects of all fixed-point types are treated as described above for integers,
4562 with the rules applying to the underlying integer value used to represent
4563 the fixed-point value.
4565 @item Modular types
4566 Objects of a modular type are initialized to all one bits, except in
4567 the special case where zero is excluded from the subtype, in which
4568 case all zero bits are used. This choice will always generate an
4569 invalid value if one exists.
4571 @item Enumeration types
4572 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4573 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4574 whose Pos value is zero, in which case a code of zero is used. This choice
4575 will always generate an invalid value if one exists.
4577 @end table
4579 @node Pragma Obsolescent
4580 @unnumberedsec Pragma Obsolescent
4581 @findex Obsolescent
4582 @noindent
4583 Syntax:
4585 @smallexample @c ada
4586 pragma Obsolescent;
4588 pragma Obsolescent (
4589   [Message =>] static_string_EXPRESSION
4590 [,[Version =>] Ada_05]]);
4592 pragma Obsolescent (
4593   [Entity  =>] NAME
4594 [,[Message =>] static_string_EXPRESSION
4595 [,[Version =>] Ada_05]] );
4596 @end smallexample
4598 @noindent
4599 This pragma can occur immediately following a declaration of an entity,
4600 including the case of a record component. If no Entity argument is present,
4601 then this declaration is the one to which the pragma applies. If an Entity
4602 parameter is present, it must either match the name of the entity in this
4603 declaration, or alternatively, the pragma can immediately follow an enumeration
4604 type declaration, where the Entity argument names one of the enumeration
4605 literals.
4607 This pragma is used to indicate that the named entity
4608 is considered obsolescent and should not be used. Typically this is
4609 used when an API must be modified by eventually removing or modifying
4610 existing subprograms or other entities. The pragma can be used at an
4611 intermediate stage when the entity is still present, but will be
4612 removed later.
4614 The effect of this pragma is to output a warning message on a reference to
4615 an entity thus marked that the subprogram is obsolescent if the appropriate
4616 warning option in the compiler is activated. If the Message parameter is
4617 present, then a second warning message is given containing this text. In
4618 addition, a reference to the entity is considered to be a violation of pragma
4619 Restrictions (No_Obsolescent_Features).
4621 This pragma can also be used as a program unit pragma for a package,
4622 in which case the entity name is the name of the package, and the
4623 pragma indicates that the entire package is considered
4624 obsolescent. In this case a client @code{with}'ing such a package
4625 violates the restriction, and the @code{with} statement is
4626 flagged with warnings if the warning option is set.
4628 If the Version parameter is present (which must be exactly
4629 the identifier Ada_05, no other argument is allowed), then the
4630 indication of obsolescence applies only when compiling in Ada 2005
4631 mode. This is primarily intended for dealing with the situations
4632 in the predefined library where subprograms or packages
4633 have become defined as obsolescent in Ada 2005
4634 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4636 The following examples show typical uses of this pragma:
4638 @smallexample @c ada
4639 package p is
4640    pragma Obsolescent (p, Message => "use pp instead of p");
4641 end p;
4643 package q is
4644    procedure q2;
4645    pragma Obsolescent ("use q2new instead");
4647    type R is new integer;
4648    pragma Obsolescent
4649      (Entity  => R,
4650       Message => "use RR in Ada 2005",
4651       Version => Ada_05);
4653    type M is record
4654       F1 : Integer;
4655       F2 : Integer;
4656       pragma Obsolescent;
4657       F3 : Integer;
4658    end record;
4660    type E is (a, bc, 'd', quack);
4661    pragma Obsolescent (Entity => bc)
4662    pragma Obsolescent (Entity => 'd')
4664    function "+"
4665      (a, b : character) return character;
4666    pragma Obsolescent (Entity => "+");
4667 end;
4668 @end smallexample
4670 @noindent
4671 Note that, as for all pragmas, if you use a pragma argument identifier,
4672 then all subsequent parameters must also use a pragma argument identifier.
4673 So if you specify "Entity =>" for the Entity argument, and a Message
4674 argument is present, it must be preceded by "Message =>".
4676 @node Pragma Optimize_Alignment
4677 @unnumberedsec Pragma Optimize_Alignment
4678 @findex Optimize_Alignment
4679 @cindex Alignment, default settings
4680 @noindent
4681 Syntax:
4683 @smallexample @c ada
4684 pragma Optimize_Alignment (TIME | SPACE | OFF);
4685 @end smallexample
4687 @noindent
4688 This is a configuration pragma which affects the choice of default alignments
4689 for types where no alignment is explicitly specified. There is a time/space
4690 trade-off in the selection of these values. Large alignments result in more
4691 efficient code, at the expense of larger data space, since sizes have to be
4692 increased to match these alignments. Smaller alignments save space, but the
4693 access code is slower. The normal choice of default alignments (which is what
4694 you get if you do not use this pragma, or if you use an argument of OFF),
4695 tries to balance these two requirements.
4697 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4698 First any packed record is given an alignment of 1. Second, if a size is given
4699 for the type, then the alignment is chosen to avoid increasing this size. For
4700 example, consider:
4702 @smallexample @c ada
4703    type R is record
4704       X : Integer;
4705       Y : Character;
4706    end record;
4708    for R'Size use 5*8;
4709 @end smallexample
4711 @noindent
4712 In the default mode, this type gets an alignment of 4, so that access to the
4713 Integer field X are efficient. But this means that objects of the type end up
4714 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4715 allowed to be bigger than the size of the type, but it can waste space if for
4716 example fields of type R appear in an enclosing record. If the above type is
4717 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4719 However, there is one case in which SPACE is ignored. If a variable length
4720 record (that is a discriminated record with a component which is an array
4721 whose length depends on a discriminant), has a pragma Pack, then it is not
4722 in general possible to set the alignment of such a record to one, so the
4723 pragma is ignored in this case (with a warning).
4725 Specifying TIME causes larger default alignments to be chosen in the case of
4726 small types with sizes that are not a power of 2. For example, consider:
4728 @smallexample @c ada
4729    type R is record
4730       A : Character;
4731       B : Character;
4732       C : Boolean;
4733    end record;
4735    pragma Pack (R);
4736    for R'Size use 17;
4737 @end smallexample
4739 @noindent
4740 The default alignment for this record is normally 1, but if this type is
4741 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4742 to 4, which wastes space for objects of the type, since they are now 4 bytes
4743 long, but results in more efficient access when the whole record is referenced.
4745 As noted above, this is a configuration pragma, and there is a requirement
4746 that all units in a partition be compiled with a consistent setting of the
4747 optimization setting. This would normally be achieved by use of a configuration
4748 pragma file containing the appropriate setting. The exception to this rule is
4749 that units with an explicit configuration pragma in the same file as the source
4750 unit are excluded from the consistency check, as are all predefined units. The
4751 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4752 pragma appears at the start of the file.
4754 @node Pragma Ordered
4755 @unnumberedsec Pragma Ordered
4756 @findex Ordered
4757 @findex pragma @code{Ordered}
4758 @noindent
4759 Syntax:
4761 @smallexample @c ada
4762 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4763 @end smallexample
4765 @noindent
4766 Most enumeration types are from a conceptual point of view unordered.
4767 For example, consider:
4769 @smallexample @c ada
4770 type Color is (Red, Blue, Green, Yellow);
4771 @end smallexample
4773 @noindent
4774 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4775 but really these relations make no sense; the enumeration type merely
4776 specifies a set of possible colors, and the order is unimportant.
4778 For unordered enumeration types, it is generally a good idea if
4779 clients avoid comparisons (other than equality or inequality) and
4780 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4781 other than the unit where the type is declared, its body, and its subunits.)
4782 For example, if code buried in some client says:
4784 @smallexample @c ada
4785 if Current_Color < Yellow then ...
4786 if Current_Color in Blue .. Green then ...
4787 @end smallexample
4789 @noindent
4790 then the client code is relying on the order, which is undesirable.
4791 It makes the code hard to read and creates maintenance difficulties if
4792 entries have to be added to the enumeration type. Instead,
4793 the code in the client should list the possibilities, or an
4794 appropriate subtype should be declared in the unit that declares
4795 the original enumeration type. E.g., the following subtype could
4796 be declared along with the type @code{Color}:
4798 @smallexample @c ada
4799 subtype RBG is Color range Red .. Green;
4800 @end smallexample
4802 @noindent
4803 and then the client could write:
4805 @smallexample @c ada
4806 if Current_Color in RBG then ...
4807 if Current_Color = Blue or Current_Color = Green then ...
4808 @end smallexample
4810 @noindent
4811 However, some enumeration types are legitimately ordered from a conceptual
4812 point of view. For example, if you declare:
4814 @smallexample @c ada
4815 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4816 @end smallexample
4818 @noindent
4819 then the ordering imposed by the language is reasonable, and
4820 clients can depend on it, writing for example:
4822 @smallexample @c ada
4823 if D in Mon .. Fri then ...
4824 if D < Wed then ...
4825 @end smallexample
4827 @noindent
4828 The pragma @option{Ordered} is provided to mark enumeration types that
4829 are conceptually ordered, alerting the reader that clients may depend
4830 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4831 rather than one to mark them as unordered, since in our experience,
4832 the great majority of enumeration types are conceptually unordered.
4834 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4835 and @code{Wide_Wide_Character}
4836 are considered to be ordered types, so each is declared with a
4837 pragma @code{Ordered} in package @code{Standard}.
4839 Normally pragma @code{Ordered} serves only as documentation and a guide for
4840 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4841 requests warnings for inappropriate uses (comparisons and explicit
4842 subranges) for unordered types. If this switch is used, then any
4843 enumeration type not marked with pragma @code{Ordered} will be considered
4844 as unordered, and will generate warnings for inappropriate uses.
4846 For additional information please refer to the description of the
4847 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4849 @node Pragma Overflow_Mode
4850 @unnumberedsec Pragma Overflow_Mode
4851 @findex Overflow checks
4852 @findex Overflow mode
4853 @findex pragma @code{Overflow_Mode}
4854 @noindent
4855 Syntax:
4857 @smallexample @c ada
4858 pragma Overflow_Mode
4859  (  [General    =>] MODE
4860   [,[Assertions =>] MODE]);
4862 MODE ::= STRICT | MINIMIZED | ELIMINATED
4863 @end smallexample
4865 @noindent
4866 This pragma sets the current overflow mode to the given setting. For details
4867 of the meaning of these modes, please refer to the
4868 ``Overflow Check Handling in GNAT'' appendix in the
4869 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
4870 the given mode applies to all expressions. If both parameters are present,
4871 the @code{General} mode applies to expressions outside assertions, and
4872 the @code{Eliminated} mode applies to expressions within assertions.
4874 The case of the @code{MODE} parameter is ignored,
4875 so @code{MINIMIZED}, @code{Minimized} and
4876 @code{minimized} all have the same effect.
4878 The @code{Overflow_Mode} pragma has the same scoping and placement
4879 rules as pragma @code{Suppress}, so it can occur either as a
4880 configuration pragma, specifying a default for the whole
4881 program, or in a declarative scope, where it applies to the
4882 remaining declarations and statements in that scope.
4884 The pragma @code{Suppress (Overflow_Check)} suppresses
4885 overflow checking, but does not affect the overflow mode.
4887 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
4888 overflow checking, but does not affect the overflow mode.
4890 @node Pragma Overriding_Renamings
4891 @unnumberedsec Pragma Overriding_Renamings
4892 @findex Overriding_Renamings
4893 @cindex Rational profile
4894 @cindex Rational compatibility
4895 @noindent
4896 Syntax:
4898 @smallexample @c ada
4899 pragma Overriding_Renamings;
4900 @end smallexample
4902 @noindent
4903 This is a GNAT configuration pragma to simplify porting
4904 legacy code accepted by the Rational
4905 Ada compiler. In the presence of this pragma, a renaming declaration that
4906 renames an inherited operation declared in the same scope is legal if selected
4907 notation is used as in:
4909 @smallexample @c ada
4910 pragma Overriding_Renamings;
4912 package R is
4913   function F (..);
4914   ...
4915   function F (..) renames R.F;
4916 end R;
4917 @end smallexample
4919 even though
4920 RM 8.3 (15) stipulates that an overridden operation is not visible within the
4921 declaration of the overriding operation.
4923 @node Pragma Partition_Elaboration_Policy
4924 @unnumberedsec Pragma Partition_Elaboration_Policy
4925 @findex Partition_Elaboration_Policy
4926 @noindent
4927 Syntax:
4929 @smallexample @c ada
4930 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
4932 POLICY_IDENTIFIER ::= Concurrent | Sequential
4933 @end smallexample
4935 @noindent
4936 This pragma is standard in Ada 2005, but is available in all earlier
4937 versions of Ada as an implementation-defined pragma.
4938 See Ada 2012 Reference Manual for details.
4940 @node Pragma Passive
4941 @unnumberedsec Pragma Passive
4942 @findex Passive
4943 @noindent
4944 Syntax:
4946 @smallexample @c ada
4947 pragma Passive [(Semaphore | No)];
4948 @end smallexample
4950 @noindent
4951 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
4952 compatibility with DEC Ada 83 implementations, where it is used within a
4953 task definition to request that a task be made passive.  If the argument
4954 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4955 treats the pragma as an assertion that the containing task is passive
4956 and that optimization of context switch with this task is permitted and
4957 desired.  If the argument @code{No} is present, the task must not be
4958 optimized.  GNAT does not attempt to optimize any tasks in this manner
4959 (since protected objects are available in place of passive tasks).
4961 @node Pragma Persistent_BSS
4962 @unnumberedsec Pragma Persistent_BSS
4963 @findex Persistent_BSS
4964 @noindent
4965 Syntax:
4967 @smallexample @c ada
4968 pragma Persistent_BSS [(LOCAL_NAME)]
4969 @end smallexample
4971 @noindent
4972 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4973 section. On some targets the linker and loader provide for special
4974 treatment of this section, allowing a program to be reloaded without
4975 affecting the contents of this data (hence the name persistent).
4977 There are two forms of usage. If an argument is given, it must be the
4978 local name of a library level object, with no explicit initialization
4979 and whose type is potentially persistent. If no argument is given, then
4980 the pragma is a configuration pragma, and applies to all library level
4981 objects with no explicit initialization of potentially persistent types.
4983 A potentially persistent type is a scalar type, or a non-tagged,
4984 non-discriminated record, all of whose components have no explicit
4985 initialization and are themselves of a potentially persistent type,
4986 or an array, all of whose constraints are static, and whose component
4987 type is potentially persistent.
4989 If this pragma is used on a target where this feature is not supported,
4990 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4992 @node Pragma Polling
4993 @unnumberedsec Pragma Polling
4994 @findex Polling
4995 @noindent
4996 Syntax:
4998 @smallexample @c ada
4999 pragma Polling (ON | OFF);
5000 @end smallexample
5002 @noindent
5003 This pragma controls the generation of polling code.  This is normally off.
5004 If @code{pragma Polling (ON)} is used then periodic calls are generated to
5005 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
5006 runtime library, and can be found in file @file{a-excpol.adb}.
5008 Pragma @code{Polling} can appear as a configuration pragma (for example it
5009 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
5010 can be used in the statement or declaration sequence to control polling
5011 more locally.
5013 A call to the polling routine is generated at the start of every loop and
5014 at the start of every subprogram call.  This guarantees that the @code{Poll}
5015 routine is called frequently, and places an upper bound (determined by
5016 the complexity of the code) on the period between two @code{Poll} calls.
5018 The primary purpose of the polling interface is to enable asynchronous
5019 aborts on targets that cannot otherwise support it (for example Windows
5020 NT), but it may be used for any other purpose requiring periodic polling.
5021 The standard version is null, and can be replaced by a user program.  This
5022 will require re-compilation of the @code{Ada.Exceptions} package that can
5023 be found in files @file{a-except.ads} and @file{a-except.adb}.
5025 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
5026 distribution) is used to enable the asynchronous abort capability on
5027 targets that do not normally support the capability.  The version of
5028 @code{Poll} in this file makes a call to the appropriate runtime routine
5029 to test for an abort condition.
5031 Note that polling can also be enabled by use of the @option{-gnatP} switch.
5032 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
5033 details.
5035 @node Pragma Post
5036 @unnumberedsec Pragma Post
5037 @cindex Post
5038 @cindex Checks, postconditions
5039 @findex Postconditions
5040 @noindent
5041 Syntax:
5043 @smallexample @c ada
5044 pragma Post (Boolean_Expression);
5045 @end smallexample
5047 @noindent
5048 The @code{Post} pragma is intended to be an exact replacement for
5049 the language-defined
5050 @code{Post} aspect, and shares its restrictions and semantics.
5051 It must appear either immediately following the corresponding
5052 subprogram declaration (only other pragmas may intervene), or
5053 if there is no separate subprogram declaration, then it can
5054 appear at the start of the declarations in a subprogram body
5055 (preceded only by other pragmas).
5057 @node Pragma Postcondition
5058 @unnumberedsec Pragma Postcondition
5059 @cindex Postcondition
5060 @cindex Checks, postconditions
5061 @findex Postconditions
5062 @noindent
5063 Syntax:
5065 @smallexample @c ada
5066 pragma Postcondition (
5067    [Check   =>] Boolean_Expression
5068  [,[Message =>] String_Expression]);
5069 @end smallexample
5071 @noindent
5072 The @code{Postcondition} pragma allows specification of automatic
5073 postcondition checks for subprograms. These checks are similar to
5074 assertions, but are automatically inserted just prior to the return
5075 statements of the subprogram with which they are associated (including
5076 implicit returns at the end of procedure bodies and associated
5077 exception handlers).
5079 In addition, the boolean expression which is the condition which
5080 must be true may contain references to function'Result in the case
5081 of a function to refer to the returned value.
5083 @code{Postcondition} pragmas may appear either immediately following the
5084 (separate) declaration of a subprogram, or at the start of the
5085 declarations of a subprogram body. Only other pragmas may intervene
5086 (that is appear between the subprogram declaration and its
5087 postconditions, or appear before the postcondition in the
5088 declaration sequence in a subprogram body). In the case of a
5089 postcondition appearing after a subprogram declaration, the
5090 formal arguments of the subprogram are visible, and can be
5091 referenced in the postcondition expressions.
5093 The postconditions are collected and automatically tested just
5094 before any return (implicit or explicit) in the subprogram body.
5095 A postcondition is only recognized if postconditions are active
5096 at the time the pragma is encountered. The compiler switch @option{gnata}
5097 turns on all postconditions by default, and pragma @code{Check_Policy}
5098 with an identifier of @code{Postcondition} can also be used to
5099 control whether postconditions are active.
5101 The general approach is that postconditions are placed in the spec
5102 if they represent functional aspects which make sense to the client.
5103 For example we might have:
5105 @smallexample @c ada
5106    function Direction return Integer;
5107    pragma Postcondition
5108     (Direction'Result = +1
5109        or else
5110      Direction'Result = -1);
5111 @end smallexample
5113 @noindent
5114 which serves to document that the result must be +1 or -1, and
5115 will test that this is the case at run time if postcondition
5116 checking is active.
5118 Postconditions within the subprogram body can be used to
5119 check that some internal aspect of the implementation,
5120 not visible to the client, is operating as expected.
5121 For instance if a square root routine keeps an internal
5122 counter of the number of times it is called, then we
5123 might have the following postcondition:
5125 @smallexample @c ada
5126    Sqrt_Calls : Natural := 0;
5128    function Sqrt (Arg : Float) return Float is
5129      pragma Postcondition
5130        (Sqrt_Calls = Sqrt_Calls'Old + 1);
5131      ...
5132    end Sqrt
5133 @end smallexample
5135 @noindent
5136 As this example, shows, the use of the @code{Old} attribute
5137 is often useful in postconditions to refer to the state on
5138 entry to the subprogram.
5140 Note that postconditions are only checked on normal returns
5141 from the subprogram. If an abnormal return results from
5142 raising an exception, then the postconditions are not checked.
5144 If a postcondition fails, then the exception
5145 @code{System.Assertions.Assert_Failure} is raised. If
5146 a message argument was supplied, then the given string
5147 will be used as the exception message. If no message
5148 argument was supplied, then the default message has
5149 the form "Postcondition failed at file:line". The
5150 exception is raised in the context of the subprogram
5151 body, so it is possible to catch postcondition failures
5152 within the subprogram body itself.
5154 Within a package spec, normal visibility rules
5155 in Ada would prevent forward references within a
5156 postcondition pragma to functions defined later in
5157 the same package. This would introduce undesirable
5158 ordering constraints. To avoid this problem, all
5159 postcondition pragmas are analyzed at the end of
5160 the package spec, allowing forward references.
5162 The following example shows that this even allows
5163 mutually recursive postconditions as in:
5165 @smallexample @c ada
5166 package Parity_Functions is
5167    function Odd  (X : Natural) return Boolean;
5168    pragma Postcondition
5169      (Odd'Result =
5170         (x = 1
5171           or else
5172         (x /= 0 and then Even (X - 1))));
5174    function Even (X : Natural) return Boolean;
5175    pragma Postcondition
5176      (Even'Result =
5177         (x = 0
5178           or else
5179         (x /= 1 and then Odd (X - 1))));
5181 end Parity_Functions;
5182 @end smallexample
5184 @noindent
5185 There are no restrictions on the complexity or form of
5186 conditions used within @code{Postcondition} pragmas.
5187 The following example shows that it is even possible
5188 to verify performance behavior.
5190 @smallexample @c ada
5191 package Sort is
5193    Performance : constant Float;
5194    --  Performance constant set by implementation
5195    --  to match target architecture behavior.
5197    procedure Treesort (Arg : String);
5198    --  Sorts characters of argument using N*logN sort
5199    pragma Postcondition
5200      (Float (Clock - Clock'Old) <=
5201         Float (Arg'Length) *
5202         log (Float (Arg'Length)) *
5203         Performance);
5204 end Sort;
5205 @end smallexample
5207 @noindent
5208 Note: postcondition pragmas associated with subprograms that are
5209 marked as Inline_Always, or those marked as Inline with front-end
5210 inlining (-gnatN option set) are accepted and legality-checked
5211 by the compiler, but are ignored at run-time even if postcondition
5212 checking is enabled.
5214 Note that pragma @code{Postcondition} differs from the language-defined
5215 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
5216 multiple occurrences, allowing occurences in the body even if there
5217 is a separate spec, and allowing a second string parameter, and the
5218 use of the pragma identifier @code{Check}. Historically, pragma
5219 @code{Postcondition} was implemented prior to the development of
5220 Ada 2012, and has been retained in its original form for
5221 compatibility purposes.
5223 @node Pragma Post_Class
5224 @unnumberedsec Pragma Post_Class
5225 @cindex Post
5226 @cindex Checks, postconditions
5227 @findex Postconditions
5228 @noindent
5229 Syntax:
5231 @smallexample @c ada
5232 pragma Post_Class (Boolean_Expression);
5233 @end smallexample
5235 @noindent
5236 The @code{Post_Class} pragma is intended to be an exact replacement for
5237 the language-defined
5238 @code{Post'Class} aspect, and shares its restrictions and semantics.
5239 It must appear either immediately following the corresponding
5240 subprogram declaration (only other pragmas may intervene), or
5241 if there is no separate subprogram declaration, then it can
5242 appear at the start of the declarations in a subprogram body
5243 (preceded only by other pragmas).
5245 Note: This pragma is called @code{Post_Class} rather than
5246 @code{Post'Class} because the latter would not be strictly
5247 conforming to the allowed syntax for pragmas. The motivation
5248 for provinding pragmas equivalent to the aspects is to allow a program
5249 to be written using the pragmas, and then compiled if necessary
5250 using an Ada compiler that does not recognize the pragmas or
5251 aspects, but is prepared to ignore the pragmas. The assertion
5252 policy that controls this pragma is @code{Post'Class}, not
5253 @code{Post_Class}.
5255 @node Pragma Pre
5256 @unnumberedsec Pragma Pre
5257 @cindex Pre
5258 @cindex Checks, preconditions
5259 @findex Preconditions
5260 @noindent
5261 Syntax:
5263 @smallexample @c ada
5264 pragma Pre (Boolean_Expression);
5265 @end smallexample
5267 @noindent
5268 The @code{Pre} pragma is intended to be an exact replacement for
5269 the language-defined
5270 @code{Pre} aspect, and shares its restrictions and semantics.
5271 It must appear either immediately following the corresponding
5272 subprogram declaration (only other pragmas may intervene), or
5273 if there is no separate subprogram declaration, then it can
5274 appear at the start of the declarations in a subprogram body
5275 (preceded only by other pragmas).
5277 @node Pragma Precondition
5278 @unnumberedsec Pragma Precondition
5279 @cindex Preconditions
5280 @cindex Checks, preconditions
5281 @findex Preconditions
5282 @noindent
5283 Syntax:
5285 @smallexample @c ada
5286 pragma Precondition (
5287    [Check   =>] Boolean_Expression
5288  [,[Message =>] String_Expression]);
5289 @end smallexample
5291 @noindent
5292 The @code{Precondition} pragma is similar to @code{Postcondition}
5293 except that the corresponding checks take place immediately upon
5294 entry to the subprogram, and if a precondition fails, the exception
5295 is raised in the context of the caller, and the attribute 'Result
5296 cannot be used within the precondition expression.
5298 Otherwise, the placement and visibility rules are identical to those
5299 described for postconditions. The following is an example of use
5300 within a package spec:
5302 @smallexample @c ada
5303 package Math_Functions is
5304    ...
5305    function Sqrt (Arg : Float) return Float;
5306    pragma Precondition (Arg >= 0.0)
5307    ...
5308 end Math_Functions;
5309 @end smallexample
5311 @noindent
5312 @code{Precondition} pragmas may appear either immediately following the
5313 (separate) declaration of a subprogram, or at the start of the
5314 declarations of a subprogram body. Only other pragmas may intervene
5315 (that is appear between the subprogram declaration and its
5316 postconditions, or appear before the postcondition in the
5317 declaration sequence in a subprogram body).
5319 Note: precondition pragmas associated with subprograms that are
5320 marked as Inline_Always, or those marked as Inline with front-end
5321 inlining (-gnatN option set) are accepted and legality-checked
5322 by the compiler, but are ignored at run-time even if precondition
5323 checking is enabled.
5325 Note that pragma @code{Precondition} differs from the language-defined
5326 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
5327 multiple occurrences, allowing occurences in the body even if there
5328 is a separate spec, and allowing a second string parameter, and the
5329 use of the pragma identifier @code{Check}. Historically, pragma
5330 @code{Precondition} was implemented prior to the development of
5331 Ada 2012, and has been retained in its original form for
5332 compatibility purposes.
5334 @node Pragma Predicate
5335 @unnumberedsec Pragma Predicate
5336 @findex Predicate
5337 @findex Predicate pragma
5338 @noindent
5339 Syntax:
5341 @smallexample @c ada
5342 pragma Predicate
5343   ([Entity =>] type_LOCAL_NAME,
5344    [Check  =>] EXPRESSION);
5345 @end smallexample
5347 @noindent
5348 This pragma (available in all versions of Ada in GNAT) encompasses both
5349 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
5350 Ada 2012. A predicate is regarded as static if it has an allowed form
5351 for @code{Static_Predicate} and is otherwise treated as a
5352 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
5353 pragma behave exactly as described in the Ada 2012 reference manual.
5354 For example, if we have
5356 @smallexample @c ada
5357 type R is range 1 .. 10;
5358 subtype S is R;
5359 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5360 subtype Q is R
5361 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5362 @end smallexample
5364 @noindent
5365 the effect is identical to the following Ada 2012 code:
5367 @smallexample @c ada
5368 type R is range 1 .. 10;
5369 subtype S is R with
5370   Static_Predicate => S not in 4 .. 6;
5371 subtype Q is R with
5372   Dynamic_Predicate => F(Q) or G(Q);
5373 @end smallexample
5375 Note that there is are no pragmas @code{Dynamic_Predicate}
5376 or @code{Static_Predicate}. That is
5377 because these pragmas would affect legality and semantics of
5378 the program and thus do not have a neutral effect if ignored.
5379 The motivation behind providing pragmas equivalent to
5380 corresponding aspects is to allow a program to be written
5381 using the pragmas, and then compiled with a compiler that
5382 will ignore the pragmas. That doesn't work in the case of
5383 static and dynamic predicates, since if the corresponding
5384 pragmas are ignored, then the behavior of the program is
5385 fundamentally changed (for example a membership test
5386 @code{A in B} would not take into account a predicate
5387 defined for subtype B). When following this approach, the
5388 use of predicates should be avoided.
5390 @node Pragma Preelaborable_Initialization
5391 @unnumberedsec Pragma Preelaborable_Initialization
5392 @findex Preelaborable_Initialization
5393 @noindent
5394 Syntax:
5396 @smallexample @c ada
5397 pragma Preelaborable_Initialization (DIRECT_NAME);
5398 @end smallexample
5400 @noindent
5401 This pragma is standard in Ada 2005, but is available in all earlier
5402 versions of Ada as an implementation-defined pragma.
5403 See Ada 2012 Reference Manual for details.
5405 @node Pragma Preelaborate_05
5406 @unnumberedsec Pragma Preelaborate_05
5407 @findex Preelaborate_05
5408 @noindent
5409 Syntax:
5411 @smallexample @c ada
5412 pragma Preelaborate_05 [(library_unit_NAME)];
5413 @end smallexample
5415 @noindent
5416 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5417 and is intended for use in the standard run-time library only. It has
5418 no effect in Ada 83 or Ada 95 mode, but is
5419 equivalent to @code{pragma Prelaborate} when operating in later
5420 Ada versions. This is used to handle some cases where packages
5421 not previously preelaborable became so in Ada 2005.
5423 @node Pragma Pre_Class
5424 @unnumberedsec Pragma Pre_Class
5425 @cindex Pre_Class
5426 @cindex Checks, preconditions
5427 @findex Preconditions
5428 @noindent
5429 Syntax:
5431 @smallexample @c ada
5432 pragma Pre_Class (Boolean_Expression);
5433 @end smallexample
5435 @noindent
5436 The @code{Pre_Class} pragma is intended to be an exact replacement for
5437 the language-defined
5438 @code{Pre'Class} aspect, and shares its restrictions and semantics.
5439 It must appear either immediately following the corresponding
5440 subprogram declaration (only other pragmas may intervene), or
5441 if there is no separate subprogram declaration, then it can
5442 appear at the start of the declarations in a subprogram body
5443 (preceded only by other pragmas).
5445 Note: This pragma is called @code{Pre_Class} rather than
5446 @code{Pre'Class} because the latter would not be strictly
5447 conforming to the allowed syntax for pragmas. The motivation
5448 for providing pragmas equivalent to the aspects is to allow a program
5449 to be written using the pragmas, and then compiled if necessary
5450 using an Ada compiler that does not recognize the pragmas or
5451 aspects, but is prepared to ignore the pragmas. The assertion
5452 policy that controls this pragma is @code{Pre'Class}, not
5453 @code{Pre_Class}.
5455 @node Pragma Priority_Specific_Dispatching
5456 @unnumberedsec Pragma Priority_Specific_Dispatching
5457 @findex Priority_Specific_Dispatching
5458 @noindent
5459 Syntax:
5461 @smallexample @c ada
5462 pragma Priority_Specific_Dispatching (
5463    POLICY_IDENTIFIER,
5464    first_priority_EXPRESSION,
5465    last_priority_EXPRESSION)
5467 POLICY_IDENTIFIER ::=
5468    EDF_Across_Priorities            |
5469    FIFO_Within_Priorities           |
5470    Non_Preemptive_Within_Priorities |
5471    Round_Robin_Within_Priorities
5472 @end smallexample
5474 @noindent
5475 This pragma is standard in Ada 2005, but is available in all earlier
5476 versions of Ada as an implementation-defined pragma.
5477 See Ada 2012 Reference Manual for details.
5479 @node Pragma Profile
5480 @unnumberedsec Pragma Profile
5481 @findex Profile
5482 @noindent
5483 Syntax:
5485 @smallexample @c ada
5486 pragma Profile (Ravenscar | Restricted | Rational);
5487 @end smallexample
5489 @noindent
5490 This pragma is standard in Ada 2005, but is available in all earlier
5491 versions of Ada as an implementation-defined pragma. This is a
5492 configuration pragma that establishes a set of configiuration pragmas
5493 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5494 The other two possibilities (@code{Restricted} or @code{Rational})
5495 are implementation-defined. The set of configuration pragmas
5496 is defined in the following sections.
5498 @itemize
5500 @item Pragma Profile (Ravenscar)
5501 @findex Ravenscar
5502 @noindent
5504 The @code{Ravenscar} profile is standard in Ada 2005,
5505 but is available in all earlier
5506 versions of Ada as an implementation-defined pragma. This profile
5507 establishes the following set of configuration pragmas:
5509 @table @code
5510 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5511 [RM D.2.2] Tasks are dispatched following a preemptive
5512 priority-ordered scheduling policy.
5514 @item Locking_Policy (Ceiling_Locking)
5515 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5516 the ceiling priority of the corresponding protected object.
5518 @item Detect_Blocking
5519 This pragma forces the detection of potentially blocking operations within a
5520 protected operation, and to raise Program_Error if that happens.
5521 @end table
5522 @noindent
5524 plus the following set of restrictions:
5526 @table @code
5527 @item Max_Entry_Queue_Length => 1
5528 No task can be queued on a protected entry.
5529 @item Max_Protected_Entries => 1
5530 @item Max_Task_Entries => 0
5531 No rendezvous statements are allowed.
5532 @item No_Abort_Statements
5533 @item No_Dynamic_Attachment
5534 @item No_Dynamic_Priorities
5535 @item No_Implicit_Heap_Allocations
5536 @item No_Local_Protected_Objects
5537 @item No_Local_Timing_Events
5538 @item No_Protected_Type_Allocators
5539 @item No_Relative_Delay
5540 @item No_Requeue_Statements
5541 @item No_Select_Statements
5542 @item No_Specific_Termination_Handlers
5543 @item No_Task_Allocators
5544 @item No_Task_Hierarchy
5545 @item No_Task_Termination
5546 @item Simple_Barriers
5547 @end table
5548 @noindent
5550 The Ravenscar profile also includes the following restrictions that specify
5551 that there are no semantic dependences on the corresponding predefined
5552 packages:
5554 @table @code
5555 @item No_Dependence => Ada.Asynchronous_Task_Control
5556 @item No_Dependence => Ada.Calendar
5557 @item No_Dependence => Ada.Execution_Time.Group_Budget
5558 @item No_Dependence => Ada.Execution_Time.Timers
5559 @item No_Dependence => Ada.Task_Attributes
5560 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5561 @end table
5563 @noindent
5565 This set of configuration pragmas and restrictions correspond to the
5566 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5567 published by the @cite{International Real-Time Ada Workshop}, 1997,
5568 and whose most recent description is available at
5569 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5571 The original definition of the profile was revised at subsequent IRTAW
5572 meetings. It has been included in the ISO
5573 @cite{Guide for the Use of the Ada Programming Language in High
5574 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5575 the next revision of the standard. The formal definition given by
5576 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5577 AI-305) available at
5578 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5579 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5581 The above set is a superset of the restrictions provided by pragma
5582 @code{Profile (Restricted)}, it includes six additional restrictions
5583 (@code{Simple_Barriers}, @code{No_Select_Statements},
5584 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5585 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
5586 that pragma @code{Profile (Ravenscar)}, like the pragma
5587 @code{Profile (Restricted)},
5588 automatically causes the use of a simplified,
5589 more efficient version of the tasking run-time system.
5591 @item Pragma Profile (Restricted)
5592 @findex Restricted Run Time
5593 @noindent
5594 This profile corresponds to the GNAT restricted run time. It
5595 establishes the following set of restrictions:
5597 @itemize @bullet
5598 @item No_Abort_Statements
5599 @item No_Entry_Queue
5600 @item No_Task_Hierarchy
5601 @item No_Task_Allocators
5602 @item No_Dynamic_Priorities
5603 @item No_Terminate_Alternatives
5604 @item No_Dynamic_Attachment
5605 @item No_Protected_Type_Allocators
5606 @item No_Local_Protected_Objects
5607 @item No_Requeue_Statements
5608 @item No_Task_Attributes_Package
5609 @item Max_Asynchronous_Select_Nesting =  0
5610 @item Max_Task_Entries =  0
5611 @item Max_Protected_Entries = 1
5612 @item Max_Select_Alternatives = 0
5613 @end itemize
5615 @noindent
5616 This set of restrictions causes the automatic selection of a simplified
5617 version of the run time that provides improved performance for the
5618 limited set of tasking functionality permitted by this set of restrictions.
5620 @item Pragma Profile (Rational)
5621 @findex Rational compatibility mode
5622 @noindent
5623 The Rational profile is intended to facilitate porting legacy code that
5624 compiles with the Rational APEX compiler, even when the code includes non-
5625 conforming Ada constructs.  The profile enables the following three pragmas:
5627 @itemize @bullet
5628 @item pragma Implicit_Packing
5629 @item pragma Overriding_Renamings
5630 @item pragma Use_VADS_Size
5631 @end itemize
5633 @end itemize
5635 @node Pragma Profile_Warnings
5636 @unnumberedsec Pragma Profile_Warnings
5637 @findex Profile_Warnings
5638 @noindent
5639 Syntax:
5641 @smallexample @c ada
5642 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5643 @end smallexample
5645 @noindent
5646 This is an implementation-defined pragma that is similar in
5647 effect to @code{pragma Profile} except that instead of
5648 generating @code{Restrictions} pragmas, it generates
5649 @code{Restriction_Warnings} pragmas. The result is that
5650 violations of the profile generate warning messages instead
5651 of error messages.
5653 @node Pragma Propagate_Exceptions
5654 @unnumberedsec Pragma Propagate_Exceptions
5655 @cindex Interfacing to C++
5656 @findex Propagate_Exceptions
5657 @noindent
5658 Syntax:
5660 @smallexample @c ada
5661 pragma Propagate_Exceptions;
5662 @end smallexample
5664 @noindent
5665 This pragma is now obsolete and, other than generating a warning if warnings
5666 on obsolescent features are enabled, is ignored.
5667 It is retained for compatibility
5668 purposes. It used to be used in connection with optimization of
5669 a now-obsolete mechanism for implementation of exceptions.
5671 @node Pragma Psect_Object
5672 @unnumberedsec Pragma Psect_Object
5673 @findex Psect_Object
5674 @noindent
5675 Syntax:
5677 @smallexample @c ada
5678 pragma Psect_Object (
5679      [Internal =>] LOCAL_NAME,
5680   [, [External =>] EXTERNAL_SYMBOL]
5681   [, [Size     =>] EXTERNAL_SYMBOL]);
5683 EXTERNAL_SYMBOL ::=
5684   IDENTIFIER
5685 | static_string_EXPRESSION
5686 @end smallexample
5688 @noindent
5689 This pragma is identical in effect to pragma @code{Common_Object}.
5691 @node Pragma Pure_05
5692 @unnumberedsec Pragma Pure_05
5693 @findex Pure_05
5694 @noindent
5695 Syntax:
5697 @smallexample @c ada
5698 pragma Pure_05 [(library_unit_NAME)];
5699 @end smallexample
5701 @noindent
5702 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5703 and is intended for use in the standard run-time library only. It has
5704 no effect in Ada 83 or Ada 95 mode, but is
5705 equivalent to @code{pragma Pure} when operating in later
5706 Ada versions. This is used to handle some cases where packages
5707 not previously pure became so in Ada 2005.
5709 @node Pragma Pure_12
5710 @unnumberedsec Pragma Pure_12
5711 @findex Pure_12
5712 @noindent
5713 Syntax:
5715 @smallexample @c ada
5716 pragma Pure_12 [(library_unit_NAME)];
5717 @end smallexample
5719 @noindent
5720 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5721 and is intended for use in the standard run-time library only. It has
5722 no effect in Ada 83, Ada 95, or Ada 2005 modes, but is
5723 equivalent to @code{pragma Pure} when operating in later
5724 Ada versions. This is used to handle some cases where packages
5725 not previously pure became so in Ada 2012.
5727 @node Pragma Pure_Function
5728 @unnumberedsec Pragma Pure_Function
5729 @findex Pure_Function
5730 @noindent
5731 Syntax:
5733 @smallexample @c ada
5734 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5735 @end smallexample
5737 @noindent
5738 This pragma appears in the same declarative part as a function
5739 declaration (or a set of function declarations if more than one
5740 overloaded declaration exists, in which case the pragma applies
5741 to all entities).  It specifies that the function @code{Entity} is
5742 to be considered pure for the purposes of code generation.  This means
5743 that the compiler can assume that there are no side effects, and
5744 in particular that two calls with identical arguments produce the
5745 same result.  It also means that the function can be used in an
5746 address clause.
5748 Note that, quite deliberately, there are no static checks to try
5749 to ensure that this promise is met, so @code{Pure_Function} can be used
5750 with functions that are conceptually pure, even if they do modify
5751 global variables.  For example, a square root function that is
5752 instrumented to count the number of times it is called is still
5753 conceptually pure, and can still be optimized, even though it
5754 modifies a global variable (the count).  Memo functions are another
5755 example (where a table of previous calls is kept and consulted to
5756 avoid re-computation).
5758 Note also that the normal rules excluding optimization of subprograms
5759 in pure units (when parameter types are descended from System.Address,
5760 or when the full view of a parameter type is limited), do not apply
5761 for the Pure_Function case. If you explicitly specify Pure_Function,
5762 the compiler may optimize away calls with identical arguments, and
5763 if that results in unexpected behavior, the proper action is not to
5764 use the pragma for subprograms that are not (conceptually) pure.
5766 @findex Pure
5767 Note: Most functions in a @code{Pure} package are automatically pure, and
5768 there is no need to use pragma @code{Pure_Function} for such functions.  One
5769 exception is any function that has at least one formal of type
5770 @code{System.Address} or a type derived from it.  Such functions are not
5771 considered pure by default, since the compiler assumes that the
5772 @code{Address} parameter may be functioning as a pointer and that the
5773 referenced data may change even if the address value does not.
5774 Similarly, imported functions are not considered to be pure by default,
5775 since there is no way of checking that they are in fact pure.  The use
5776 of pragma @code{Pure_Function} for such a function will override these default
5777 assumption, and cause the compiler to treat a designated subprogram as pure
5778 in these cases.
5780 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5781 applies to the underlying renamed function.  This can be used to
5782 disambiguate cases of overloading where some but not all functions
5783 in a set of overloaded functions are to be designated as pure.
5785 If pragma @code{Pure_Function} is applied to a library level function, the
5786 function is also considered pure from an optimization point of view, but the
5787 unit is not a Pure unit in the categorization sense. So for example, a function
5788 thus marked is free to @code{with} non-pure units.
5790 @node Pragma Ravenscar
5791 @unnumberedsec Pragma Ravenscar
5792 @findex Pragma Ravenscar
5793 @noindent
5794 Syntax:
5796 @smallexample @c ada
5797 pragma Ravenscar;
5798 @end smallexample
5800 @noindent
5801 This pragma is considered obsolescent, but is retained for
5802 compatibility purposes. It is equivalent to:
5804 @smallexample @c ada
5805 pragma Profile (Ravenscar);
5806 @end smallexample
5808 @noindent
5809 which is the preferred method of setting the @code{Ravenscar} profile.
5811 @node Pragma Relative_Deadline
5812 @unnumberedsec Pragma Relative_Deadline
5813 @findex Relative_Deadline
5814 @noindent
5815 Syntax:
5817 @smallexample @c ada
5818 pragma Relative_Deadline (time_span_EXPRESSSION);
5819 @end smallexample
5821 @noindent
5822 This pragma is standard in Ada 2005, but is available in all earlier
5823 versions of Ada as an implementation-defined pragma.
5824 See Ada 2012 Reference Manual for details.
5826 @node Pragma Remote_Access_Type
5827 @unnumberedsec Pragma Remote_Access_Type
5828 @findex Remote_Access_Type
5829 @noindent
5830 Syntax:
5832 @smallexample @c ada
5833 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
5834 @end smallexample
5836 @noindent
5837 This pragma appears in the formal part of a generic declaration.
5838 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
5839 the use of a remote access to class-wide type as actual for a formal
5840 access type.
5842 When this pragma applies to a formal access type @code{Entity}, that
5843 type is treated as a remote access to class-wide type in the generic.
5844 It must be a formal general access type, and its designated type must
5845 be the class-wide type of a formal tagged limited private type from the
5846 same generic declaration.
5848 In the generic unit, the formal type is subject to all restrictions
5849 pertaining to remote access to class-wide types. At instantiation, the
5850 actual type must be a remote access to class-wide type.
5852 @node Pragma Restricted_Run_Time
5853 @unnumberedsec Pragma Restricted_Run_Time
5854 @findex Pragma Restricted_Run_Time
5855 @noindent
5856 Syntax:
5858 @smallexample @c ada
5859 pragma Restricted_Run_Time;
5860 @end smallexample
5862 @noindent
5863 This pragma is considered obsolescent, but is retained for
5864 compatibility purposes. It is equivalent to:
5866 @smallexample @c ada
5867 pragma Profile (Restricted);
5868 @end smallexample
5870 @noindent
5871 which is the preferred method of setting the restricted run time
5872 profile.
5874 @node Pragma Restriction_Warnings
5875 @unnumberedsec Pragma Restriction_Warnings
5876 @findex Restriction_Warnings
5877 @noindent
5878 Syntax:
5880 @smallexample @c ada
5881 pragma Restriction_Warnings
5882   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
5883 @end smallexample
5885 @noindent
5886 This pragma allows a series of restriction identifiers to be
5887 specified (the list of allowed identifiers is the same as for
5888 pragma @code{Restrictions}). For each of these identifiers
5889 the compiler checks for violations of the restriction, but
5890 generates a warning message rather than an error message
5891 if the restriction is violated.
5893 @node Pragma Share_Generic
5894 @unnumberedsec Pragma Share_Generic
5895 @findex Share_Generic
5896 @noindent
5897 Syntax:
5899 @smallexample @c ada
5900 pragma Share_Generic (GNAME @{, GNAME@});
5902 GNAME ::= generic_unit_NAME | generic_instance_NAME
5903 @end smallexample
5905 @noindent
5906 This pragma is provided for compatibility with Dec Ada 83. It has
5907 no effect in @code{GNAT} (which does not implement shared generics), other
5908 than to check that the given names are all names of generic units or
5909 generic instances.
5911 @node Pragma Shared
5912 @unnumberedsec Pragma Shared
5913 @findex Shared
5915 @noindent
5916 This pragma is provided for compatibility with Ada 83. The syntax and
5917 semantics are identical to pragma Atomic.
5919 @node Pragma Short_Circuit_And_Or
5920 @unnumberedsec Pragma Short_Circuit_And_Or
5921 @findex Short_Circuit_And_Or
5922 @noindent
5923 Syntax:
5925 @smallexample @c ada
5926 pragma Short_Circuit_And_Or;
5927 @end smallexample
5929 @noindent
5930 This configuration pragma causes any occurrence of the AND operator applied to
5931 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
5932 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
5933 may be useful in the context of certification protocols requiring the use of
5934 short-circuited logical operators. If this configuration pragma occurs locally
5935 within the file being compiled, it applies only to the file being compiled.
5936 There is no requirement that all units in a partition use this option.
5938 @node Pragma Short_Descriptors
5939 @unnumberedsec Pragma Short_Descriptors
5940 @findex Short_Descriptors
5941 @noindent
5942 Syntax:
5944 @smallexample @c ada
5945 pragma Short_Descriptors
5946 @end smallexample
5948 @noindent
5949 In VMS versions of the compiler, this configuration pragma causes all
5950 occurrences of the mechanism types Descriptor[_xxx] to be treated as
5951 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
5952 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
5953 versions.
5955 @node Pragma Simple_Storage_Pool_Type
5956 @unnumberedsec Pragma Simple_Storage_Pool_Type
5957 @findex Simple_Storage_Pool_Type
5958 @cindex Storage pool, simple
5959 @cindex Simple storage pool
5960 @noindent
5961 Syntax:
5963 @smallexample @c ada
5964 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
5965 @end smallexample
5967 @noindent
5968 A type can be established as a ``simple storage pool type'' by applying
5969 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
5970 A type named in the pragma must be a library-level immutably limited record
5971 type or limited tagged type declared immediately within a package declaration.
5972 The type can also be a limited private type whose full type is allowed as
5973 a simple storage pool type.
5975 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
5976 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
5977 are subtype conformant with the following subprogram declarations:
5979 @smallexample @c ada
5980 procedure Allocate
5981   (Pool                     : in out SSP;
5982    Storage_Address          : out System.Address;
5983    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5984    Alignment                : System.Storage_Elements.Storage_Count);
5986 procedure Deallocate
5987   (Pool : in out SSP;
5988    Storage_Address          : System.Address;
5989    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5990    Alignment                : System.Storage_Elements.Storage_Count);
5992 function Storage_Size (Pool : SSP)
5993   return System.Storage_Elements.Storage_Count;
5994 @end smallexample
5996 @noindent
5997 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
5998 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
5999 applying an unchecked deallocation has no effect other than to set its actual
6000 parameter to null. If @code{Storage_Size} is not declared, then the
6001 @code{Storage_Size} attribute applied to an access type associated with
6002 a pool object of type SSP returns zero. Additional operations can be declared
6003 for a simple storage pool type (such as for supporting a mark/release
6004 storage-management discipline).
6006 An object of a simple storage pool type can be associated with an access
6007 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
6009 @smallexample @c ada
6011 My_Pool : My_Simple_Storage_Pool_Type;
6013 type Acc is access My_Data_Type;
6015 for Acc'Simple_Storage_Pool use My_Pool;
6017 @end smallexample
6019 @noindent
6020 See attribute @code{Simple_Storage_Pool} for further details.
6022 @node Pragma Source_File_Name
6023 @unnumberedsec Pragma Source_File_Name
6024 @findex Source_File_Name
6025 @noindent
6026 Syntax:
6028 @smallexample @c ada
6029 pragma Source_File_Name (
6030   [Unit_Name   =>] unit_NAME,
6031   Spec_File_Name =>  STRING_LITERAL,
6032   [Index => INTEGER_LITERAL]);
6034 pragma Source_File_Name (
6035   [Unit_Name   =>] unit_NAME,
6036   Body_File_Name =>  STRING_LITERAL,
6037   [Index => INTEGER_LITERAL]);
6038 @end smallexample
6040 @noindent
6041 Use this to override the normal naming convention.  It is a configuration
6042 pragma, and so has the usual applicability of configuration pragmas
6043 (i.e.@: it applies to either an entire partition, or to all units in a
6044 compilation, or to a single unit, depending on how it is used.
6045 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
6046 the second argument is required, and indicates whether this is the file
6047 name for the spec or for the body.
6049 The optional Index argument should be used when a file contains multiple
6050 units, and when you do not want to use @code{gnatchop} to separate then
6051 into multiple files (which is the recommended procedure to limit the
6052 number of recompilations that are needed when some sources change).
6053 For instance, if the source file @file{source.ada} contains
6055 @smallexample @c ada
6056 package B is
6058 end B;
6060 with B;
6061 procedure A is
6062 begin
6063    ..
6064 end A;
6065 @end smallexample
6067 you could use the following configuration pragmas:
6069 @smallexample @c ada
6070 pragma Source_File_Name
6071   (B, Spec_File_Name => "source.ada", Index => 1);
6072 pragma Source_File_Name
6073   (A, Body_File_Name => "source.ada", Index => 2);
6074 @end smallexample
6076 Note that the @code{gnatname} utility can also be used to generate those
6077 configuration pragmas.
6079 Another form of the @code{Source_File_Name} pragma allows
6080 the specification of patterns defining alternative file naming schemes
6081 to apply to all files.
6083 @smallexample @c ada
6084 pragma Source_File_Name
6085   (  [Spec_File_Name  =>] STRING_LITERAL
6086    [,[Casing          =>] CASING_SPEC]
6087    [,[Dot_Replacement =>] STRING_LITERAL]);
6089 pragma Source_File_Name
6090   (  [Body_File_Name  =>] STRING_LITERAL
6091    [,[Casing          =>] CASING_SPEC]
6092    [,[Dot_Replacement =>] STRING_LITERAL]);
6094 pragma Source_File_Name
6095   (  [Subunit_File_Name =>] STRING_LITERAL
6096    [,[Casing            =>] CASING_SPEC]
6097    [,[Dot_Replacement   =>] STRING_LITERAL]);
6099 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
6100 @end smallexample
6102 @noindent
6103 The first argument is a pattern that contains a single asterisk indicating
6104 the point at which the unit name is to be inserted in the pattern string
6105 to form the file name.  The second argument is optional.  If present it
6106 specifies the casing of the unit name in the resulting file name string.
6107 The default is lower case.  Finally the third argument allows for systematic
6108 replacement of any dots in the unit name by the specified string literal.
6110 Note that Source_File_Name pragmas should not be used if you are using
6111 project files. The reason for this rule is that the project manager is not
6112 aware of these pragmas, and so other tools that use the projet file would not
6113 be aware of the intended naming conventions. If you are using project files,
6114 file naming is controlled by Source_File_Name_Project pragmas, which are
6115 usually supplied automatically by the project manager. A pragma
6116 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
6118 For more details on the use of the @code{Source_File_Name} pragma,
6119 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
6120 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
6121 User's Guide}.
6123 @node Pragma Source_File_Name_Project
6124 @unnumberedsec Pragma Source_File_Name_Project
6125 @findex Source_File_Name_Project
6126 @noindent
6128 This pragma has the same syntax and semantics as pragma Source_File_Name.
6129 It is only allowed as a stand alone configuration pragma.
6130 It cannot appear after a @ref{Pragma Source_File_Name}, and
6131 most importantly, once pragma Source_File_Name_Project appears,
6132 no further Source_File_Name pragmas are allowed.
6134 The intention is that Source_File_Name_Project pragmas are always
6135 generated by the Project Manager in a manner consistent with the naming
6136 specified in a project file, and when naming is controlled in this manner,
6137 it is not permissible to attempt to modify this naming scheme using
6138 Source_File_Name or Source_File_Name_Project pragmas (which would not be
6139 known to the project manager).
6141 @node Pragma Source_Reference
6142 @unnumberedsec Pragma Source_Reference
6143 @findex Source_Reference
6144 @noindent
6145 Syntax:
6147 @smallexample @c ada
6148 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
6149 @end smallexample
6151 @noindent
6152 This pragma must appear as the first line of a source file.
6153 @var{integer_literal} is the logical line number of the line following
6154 the pragma line (for use in error messages and debugging
6155 information).  @var{string_literal} is a static string constant that
6156 specifies the file name to be used in error messages and debugging
6157 information.  This is most notably used for the output of @code{gnatchop}
6158 with the @option{-r} switch, to make sure that the original unchopped
6159 source file is the one referred to.
6161 The second argument must be a string literal, it cannot be a static
6162 string expression other than a string literal.  This is because its value
6163 is needed for error messages issued by all phases of the compiler.
6165 @node Pragma SPARK_Mode
6166 @unnumberedsec Pragma SPARK_Mode
6167 @findex SPARK_Mode
6168 @noindent
6169 Syntax:
6171 @smallexample @c ada
6172 pragma SPARK_Mode [ (On | Off | Auto) ] ;
6173 @end smallexample
6175 @noindent
6176 This pragma is used to designate whether a contract and its implementation must
6177 follow the SPARK 2014 programming language syntactic and semantic rules. The
6178 pragma is intended for use with formal verification tools and has no effect on
6179 the generated code.
6181 When used as a configuration pragma over a whole compilation or in a particular
6182 compilation unit, it sets the mode of the units involved, in particular:
6184 @itemize @bullet
6186 @item
6187 @code{On}: All entities in the units must follow the SPARK 2014 language, and
6188 an error will be generated if not, unless locally overridden by a local
6189 SPARK_Mode pragma or aspect. @code{On} is the default mode when pragma
6190 SPARK_Mode is used without an argument.
6192 @item
6193 @code{Off}: The units are considered to be in Ada by default and therefore not
6194 part of SPARK 2014 unless overridden locally. These units may be called by
6195 SPARK 2014 units.
6197 @item
6198 @code{Auto}: The formal verification tools will automatically detect whether
6199 each entity is in SPARK 2014 or in Ada.
6201 @end itemize
6203 Pragma SPARK_Mode can be used as a local pragma with the following semantics:
6205 @itemize @bullet
6207 @item
6208 Auto cannot be used as a mode argument.
6210 @item
6211 When the pragma at the start of the visible declarations (preceded only
6212 by other pragmas) of a package declaration, it marks the whole package
6213 (declaration and body) in or out of SPARK 2014.
6215 @item
6216 When the pragma appears at the start of the private declarations of a
6217 package (only other pragmas can appear between the @code{private} keyword
6218 and the @code{SPARK_Mode} pragma), it marks the private part in or
6219 out of SPARK 2014 (overriding the default mode of the visible part).
6221 @item
6222 When the pragma appears immediately at the start of the declarations of a
6223 package body (preceded only by other pragmas),
6224 it marks the whole body in or out of SPARK 2014 (overriding the default
6225 mode set by the declaration).
6227 @item
6228 When the pragma appears at the start of the elaboration statements of
6229 a package body (only other pragmas can appear between the @code{begin}
6230 keyword and the @code{SPARK_Mode} pragma),
6231 it marks the elaboration statements in or out of SPARK 2014 (overriding
6232 the default mode of the package body).
6234 @item
6235 When the pragma appears after a subprogram declaration (with only other
6236 pragmas intervening), it marks the whole
6237 subprogram (spec and body) in or out of SPARK 2014.
6239 @item
6240 When the pragma appears at the start of the declarations of a subprogram
6241 body (preceded only by other pragmas), it marks the whole body in or out
6242 of SPARK 2014 (overriding the default mode set by the declaration).
6244 @item
6245 Any other use of the pragma is illegal.
6247 @end itemize
6249 @node Pragma Static_Elaboration_Desired
6250 @unnumberedsec Pragma Static_Elaboration_Desired
6251 @findex Static_Elaboration_Desired
6252 @noindent
6253 Syntax:
6255 @smallexample @c ada
6256 pragma Static_Elaboration_Desired;
6257 @end smallexample
6259 @noindent
6260 This pragma is used to indicate that the compiler should attempt to initialize
6261 statically the objects declared in the library unit to which the pragma applies,
6262 when these objects are initialized (explicitly or implicitly) by an aggregate.
6263 In the absence of this pragma, aggregates in object declarations are expanded
6264 into assignments and loops, even when the aggregate components are static
6265 constants. When the aggregate is present the compiler builds a static expression
6266 that requires no run-time code, so that the initialized object can be placed in
6267 read-only data space. If the components are not static, or the aggregate has
6268 more that 100 components, the compiler emits a warning that the pragma cannot
6269 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6270 construction of larger aggregates with static components that include an others
6271 choice.)
6273 @node Pragma Stream_Convert
6274 @unnumberedsec Pragma Stream_Convert
6275 @findex Stream_Convert
6276 @noindent
6277 Syntax:
6279 @smallexample @c ada
6280 pragma Stream_Convert (
6281   [Entity =>] type_LOCAL_NAME,
6282   [Read   =>] function_NAME,
6283   [Write  =>] function_NAME);
6284 @end smallexample
6286 @noindent
6287 This pragma provides an efficient way of providing stream functions for
6288 types defined in packages.  Not only is it simpler to use than declaring
6289 the necessary functions with attribute representation clauses, but more
6290 significantly, it allows the declaration to made in such a way that the
6291 stream packages are not loaded unless they are needed.  The use of
6292 the Stream_Convert pragma adds no overhead at all, unless the stream
6293 attributes are actually used on the designated type.
6295 The first argument specifies the type for which stream functions are
6296 provided.  The second parameter provides a function used to read values
6297 of this type.  It must name a function whose argument type may be any
6298 subtype, and whose returned type must be the type given as the first
6299 argument to the pragma.
6301 The meaning of the @var{Read} parameter is that if a stream attribute directly
6302 or indirectly specifies reading of the type given as the first parameter,
6303 then a value of the type given as the argument to the Read function is
6304 read from the stream, and then the Read function is used to convert this
6305 to the required target type.
6307 Similarly the @var{Write} parameter specifies how to treat write attributes
6308 that directly or indirectly apply to the type given as the first parameter.
6309 It must have an input parameter of the type specified by the first parameter,
6310 and the return type must be the same as the input type of the Read function.
6311 The effect is to first call the Write function to convert to the given stream
6312 type, and then write the result type to the stream.
6314 The Read and Write functions must not be overloaded subprograms.  If necessary
6315 renamings can be supplied to meet this requirement.
6316 The usage of this attribute is best illustrated by a simple example, taken
6317 from the GNAT implementation of package Ada.Strings.Unbounded:
6319 @smallexample @c ada
6320 function To_Unbounded (S : String)
6321            return Unbounded_String
6322   renames To_Unbounded_String;
6324 pragma Stream_Convert
6325   (Unbounded_String, To_Unbounded, To_String);
6326 @end smallexample
6328 @noindent
6329 The specifications of the referenced functions, as given in the Ada
6330 Reference Manual are:
6332 @smallexample @c ada
6333 function To_Unbounded_String (Source : String)
6334   return Unbounded_String;
6336 function To_String (Source : Unbounded_String)
6337   return String;
6338 @end smallexample
6340 @noindent
6341 The effect is that if the value of an unbounded string is written to a stream,
6342 then the representation of the item in the stream is in the same format that
6343 would be used for @code{Standard.String'Output}, and this same representation
6344 is expected when a value of this type is read from the stream. Note that the
6345 value written always includes the bounds, even for Unbounded_String'Write,
6346 since Unbounded_String is not an array type.
6348 @node Pragma Style_Checks
6349 @unnumberedsec Pragma Style_Checks
6350 @findex Style_Checks
6351 @noindent
6352 Syntax:
6354 @smallexample @c ada
6355 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6356                      On | Off [, LOCAL_NAME]);
6357 @end smallexample
6359 @noindent
6360 This pragma is used in conjunction with compiler switches to control the
6361 built in style checking provided by GNAT@.  The compiler switches, if set,
6362 provide an initial setting for the switches, and this pragma may be used
6363 to modify these settings, or the settings may be provided entirely by
6364 the use of the pragma.  This pragma can be used anywhere that a pragma
6365 is legal, including use as a configuration pragma (including use in
6366 the @file{gnat.adc} file).
6368 The form with a string literal specifies which style options are to be
6369 activated.  These are additive, so they apply in addition to any previously
6370 set style check options.  The codes for the options are the same as those
6371 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6372 For example the following two methods can be used to enable
6373 layout checking:
6375 @itemize @bullet
6376 @item
6377 @smallexample @c ada
6378 pragma Style_Checks ("l");
6379 @end smallexample
6381 @item
6382 @smallexample
6383 gcc -c -gnatyl @dots{}
6384 @end smallexample
6385 @end itemize
6387 @noindent
6388 The form ALL_CHECKS activates all standard checks (its use is equivalent
6389 to the use of the @code{gnaty} switch with no options.  @xref{Top,
6390 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6391 @value{EDITION} User's Guide}, for details.)
6393 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6394 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6395 options (i.e. equivalent to -gnatyg).
6397 The forms with @code{Off} and @code{On}
6398 can be used to temporarily disable style checks
6399 as shown in the following example:
6401 @smallexample @c ada
6402 @iftex
6403 @leftskip=0cm
6404 @end iftex
6405 pragma Style_Checks ("k"); -- requires keywords in lower case
6406 pragma Style_Checks (Off); -- turn off style checks
6407 NULL;                      -- this will not generate an error message
6408 pragma Style_Checks (On);  -- turn style checks back on
6409 NULL;                      -- this will generate an error message
6410 @end smallexample
6412 @noindent
6413 Finally the two argument form is allowed only if the first argument is
6414 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
6415 for the specified entity, as shown in the following example:
6417 @smallexample @c ada
6418 @iftex
6419 @leftskip=0cm
6420 @end iftex
6421 pragma Style_Checks ("r"); -- require consistency of identifier casing
6422 Arg : Integer;
6423 Rf1 : Integer := ARG;      -- incorrect, wrong case
6424 pragma Style_Checks (Off, Arg);
6425 Rf2 : Integer := ARG;      -- OK, no error
6426 @end smallexample
6428 @node Pragma Subtitle
6429 @unnumberedsec Pragma Subtitle
6430 @findex Subtitle
6431 @noindent
6432 Syntax:
6434 @smallexample @c ada
6435 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6436 @end smallexample
6438 @noindent
6439 This pragma is recognized for compatibility with other Ada compilers
6440 but is ignored by GNAT@.
6442 @node Pragma Suppress
6443 @unnumberedsec Pragma Suppress
6444 @findex Suppress
6445 @noindent
6446 Syntax:
6448 @smallexample @c ada
6449 pragma Suppress (Identifier [, [On =>] Name]);
6450 @end smallexample
6452 @noindent
6453 This is a standard pragma, and supports all the check names required in
6454 the RM. It is included here because GNAT recognizes some additional check
6455 names that are implementation defined (as permitted by the RM):
6457 @itemize @bullet
6459 @item
6460 @code{Alignment_Check} can be used to suppress alignment checks
6461 on addresses used in address clauses. Such checks can also be suppressed
6462 by suppressing range checks, but the specific use of @code{Alignment_Check}
6463 allows suppression of alignment checks without suppressing other range checks.
6465 @item
6466 @code{Predicate_Check} can be used to control whether predicate checks are
6467 active. It is applicable only to predicates for which the policy is
6468 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6469 predicate is ignored or checked for the whole program, the use of
6470 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6471 predicate to be turned on and off at specific points in the program.
6473 @item
6474 @code{Validity_Check} can be used specifically to control validity checks.
6475 If @code{Suppress} is used to suppress validity checks, then no validity
6476 checks are performed, including those specified by the appropriate compiler
6477 switch or the @code{Validity_Checks} pragma.
6479 @item
6480 Additional check names previously introduced by use of the @code{Check_Name}
6481 pragma are also allowed.
6483 @end itemize
6485 @noindent
6486 Note that pragma Suppress gives the compiler permission to omit
6487 checks, but does not require the compiler to omit checks. The compiler
6488 will generate checks if they are essentially free, even when they are
6489 suppressed. In particular, if the compiler can prove that a certain
6490 check will necessarily fail, it will generate code to do an
6491 unconditional ``raise'', even if checks are suppressed. The compiler
6492 warns in this case.
6494 Of course, run-time checks are omitted whenever the compiler can prove
6495 that they will not fail, whether or not checks are suppressed.
6497 @node Pragma Suppress_All
6498 @unnumberedsec Pragma Suppress_All
6499 @findex Suppress_All
6500 @noindent
6501 Syntax:
6503 @smallexample @c ada
6504 pragma Suppress_All;
6505 @end smallexample
6507 @noindent
6508 This pragma can appear anywhere within a unit.
6509 The effect is to apply @code{Suppress (All_Checks)} to the unit
6510 in which it appears.  This pragma is implemented for compatibility with DEC
6511 Ada 83 usage where it appears at the end of a unit, and for compatibility
6512 with Rational Ada, where it appears as a program unit pragma.
6513 The use of the standard Ada pragma @code{Suppress (All_Checks)}
6514 as a normal configuration pragma is the preferred usage in GNAT@.
6516 @node Pragma Suppress_Debug_Info
6517 @unnumberedsec Pragma Suppress_Debug_Info
6518 @findex Suppress_Debug_Info
6519 @noindent
6520 Syntax:
6522 @smallexample @c ada
6523 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
6524 @end smallexample
6526 @noindent
6527 This pragma can be used to suppress generation of debug information
6528 for the specified entity. It is intended primarily for use in debugging
6529 the debugger, and navigating around debugger problems.
6531 @node Pragma Suppress_Exception_Locations
6532 @unnumberedsec Pragma Suppress_Exception_Locations
6533 @findex Suppress_Exception_Locations
6534 @noindent
6535 Syntax:
6537 @smallexample @c ada
6538 pragma Suppress_Exception_Locations;
6539 @end smallexample
6541 @noindent
6542 In normal mode, a raise statement for an exception by default generates
6543 an exception message giving the file name and line number for the location
6544 of the raise. This is useful for debugging and logging purposes, but this
6545 entails extra space for the strings for the messages. The configuration
6546 pragma @code{Suppress_Exception_Locations} can be used to suppress the
6547 generation of these strings, with the result that space is saved, but the
6548 exception message for such raises is null. This configuration pragma may
6549 appear in a global configuration pragma file, or in a specific unit as
6550 usual. It is not required that this pragma be used consistently within
6551 a partition, so it is fine to have some units within a partition compiled
6552 with this pragma and others compiled in normal mode without it.
6554 @node Pragma Suppress_Initialization
6555 @unnumberedsec Pragma Suppress_Initialization
6556 @findex Suppress_Initialization
6557 @cindex Suppressing initialization
6558 @cindex Initialization, suppression of
6559 @noindent
6560 Syntax:
6562 @smallexample @c ada
6563 pragma Suppress_Initialization ([Entity =>] subtype_Name);
6564 @end smallexample
6566 @noindent
6567 Here subtype_Name is the name introduced by a type declaration
6568 or subtype declaration.
6569 This pragma suppresses any implicit or explicit initialization
6570 for all variables of the given type or subtype,
6571 including initialization resulting from the use of pragmas
6572 Normalize_Scalars or Initialize_Scalars.
6574 This is considered a representation item, so it cannot be given after
6575 the type is frozen. It applies to all subsequent object declarations,
6576 and also any allocator that creates objects of the type.
6578 If the pragma is given for the first subtype, then it is considered
6579 to apply to the base type and all its subtypes. If the pragma is given
6580 for other than a first subtype, then it applies only to the given subtype.
6581 The pragma may not be given after the type is frozen.
6583 @node Pragma Task_Info
6584 @unnumberedsec Pragma Task_Info
6585 @findex Task_Info
6586 @noindent
6587 Syntax
6589 @smallexample @c ada
6590 pragma Task_Info (EXPRESSION);
6591 @end smallexample
6593 @noindent
6594 This pragma appears within a task definition (like pragma
6595 @code{Priority}) and applies to the task in which it appears.  The
6596 argument must be of type @code{System.Task_Info.Task_Info_Type}.
6597 The @code{Task_Info} pragma provides system dependent control over
6598 aspects of tasking implementation, for example, the ability to map
6599 tasks to specific processors.  For details on the facilities available
6600 for the version of GNAT that you are using, see the documentation
6601 in the spec of package System.Task_Info in the runtime
6602 library.
6604 @node Pragma Task_Name
6605 @unnumberedsec Pragma Task_Name
6606 @findex Task_Name
6607 @noindent
6608 Syntax
6610 @smallexample @c ada
6611 pragma Task_Name (string_EXPRESSION);
6612 @end smallexample
6614 @noindent
6615 This pragma appears within a task definition (like pragma
6616 @code{Priority}) and applies to the task in which it appears.  The
6617 argument must be of type String, and provides a name to be used for
6618 the task instance when the task is created.  Note that this expression
6619 is not required to be static, and in particular, it can contain
6620 references to task discriminants.  This facility can be used to
6621 provide different names for different tasks as they are created,
6622 as illustrated in the example below.
6624 The task name is recorded internally in the run-time structures
6625 and is accessible to tools like the debugger.  In addition the
6626 routine @code{Ada.Task_Identification.Image} will return this
6627 string, with a unique task address appended.
6629 @smallexample @c ada
6630 --  Example of the use of pragma Task_Name
6632 with Ada.Task_Identification;
6633 use Ada.Task_Identification;
6634 with Text_IO; use Text_IO;
6635 procedure t3 is
6637    type Astring is access String;
6639    task type Task_Typ (Name : access String) is
6640       pragma Task_Name (Name.all);
6641    end Task_Typ;
6643    task body Task_Typ is
6644       Nam : constant String := Image (Current_Task);
6645    begin
6646       Put_Line ("-->" & Nam (1 .. 14) & "<--");
6647    end Task_Typ;
6649    type Ptr_Task is access Task_Typ;
6650    Task_Var : Ptr_Task;
6652 begin
6653    Task_Var :=
6654      new Task_Typ (new String'("This is task 1"));
6655    Task_Var :=
6656      new Task_Typ (new String'("This is task 2"));
6657 end;
6658 @end smallexample
6660 @node Pragma Task_Storage
6661 @unnumberedsec Pragma Task_Storage
6662 @findex Task_Storage
6663 Syntax:
6665 @smallexample @c ada
6666 pragma Task_Storage (
6667   [Task_Type =>] LOCAL_NAME,
6668   [Top_Guard =>] static_integer_EXPRESSION);
6669 @end smallexample
6671 @noindent
6672 This pragma specifies the length of the guard area for tasks.  The guard
6673 area is an additional storage area allocated to a task.  A value of zero
6674 means that either no guard area is created or a minimal guard area is
6675 created, depending on the target.  This pragma can appear anywhere a
6676 @code{Storage_Size} attribute definition clause is allowed for a task
6677 type.
6679 @node Pragma Test_Case
6680 @unnumberedsec Pragma Test_Case
6681 @cindex Test cases
6682 @findex Test_Case
6683 @noindent
6684 Syntax:
6686 @smallexample @c ada
6687 pragma Test_Case (
6688    [Name     =>] static_string_Expression
6689   ,[Mode     =>] (Nominal | Robustness)
6690  [, Requires =>  Boolean_Expression]
6691  [, Ensures  =>  Boolean_Expression]);
6692 @end smallexample
6694 @noindent
6695 The @code{Test_Case} pragma allows defining fine-grain specifications
6696 for use by testing tools.
6697 The compiler checks the validity of the @code{Test_Case} pragma, but its
6698 presence does not lead to any modification of the code generated by the
6699 compiler.
6701 @code{Test_Case} pragmas may only appear immediately following the
6702 (separate) declaration of a subprogram in a package declaration, inside
6703 a package spec unit. Only other pragmas may intervene (that is appear
6704 between the subprogram declaration and a test case).
6706 The compiler checks that boolean expressions given in @code{Requires} and
6707 @code{Ensures} are valid, where the rules for @code{Requires} are the
6708 same as the rule for an expression in @code{Precondition} and the rules
6709 for @code{Ensures} are the same as the rule for an expression in
6710 @code{Postcondition}. In particular, attributes @code{'Old} and
6711 @code{'Result} can only be used within the @code{Ensures}
6712 expression. The following is an example of use within a package spec:
6714 @smallexample @c ada
6715 package Math_Functions is
6716    ...
6717    function Sqrt (Arg : Float) return Float;
6718    pragma Test_Case (Name     => "Test 1",
6719                      Mode     => Nominal,
6720                      Requires => Arg < 10000,
6721                      Ensures  => Sqrt'Result < 10);
6722    ...
6723 end Math_Functions;
6724 @end smallexample
6726 @noindent
6727 The meaning of a test case is that there is at least one context where
6728 @code{Requires} holds such that, if the associated subprogram is executed in
6729 that context, then @code{Ensures} holds when the subprogram returns.
6730 Mode @code{Nominal} indicates that the input context should also satisfy the
6731 precondition of the subprogram, and the output context should also satisfy its
6732 postcondition. More @code{Robustness} indicates that the precondition and
6733 postcondition of the subprogram should be ignored for this test case.
6735 @node Pragma Thread_Local_Storage
6736 @unnumberedsec Pragma Thread_Local_Storage
6737 @findex Thread_Local_Storage
6738 @cindex Task specific storage
6739 @cindex TLS (Thread Local Storage)
6740 @cindex Task_Attributes
6741 Syntax:
6743 @smallexample @c ada
6744 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
6745 @end smallexample
6747 @noindent
6748 This pragma specifies that the specified entity, which must be
6749 a variable declared in a library level package, is to be marked as
6750 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
6751 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
6752 (and hence each Ada task) to see a distinct copy of the variable.
6754 The variable may not have default initialization, and if there is
6755 an explicit initialization, it must be either @code{null} for an
6756 access variable, or a static expression for a scalar variable.
6757 This provides a low level mechanism similar to that provided by
6758 the @code{Ada.Task_Attributes} package, but much more efficient
6759 and is also useful in writing interface code that will interact
6760 with foreign threads.
6762 If this pragma is used on a system where @code{TLS} is not supported,
6763 then an error message will be generated and the program will be rejected.
6765 @node Pragma Time_Slice
6766 @unnumberedsec Pragma Time_Slice
6767 @findex Time_Slice
6768 @noindent
6769 Syntax:
6771 @smallexample @c ada
6772 pragma Time_Slice (static_duration_EXPRESSION);
6773 @end smallexample
6775 @noindent
6776 For implementations of GNAT on operating systems where it is possible
6777 to supply a time slice value, this pragma may be used for this purpose.
6778 It is ignored if it is used in a system that does not allow this control,
6779 or if it appears in other than the main program unit.
6780 @cindex OpenVMS
6781 Note that the effect of this pragma is identical to the effect of the
6782 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
6784 @node Pragma Title
6785 @unnumberedsec Pragma Title
6786 @findex Title
6787 @noindent
6788 Syntax:
6790 @smallexample @c ada
6791 pragma Title (TITLING_OPTION [, TITLING OPTION]);
6793 TITLING_OPTION ::=
6794   [Title    =>] STRING_LITERAL,
6795 | [Subtitle =>] STRING_LITERAL
6796 @end smallexample
6798 @noindent
6799 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
6800 pragma used in DEC Ada 83 implementations to provide a title and/or
6801 subtitle for the program listing.  The program listing generated by GNAT
6802 does not have titles or subtitles.
6804 Unlike other pragmas, the full flexibility of named notation is allowed
6805 for this pragma, i.e.@: the parameters may be given in any order if named
6806 notation is used, and named and positional notation can be mixed
6807 following the normal rules for procedure calls in Ada.
6809 @node Pragma Type_Invariant
6810 @unnumberedsec Pragma Type_Invariant
6811 @findex Invariant
6812 @findex Type_Invariant pragma
6813 @noindent
6814 Syntax:
6816 @smallexample @c ada
6817 pragma Type_Invariant
6818   ([Entity =>] type_LOCAL_NAME,
6819    [Check  =>] EXPRESSION);
6820 @end smallexample
6822 @noindent
6823 The @code{Type_Invariant} pragma is intended to be an exact
6824 replacement for the language-defined @code{Type_Invariant}
6825 aspect, and shares its restrictions and semantics. It differs
6826 from the language defined @code{Invariant} pragma in that it
6827 does not permit a string parameter, and it is
6828 controlled by the assertion identifier @code{Type_Invariant}
6829 rather than @code{Invariant}.
6831 @node Pragma Type_Invariant_Class
6832 @unnumberedsec Pragma Type_Invariant_Class
6833 @findex Invariant
6834 @findex Type_Invariant_Class pragma
6835 @noindent
6836 Syntax:
6838 @smallexample @c ada
6839 pragma Type_Invariant_Class
6840   ([Entity =>] type_LOCAL_NAME,
6841    [Check  =>] EXPRESSION);
6842 @end smallexample
6844 @noindent
6845 The @code{Type_Invariant_Class} pragma is intended to be an exact
6846 replacement for the language-defined @code{Type_Invariant'Class}
6847 aspect, and shares its restrictions and semantics.
6849 Note: This pragma is called @code{Type_Invariant_Class} rather than
6850 @code{Type_Invariant'Class} because the latter would not be strictly
6851 conforming to the allowed syntax for pragmas. The motivation
6852 for providing pragmas equivalent to the aspects is to allow a program
6853 to be written using the pragmas, and then compiled if necessary
6854 using an Ada compiler that does not recognize the pragmas or
6855 aspects, but is prepared to ignore the pragmas. The assertion
6856 policy that controls this pragma is @code{Type_Invariant'Class},
6857 not @code{Type_Invariant_Class}.
6859 @node Pragma Unchecked_Union
6860 @unnumberedsec Pragma Unchecked_Union
6861 @cindex Unions in C
6862 @findex Unchecked_Union
6863 @noindent
6864 Syntax:
6866 @smallexample @c ada
6867 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
6868 @end smallexample
6870 @noindent
6871 This pragma is used to specify a representation of a record type that is
6872 equivalent to a C union. It was introduced as a GNAT implementation defined
6873 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
6874 pragma, making it language defined, and GNAT fully implements this extended
6875 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
6876 details, consult the Ada 2012 Reference Manual, section B.3.3.
6878 @node Pragma Unimplemented_Unit
6879 @unnumberedsec Pragma Unimplemented_Unit
6880 @findex Unimplemented_Unit
6881 @noindent
6882 Syntax:
6884 @smallexample @c ada
6885 pragma Unimplemented_Unit;
6886 @end smallexample
6888 @noindent
6889 If this pragma occurs in a unit that is processed by the compiler, GNAT
6890 aborts with the message @samp{@var{xxx} not implemented}, where
6891 @var{xxx} is the name of the current compilation unit.  This pragma is
6892 intended to allow the compiler to handle unimplemented library units in
6893 a clean manner.
6895 The abort only happens if code is being generated.  Thus you can use
6896 specs of unimplemented packages in syntax or semantic checking mode.
6898 @node Pragma Universal_Aliasing
6899 @unnumberedsec Pragma Universal_Aliasing
6900 @findex Universal_Aliasing
6901 @noindent
6902 Syntax:
6904 @smallexample @c ada
6905 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
6906 @end smallexample
6908 @noindent
6909 @var{type_LOCAL_NAME} must refer to a type declaration in the current
6910 declarative part.  The effect is to inhibit strict type-based aliasing
6911 optimization for the given type.  In other words, the effect is as though
6912 access types designating this type were subject to pragma No_Strict_Aliasing.
6913 For a detailed description of the strict aliasing optimization, and the
6914 situations in which it must be suppressed, @xref{Optimization and Strict
6915 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
6917 @node Pragma Universal_Data
6918 @unnumberedsec Pragma Universal_Data
6919 @findex Universal_Data
6920 @noindent
6921 Syntax:
6923 @smallexample @c ada
6924 pragma Universal_Data [(library_unit_Name)];
6925 @end smallexample
6927 @noindent
6928 This pragma is supported only for the AAMP target and is ignored for
6929 other targets. The pragma specifies that all library-level objects
6930 (Counter 0 data) associated with the library unit are to be accessed
6931 and updated using universal addressing (24-bit addresses for AAMP5)
6932 rather than the default of 16-bit Data Environment (DENV) addressing.
6933 Use of this pragma will generally result in less efficient code for
6934 references to global data associated with the library unit, but
6935 allows such data to be located anywhere in memory. This pragma is
6936 a library unit pragma, but can also be used as a configuration pragma
6937 (including use in the @file{gnat.adc} file). The functionality
6938 of this pragma is also available by applying the -univ switch on the
6939 compilations of units where universal addressing of the data is desired.
6941 @node Pragma Unmodified
6942 @unnumberedsec Pragma Unmodified
6943 @findex Unmodified
6944 @cindex Warnings, unmodified
6945 @noindent
6946 Syntax:
6948 @smallexample @c ada
6949 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
6950 @end smallexample
6952 @noindent
6953 This pragma signals that the assignable entities (variables,
6954 @code{out} parameters, @code{in out} parameters) whose names are listed are
6955 deliberately not assigned in the current source unit. This
6956 suppresses warnings about the
6957 entities being referenced but not assigned, and in addition a warning will be
6958 generated if one of these entities is in fact assigned in the
6959 same unit as the pragma (or in the corresponding body, or one
6960 of its subunits).
6962 This is particularly useful for clearly signaling that a particular
6963 parameter is not modified, even though the spec suggests that it might
6966 @node Pragma Unreferenced
6967 @unnumberedsec Pragma Unreferenced
6968 @findex Unreferenced
6969 @cindex Warnings, unreferenced
6970 @noindent
6971 Syntax:
6973 @smallexample @c ada
6974 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
6975 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
6976 @end smallexample
6978 @noindent
6979 This pragma signals that the entities whose names are listed are
6980 deliberately not referenced in the current source unit. This
6981 suppresses warnings about the
6982 entities being unreferenced, and in addition a warning will be
6983 generated if one of these entities is in fact subsequently referenced in the
6984 same unit as the pragma (or in the corresponding body, or one
6985 of its subunits).
6987 This is particularly useful for clearly signaling that a particular
6988 parameter is not referenced in some particular subprogram implementation
6989 and that this is deliberate. It can also be useful in the case of
6990 objects declared only for their initialization or finalization side
6991 effects.
6993 If @code{LOCAL_NAME} identifies more than one matching homonym in the
6994 current scope, then the entity most recently declared is the one to which
6995 the pragma applies. Note that in the case of accept formals, the pragma
6996 Unreferenced may appear immediately after the keyword @code{do} which
6997 allows the indication of whether or not accept formals are referenced
6998 or not to be given individually for each accept statement.
7000 The left hand side of an assignment does not count as a reference for the
7001 purpose of this pragma. Thus it is fine to assign to an entity for which
7002 pragma Unreferenced is given.
7004 Note that if a warning is desired for all calls to a given subprogram,
7005 regardless of whether they occur in the same unit as the subprogram
7006 declaration, then this pragma should not be used (calls from another
7007 unit would not be flagged); pragma Obsolescent can be used instead
7008 for this purpose, see @xref{Pragma Obsolescent}.
7010 The second form of pragma @code{Unreferenced} is used within a context
7011 clause. In this case the arguments must be unit names of units previously
7012 mentioned in @code{with} clauses (similar to the usage of pragma
7013 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
7014 units and unreferenced entities within these units.
7016 @node Pragma Unreferenced_Objects
7017 @unnumberedsec Pragma Unreferenced_Objects
7018 @findex Unreferenced_Objects
7019 @cindex Warnings, unreferenced
7020 @noindent
7021 Syntax:
7023 @smallexample @c ada
7024 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
7025 @end smallexample
7027 @noindent
7028 This pragma signals that for the types or subtypes whose names are
7029 listed, objects which are declared with one of these types or subtypes may
7030 not be referenced, and if no references appear, no warnings are given.
7032 This is particularly useful for objects which are declared solely for their
7033 initialization and finalization effect. Such variables are sometimes referred
7034 to as RAII variables (Resource Acquisition Is Initialization). Using this
7035 pragma on the relevant type (most typically a limited controlled type), the
7036 compiler will automatically suppress unwanted warnings about these variables
7037 not being referenced.
7039 @node Pragma Unreserve_All_Interrupts
7040 @unnumberedsec Pragma Unreserve_All_Interrupts
7041 @findex Unreserve_All_Interrupts
7042 @noindent
7043 Syntax:
7045 @smallexample @c ada
7046 pragma Unreserve_All_Interrupts;
7047 @end smallexample
7049 @noindent
7050 Normally certain interrupts are reserved to the implementation.  Any attempt
7051 to attach an interrupt causes Program_Error to be raised, as described in
7052 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
7053 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
7054 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
7055 interrupt execution.
7057 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
7058 a program, then all such interrupts are unreserved.  This allows the
7059 program to handle these interrupts, but disables their standard
7060 functions.  For example, if this pragma is used, then pressing
7061 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
7062 a program can then handle the @code{SIGINT} interrupt as it chooses.
7064 For a full list of the interrupts handled in a specific implementation,
7065 see the source code for the spec of @code{Ada.Interrupts.Names} in
7066 file @file{a-intnam.ads}.  This is a target dependent file that contains the
7067 list of interrupts recognized for a given target.  The documentation in
7068 this file also specifies what interrupts are affected by the use of
7069 the @code{Unreserve_All_Interrupts} pragma.
7071 For a more general facility for controlling what interrupts can be
7072 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
7073 of the @code{Unreserve_All_Interrupts} pragma.
7075 @node Pragma Unsuppress
7076 @unnumberedsec Pragma Unsuppress
7077 @findex Unsuppress
7078 @noindent
7079 Syntax:
7081 @smallexample @c ada
7082 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
7083 @end smallexample
7085 @noindent
7086 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
7087 there is no corresponding pragma @code{Suppress} in effect, it has no
7088 effect.  The range of the effect is the same as for pragma
7089 @code{Suppress}.  The meaning of the arguments is identical to that used
7090 in pragma @code{Suppress}.
7092 One important application is to ensure that checks are on in cases where
7093 code depends on the checks for its correct functioning, so that the code
7094 will compile correctly even if the compiler switches are set to suppress
7095 checks.
7097 This pragma is standard in Ada 2005. It is available in all earlier versions
7098 of Ada as an implementation-defined pragma.
7100 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
7101 a number of implementation-defined check names. See description of pragma
7102 @code{Suppress} for full details.
7104 @node Pragma Use_VADS_Size
7105 @unnumberedsec Pragma Use_VADS_Size
7106 @cindex @code{Size}, VADS compatibility
7107 @cindex Rational profile
7108 @findex Use_VADS_Size
7109 @noindent
7110 Syntax:
7112 @smallexample @c ada
7113 pragma Use_VADS_Size;
7114 @end smallexample
7116 @noindent
7117 This is a configuration pragma.  In a unit to which it applies, any use
7118 of the 'Size attribute is automatically interpreted as a use of the
7119 'VADS_Size attribute.  Note that this may result in incorrect semantic
7120 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
7121 the handling of existing code which depends on the interpretation of Size
7122 as implemented in the VADS compiler.  See description of the VADS_Size
7123 attribute for further details.
7125 @node Pragma Validity_Checks
7126 @unnumberedsec Pragma Validity_Checks
7127 @findex Validity_Checks
7128 @noindent
7129 Syntax:
7131 @smallexample @c ada
7132 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
7133 @end smallexample
7135 @noindent
7136 This pragma is used in conjunction with compiler switches to control the
7137 built-in validity checking provided by GNAT@.  The compiler switches, if set
7138 provide an initial setting for the switches, and this pragma may be used
7139 to modify these settings, or the settings may be provided entirely by
7140 the use of the pragma.  This pragma can be used anywhere that a pragma
7141 is legal, including use as a configuration pragma (including use in
7142 the @file{gnat.adc} file).
7144 The form with a string literal specifies which validity options are to be
7145 activated.  The validity checks are first set to include only the default
7146 reference manual settings, and then a string of letters in the string
7147 specifies the exact set of options required.  The form of this string
7148 is exactly as described for the @option{-gnatVx} compiler switch (see the
7149 @value{EDITION} User's Guide for details).  For example the following two
7150 methods can be used to enable validity checking for mode @code{in} and
7151 @code{in out} subprogram parameters:
7153 @itemize @bullet
7154 @item
7155 @smallexample @c ada
7156 pragma Validity_Checks ("im");
7157 @end smallexample
7159 @item
7160 @smallexample
7161 gcc -c -gnatVim @dots{}
7162 @end smallexample
7163 @end itemize
7165 @noindent
7166 The form ALL_CHECKS activates all standard checks (its use is equivalent
7167 to the use of the @code{gnatva} switch.
7169 The forms with @code{Off} and @code{On}
7170 can be used to temporarily disable validity checks
7171 as shown in the following example:
7173 @smallexample @c ada
7174 @iftex
7175 @leftskip=0cm
7176 @end iftex
7177 pragma Validity_Checks ("c"); -- validity checks for copies
7178 pragma Validity_Checks (Off); -- turn off validity checks
7179 A := B;                       -- B will not be validity checked
7180 pragma Validity_Checks (On);  -- turn validity checks back on
7181 A := C;                       -- C will be validity checked
7182 @end smallexample
7184 @node Pragma Volatile
7185 @unnumberedsec Pragma Volatile
7186 @findex Volatile
7187 @noindent
7188 Syntax:
7190 @smallexample @c ada
7191 pragma Volatile (LOCAL_NAME);
7192 @end smallexample
7194 @noindent
7195 This pragma is defined by the Ada Reference Manual, and the GNAT
7196 implementation is fully conformant with this definition.  The reason it
7197 is mentioned in this section is that a pragma of the same name was supplied
7198 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
7199 implementation of pragma Volatile is upwards compatible with the
7200 implementation in DEC Ada 83.
7202 @node Pragma Warnings
7203 @unnumberedsec Pragma Warnings
7204 @findex Warnings
7205 @noindent
7206 Syntax:
7208 @smallexample @c ada
7209 pragma Warnings (On | Off [,REASON]);
7210 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
7211 pragma Warnings (static_string_EXPRESSION [,REASON]);
7212 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
7214 REASON ::= Reason => static_string_EXPRESSION
7215 @end smallexample
7217 @noindent
7218 Normally warnings are enabled, with the output being controlled by
7219 the command line switch.  Warnings (@code{Off}) turns off generation of
7220 warnings until a Warnings (@code{On}) is encountered or the end of the
7221 current unit.  If generation of warnings is turned off using this
7222 pragma, then some or all of the warning messages are suppressed,
7223 regardless of the setting of the command line switches.
7225 The @code{Reason} parameter may optionally appear as the last argument
7226 in any of the forms of this pragma. It is intended purely for the
7227 purposes of documenting the reason for the @code{Warnings} pragma.
7228 The compiler will check that the argument is a static string but
7229 otherwise ignore this argument. Other tools may provide specialized
7230 processing for this string.
7232 The form with a single argument (or two arguments if Reason present),
7233 where the first argument is @code{ON} or @code{OFF}
7234 may be used as a configuration pragma.
7236 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
7237 the specified entity.  This suppression is effective from the point where
7238 it occurs till the end of the extended scope of the variable (similar to
7239 the scope of @code{Suppress}). This form cannot be used as a configuration
7240 pragma.
7242 The form with a single static_string_EXPRESSION argument (and possible
7243 reason) provides more precise
7244 control over which warnings are active. The string is a list of letters
7245 specifying which warnings are to be activated and which deactivated. The
7246 code for these letters is the same as the string used in the command
7247 line switch controlling warnings. For a brief summary, use the gnatmake
7248 command with no arguments, which will generate usage information containing
7249 the list of warnings switches supported. For
7250 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
7251 User's Guide}. This form can also be used as a configuration pragma.
7253 @noindent
7254 The warnings controlled by the `-gnatw' switch are generated by the front end
7255 of the compiler. The `GCC' back end can provide additional warnings and they
7256 are controlled by the `-W' switch.
7257 The form with a single static_string_EXPRESSION argument also works for the
7258 latters, but the string must be a single full `-W' switch in this case.
7259 The above reference lists a few examples of these additional warnings.
7261 @noindent
7262 The specified warnings will be in effect until the end of the program
7263 or another pragma Warnings is encountered. The effect of the pragma is
7264 cumulative. Initially the set of warnings is the standard default set
7265 as possibly modified by compiler switches. Then each pragma Warning
7266 modifies this set of warnings as specified. This form of the pragma may
7267 also be used as a configuration pragma.
7269 The fourth form, with an @code{On|Off} parameter and a string, is used to
7270 control individual messages, based on their text. The string argument
7271 is a pattern that is used to match against the text of individual
7272 warning messages (not including the initial "warning: " tag).
7274 The pattern may contain asterisks, which match zero or more characters in
7275 the message. For example, you can use
7276 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
7277 message @code{warning: 960 bits of "a" unused}. No other regular
7278 expression notations are permitted. All characters other than asterisk in
7279 these three specific cases are treated as literal characters in the match.
7281 The above use of patterns to match the message applies only to warning
7282 messages generated by the front end. This form of the pragma with a
7283 string argument can also be used to control back end warnings controlled
7284 by a "-Wxxx" switch. Such warnings can be identified by the appearance
7285 of a string of the form "[-Wxxx]" in the message which identifies the
7286 "-W" switch that controls the message. By using the text of the
7287 "-W" switch in the pragma, such back end warnings can be turned on and off.
7289 There are two ways to use the pragma in this form. The OFF form can be used as a
7290 configuration pragma. The effect is to suppress all warnings (if any)
7291 that match the pattern string throughout the compilation (or match the
7292 -W switch in the back end case).
7294 The second usage is to suppress a warning locally, and in this case, two
7295 pragmas must appear in sequence:
7297 @smallexample @c ada
7298 pragma Warnings (Off, Pattern);
7299 @dots{} code where given warning is to be suppressed
7300 pragma Warnings (On, Pattern);
7301 @end smallexample
7303 @noindent
7304 In this usage, the pattern string must match in the Off and On pragmas,
7305 and at least one matching warning must be suppressed.
7307 Note: to write a string that will match any warning, use the string
7308 @code{"***"}. It will not work to use a single asterisk or two asterisks
7309 since this looks like an operator name. This form with three asterisks
7310 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
7311 matching @code{pragma Warnings (On, "***")} will be required. This can be
7312 helpful in avoiding forgetting to turn warnings back on.
7314 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7315 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7316 be useful in checking whether obsolete pragmas in existing programs are hiding
7317 real problems.
7319 Note: pragma Warnings does not affect the processing of style messages. See
7320 separate entry for pragma Style_Checks for control of style messages.
7322 @node Pragma Weak_External
7323 @unnumberedsec Pragma Weak_External
7324 @findex Weak_External
7325 @noindent
7326 Syntax:
7328 @smallexample @c ada
7329 pragma Weak_External ([Entity =>] LOCAL_NAME);
7330 @end smallexample
7332 @noindent
7333 @var{LOCAL_NAME} must refer to an object that is declared at the library
7334 level. This pragma specifies that the given entity should be marked as a
7335 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
7336 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
7337 of a regular symbol, that is to say a symbol that does not have to be
7338 resolved by the linker if used in conjunction with a pragma Import.
7340 When a weak symbol is not resolved by the linker, its address is set to
7341 zero. This is useful in writing interfaces to external modules that may
7342 or may not be linked in the final executable, for example depending on
7343 configuration settings.
7345 If a program references at run time an entity to which this pragma has been
7346 applied, and the corresponding symbol was not resolved at link time, then
7347 the execution of the program is erroneous. It is not erroneous to take the
7348 Address of such an entity, for example to guard potential references,
7349 as shown in the example below.
7351 Some file formats do not support weak symbols so not all target machines
7352 support this pragma.
7354 @smallexample @c ada
7355 --  Example of the use of pragma Weak_External
7357 package External_Module is
7358   key : Integer;
7359   pragma Import (C, key);
7360   pragma Weak_External (key);
7361   function Present return boolean;
7362 end External_Module;
7364 with System; use System;
7365 package body External_Module is
7366   function Present return boolean is
7367   begin
7368     return key'Address /= System.Null_Address;
7369   end Present;
7370 end External_Module;
7371 @end smallexample
7373 @node Pragma Wide_Character_Encoding
7374 @unnumberedsec Pragma Wide_Character_Encoding
7375 @findex Wide_Character_Encoding
7376 @noindent
7377 Syntax:
7379 @smallexample @c ada
7380 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
7381 @end smallexample
7383 @noindent
7384 This pragma specifies the wide character encoding to be used in program
7385 source text appearing subsequently. It is a configuration pragma, but may
7386 also be used at any point that a pragma is allowed, and it is permissible
7387 to have more than one such pragma in a file, allowing multiple encodings
7388 to appear within the same file.
7390 The argument can be an identifier or a character literal. In the identifier
7391 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
7392 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
7393 case it is correspondingly one of the characters @samp{h}, @samp{u},
7394 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
7396 Note that when the pragma is used within a file, it affects only the
7397 encoding within that file, and does not affect withed units, specs,
7398 or subunits.
7400 @node Implementation Defined Aspects
7401 @chapter Implementation Defined Aspects
7402 Ada defines (throughout the Ada 2012 reference manual, summarized
7403 in annex K) a set of aspects that can be specified for certain entities.
7404 These language defined aspects are implemented in GNAT in Ada 2012 mode
7405 and work as described in the Ada 2012 Reference Manual.
7407 In addition, Ada 2012 allows implementations to define additional aspects
7408 whose meaning is defined by the implementation.  GNAT provides
7409 a number of these implementation-dependent aspects which can be used
7410 to extend and enhance the functionality of the compiler.  This section of
7411 the GNAT reference manual describes these additional attributes.
7413 Note that any program using these aspects may not be portable to
7414 other compilers (although GNAT implements this set of aspects on all
7415 platforms).  Therefore if portability to other compilers is an important
7416 consideration, you should minimize the use of these aspects.
7418 Note that for many of these aspects, the effect is essentially similar
7419 to the use of a pragma or attribute specification with the same name
7420 applied to the entity. For example, if we write:
7422 @smallexample @c ada
7423 type R is range 1 .. 100
7424   with Value_Size => 10;
7425 @end smallexample
7427 @noindent
7428 then the effect is the same as:
7430 @smallexample @c ada
7431 type R is range 1 .. 100;
7432 for R'Value_Size use 10;
7433 @end smallexample
7435 @noindent
7436 and if we write:
7438 @smallexample @c ada
7439 type R is new Integer
7440   with Shared => True;
7441 @end smallexample
7443 @noindent
7444 then the effect is the same as:
7446 @smallexample @c ada
7447 type R is new Integer;
7448 pragma Shared (R);
7449 @end smallexample
7451 @noindent
7452 In the documentation sections that follow, such cases are simply marked
7453 as being equivalent to the corresponding pragma or attribute definition
7454 clause.
7456 @menu
7457 * Aspect Abstract_State::
7458 * Aspect Ada_2005::
7459 * Aspect Ada_2012::
7460 * Aspect Compiler_Unit::
7461 * Aspect Contract_Cases::
7462 * Aspect Depends::
7463 * Aspect Dimension::
7464 * Aspect Dimension_System::
7465 * Aspect Favor_Top_Level::
7466 * Aspect Global::
7467 * Aspect Inline_Always::
7468 * Aspect Invariant::
7469 * Aspect Lock_Free::
7470 * Aspect Object_Size::
7471 * Aspect Persistent_BSS::
7472 * Aspect Predicate::
7473 * Aspect Preelaborate_05::
7474 * Aspect Pure_05::
7475 * Aspect Pure_12::
7476 * Aspect Pure_Function::
7477 * Aspect Remote_Access_Type::
7478 * Aspect Scalar_Storage_Order::
7479 * Aspect Shared::
7480 * Aspect Simple_Storage_Pool::
7481 * Aspect Simple_Storage_Pool_Type::
7482 * Aspect SPARK_Mode::
7483 * Aspect Suppress_Debug_Info::
7484 * Aspect Test_Case::
7485 * Aspect Universal_Aliasing::
7486 * Aspect Universal_Data::
7487 * Aspect Unmodified::
7488 * Aspect Unreferenced::
7489 * Aspect Unreferenced_Objects::
7490 * Aspect Value_Size::
7491 * Aspect Warnings::
7492 @end menu
7494 @node Aspect Abstract_State
7495 @unnumberedsec Aspect Abstract_State
7496 @findex Abstract_State
7497 @noindent
7498 This aspect is equivalent to pragma @code{Abstract_State}.
7500 @node Aspect Ada_2005
7501 @unnumberedsec Aspect Ada_2005
7502 @findex Ada_2005
7503 @noindent
7504 This aspect is equivalent to the one argument form of pragma @code{Ada_2005}.
7506 @node Aspect Ada_2012
7507 @unnumberedsec Aspect Ada_2012
7508 @findex Ada_2012
7509 @noindent
7510 This aspect is equivalent to the one argument form of pragma @code{Ada_2012}.
7512 @node Aspect Compiler_Unit
7513 @unnumberedsec Aspect Compiler_Unit
7514 @findex Compiler_Unit
7515 @noindent
7516 This aspect is equivalent to pragma @code{Compiler_Unit}.
7518 @node Aspect Contract_Cases
7519 @unnumberedsec Aspect Contract_Cases
7520 @findex Contract_Cases
7521 @noindent
7522 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
7523 of clauses being enclosed in parentheses so that syntactically it is an
7524 aggregate.
7526 @node Aspect Depends
7527 @unnumberedsec Aspect Depends
7528 @findex Depends
7529 @noindent
7530 This aspect is equivalent to pragma @code{Depends}.
7532 * Dimension::
7534 @node Aspect Dimension
7535 @unnumberedsec Aspect Dimension
7536 @findex Dimension
7537 @noindent
7538 The @code{Dimension} aspect is used to specify the dimensions of a given
7539 subtype of a dimensioned numeric type. The aspect also specifies a symbol
7540 used when doing formatted output of dimensioned quantities. The syntax is:
7542 @smallexample @c ada
7543 with Dimension =>
7544   ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
7546 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
7548 DIMENSION_VALUE ::=
7549   RATIONAL
7550 | others               => RATIONAL
7551 | DISCRETE_CHOICE_LIST => RATIONAL
7553 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
7554 @end smallexample
7556 @noindent
7557 This aspect can only be applied to a subtype whose parent type has
7558 a @code{Dimension_Systen} aspect. The aspect must specify values for
7559 all dimensions of the system. The rational values are the powers of the
7560 corresponding dimensions that are used by the compiler to verify that
7561 physical (numeric) computations are dimensionally consistent. For example,
7562 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
7563 For further examples of the usage
7564 of this aspect, see package @code{System.Dim.Mks}.
7565 Note that when the dimensioned type is an integer type, then any
7566 dimension value must be an integer literal.
7568 @node Aspect Dimension_System
7569 @unnumberedsec Aspect Dimension_System
7570 @findex Dimension_System
7571 @noindent
7572 The @code{Dimension_System} aspect is used to define a system of
7573 dimensions that will be used in subsequent subtype declarations with
7574 @code{Dimension} aspects that reference this system. The syntax is:
7576 @smallexample @c ada
7577 with Dimension_System => (DIMENSION @{, DIMENSION@});
7579 DIMENSION ::= ([Unit_Name   =>] IDENTIFIER,
7580                [Unit_Symbol =>] SYMBOL,
7581                [Dim_Symbol  =>] SYMBOL)
7583 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
7584 @end smallexample
7586 @noindent
7587 This aspect is applied to a type, which must be a numeric derived type
7588 (typically a floating-point type), that
7589 will represent values within the dimension system. Each @code{DIMENSION}
7590 corresponds to one particular dimension. A maximum of 7 dimensions may
7591 be specified. @code{Unit_Name} is the name of the dimension (for example
7592 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
7593 of this dimension (for example 'm' for Meter). @code{Dim_Symbol} gives
7594 the identification within the dimension system (typically this is a
7595 single letter, e.g. 'L' standing for length for unit name Meter). The
7596 Unit_Smbol is used in formatted output of dimensioned quantities. The
7597 Dim_Symbol is used in error messages when numeric operations have
7598 inconsistent dimensions.
7600 GNAT provides the standard definition of the International MKS system in
7601 the run-time package @code{System.Dim.Mks}. You can easily define
7602 similar packages for cgs units or British units, and define conversion factors
7603 between values in different systems. The MKS system is characterized by the
7604 following aspect:
7606 @smallexample @c ada
7607    type Mks_Type is new Long_Long_Float
7608      with
7609       Dimension_System => (
7610         (Unit_Name => Meter,    Unit_Symbol => 'm',   Dim_Symbol => 'L'),
7611         (Unit_Name => Kilogram, Unit_Symbol => "kg",  Dim_Symbol => 'M'),
7612         (Unit_Name => Second,   Unit_Symbol => 's',   Dim_Symbol => 'T'),
7613         (Unit_Name => Ampere,   Unit_Symbol => 'A',   Dim_Symbol => 'I'),
7614         (Unit_Name => Kelvin,   Unit_Symbol => 'K',   Dim_Symbol => "Theta"),
7615         (Unit_Name => Mole,     Unit_Symbol => "mol", Dim_Symbol => 'N'),
7616         (Unit_Name => Candela,  Unit_Symbol => "cd",  Dim_Symbol => 'J'));
7617 @end smallexample
7619 @noindent
7620 See section "Performing Dimensionality Analysis in GNAT" in the GNAT Users
7621 Guide for detailed examples of use of the dimension system.
7623 @node Aspect Favor_Top_Level
7624 @unnumberedsec Aspect Favor_Top_Level
7625 @findex Favor_Top_Level
7626 @noindent
7627 This aspect is equivalent to pragma @code{Favor_Top_Level}.
7629 @node Aspect Global
7630 @unnumberedsec Aspect Global
7631 @findex Global
7632 @noindent
7633 This aspect is equivalent pragma @code{Global}.
7635 @node Aspect Inline_Always
7636 @unnumberedsec Aspect Inline_Always
7637 @findex Inline_Always
7638 @noindent
7639 This aspect is equivalent to pragma @code{Inline_Always}.
7641 @node Aspect Invariant
7642 @unnumberedsec Aspect Invariant
7643 @findex Invariant
7644 @noindent
7645 This aspect is equivalent to pragma @code{Invariant}. It is a
7646 synonym for the language defined aspect @code{Type_Invariant} except
7647 that it is separately controllable using pragma @code{Assertion_Policy}.
7649 @node Aspect Lock_Free
7650 @unnumberedsec Aspect Lock_Free
7651 @findex Lock_Free
7652 @noindent
7653 This aspect is equivalent to pragma @code{Lock_Free}.
7655 @node Aspect Object_Size
7656 @unnumberedsec Aspect Object_Size
7657 @findex Object_Size
7658 @noindent
7659 This aspect is equivalent to an @code{Object_Size} attribute definition
7660 clause.
7662 @node Aspect Persistent_BSS
7663 @unnumberedsec Aspect Persistent_BSS
7664 @findex Persistent_BSS
7665 @noindent
7666 This aspect is equivalent to pragma @code{Persistent_BSS}.
7668 @node Aspect Predicate
7669 @unnumberedsec Aspect Predicate
7670 @findex Predicate
7671 @noindent
7672 This aspect is equivalent to pragma @code{Predicate}. It is thus
7673 similar to the language defined aspects @code{Dynamic_Predicate}
7674 and @code{Static_Predicate} except that whether the resulting
7675 predicate is static or dynamic is controlled by the form of the
7676 expression. It is also separately controllable using pragma
7677 @code{Assertion_Policy}.
7679 @node Aspect Preelaborate_05
7680 @unnumberedsec Aspect Preelaborate_05
7681 @findex Preelaborate_05
7682 @noindent
7683 This aspect is equivalent to pragma @code{Preelaborate_05}.
7685 @node Aspect Pure_05
7686 @unnumberedsec Aspect Pure_05
7687 @findex Pure_05
7688 @noindent
7689 This aspect is equivalent to pragma @code{Pure_05}.
7691 @node Aspect Pure_12
7692 @unnumberedsec Aspect Pure_12
7693 @findex Pure_12
7694 @noindent
7695 This aspect is equivalent to pragma @code{Pure_12}.
7697 @node Aspect Pure_Function
7698 @unnumberedsec Aspect Pure_Function
7699 @findex Pure_Function
7700 @noindent
7701 This aspect is equivalent to pragma @code{Pure_Function}.
7703 @node Aspect Remote_Access_Type
7704 @unnumberedsec Aspect Remote_Access_Type
7705 @findex Remote_Access_Type
7706 @noindent
7707 This aspect is equivalent to pragma @code{Remote_Access_Type}.
7709 @node Aspect Scalar_Storage_Order
7710 @unnumberedsec Aspect Scalar_Storage_Order
7711 @findex Scalar_Storage_Order
7712 @noindent
7713 This aspect is equivalent to a @code{Scalar_Storage_Order}
7714 attribute definition clause.
7716 @node Aspect Shared
7717 @unnumberedsec Aspect Shared
7718 @findex Shared
7719 @noindent
7720 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
7721 for aspect @code{Atomic}.
7723 @node Aspect Simple_Storage_Pool
7724 @unnumberedsec Aspect Simple_Storage_Pool
7725 @findex Simple_Storage_Pool
7726 @noindent
7727 This aspect is equivalent to a @code{Simple_Storage_Pool}
7728 attribute definition clause.
7730 @node Aspect Simple_Storage_Pool_Type
7731 @unnumberedsec Aspect Simple_Storage_Pool_Type
7732 @findex Simple_Storage_Pool_Type
7733 @noindent
7734 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
7736 @node Aspect SPARK_Mode
7737 @unnumberedsec Aspect SPARK_Mode
7738 @findex SPARK_Mode
7739 @noindent
7740 This aspect is equivalent to pragma @code{SPARK_Mode}.
7742 @node Aspect Suppress_Debug_Info
7743 @unnumberedsec Aspect Suppress_Debug_Info
7744 @findex Suppress_Debug_Info
7745 @noindent
7746 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
7748 @node Aspect Test_Case
7749 @unnumberedsec Aspect Test_Case
7750 @findex Test_Case
7751 @noindent
7752 This aspect is equivalent to pragma @code{Test_Case}.
7754 @node Aspect Universal_Aliasing
7755 @unnumberedsec Aspect Universal_Aliasing
7756 @findex Universal_Aliasing
7757 @noindent
7758 This aspect is equivalent to pragma @code{Universal_Aliasing}.
7760 @node Aspect Universal_Data
7761 @unnumberedsec Aspect Universal_Data
7762 @findex Universal_Data
7763 @noindent
7764 This aspect is equivalent to pragma @code{Universal_Data}.
7766 @node Aspect Unmodified
7767 @unnumberedsec Aspect Unmodified
7768 @findex Unmodified
7769 @noindent
7770 This aspect is equivalent to pragma @code{Unmodified}.
7772 @node Aspect Unreferenced
7773 @unnumberedsec Aspect Unreferenced
7774 @findex Unreferenced
7775 @noindent
7776 This aspect is equivalent to pragma @code{Unreferenced}.
7778 @node Aspect Unreferenced_Objects
7779 @unnumberedsec Aspect Unreferenced_Objects
7780 @findex Unreferenced_Objects
7781 @noindent
7782 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
7784 @node Aspect Value_Size
7785 @unnumberedsec Aspect Value_Size
7786 @findex Value_Size
7787 @noindent
7788 This aspect is equivalent to a @code{Value_Size}
7789 attribute definition clause.
7791 @node Aspect Warnings
7792 @unnumberedsec Aspect Warnings
7793 @findex Warnings
7794 @noindent
7795 This aspect is equivalent to the two argument form of pragma @code{Warnings},
7796 where the first argument is @code{ON} or @code{OFF} and the second argument
7797 is the entity.
7799 @node Implementation Defined Attributes
7800 @chapter Implementation Defined Attributes
7801 Ada defines (throughout the Ada reference manual,
7802 summarized in Annex K),
7803 a set of attributes that provide useful additional functionality in all
7804 areas of the language.  These language defined attributes are implemented
7805 in GNAT and work as described in the Ada Reference Manual.
7807 In addition, Ada allows implementations to define additional
7808 attributes whose meaning is defined by the implementation.  GNAT provides
7809 a number of these implementation-dependent attributes which can be used
7810 to extend and enhance the functionality of the compiler.  This section of
7811 the GNAT reference manual describes these additional attributes.
7813 Note that any program using these attributes may not be portable to
7814 other compilers (although GNAT implements this set of attributes on all
7815 platforms).  Therefore if portability to other compilers is an important
7816 consideration, you should minimize the use of these attributes.
7818 @menu
7819 * Attribute Abort_Signal::
7820 * Attribute Address_Size::
7821 * Attribute Asm_Input::
7822 * Attribute Asm_Output::
7823 * Attribute AST_Entry::
7824 * Attribute Bit::
7825 * Attribute Bit_Position::
7826 * Attribute Compiler_Version::
7827 * Attribute Code_Address::
7828 * Attribute Default_Bit_Order::
7829 * Attribute Descriptor_Size::
7830 * Attribute Elaborated::
7831 * Attribute Elab_Body::
7832 * Attribute Elab_Spec::
7833 * Attribute Elab_Subp_Body::
7834 * Attribute Emax::
7835 * Attribute Enabled::
7836 * Attribute Enum_Rep::
7837 * Attribute Enum_Val::
7838 * Attribute Epsilon::
7839 * Attribute Fixed_Value::
7840 * Attribute Has_Access_Values::
7841 * Attribute Has_Discriminants::
7842 * Attribute Img::
7843 * Attribute Integer_Value::
7844 * Attribute Invalid_Value::
7845 * Attribute Large::
7846 * Attribute Library_Level::
7847 * Attribute Loop_Entry::
7848 * Attribute Machine_Size::
7849 * Attribute Mantissa::
7850 * Attribute Max_Interrupt_Priority::
7851 * Attribute Max_Priority::
7852 * Attribute Maximum_Alignment::
7853 * Attribute Mechanism_Code::
7854 * Attribute Null_Parameter::
7855 * Attribute Object_Size::
7856 * Attribute Passed_By_Reference::
7857 * Attribute Pool_Address::
7858 * Attribute Range_Length::
7859 * Attribute Ref::
7860 * Attribute Restriction_Set::
7861 * Attribute Result::
7862 * Attribute Safe_Emax::
7863 * Attribute Safe_Large::
7864 * Attribute Scalar_Storage_Order::
7865 * Attribute Simple_Storage_Pool::
7866 * Attribute Small::
7867 * Attribute Storage_Unit::
7868 * Attribute Stub_Type::
7869 * Attribute System_Allocator_Alignment::
7870 * Attribute Target_Name::
7871 * Attribute Tick::
7872 * Attribute To_Address::
7873 * Attribute Type_Class::
7874 * Attribute UET_Address::
7875 * Attribute Unconstrained_Array::
7876 * Attribute Universal_Literal_String::
7877 * Attribute Unrestricted_Access::
7878 * Attribute Update::
7879 * Attribute Valid_Scalars::
7880 * Attribute VADS_Size::
7881 * Attribute Value_Size::
7882 * Attribute Wchar_T_Size::
7883 * Attribute Word_Size::
7884 @end menu
7886 @node Attribute Abort_Signal
7887 @unnumberedsec Attribute Abort_Signal
7888 @findex Abort_Signal
7889 @noindent
7890 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
7891 prefix) provides the entity for the special exception used to signal
7892 task abort or asynchronous transfer of control.  Normally this attribute
7893 should only be used in the tasking runtime (it is highly peculiar, and
7894 completely outside the normal semantics of Ada, for a user program to
7895 intercept the abort exception).
7897 @node Attribute Address_Size
7898 @unnumberedsec Attribute Address_Size
7899 @cindex Size of @code{Address}
7900 @findex Address_Size
7901 @noindent
7902 @code{Standard'Address_Size} (@code{Standard} is the only allowed
7903 prefix) is a static constant giving the number of bits in an
7904 @code{Address}. It is the same value as System.Address'Size,
7905 but has the advantage of being static, while a direct
7906 reference to System.Address'Size is non-static because Address
7907 is a private type.
7909 @node Attribute Asm_Input
7910 @unnumberedsec Attribute Asm_Input
7911 @findex Asm_Input
7912 @noindent
7913 The @code{Asm_Input} attribute denotes a function that takes two
7914 parameters.  The first is a string, the second is an expression of the
7915 type designated by the prefix.  The first (string) argument is required
7916 to be a static expression, and is the constraint for the parameter,
7917 (e.g.@: what kind of register is required).  The second argument is the
7918 value to be used as the input argument.  The possible values for the
7919 constant are the same as those used in the RTL, and are dependent on
7920 the configuration file used to built the GCC back end.
7921 @ref{Machine Code Insertions}
7923 @node Attribute Asm_Output
7924 @unnumberedsec Attribute Asm_Output
7925 @findex Asm_Output
7926 @noindent
7927 The @code{Asm_Output} attribute denotes a function that takes two
7928 parameters.  The first is a string, the second is the name of a variable
7929 of the type designated by the attribute prefix.  The first (string)
7930 argument is required to be a static expression and designates the
7931 constraint for the parameter (e.g.@: what kind of register is
7932 required).  The second argument is the variable to be updated with the
7933 result.  The possible values for constraint are the same as those used in
7934 the RTL, and are dependent on the configuration file used to build the
7935 GCC back end.  If there are no output operands, then this argument may
7936 either be omitted, or explicitly given as @code{No_Output_Operands}.
7937 @ref{Machine Code Insertions}
7939 @node Attribute AST_Entry
7940 @unnumberedsec Attribute AST_Entry
7941 @cindex OpenVMS
7942 @findex AST_Entry
7943 @noindent
7944 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
7945 the name of an entry, it yields a value of the predefined type AST_Handler
7946 (declared in the predefined package System, as extended by the use of
7947 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
7948 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
7949 Language Reference Manual}, section 9.12a.
7951 @node Attribute Bit
7952 @unnumberedsec Attribute Bit
7953 @findex Bit
7954 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
7955 offset within the storage unit (byte) that contains the first bit of
7956 storage allocated for the object.  The value of this attribute is of the
7957 type @code{Universal_Integer}, and is always a non-negative number not
7958 exceeding the value of @code{System.Storage_Unit}.
7960 For an object that is a variable or a constant allocated in a register,
7961 the value is zero.  (The use of this attribute does not force the
7962 allocation of a variable to memory).
7964 For an object that is a formal parameter, this attribute applies
7965 to either the matching actual parameter or to a copy of the
7966 matching actual parameter.
7968 For an access object the value is zero.  Note that
7969 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
7970 designated object.  Similarly for a record component
7971 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
7972 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
7973 are subject to index checks.
7975 This attribute is designed to be compatible with the DEC Ada 83 definition
7976 and implementation of the @code{Bit} attribute.
7978 @node Attribute Bit_Position
7979 @unnumberedsec Attribute Bit_Position
7980 @findex Bit_Position
7981 @noindent
7982 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
7983 of the fields of the record type, yields the bit
7984 offset within the record contains the first bit of
7985 storage allocated for the object.  The value of this attribute is of the
7986 type @code{Universal_Integer}.  The value depends only on the field
7987 @var{C} and is independent of the alignment of
7988 the containing record @var{R}.
7990 @node Attribute Compiler_Version
7991 @unnumberedsec Attribute Compiler_Version
7992 @findex Compiler_Version
7993 @noindent
7994 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
7995 prefix) yields a static string identifying the version of the compiler
7996 being used to compile the unit containing the attribute reference. A
7997 typical result would be something like "@value{EDITION} @i{version} (20090221)".
7999 @node Attribute Code_Address
8000 @unnumberedsec Attribute Code_Address
8001 @findex Code_Address
8002 @cindex Subprogram address
8003 @cindex Address of subprogram code
8004 @noindent
8005 The @code{'Address}
8006 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
8007 intended effect seems to be to provide
8008 an address value which can be used to call the subprogram by means of
8009 an address clause as in the following example:
8011 @smallexample @c ada
8012 procedure K is @dots{}
8014 procedure L;
8015 for L'Address use K'Address;
8016 pragma Import (Ada, L);
8017 @end smallexample
8019 @noindent
8020 A call to @code{L} is then expected to result in a call to @code{K}@.
8021 In Ada 83, where there were no access-to-subprogram values, this was
8022 a common work-around for getting the effect of an indirect call.
8023 GNAT implements the above use of @code{Address} and the technique
8024 illustrated by the example code works correctly.
8026 However, for some purposes, it is useful to have the address of the start
8027 of the generated code for the subprogram.  On some architectures, this is
8028 not necessarily the same as the @code{Address} value described above.
8029 For example, the @code{Address} value may reference a subprogram
8030 descriptor rather than the subprogram itself.
8032 The @code{'Code_Address} attribute, which can only be applied to
8033 subprogram entities, always returns the address of the start of the
8034 generated code of the specified subprogram, which may or may not be
8035 the same value as is returned by the corresponding @code{'Address}
8036 attribute.
8038 @node Attribute Default_Bit_Order
8039 @unnumberedsec Attribute Default_Bit_Order
8040 @cindex Big endian
8041 @cindex Little endian
8042 @findex Default_Bit_Order
8043 @noindent
8044 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
8045 permissible prefix), provides the value @code{System.Default_Bit_Order}
8046 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
8047 @code{Low_Order_First}).  This is used to construct the definition of
8048 @code{Default_Bit_Order} in package @code{System}.
8050 @node Attribute Descriptor_Size
8051 @unnumberedsec Attribute Descriptor_Size
8052 @cindex Descriptor
8053 @cindex Dope vector
8054 @findex Descriptor_Size
8055 @noindent
8056 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
8057 descriptor allocated for a type.  The result is non-zero only for unconstrained
8058 array types and the returned value is of type universal integer.  In GNAT, an
8059 array descriptor contains bounds information and is located immediately before
8060 the first element of the array.
8062 @smallexample @c ada
8063 type Unconstr_Array is array (Positive range <>) of Boolean;
8064 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
8065 @end smallexample
8067 @noindent
8068 The attribute takes into account any additional padding due to type alignment.
8069 In the example above, the descriptor contains two values of type
8070 @code{Positive} representing the low and high bound.  Since @code{Positive} has
8071 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
8072 Positive'Size + 2} or 64 bits.
8074 @node Attribute Elaborated
8075 @unnumberedsec Attribute Elaborated
8076 @findex Elaborated
8077 @noindent
8078 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
8079 value is a Boolean which indicates whether or not the given unit has been
8080 elaborated.  This attribute is primarily intended for internal use by the
8081 generated code for dynamic elaboration checking, but it can also be used
8082 in user programs.  The value will always be True once elaboration of all
8083 units has been completed.  An exception is for units which need no
8084 elaboration, the value is always False for such units.
8086 @node Attribute Elab_Body
8087 @unnumberedsec Attribute Elab_Body
8088 @findex Elab_Body
8089 @noindent
8090 This attribute can only be applied to a program unit name.  It returns
8091 the entity for the corresponding elaboration procedure for elaborating
8092 the body of the referenced unit.  This is used in the main generated
8093 elaboration procedure by the binder and is not normally used in any
8094 other context.  However, there may be specialized situations in which it
8095 is useful to be able to call this elaboration procedure from Ada code,
8096 e.g.@: if it is necessary to do selective re-elaboration to fix some
8097 error.
8099 @node Attribute Elab_Spec
8100 @unnumberedsec Attribute Elab_Spec
8101 @findex Elab_Spec
8102 @noindent
8103 This attribute can only be applied to a program unit name.  It returns
8104 the entity for the corresponding elaboration procedure for elaborating
8105 the spec of the referenced unit.  This is used in the main
8106 generated elaboration procedure by the binder and is not normally used
8107 in any other context.  However, there may be specialized situations in
8108 which it is useful to be able to call this elaboration procedure from
8109 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
8110 some error.
8112 @node Attribute Elab_Subp_Body
8113 @unnumberedsec Attribute Elab_Subp_Body
8114 @findex Elab_Subp_Body
8115 @noindent
8116 This attribute can only be applied to a library level subprogram
8117 name and is only allowed in CodePeer mode. It returns the entity
8118 for the corresponding elaboration procedure for elaborating the body
8119 of the referenced subprogram unit. This is used in the main generated
8120 elaboration procedure by the binder in CodePeer mode only and is unrecognized
8121 otherwise.
8123 @node Attribute Emax
8124 @unnumberedsec Attribute Emax
8125 @cindex Ada 83 attributes
8126 @findex Emax
8127 @noindent
8128 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
8129 the Ada 83 reference manual for an exact description of the semantics of
8130 this attribute.
8132 @node Attribute Enabled
8133 @unnumberedsec Attribute Enabled
8134 @findex Enabled
8135 @noindent
8136 The @code{Enabled} attribute allows an application program to check at compile
8137 time to see if the designated check is currently enabled. The prefix is a
8138 simple identifier, referencing any predefined check name (other than
8139 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
8140 no argument is given for the attribute, the check is for the general state
8141 of the check, if an argument is given, then it is an entity name, and the
8142 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
8143 given naming the entity (if not, then the argument is ignored).
8145 Note that instantiations inherit the check status at the point of the
8146 instantiation, so a useful idiom is to have a library package that
8147 introduces a check name with @code{pragma Check_Name}, and then contains
8148 generic packages or subprograms which use the @code{Enabled} attribute
8149 to see if the check is enabled. A user of this package can then issue
8150 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
8151 the package or subprogram, controlling whether the check will be present.
8153 @node Attribute Enum_Rep
8154 @unnumberedsec Attribute Enum_Rep
8155 @cindex Representation of enums
8156 @findex Enum_Rep
8157 @noindent
8158 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
8159 function with the following spec:
8161 @smallexample @c ada
8162 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
8163   return @i{Universal_Integer};
8164 @end smallexample
8166 @noindent
8167 It is also allowable to apply @code{Enum_Rep} directly to an object of an
8168 enumeration type or to a non-overloaded enumeration
8169 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
8170 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
8171 enumeration literal or object.
8173 The function returns the representation value for the given enumeration
8174 value.  This will be equal to value of the @code{Pos} attribute in the
8175 absence of an enumeration representation clause.  This is a static
8176 attribute (i.e.@: the result is static if the argument is static).
8178 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
8179 in which case it simply returns the integer value.  The reason for this
8180 is to allow it to be used for @code{(<>)} discrete formal arguments in
8181 a generic unit that can be instantiated with either enumeration types
8182 or integer types.  Note that if @code{Enum_Rep} is used on a modular
8183 type whose upper bound exceeds the upper bound of the largest signed
8184 integer type, and the argument is a variable, so that the universal
8185 integer calculation is done at run time, then the call to @code{Enum_Rep}
8186 may raise @code{Constraint_Error}.
8188 @node Attribute Enum_Val
8189 @unnumberedsec Attribute Enum_Val
8190 @cindex Representation of enums
8191 @findex Enum_Val
8192 @noindent
8193 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
8194 function with the following spec:
8196 @smallexample @c ada
8197 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
8198   return @var{S}'Base};
8199 @end smallexample
8201 @noindent
8202 The function returns the enumeration value whose representation matches the
8203 argument, or raises Constraint_Error if no enumeration literal of the type
8204 has the matching value.
8205 This will be equal to value of the @code{Val} attribute in the
8206 absence of an enumeration representation clause.  This is a static
8207 attribute (i.e.@: the result is static if the argument is static).
8209 @node Attribute Epsilon
8210 @unnumberedsec Attribute Epsilon
8211 @cindex Ada 83 attributes
8212 @findex Epsilon
8213 @noindent
8214 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
8215 the Ada 83 reference manual for an exact description of the semantics of
8216 this attribute.
8218 @node Attribute Fixed_Value
8219 @unnumberedsec Attribute Fixed_Value
8220 @findex Fixed_Value
8221 @noindent
8222 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
8223 function with the following specification:
8225 @smallexample @c ada
8226 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
8227   return @var{S};
8228 @end smallexample
8230 @noindent
8231 The value returned is the fixed-point value @var{V} such that
8233 @smallexample @c ada
8234 @var{V} = Arg * @var{S}'Small
8235 @end smallexample
8237 @noindent
8238 The effect is thus similar to first converting the argument to the
8239 integer type used to represent @var{S}, and then doing an unchecked
8240 conversion to the fixed-point type.  The difference is
8241 that there are full range checks, to ensure that the result is in range.
8242 This attribute is primarily intended for use in implementation of the
8243 input-output functions for fixed-point values.
8245 @node Attribute Has_Access_Values
8246 @unnumberedsec Attribute Has_Access_Values
8247 @cindex Access values, testing for
8248 @findex Has_Access_Values
8249 @noindent
8250 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
8251 is a Boolean value which is True if the is an access type, or is a composite
8252 type with a component (at any nesting depth) that is an access type, and is
8253 False otherwise.
8254 The intended use of this attribute is in conjunction with generic
8255 definitions.  If the attribute is applied to a generic private type, it
8256 indicates whether or not the corresponding actual type has access values.
8258 @node Attribute Has_Discriminants
8259 @unnumberedsec Attribute Has_Discriminants
8260 @cindex Discriminants, testing for
8261 @findex Has_Discriminants
8262 @noindent
8263 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
8264 is a Boolean value which is True if the type has discriminants, and False
8265 otherwise.  The intended use of this attribute is in conjunction with generic
8266 definitions.  If the attribute is applied to a generic private type, it
8267 indicates whether or not the corresponding actual type has discriminants.
8269 @node Attribute Img
8270 @unnumberedsec Attribute Img
8271 @findex Img
8272 @noindent
8273 The @code{Img} attribute differs from @code{Image} in that it is applied
8274 directly to an object, and yields the same result as
8275 @code{Image} for the subtype of the object.  This is convenient for
8276 debugging:
8278 @smallexample @c ada
8279 Put_Line ("X = " & X'Img);
8280 @end smallexample
8282 @noindent
8283 has the same meaning as the more verbose:
8285 @smallexample @c ada
8286 Put_Line ("X = " & @var{T}'Image (X));
8287 @end smallexample
8289 @noindent
8290 where @var{T} is the (sub)type of the object @code{X}.
8292 Note that technically, in analogy to @code{Image},
8293 @code{X'Img} returns a parameterless function
8294 that returns the appropriate string when called. This means that
8295 @code{X'Img} can be renamed as a function-returning-string, or used
8296 in an instantiation as a function parameter.
8298 @node Attribute Integer_Value
8299 @unnumberedsec Attribute Integer_Value
8300 @findex Integer_Value
8301 @noindent
8302 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
8303 function with the following spec:
8305 @smallexample @c ada
8306 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
8307   return @var{S};
8308 @end smallexample
8310 @noindent
8311 The value returned is the integer value @var{V}, such that
8313 @smallexample @c ada
8314 Arg = @var{V} * @var{T}'Small
8315 @end smallexample
8317 @noindent
8318 where @var{T} is the type of @code{Arg}.
8319 The effect is thus similar to first doing an unchecked conversion from
8320 the fixed-point type to its corresponding implementation type, and then
8321 converting the result to the target integer type.  The difference is
8322 that there are full range checks, to ensure that the result is in range.
8323 This attribute is primarily intended for use in implementation of the
8324 standard input-output functions for fixed-point values.
8326 @node Attribute Invalid_Value
8327 @unnumberedsec Attribute Invalid_Value
8328 @findex Invalid_Value
8329 @noindent
8330 For every scalar type S, S'Invalid_Value returns an undefined value of the
8331 type. If possible this value is an invalid representation for the type. The
8332 value returned is identical to the value used to initialize an otherwise
8333 uninitialized value of the type if pragma Initialize_Scalars is used,
8334 including the ability to modify the value with the binder -Sxx flag and
8335 relevant environment variables at run time.
8337 @node Attribute Large
8338 @unnumberedsec Attribute Large
8339 @cindex Ada 83 attributes
8340 @findex Large
8341 @noindent
8342 The @code{Large} attribute is provided for compatibility with Ada 83.  See
8343 the Ada 83 reference manual for an exact description of the semantics of
8344 this attribute.
8346 @node Attribute Library_Level
8347 @unnumberedsec Attribute Library_Level
8348 @findex Library_Level
8349 @noindent
8350 @noindent
8351 @code{P'Library_Level}, where P is an entity name,
8352 returns a Boolean value which is True if the entity is declared
8353 at the library level, and False otherwise. Note that within a
8354 generic instantition, the name of the generic unit denotes the
8355 instance, which means that this attribute can be used to test
8356 if a generic is instantiated at the library level, as shown
8357 in this example:
8359 @smallexample @c ada
8360 generic
8361   ...
8362 package Gen is
8363   pragma Compile_Time_Error
8364     (not Gen'Library_Level,
8365      "Gen can only be instantiated at library level");
8366   ...
8367 end Gen;
8368 @end smallexample
8370 @node Attribute Loop_Entry
8371 @unnumberedsec Attribute Loop_Entry
8372 @findex Loop_Entry
8373 @noindent
8374 Syntax:
8376 @smallexample @c ada
8377 X'Loop_Entry [(loop_name)]
8378 @end smallexample
8380 @noindent
8381 The @code{Loop_Entry} attribute is used to refer to the value that an
8382 expression had upon entry to a given loop in much the same way that the
8383 @code{Old} attribute in a subprogram postcondition can be used to refer
8384 to the value an expression had upon entry to the subprogram. The
8385 relevant loop is either identified by the given loop name, or it is the
8386 innermost enclosing loop when no loop name is given.
8388 @noindent
8389 A @code{Loop_Entry} attribute can only occur within a
8390 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
8391 @code{Loop_Entry} is to compare the current value of objects with their
8392 initial value at loop entry, in a @code{Loop_Invariant} pragma.
8394 @noindent
8395 The effect of using @code{X'Loop_Entry} is the same as declaring
8396 a constant initialized with the initial value of @code{X} at loop
8397 entry. This copy is not performed if the loop is not entered, or if the
8398 corresponding pragmas are ignored or disabled.
8400 @node Attribute Machine_Size
8401 @unnumberedsec Attribute Machine_Size
8402 @findex Machine_Size
8403 @noindent
8404 This attribute is identical to the @code{Object_Size} attribute.  It is
8405 provided for compatibility with the DEC Ada 83 attribute of this name.
8407 @node Attribute Mantissa
8408 @unnumberedsec Attribute Mantissa
8409 @cindex Ada 83 attributes
8410 @findex Mantissa
8411 @noindent
8412 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
8413 the Ada 83 reference manual for an exact description of the semantics of
8414 this attribute.
8416 @node Attribute Max_Interrupt_Priority
8417 @unnumberedsec Attribute Max_Interrupt_Priority
8418 @cindex Interrupt priority, maximum
8419 @findex Max_Interrupt_Priority
8420 @noindent
8421 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
8422 permissible prefix), provides the same value as
8423 @code{System.Max_Interrupt_Priority}.
8425 @node Attribute Max_Priority
8426 @unnumberedsec Attribute Max_Priority
8427 @cindex Priority, maximum
8428 @findex Max_Priority
8429 @noindent
8430 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
8431 prefix) provides the same value as @code{System.Max_Priority}.
8433 @node Attribute Maximum_Alignment
8434 @unnumberedsec Attribute Maximum_Alignment
8435 @cindex Alignment, maximum
8436 @findex Maximum_Alignment
8437 @noindent
8438 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
8439 permissible prefix) provides the maximum useful alignment value for the
8440 target.  This is a static value that can be used to specify the alignment
8441 for an object, guaranteeing that it is properly aligned in all
8442 cases.
8444 @node Attribute Mechanism_Code
8445 @unnumberedsec Attribute Mechanism_Code
8446 @cindex Return values, passing mechanism
8447 @cindex Parameters, passing mechanism
8448 @findex Mechanism_Code
8449 @noindent
8450 @code{@var{function}'Mechanism_Code} yields an integer code for the
8451 mechanism used for the result of function, and
8452 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
8453 used for formal parameter number @var{n} (a static integer value with 1
8454 meaning the first parameter) of @var{subprogram}.  The code returned is:
8456 @table @asis
8457 @item 1
8458 by copy (value)
8459 @item 2
8460 by reference
8461 @item 3
8462 by descriptor (default descriptor class)
8463 @item 4
8464 by descriptor (UBS: unaligned bit string)
8465 @item 5
8466 by descriptor (UBSB: aligned bit string with arbitrary bounds)
8467 @item 6
8468 by descriptor (UBA: unaligned bit array)
8469 @item 7
8470 by descriptor (S: string, also scalar access type parameter)
8471 @item 8
8472 by descriptor (SB: string with arbitrary bounds)
8473 @item 9
8474 by descriptor (A: contiguous array)
8475 @item 10
8476 by descriptor (NCA: non-contiguous array)
8477 @end table
8479 @noindent
8480 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
8481 @cindex OpenVMS
8483 @node Attribute Null_Parameter
8484 @unnumberedsec Attribute Null_Parameter
8485 @cindex Zero address, passing
8486 @findex Null_Parameter
8487 @noindent
8488 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
8489 type or subtype @var{T} allocated at machine address zero.  The attribute
8490 is allowed only as the default expression of a formal parameter, or as
8491 an actual expression of a subprogram call.  In either case, the
8492 subprogram must be imported.
8494 The identity of the object is represented by the address zero in the
8495 argument list, independent of the passing mechanism (explicit or
8496 default).
8498 This capability is needed to specify that a zero address should be
8499 passed for a record or other composite object passed by reference.
8500 There is no way of indicating this without the @code{Null_Parameter}
8501 attribute.
8503 @node Attribute Object_Size
8504 @unnumberedsec Attribute Object_Size
8505 @cindex Size, used for objects
8506 @findex Object_Size
8507 @noindent
8508 The size of an object is not necessarily the same as the size of the type
8509 of an object.  This is because by default object sizes are increased to be
8510 a multiple of the alignment of the object.  For example,
8511 @code{Natural'Size} is
8512 31, but by default objects of type @code{Natural} will have a size of 32 bits.
8513 Similarly, a record containing an integer and a character:
8515 @smallexample @c ada
8516 type Rec is record
8517    I : Integer;
8518    C : Character;
8519 end record;
8520 @end smallexample
8522 @noindent
8523 will have a size of 40 (that is @code{Rec'Size} will be 40).  The
8524 alignment will be 4, because of the
8525 integer field, and so the default size of record objects for this type
8526 will be 64 (8 bytes).
8528 @node Attribute Passed_By_Reference
8529 @unnumberedsec Attribute Passed_By_Reference
8530 @cindex Parameters, when passed by reference
8531 @findex Passed_By_Reference
8532 @noindent
8533 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
8534 a value of type @code{Boolean} value that is @code{True} if the type is
8535 normally passed by reference and @code{False} if the type is normally
8536 passed by copy in calls.  For scalar types, the result is always @code{False}
8537 and is static.  For non-scalar types, the result is non-static.
8539 @node Attribute Pool_Address
8540 @unnumberedsec Attribute Pool_Address
8541 @cindex Parameters, when passed by reference
8542 @findex Pool_Address
8543 @noindent
8544 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
8545 of X within its storage pool. This is the same as
8546 @code{@var{X}'Address}, except that for an unconstrained array whose
8547 bounds are allocated just before the first component,
8548 @code{@var{X}'Pool_Address} returns the address of those bounds,
8549 whereas @code{@var{X}'Address} returns the address of the first
8550 component.
8552 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
8553 the object is allocated'', which could be a user-defined storage pool,
8554 the global heap, on the stack, or in a static memory area. For an
8555 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
8556 what is passed to @code{Allocate} and returned from @code{Deallocate}.
8558 @node Attribute Range_Length
8559 @unnumberedsec Attribute Range_Length
8560 @findex Range_Length
8561 @noindent
8562 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
8563 the number of values represented by the subtype (zero for a null
8564 range).  The result is static for static subtypes.  @code{Range_Length}
8565 applied to the index subtype of a one dimensional array always gives the
8566 same result as @code{Length} applied to the array itself.
8568 @node Attribute Ref
8569 @unnumberedsec Attribute Ref
8570 @findex Ref
8571 @noindent
8574 @node Attribute Restriction_Set
8575 @unnumberedsec Attribute Restriction_Set
8576 @findex Restriction_Set
8577 @cindex Restrictions
8578 @noindent
8579 This attribute allows compile time testing of restrictions that
8580 are currently in effect. It is primarily intended for specializing
8581 code in the run-time based on restrictions that are active (e.g.
8582 don't need to save fpt registers if restriction No_Floating_Point
8583 is known to be in effect), but can be used anywhere.
8585 There are two forms:
8587 @smallexample @c ada
8588 System'Restriction_Set (partition_boolean_restriction_NAME)
8589 System'Restriction_Set (No_Dependence => library_unit_NAME);
8590 @end smallexample
8592 @noindent
8593 In the case of the first form, the only restriction names
8594 allowed are parameterless restrictions that are checked
8595 for consistency at bind time. For a complete list see the
8596 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
8598 The result returned is True if the restriction is known to
8599 be in effect, and False if the restriction is known not to
8600 be in effect. An important guarantee is that the value of
8601 a Restriction_Set attribute is known to be consistent throughout
8602 all the code of a partition.
8604 This is trivially achieved if the entire partition is compiled
8605 with a consistent set of restriction pragmas. However, the
8606 compilation model does not require this. It is possible to
8607 compile one set of units with one set of pragmas, and another
8608 set of units with another set of pragmas. It is even possible
8609 to compile a spec with one set of pragmas, and then WITH the
8610 same spec with a different set of pragmas. Inconsistencies
8611 in the actual use of the restriction are checked at bind time.
8613 In order to achieve the guarantee of consistency for the
8614 Restriction_Set pragma, we consider that a use of the pragma
8615 that yields False is equivalent to a violation of the
8616 restriction.
8618 So for example if you write
8620 @smallexample @c ada
8621 if System'Restriction_Set (No_Floating_Point) then
8622    ...
8623 else
8624    ...
8625 end if;
8626 @end smallexample
8628 @noindent
8629 And the result is False, so that the else branch is executed,
8630 you can assume that this restriction is not set for any unit
8631 in the partition. This is checked by considering this use of
8632 the restriction pragma to be a violation of the restriction
8633 No_Floating_Point. This means that no other unit can attempt
8634 to set this restriction (if some unit does attempt to set it,
8635 the binder will refuse to bind the partition).
8637 Technical note: The restriction name and the unit name are
8638 intepreted entirely syntactically, as in the corresponding
8639 Restrictions pragma, they are not analyzed semantically,
8640 so they do not have a type.
8642 @node Attribute Result
8643 @unnumberedsec Attribute Result
8644 @findex Result
8645 @noindent
8646 @code{@var{function}'Result} can only be used with in a Postcondition pragma
8647 for a function. The prefix must be the name of the corresponding function. This
8648 is used to refer to the result of the function in the postcondition expression.
8649 For a further discussion of the use of this attribute and examples of its use,
8650 see the description of pragma Postcondition.
8652 @node Attribute Safe_Emax
8653 @unnumberedsec Attribute Safe_Emax
8654 @cindex Ada 83 attributes
8655 @findex Safe_Emax
8656 @noindent
8657 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
8658 the Ada 83 reference manual for an exact description of the semantics of
8659 this attribute.
8661 @node Attribute Safe_Large
8662 @unnumberedsec Attribute Safe_Large
8663 @cindex Ada 83 attributes
8664 @findex Safe_Large
8665 @noindent
8666 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
8667 the Ada 83 reference manual for an exact description of the semantics of
8668 this attribute.
8670 @node Attribute Scalar_Storage_Order
8671 @unnumberedsec Attribute Scalar_Storage_Order
8672 @cindex Endianness
8673 @cindex Scalar storage order
8674 @findex Scalar_Storage_Order
8675 @noindent
8676 For every array or record type @var{S}, the representation attribute
8677 @code{Scalar_Storage_Order} denotes the order in which storage elements
8678 that make up scalar components are ordered within S:
8680 @smallexample @c ada
8681    --  Component type definitions
8683    subtype Yr_Type is Natural range 0 .. 127;
8684    subtype Mo_Type is Natural range 1 .. 12;
8685    subtype Da_Type is Natural range 1 .. 31;
8687    --  Record declaration
8689    type Date is record
8690       Years_Since_1980 : Yr_Type;
8691       Month            : Mo_Type;
8692       Day_Of_Month     : Da_Type;
8693    end record;
8695    --  Record representation clause
8697    for Date use record
8698       Years_Since_1980 at 0 range 0  ..  6;
8699       Month            at 0 range 7  .. 10;
8700       Day_Of_Month     at 0 range 11 .. 15;
8701    end record;
8703    --  Attribute definition clauses
8705    for Date'Bit_Order use System.High_Order_First;
8706    for Date'Scalar_Storage_Order use System.High_Order_First;
8707    --  If Scalar_Storage_Order is specified, it must be consistent with
8708    --  Bit_Order, so it's best to always define the latter explicitly if
8709    --  the former is used.
8710 @end smallexample
8712 Other properties are
8713 as for standard representation attribute @code{Bit_Order}, as defined by
8714 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
8716 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
8717 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
8718 this means that if a @code{Scalar_Storage_Order} attribute definition
8719 clause is not confirming, then the type's @code{Bit_Order} shall be
8720 specified explicitly and set to the same value.
8722 For a record extension, the derived type shall have the same scalar storage
8723 order as the parent type.
8725 If a component of @var{S} has itself a record or array type, then it shall also
8726 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
8727 if the component does not start on a byte boundary, then the scalar storage
8728 order specified for S and for the nested component type shall be identical.
8730 If @var{S} appears as the type of a record or array component, the enclosing
8731 record or array shall also have a @code{Scalar_Storage_Order} attribute
8732 definition clause.
8734 No component of a type that has a @code{Scalar_Storage_Order} attribute
8735 definition may be aliased.
8737 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
8738 with a value equal to @code{System.Default_Bit_Order}) has no effect.
8740 If the opposite storage order is specified, then whenever the value of
8741 a scalar component of an object of type @var{S} is read, the storage
8742 elements of the enclosing machine scalar are first reversed (before
8743 retrieving the component value, possibly applying some shift and mask
8744 operatings on the enclosing machine scalar), and the opposite operation
8745 is done for writes.
8747 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
8748 are relaxed. Instead, the following rules apply:
8750 @itemize @bullet
8751 @item the underlying storage elements are those at positions
8752   @code{(position + first_bit / storage_element_size) ..
8753         (position + (last_bit + storage_element_size - 1) /
8754                     storage_element_size)}
8755 @item the sequence of underlying storage elements shall have
8756         a size no greater than the largest machine scalar
8757 @item the enclosing machine scalar is defined as the smallest machine
8758         scalar starting at a position no greater than
8759         @code{position + first_bit / storage_element_size} and covering
8760         storage elements at least up to @code{position + (last_bit +
8761         storage_element_size - 1) / storage_element_size}
8762 @item the position of the component is interpreted relative to that machine
8763  scalar.
8765 @end itemize
8767 @node Attribute Simple_Storage_Pool
8768 @unnumberedsec Attribute Simple_Storage_Pool
8769 @cindex Storage pool, simple
8770 @cindex Simple storage pool
8771 @findex Simple_Storage_Pool
8772 @noindent
8773 For every nonformal, nonderived access-to-object type @var{Acc}, the
8774 representation attribute @code{Simple_Storage_Pool} may be specified
8775 via an attribute_definition_clause (or by specifying the equivalent aspect):
8777 @smallexample @c ada
8779 My_Pool : My_Simple_Storage_Pool_Type;
8781 type Acc is access My_Data_Type;
8783 for Acc'Simple_Storage_Pool use My_Pool;
8785 @end smallexample
8787 @noindent
8788 The name given in an attribute_definition_clause for the
8789 @code{Simple_Storage_Pool} attribute shall denote a variable of
8790 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
8792 The use of this attribute is only allowed for a prefix denoting a type
8793 for which it has been specified. The type of the attribute is the type
8794 of the variable specified as the simple storage pool of the access type,
8795 and the attribute denotes that variable.
8797 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
8798 for the same access type.
8800 If the @code{Simple_Storage_Pool} attribute has been specified for an access
8801 type, then applying the @code{Storage_Pool} attribute to the type is flagged
8802 with a warning and its evaluation raises the exception @code{Program_Error}.
8804 If the Simple_Storage_Pool attribute has been specified for an access
8805 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
8806 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
8807 which is intended to indicate the number of storage elements reserved for
8808 the simple storage pool. If the Storage_Size function has not been defined
8809 for the simple storage pool type, then this attribute returns zero.
8811 If an access type @var{S} has a specified simple storage pool of type
8812 @var{SSP}, then the evaluation of an allocator for that access type calls
8813 the primitive @code{Allocate} procedure for type @var{SSP}, passing
8814 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
8815 semantics of such allocators is the same as those defined for allocators
8816 in section 13.11 of the Ada Reference Manual, with the term
8817 ``simple storage pool'' substituted for ``storage pool''.
8819 If an access type @var{S} has a specified simple storage pool of type
8820 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
8821 for that access type invokes the primitive @code{Deallocate} procedure
8822 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
8823 parameter. The detailed semantics of such unchecked deallocations is the same
8824 as defined in section 13.11.2 of the Ada Reference Manual, except that the
8825 term ``simple storage pool'' is substituted for ``storage pool''.
8827 @node Attribute Small
8828 @unnumberedsec Attribute Small
8829 @cindex Ada 83 attributes
8830 @findex Small
8831 @noindent
8832 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
8833 fixed-point types.
8834 GNAT also allows this attribute to be applied to floating-point types
8835 for compatibility with Ada 83.  See
8836 the Ada 83 reference manual for an exact description of the semantics of
8837 this attribute when applied to floating-point types.
8839 @node Attribute Storage_Unit
8840 @unnumberedsec Attribute Storage_Unit
8841 @findex Storage_Unit
8842 @noindent
8843 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
8844 prefix) provides the same value as @code{System.Storage_Unit}.
8846 @node Attribute Stub_Type
8847 @unnumberedsec Attribute Stub_Type
8848 @findex Stub_Type
8849 @noindent
8850 The GNAT implementation of remote access-to-classwide types is
8851 organized as described in AARM section E.4 (20.t): a value of an RACW type
8852 (designating a remote object) is represented as a normal access
8853 value, pointing to a "stub" object which in turn contains the
8854 necessary information to contact the designated remote object. A
8855 call on any dispatching operation of such a stub object does the
8856 remote call, if necessary, using the information in the stub object
8857 to locate the target partition, etc.
8859 For a prefix @code{T} that denotes a remote access-to-classwide type,
8860 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
8862 By construction, the layout of @code{T'Stub_Type} is identical to that of
8863 type @code{RACW_Stub_Type} declared in the internal implementation-defined
8864 unit @code{System.Partition_Interface}. Use of this attribute will create
8865 an implicit dependency on this unit.
8867 @node Attribute System_Allocator_Alignment
8868 @unnumberedsec Attribute System_Allocator_Alignment
8869 @cindex Alignment, allocator
8870 @findex System_Allocator_Alignment
8871 @noindent
8872 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
8873 permissible prefix) provides the observable guaranted to be honored by
8874 the system allocator (malloc). This is a static value that can be used
8875 in user storage pools based on malloc either to reject allocation
8876 with alignment too large or to enable a realignment circuitry if the
8877 alignment request is larger than this value.
8879 @node Attribute Target_Name
8880 @unnumberedsec Attribute Target_Name
8881 @findex Target_Name
8882 @noindent
8883 @code{Standard'Target_Name} (@code{Standard} is the only permissible
8884 prefix) provides a static string value that identifies the target
8885 for the current compilation. For GCC implementations, this is the
8886 standard gcc target name without the terminating slash (for
8887 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
8889 @node Attribute Tick
8890 @unnumberedsec Attribute Tick
8891 @findex Tick
8892 @noindent
8893 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
8894 provides the same value as @code{System.Tick},
8896 @node Attribute To_Address
8897 @unnumberedsec Attribute To_Address
8898 @findex To_Address
8899 @noindent
8900 The @code{System'To_Address}
8901 (@code{System} is the only permissible prefix)
8902 denotes a function identical to
8903 @code{System.Storage_Elements.To_Address} except that
8904 it is a static attribute.  This means that if its argument is
8905 a static expression, then the result of the attribute is a
8906 static expression.  This means that such an expression can be
8907 used in contexts (e.g.@: preelaborable packages) which require a
8908 static expression and where the function call could not be used
8909 (since the function call is always non-static, even if its
8910 argument is static). The argument must be in the range
8911 -(2**(m-1) .. 2**m-1, where m is the memory size
8912 (typically 32 or 64). Negative values are intepreted in a
8913 modular manner (e.g. -1 means the same as 16#FFFF_FFFF# on
8914 a 32 bits machine).
8916 @node Attribute Type_Class
8917 @unnumberedsec Attribute Type_Class
8918 @findex Type_Class
8919 @noindent
8920 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
8921 the value of the type class for the full type of @var{type}.  If
8922 @var{type} is a generic formal type, the value is the value for the
8923 corresponding actual subtype.  The value of this attribute is of type
8924 @code{System.Aux_DEC.Type_Class}, which has the following definition:
8926 @smallexample @c ada
8927   type Type_Class is
8928     (Type_Class_Enumeration,
8929      Type_Class_Integer,
8930      Type_Class_Fixed_Point,
8931      Type_Class_Floating_Point,
8932      Type_Class_Array,
8933      Type_Class_Record,
8934      Type_Class_Access,
8935      Type_Class_Task,
8936      Type_Class_Address);
8937 @end smallexample
8939 @noindent
8940 Protected types yield the value @code{Type_Class_Task}, which thus
8941 applies to all concurrent types.  This attribute is designed to
8942 be compatible with the DEC Ada 83 attribute of the same name.
8944 @node Attribute UET_Address
8945 @unnumberedsec Attribute UET_Address
8946 @findex UET_Address
8947 @noindent
8948 The @code{UET_Address} attribute can only be used for a prefix which
8949 denotes a library package.  It yields the address of the unit exception
8950 table when zero cost exception handling is used.  This attribute is
8951 intended only for use within the GNAT implementation.  See the unit
8952 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
8953 for details on how this attribute is used in the implementation.
8955 @node Attribute Unconstrained_Array
8956 @unnumberedsec Attribute Unconstrained_Array
8957 @findex Unconstrained_Array
8958 @noindent
8959 The @code{Unconstrained_Array} attribute can be used with a prefix that
8960 denotes any type or subtype. It is a static attribute that yields
8961 @code{True} if the prefix designates an unconstrained array,
8962 and @code{False} otherwise. In a generic instance, the result is
8963 still static, and yields the result of applying this test to the
8964 generic actual.
8966 @node Attribute Universal_Literal_String
8967 @unnumberedsec Attribute Universal_Literal_String
8968 @cindex Named numbers, representation of
8969 @findex Universal_Literal_String
8970 @noindent
8971 The prefix of @code{Universal_Literal_String} must be a named
8972 number.  The static result is the string consisting of the characters of
8973 the number as defined in the original source.  This allows the user
8974 program to access the actual text of named numbers without intermediate
8975 conversions and without the need to enclose the strings in quotes (which
8976 would preclude their use as numbers).
8978 For example, the following program prints the first 50 digits of pi:
8980 @smallexample @c ada
8981 with Text_IO; use Text_IO;
8982 with Ada.Numerics;
8983 procedure Pi is
8984 begin
8985    Put (Ada.Numerics.Pi'Universal_Literal_String);
8986 end;
8987 @end smallexample
8989 @node Attribute Unrestricted_Access
8990 @unnumberedsec Attribute Unrestricted_Access
8991 @cindex @code{Access}, unrestricted
8992 @findex Unrestricted_Access
8993 @noindent
8994 The @code{Unrestricted_Access} attribute is similar to @code{Access}
8995 except that all accessibility and aliased view checks are omitted.  This
8996 is a user-beware attribute.  It is similar to
8997 @code{Address}, for which it is a desirable replacement where the value
8998 desired is an access type.  In other words, its effect is identical to
8999 first applying the @code{Address} attribute and then doing an unchecked
9000 conversion to a desired access type.  In GNAT, but not necessarily in
9001 other implementations, the use of static chains for inner level
9002 subprograms means that @code{Unrestricted_Access} applied to a
9003 subprogram yields a value that can be called as long as the subprogram
9004 is in scope (normal Ada accessibility rules restrict this usage).
9006 It is possible to use @code{Unrestricted_Access} for any type, but care
9007 must be exercised if it is used to create pointers to unconstrained
9008 objects. In this case, the resulting pointer has the same scope as the
9009 context of the attribute, and may not be returned to some enclosing
9010 scope. For instance, a function cannot use @code{Unrestricted_Access}
9011 to create a unconstrained pointer and then return that value to the
9012 caller.
9014 @node Attribute Update
9015 @unnumberedsec Attribute Update
9016 @findex Update
9017 @noindent
9018 The @code{Update} attribute creates a copy of an array or record value
9019 with one or more modified components. The syntax is:
9021 @smallexample @c ada
9022 PREFIX'Update (AGGREGATE)
9023 @end smallexample
9025 @noindent
9026 where @code{PREFIX} is the name of an array or record object, and
9027 @code{AGGREGATE} is a named aggregate that does not contain an @code{others}
9028 choice. The effect is to yield a copy of the array or record value which
9029 is unchanged apart from the components mentioned in the aggregate, which
9030 are changed to the indicated value. The original value of the array or
9031 record value is not affected. For example:
9033 @smallexample @c ada
9034 type Arr is Array (1 .. 5) of Integer;
9036 Avar1 : Arr := (1,2,3,4,5);
9037 Avar2 : Arr := Avar1'Update ((2 => 10, 3 .. 4 => 20));
9038 @end smallexample
9040 @noindent
9041 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
9042 begin unmodified. Similarly:
9044 @smallexample @c ada
9045 type Rec is A, B, C : Integer;
9047 Rvar1 : Rec := (A => 1, B => 2, C => 3);
9048 Rvar2 : Rec := Rvar1'Update ((B => 20));
9049 @end smallexample
9051 @noindent
9052 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
9053 with @code{Rvar1} being unmodifed.
9054 Note that the value of the attribute reference is computed
9055 completely before it is used. This means that if you write:
9057 @smallexample @c ada
9058 Avar1 := Avar1'Update ((1 => 10, 2 => Function_Call));
9059 @end smallexample
9061 @noindent
9062 then the value of @code{Avar1} is not modified if @code{Function_Call}
9063 raises an exception, unlike the effect of a series of direct assignments
9064 to elements of @code{Avar1}. In general this requires that
9065 two extra complete copies of the object are required, which should be
9066 kept in mind when considering efficiency.
9068 The @code{Update} attribute cannot be applied to prefixes of a limited
9069 type, and cannot reference discriminants in the case of a record type.
9070 The accessibility level of an Update attribute result object is defined
9071 as for an aggregate.
9073 In the record case, no component can be mentioned more than once. In
9074 the array case, two overlapping ranges can appear in the aggregate,
9075 in which case the modifications are processed left to right.
9077 Multi-dimensional arrays can be modified, as shown by this example:
9079 @smallexample @c ada
9080 A : array (1 .. 10, 1 .. 10) of Integer;
9082 A := A'Update (1 => (2 => 20), 3 => (4 => 30));
9083 @end smallexample
9085 @noindent
9086 which changes element (1,2) to 20 and (3,4) to 30.
9088 @node Attribute Valid_Scalars
9089 @unnumberedsec Attribute Valid_Scalars
9090 @findex Valid_Scalars
9091 @noindent
9092 The @code{'Valid_Scalars} attribute is intended to make it easier to
9093 check the validity of scalar subcomponents of composite objects. It
9094 is defined for any prefix @code{X} that denotes an object.
9095 The value of this attribute is of the predefined type Boolean.
9096 @code{X'Valid_Scalars} yields True if and only if evaluation of
9097 @code{P'Valid} yields True for every scalar part P of X or if X has
9098 no scalar parts. It is not specified in what order the scalar parts
9099 are checked, nor whether any more are checked after any one of them
9100 is determined to be invalid. If the prefix @code{X} is of a class-wide
9101 type @code{T'Class} (where @code{T} is the associated specific type),
9102 or if the prefix @code{X} is of a specific tagged type @code{T}, then
9103 only the scalar parts of components of @code{T} are traversed; in other
9104 words, components of extensions of @code{T} are not traversed even if
9105 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
9106 be determined at compile time that the prefix of the attribute has no
9107 scalar parts (e.g., if the prefix is of an access type, an interface type,
9108 an undiscriminated task type, or an undiscriminated protected type).
9110 @node Attribute VADS_Size
9111 @unnumberedsec Attribute VADS_Size
9112 @cindex @code{Size}, VADS compatibility
9113 @findex VADS_Size
9114 @noindent
9115 The @code{'VADS_Size} attribute is intended to make it easier to port
9116 legacy code which relies on the semantics of @code{'Size} as implemented
9117 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
9118 same semantic interpretation.  In particular, @code{'VADS_Size} applied
9119 to a predefined or other primitive type with no Size clause yields the
9120 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
9121 typical machines).  In addition @code{'VADS_Size} applied to an object
9122 gives the result that would be obtained by applying the attribute to
9123 the corresponding type.
9125 @node Attribute Value_Size
9126 @unnumberedsec Attribute Value_Size
9127 @cindex @code{Size}, setting for not-first subtype
9128 @findex Value_Size
9129 @code{@var{type}'Value_Size} is the number of bits required to represent
9130 a value of the given subtype.  It is the same as @code{@var{type}'Size},
9131 but, unlike @code{Size}, may be set for non-first subtypes.
9133 @node Attribute Wchar_T_Size
9134 @unnumberedsec Attribute Wchar_T_Size
9135 @findex Wchar_T_Size
9136 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
9137 prefix) provides the size in bits of the C @code{wchar_t} type
9138 primarily for constructing the definition of this type in
9139 package @code{Interfaces.C}.
9141 @node Attribute Word_Size
9142 @unnumberedsec Attribute Word_Size
9143 @findex Word_Size
9144 @code{Standard'Word_Size} (@code{Standard} is the only permissible
9145 prefix) provides the value @code{System.Word_Size}.
9147 @node Standard and Implementation Defined Restrictions
9148 @chapter Standard and Implementation Defined Restrictions
9150 @noindent
9151 All RM defined Restriction identifiers are implemented:
9153 @itemize @bullet
9154 @item language-defined restrictions (see 13.12.1)
9155 @item tasking restrictions (see D.7)
9156 @item high integrity restrictions (see H.4)
9157 @end itemize
9159 @noindent
9160 GNAT implements additional restriction identifiers. All restrictions, whether
9161 language defined or GNAT-specific, are listed in the following.
9163 @menu
9164 * Partition-Wide Restrictions::
9165 * Program Unit Level Restrictions::
9166 @end menu
9168 @node Partition-Wide Restrictions
9169 @section Partition-Wide Restrictions
9171 There are two separate lists of restriction identifiers. The first
9172 set requires consistency throughout a partition (in other words, if the
9173 restriction identifier is used for any compilation unit in the partition,
9174 then all compilation units in the partition must obey the restriction).
9176 @menu
9177 * Immediate_Reclamation::
9178 * Max_Asynchronous_Select_Nesting::
9179 * Max_Entry_Queue_Length::
9180 * Max_Protected_Entries::
9181 * Max_Select_Alternatives::
9182 * Max_Storage_At_Blocking::
9183 * Max_Task_Entries::
9184 * Max_Tasks::
9185 * No_Abort_Statements::
9186 * No_Access_Parameter_Allocators::
9187 * No_Access_Subprograms::
9188 * No_Allocators::
9189 * No_Anonymous_Allocators::
9190 * No_Calendar::
9191 * No_Coextensions::
9192 * No_Default_Initialization::
9193 * No_Delay::
9194 * No_Dependence::
9195 * No_Direct_Boolean_Operators::
9196 * No_Dispatch::
9197 * No_Dispatching_Calls::
9198 * No_Dynamic_Attachment::
9199 * No_Dynamic_Priorities::
9200 * No_Entry_Calls_In_Elaboration_Code::
9201 * No_Enumeration_Maps::
9202 * No_Exception_Handlers::
9203 * No_Exception_Propagation::
9204 * No_Exception_Registration::
9205 * No_Exceptions::
9206 * No_Finalization::
9207 * No_Fixed_Point::
9208 * No_Floating_Point::
9209 * No_Implicit_Conditionals::
9210 * No_Implicit_Dynamic_Code::
9211 * No_Implicit_Heap_Allocations::
9212 * No_Implicit_Loops::
9213 * No_Initialize_Scalars::
9214 * No_IO::
9215 * No_Local_Allocators::
9216 * No_Local_Protected_Objects::
9217 * No_Local_Timing_Events::
9218 * No_Nested_Finalization::
9219 * No_Protected_Type_Allocators::
9220 * No_Protected_Types::
9221 * No_Recursion::
9222 * No_Reentrancy::
9223 * No_Relative_Delay::
9224 * No_Requeue_Statements::
9225 * No_Secondary_Stack::
9226 * No_Select_Statements::
9227 * No_Specific_Termination_Handlers::
9228 * No_Specification_of_Aspect::
9229 * No_Standard_Allocators_After_Elaboration::
9230 * No_Standard_Storage_Pools::
9231 * No_Stream_Optimizations::
9232 * No_Streams::
9233 * No_Task_Allocators::
9234 * No_Task_Attributes_Package::
9235 * No_Task_Hierarchy::
9236 * No_Task_Termination::
9237 * No_Tasking::
9238 * No_Terminate_Alternatives::
9239 * No_Unchecked_Access::
9240 * Simple_Barriers::
9241 * Static_Priorities::
9242 * Static_Storage_Size::
9243 @end menu
9245 @node Immediate_Reclamation
9246 @unnumberedsubsec Immediate_Reclamation
9247 @findex Immediate_Reclamation
9248 [RM H.4] This restriction ensures that, except for storage occupied by
9249 objects created by allocators and not deallocated via unchecked
9250 deallocation, any storage reserved at run time for an object is
9251 immediately reclaimed when the object no longer exists.
9253 @node Max_Asynchronous_Select_Nesting
9254 @unnumberedsubsec Max_Asynchronous_Select_Nesting
9255 @findex Max_Asynchronous_Select_Nesting
9256 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
9257 selects. Violations of this restriction with a value of zero are
9258 detected at compile time. Violations of this restriction with values
9259 other than zero cause Storage_Error to be raised.
9261 @node Max_Entry_Queue_Length
9262 @unnumberedsubsec Max_Entry_Queue_Length
9263 @findex Max_Entry_Queue_Length
9264 [RM D.7] This restriction is a declaration that any protected entry compiled in
9265 the scope of the restriction has at most the specified number of
9266 tasks waiting on the entry at any one time, and so no queue is required.
9267 Note that this restriction is checked at run time. Violation of this
9268 restriction results in the raising of Program_Error exception at the point of
9269 the call.
9271 @findex Max_Entry_Queue_Depth
9272 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
9273 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
9274 compatibility purposes (and a warning will be generated for its use if
9275 warnings on obsolescent features are activated).
9277 @node Max_Protected_Entries
9278 @unnumberedsubsec Max_Protected_Entries
9279 @findex Max_Protected_Entries
9280 [RM D.7] Specifies the maximum number of entries per protected type. The
9281 bounds of every entry family of a protected unit shall be static, or shall be
9282 defined by a discriminant of a subtype whose corresponding bound is static.
9284 @node Max_Select_Alternatives
9285 @unnumberedsubsec Max_Select_Alternatives
9286 @findex Max_Select_Alternatives
9287 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
9289 @node Max_Storage_At_Blocking
9290 @unnumberedsubsec Max_Storage_At_Blocking
9291 @findex Max_Storage_At_Blocking
9292 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
9293 Storage_Size that can be retained by a blocked task. A violation of this
9294 restriction causes Storage_Error to be raised.
9296 @node Max_Task_Entries
9297 @unnumberedsubsec Max_Task_Entries
9298 @findex Max_Task_Entries
9299 [RM D.7] Specifies the maximum number of entries
9300 per task.  The bounds of every entry family
9301 of a task unit shall be static, or shall be
9302 defined by a discriminant of a subtype whose
9303 corresponding bound is static.
9305 @node Max_Tasks
9306 @unnumberedsubsec Max_Tasks
9307 @findex Max_Tasks
9308 [RM D.7] Specifies the maximum number of task that may be created, not
9309 counting the creation of the environment task.  Violations of this
9310 restriction with a value of zero are detected at compile
9311 time. Violations of this restriction with values other than zero cause
9312 Storage_Error to be raised.
9314 @node No_Abort_Statements
9315 @unnumberedsubsec No_Abort_Statements
9316 @findex No_Abort_Statements
9317 [RM D.7] There are no abort_statements, and there are
9318 no calls to Task_Identification.Abort_Task.
9320 @node No_Access_Parameter_Allocators
9321 @unnumberedsubsec No_Access_Parameter_Allocators
9322 @findex No_Access_Parameter_Allocators
9323 [RM H.4] This restriction ensures at compile time that there are no
9324 occurrences of an allocator as the actual parameter to an access
9325 parameter.
9327 @node No_Access_Subprograms
9328 @unnumberedsubsec No_Access_Subprograms
9329 @findex No_Access_Subprograms
9330 [RM H.4] This restriction ensures at compile time that there are no
9331 declarations of access-to-subprogram types.
9333 @node No_Allocators
9334 @unnumberedsubsec No_Allocators
9335 @findex No_Allocators
9336 [RM H.4] This restriction ensures at compile time that there are no
9337 occurrences of an allocator.
9339 @node No_Anonymous_Allocators
9340 @unnumberedsubsec No_Anonymous_Allocators
9341 @findex No_Anonymous_Allocators
9342 [RM H.4] This restriction ensures at compile time that there are no
9343 occurrences of an allocator of anonymous access type.
9345 @node No_Calendar
9346 @unnumberedsubsec No_Calendar
9347 @findex No_Calendar
9348 [GNAT] This restriction ensures at compile time that there is no implicit or
9349 explicit dependence on the package @code{Ada.Calendar}.
9351 @node No_Coextensions
9352 @unnumberedsubsec No_Coextensions
9353 @findex No_Coextensions
9354 [RM H.4] This restriction ensures at compile time that there are no
9355 coextensions. See 3.10.2.
9357 @node No_Default_Initialization
9358 @unnumberedsubsec No_Default_Initialization
9359 @findex No_Default_Initialization
9361 [GNAT] This restriction prohibits any instance of default initialization
9362 of variables.  The binder implements a consistency rule which prevents
9363 any unit compiled without the restriction from with'ing a unit with the
9364 restriction (this allows the generation of initialization procedures to
9365 be skipped, since you can be sure that no call is ever generated to an
9366 initialization procedure in a unit with the restriction active). If used
9367 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
9368 is to prohibit all cases of variables declared without a specific
9369 initializer (including the case of OUT scalar parameters).
9371 @node No_Delay
9372 @unnumberedsubsec No_Delay
9373 @findex No_Delay
9374 [RM H.4] This restriction ensures at compile time that there are no
9375 delay statements and no dependences on package Calendar.
9377 @node No_Dependence
9378 @unnumberedsubsec No_Dependence
9379 @findex No_Dependence
9380 [RM 13.12.1] This restriction checks at compile time that there are no
9381 dependence on a library unit.
9383 @node No_Direct_Boolean_Operators
9384 @unnumberedsubsec No_Direct_Boolean_Operators
9385 @findex No_Direct_Boolean_Operators
9386 [GNAT] This restriction ensures that no logical operators (and/or/xor)
9387 are used on operands of type Boolean (or any type derived from Boolean).
9388 This is intended for use in safety critical programs where the certification
9389 protocol requires the use of short-circuit (and then, or else) forms for all
9390 composite boolean operations.
9392 @node No_Dispatch
9393 @unnumberedsubsec No_Dispatch
9394 @findex No_Dispatch
9395 [RM H.4] This restriction ensures at compile time that there are no
9396 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
9398 @node No_Dispatching_Calls
9399 @unnumberedsubsec No_Dispatching_Calls
9400 @findex No_Dispatching_Calls
9401 [GNAT] This restriction ensures at compile time that the code generated by the
9402 compiler involves no dispatching calls. The use of this restriction allows the
9403 safe use of record extensions, classwide membership tests and other classwide
9404 features not involving implicit dispatching. This restriction ensures that
9405 the code contains no indirect calls through a dispatching mechanism. Note that
9406 this includes internally-generated calls created by the compiler, for example
9407 in the implementation of class-wide objects assignments. The
9408 membership test is allowed in the presence of this restriction, because its
9409 implementation requires no dispatching.
9410 This restriction is comparable to the official Ada restriction
9411 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
9412 all classwide constructs that do not imply dispatching.
9413 The following example indicates constructs that violate this restriction.
9415 @smallexample
9416 package Pkg is
9417   type T is tagged record
9418     Data : Natural;
9419   end record;
9420   procedure P (X : T);
9422   type DT is new T with record
9423     More_Data : Natural;
9424   end record;
9425   procedure Q (X : DT);
9426 end Pkg;
9428 with Pkg; use Pkg;
9429 procedure Example is
9430   procedure Test (O : T'Class) is
9431     N : Natural  := O'Size;--  Error: Dispatching call
9432     C : T'Class := O;      --  Error: implicit Dispatching Call
9433   begin
9434     if O in DT'Class then  --  OK   : Membership test
9435        Q (DT (O));         --  OK   : Type conversion plus direct call
9436     else
9437        P (O);              --  Error: Dispatching call
9438     end if;
9439   end Test;
9441   Obj : DT;
9442 begin
9443   P (Obj);                 --  OK   : Direct call
9444   P (T (Obj));             --  OK   : Type conversion plus direct call
9445   P (T'Class (Obj));       --  Error: Dispatching call
9447   Test (Obj);              --  OK   : Type conversion
9449   if Obj in T'Class then   --  OK   : Membership test
9450      null;
9451   end if;
9452 end Example;
9453 @end smallexample
9455 @node No_Dynamic_Attachment
9456 @unnumberedsubsec No_Dynamic_Attachment
9457 @findex No_Dynamic_Attachment
9458 [RM D.7] This restriction ensures that there is no call to any of the
9459 operations defined in package Ada.Interrupts
9460 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
9461 Detach_Handler, and Reference).
9463 @findex No_Dynamic_Interrupts
9464 The restriction @code{No_Dynamic_Interrupts} is recognized as a
9465 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
9466 compatibility purposes (and a warning will be generated for its use if
9467 warnings on obsolescent features are activated).
9469 @node No_Dynamic_Priorities
9470 @unnumberedsubsec No_Dynamic_Priorities
9471 @findex No_Dynamic_Priorities
9472 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
9474 @node No_Entry_Calls_In_Elaboration_Code
9475 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
9476 @findex No_Entry_Calls_In_Elaboration_Code
9477 [GNAT] This restriction ensures at compile time that no task or protected entry
9478 calls are made during elaboration code.  As a result of the use of this
9479 restriction, the compiler can assume that no code past an accept statement
9480 in a task can be executed at elaboration time.
9482 @node No_Enumeration_Maps
9483 @unnumberedsubsec No_Enumeration_Maps
9484 @findex No_Enumeration_Maps
9485 [GNAT] This restriction ensures at compile time that no operations requiring
9486 enumeration maps are used (that is Image and Value attributes applied
9487 to enumeration types).
9489 @node No_Exception_Handlers
9490 @unnumberedsubsec No_Exception_Handlers
9491 @findex No_Exception_Handlers
9492 [GNAT] This restriction ensures at compile time that there are no explicit
9493 exception handlers. It also indicates that no exception propagation will
9494 be provided. In this mode, exceptions may be raised but will result in
9495 an immediate call to the last chance handler, a routine that the user
9496 must define with the following profile:
9498 @smallexample @c ada
9499 procedure Last_Chance_Handler
9500   (Source_Location : System.Address; Line : Integer);
9501 pragma Export (C, Last_Chance_Handler,
9502                "__gnat_last_chance_handler");
9503 @end smallexample
9505 The parameter is a C null-terminated string representing a message to be
9506 associated with the exception (typically the source location of the raise
9507 statement generated by the compiler). The Line parameter when nonzero
9508 represents the line number in the source program where the raise occurs.
9510 @node No_Exception_Propagation
9511 @unnumberedsubsec No_Exception_Propagation
9512 @findex No_Exception_Propagation
9513 [GNAT] This restriction guarantees that exceptions are never propagated
9514 to an outer subprogram scope. The only case in which an exception may
9515 be raised is when the handler is statically in the same subprogram, so
9516 that the effect of a raise is essentially like a goto statement. Any
9517 other raise statement (implicit or explicit) will be considered
9518 unhandled. Exception handlers are allowed, but may not contain an
9519 exception occurrence identifier (exception choice). In addition, use of
9520 the package GNAT.Current_Exception is not permitted, and reraise
9521 statements (raise with no operand) are not permitted.
9523 @node No_Exception_Registration
9524 @unnumberedsubsec No_Exception_Registration
9525 @findex No_Exception_Registration
9526 [GNAT] This restriction ensures at compile time that no stream operations for
9527 types Exception_Id or Exception_Occurrence are used. This also makes it
9528 impossible to pass exceptions to or from a partition with this restriction
9529 in a distributed environment. If this exception is active, then the generated
9530 code is simplified by omitting the otherwise-required global registration
9531 of exceptions when they are declared.
9533 @node No_Exceptions
9534 @unnumberedsubsec No_Exceptions
9535 @findex No_Exceptions
9536 [RM H.4] This restriction ensures at compile time that there are no
9537 raise statements and no exception handlers.
9539 @node No_Finalization
9540 @unnumberedsubsec No_Finalization
9541 @findex No_Finalization
9542 [GNAT] This restriction disables the language features described in
9543 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
9544 performed by the compiler to support these features. The following types
9545 are no longer considered controlled when this restriction is in effect:
9546 @itemize @bullet
9547 @item
9548 @code{Ada.Finalization.Controlled}
9549 @item
9550 @code{Ada.Finalization.Limited_Controlled}
9551 @item
9552 Derivations from @code{Controlled} or @code{Limited_Controlled}
9553 @item
9554 Class-wide types
9555 @item
9556 Protected types
9557 @item
9558 Task types
9559 @item
9560 Array and record types with controlled components
9561 @end itemize
9562 The compiler no longer generates code to initialize, finalize or adjust an
9563 object or a nested component, either declared on the stack or on the heap. The
9564 deallocation of a controlled object no longer finalizes its contents.
9566 @node No_Fixed_Point
9567 @unnumberedsubsec No_Fixed_Point
9568 @findex No_Fixed_Point
9569 [RM H.4] This restriction ensures at compile time that there are no
9570 occurrences of fixed point types and operations.
9572 @node No_Floating_Point
9573 @unnumberedsubsec No_Floating_Point
9574 @findex No_Floating_Point
9575 [RM H.4] This restriction ensures at compile time that there are no
9576 occurrences of floating point types and operations.
9578 @node No_Implicit_Conditionals
9579 @unnumberedsubsec No_Implicit_Conditionals
9580 @findex No_Implicit_Conditionals
9581 [GNAT] This restriction ensures that the generated code does not contain any
9582 implicit conditionals, either by modifying the generated code where possible,
9583 or by rejecting any construct that would otherwise generate an implicit
9584 conditional. Note that this check does not include run time constraint
9585 checks, which on some targets may generate implicit conditionals as
9586 well. To control the latter, constraint checks can be suppressed in the
9587 normal manner. Constructs generating implicit conditionals include comparisons
9588 of composite objects and the Max/Min attributes.
9590 @node No_Implicit_Dynamic_Code
9591 @unnumberedsubsec No_Implicit_Dynamic_Code
9592 @findex No_Implicit_Dynamic_Code
9593 @cindex trampoline
9594 [GNAT] This restriction prevents the compiler from building ``trampolines''.
9595 This is a structure that is built on the stack and contains dynamic
9596 code to be executed at run time. On some targets, a trampoline is
9597 built for the following features: @code{Access},
9598 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
9599 nested task bodies; primitive operations of nested tagged types.
9600 Trampolines do not work on machines that prevent execution of stack
9601 data. For example, on windows systems, enabling DEP (data execution
9602 protection) will cause trampolines to raise an exception.
9603 Trampolines are also quite slow at run time.
9605 On many targets, trampolines have been largely eliminated. Look at the
9606 version of system.ads for your target --- if it has
9607 Always_Compatible_Rep equal to False, then trampolines are largely
9608 eliminated. In particular, a trampoline is built for the following
9609 features: @code{Address} of a nested subprogram;
9610 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
9611 but only if pragma Favor_Top_Level applies, or the access type has a
9612 foreign-language convention; primitive operations of nested tagged
9613 types.
9615 @node No_Implicit_Heap_Allocations
9616 @unnumberedsubsec No_Implicit_Heap_Allocations
9617 @findex No_Implicit_Heap_Allocations
9618 [RM D.7] No constructs are allowed to cause implicit heap allocation.
9620 @node No_Implicit_Loops
9621 @unnumberedsubsec No_Implicit_Loops
9622 @findex No_Implicit_Loops
9623 [GNAT] This restriction ensures that the generated code does not contain any
9624 implicit @code{for} loops, either by modifying
9625 the generated code where possible,
9626 or by rejecting any construct that would otherwise generate an implicit
9627 @code{for} loop. If this restriction is active, it is possible to build
9628 large array aggregates with all static components without generating an
9629 intermediate temporary, and without generating a loop to initialize individual
9630 components. Otherwise, a loop is created for arrays larger than about 5000
9631 scalar components.
9633 @node No_Initialize_Scalars
9634 @unnumberedsubsec No_Initialize_Scalars
9635 @findex No_Initialize_Scalars
9636 [GNAT] This restriction ensures that no unit in the partition is compiled with
9637 pragma Initialize_Scalars. This allows the generation of more efficient
9638 code, and in particular eliminates dummy null initialization routines that
9639 are otherwise generated for some record and array types.
9641 @node No_IO
9642 @unnumberedsubsec No_IO
9643 @findex No_IO
9644 [RM H.4] This restriction ensures at compile time that there are no
9645 dependences on any of the library units Sequential_IO, Direct_IO,
9646 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
9648 @node No_Local_Allocators
9649 @unnumberedsubsec No_Local_Allocators
9650 @findex No_Local_Allocators
9651 [RM H.4] This restriction ensures at compile time that there are no
9652 occurrences of an allocator in subprograms, generic subprograms, tasks,
9653 and entry bodies.
9655 @node No_Local_Protected_Objects
9656 @unnumberedsubsec No_Local_Protected_Objects
9657 @findex No_Local_Protected_Objects
9658 [RM D.7] This restriction ensures at compile time that protected objects are
9659 only declared at the library level.
9661 @node No_Local_Timing_Events
9662 @unnumberedsubsec No_Local_Timing_Events
9663 @findex No_Local_Timing_Events
9664 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
9665 declared at the library level.
9667 @node No_Nested_Finalization
9668 @unnumberedsubsec No_Nested_Finalization
9669 @findex No_Nested_Finalization
9670 [RM D.7] All objects requiring finalization are declared at the library level.
9672 @node No_Protected_Type_Allocators
9673 @unnumberedsubsec No_Protected_Type_Allocators
9674 @findex No_Protected_Type_Allocators
9675 [RM D.7] This restriction ensures at compile time that there are no allocator
9676 expressions that attempt to allocate protected objects.
9678 @node No_Protected_Types
9679 @unnumberedsubsec No_Protected_Types
9680 @findex No_Protected_Types
9681 [RM H.4] This restriction ensures at compile time that there are no
9682 declarations of protected types or protected objects.
9684 @node No_Recursion
9685 @unnumberedsubsec No_Recursion
9686 @findex No_Recursion
9687 [RM H.4] A program execution is erroneous if a subprogram is invoked as
9688 part of its execution.
9690 @node No_Reentrancy
9691 @unnumberedsubsec No_Reentrancy
9692 @findex No_Reentrancy
9693 [RM H.4] A program execution is erroneous if a subprogram is executed by
9694 two tasks at the same time.
9696 @node No_Relative_Delay
9697 @unnumberedsubsec No_Relative_Delay
9698 @findex No_Relative_Delay
9699 [RM D.7] This restriction ensures at compile time that there are no delay
9700 relative statements and prevents expressions such as @code{delay 1.23;} from
9701 appearing in source code.
9703 @node No_Requeue_Statements
9704 @unnumberedsubsec No_Requeue_Statements
9705 @findex No_Requeue_Statements
9706 [RM D.7] This restriction ensures at compile time that no requeue statements
9707 are permitted and prevents keyword @code{requeue} from being used in source
9708 code.
9710 @findex No_Requeue
9711 The restriction @code{No_Requeue} is recognized as a
9712 synonym for @code{No_Requeue_Statements}. This is retained for historical
9713 compatibility purposes (and a warning will be generated for its use if
9714 warnings on oNobsolescent features are activated).
9716 @node No_Secondary_Stack
9717 @unnumberedsubsec No_Secondary_Stack
9718 @findex No_Secondary_Stack
9719 [GNAT] This restriction ensures at compile time that the generated code
9720 does not contain any reference to the secondary stack.  The secondary
9721 stack is used to implement functions returning unconstrained objects
9722 (arrays or records) on some targets.
9724 @node No_Select_Statements
9725 @unnumberedsubsec No_Select_Statements
9726 @findex No_Select_Statements
9727 [RM D.7] This restriction ensures at compile time no select statements of any
9728 kind are permitted, that is the keyword @code{select} may not appear.
9730 @node No_Specific_Termination_Handlers
9731 @unnumberedsubsec No_Specific_Termination_Handlers
9732 @findex No_Specific_Termination_Handlers
9733 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
9734 or to Ada.Task_Termination.Specific_Handler.
9736 @node No_Specification_of_Aspect
9737 @unnumberedsubsec No_Specification_of_Aspect
9738 @findex No_Specification_of_Aspect
9739 [RM 13.12.1] This restriction checks at compile time that no aspect
9740 specification, attribute definition clause, or pragma is given for a
9741 given aspect.
9743 @node No_Standard_Allocators_After_Elaboration
9744 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
9745 @findex No_Standard_Allocators_After_Elaboration
9746 [RM D.7] Specifies that an allocator using a standard storage pool
9747 should never be evaluated at run time after the elaboration of the
9748 library items of the partition has completed. Otherwise, Storage_Error
9749 is raised.
9751 @node No_Standard_Storage_Pools
9752 @unnumberedsubsec No_Standard_Storage_Pools
9753 @findex No_Standard_Storage_Pools
9754 [GNAT] This restriction ensures at compile time that no access types
9755 use the standard default storage pool.  Any access type declared must
9756 have an explicit Storage_Pool attribute defined specifying a
9757 user-defined storage pool.
9759 @node No_Stream_Optimizations
9760 @unnumberedsubsec No_Stream_Optimizations
9761 @findex No_Stream_Optimizations
9762 [GNAT] This restriction affects the performance of stream operations on types
9763 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
9764 compiler uses block reads and writes when manipulating @code{String} objects
9765 due to their supperior performance. When this restriction is in effect, the
9766 compiler performs all IO operations on a per-character basis.
9768 @node No_Streams
9769 @unnumberedsubsec No_Streams
9770 @findex No_Streams
9771 [GNAT] This restriction ensures at compile/bind time that there are no
9772 stream objects created and no use of stream attributes.
9773 This restriction does not forbid dependences on the package
9774 @code{Ada.Streams}. So it is permissible to with
9775 @code{Ada.Streams} (or another package that does so itself)
9776 as long as no actual stream objects are created and no
9777 stream attributes are used.
9779 Note that the use of restriction allows optimization of tagged types,
9780 since they do not need to worry about dispatching stream operations.
9781 To take maximum advantage of this space-saving optimization, any
9782 unit declaring a tagged type should be compiled with the restriction,
9783 though this is not required.
9785 @node No_Task_Allocators
9786 @unnumberedsubsec No_Task_Allocators
9787 @findex No_Task_Allocators
9788 [RM D.7] There are no allocators for task types
9789 or types containing task subcomponents.
9791 @node No_Task_Attributes_Package
9792 @unnumberedsubsec No_Task_Attributes_Package
9793 @findex No_Task_Attributes_Package
9794 [GNAT] This restriction ensures at compile time that there are no implicit or
9795 explicit dependencies on the package @code{Ada.Task_Attributes}.
9797 @findex No_Task_Attributes
9798 The restriction @code{No_Task_Attributes} is recognized as a synonym
9799 for @code{No_Task_Attributes_Package}. This is retained for historical
9800 compatibility purposes (and a warning will be generated for its use if
9801 warnings on obsolescent features are activated).
9803 @node No_Task_Hierarchy
9804 @unnumberedsubsec No_Task_Hierarchy
9805 @findex No_Task_Hierarchy
9806 [RM D.7] All (non-environment) tasks depend
9807 directly on the environment task of the partition.
9809 @node No_Task_Termination
9810 @unnumberedsubsec No_Task_Termination
9811 @findex No_Task_Termination
9812 [RM D.7] Tasks which terminate are erroneous.
9814 @node No_Tasking
9815 @unnumberedsubsec No_Tasking
9816 @findex No_Tasking
9817 [GNAT] This restriction prevents the declaration of tasks or task types
9818 throughout the partition.  It is similar in effect to the use of
9819 @code{Max_Tasks => 0} except that violations are caught at compile time
9820 and cause an error message to be output either by the compiler or
9821 binder.
9823 @node No_Terminate_Alternatives
9824 @unnumberedsubsec No_Terminate_Alternatives
9825 @findex No_Terminate_Alternatives
9826 [RM D.7] There are no selective accepts with terminate alternatives.
9828 @node No_Unchecked_Access
9829 @unnumberedsubsec No_Unchecked_Access
9830 @findex No_Unchecked_Access
9831 [RM H.4] This restriction ensures at compile time that there are no
9832 occurrences of the Unchecked_Access attribute.
9834 @node Simple_Barriers
9835 @unnumberedsubsec Simple_Barriers
9836 @findex Simple_Barriers
9837 [RM D.7] This restriction ensures at compile time that barriers in entry
9838 declarations for protected types are restricted to either static boolean
9839 expressions or references to simple boolean variables defined in the private
9840 part of the protected type.  No other form of entry barriers is permitted.
9842 @findex Boolean_Entry_Barriers
9843 The restriction @code{Boolean_Entry_Barriers} is recognized as a
9844 synonym for @code{Simple_Barriers}. This is retained for historical
9845 compatibility purposes (and a warning will be generated for its use if
9846 warnings on obsolescent features are activated).
9848 @node Static_Priorities
9849 @unnumberedsubsec Static_Priorities
9850 @findex Static_Priorities
9851 [GNAT] This restriction ensures at compile time that all priority expressions
9852 are static, and that there are no dependences on the package
9853 @code{Ada.Dynamic_Priorities}.
9855 @node Static_Storage_Size
9856 @unnumberedsubsec Static_Storage_Size
9857 @findex Static_Storage_Size
9858 [GNAT] This restriction ensures at compile time that any expression appearing
9859 in a Storage_Size pragma or attribute definition clause is static.
9861 @node Program Unit Level Restrictions
9862 @section Program Unit Level Restrictions
9864 @noindent
9865 The second set of restriction identifiers
9866 does not require partition-wide consistency.
9867 The restriction may be enforced for a single
9868 compilation unit without any effect on any of the
9869 other compilation units in the partition.
9871 @menu
9872 * No_Elaboration_Code::
9873 * No_Entry_Queue::
9874 * No_Implementation_Aspect_Specifications::
9875 * No_Implementation_Attributes::
9876 * No_Implementation_Identifiers::
9877 * No_Implementation_Pragmas::
9878 * No_Implementation_Restrictions::
9879 * No_Implementation_Units::
9880 * No_Implicit_Aliasing::
9881 * No_Obsolescent_Features::
9882 * No_Wide_Characters::
9883 * SPARK_05::
9884 @end menu
9886 @node No_Elaboration_Code
9887 @unnumberedsubsec No_Elaboration_Code
9888 @findex No_Elaboration_Code
9889 [GNAT] This restriction ensures at compile time that no elaboration code is
9890 generated.  Note that this is not the same condition as is enforced
9891 by pragma @code{Preelaborate}.  There are cases in which pragma
9892 @code{Preelaborate} still permits code to be generated (e.g.@: code
9893 to initialize a large array to all zeroes), and there are cases of units
9894 which do not meet the requirements for pragma @code{Preelaborate},
9895 but for which no elaboration code is generated.  Generally, it is
9896 the case that preelaborable units will meet the restrictions, with
9897 the exception of large aggregates initialized with an others_clause,
9898 and exception declarations (which generate calls to a run-time
9899 registry procedure).  This restriction is enforced on
9900 a unit by unit basis, it need not be obeyed consistently
9901 throughout a partition.
9903 In the case of aggregates with others, if the aggregate has a dynamic
9904 size, there is no way to eliminate the elaboration code (such dynamic
9905 bounds would be incompatible with @code{Preelaborate} in any case). If
9906 the bounds are static, then use of this restriction actually modifies
9907 the code choice of the compiler to avoid generating a loop, and instead
9908 generate the aggregate statically if possible, no matter how many times
9909 the data for the others clause must be repeatedly generated.
9911 It is not possible to precisely document
9912 the constructs which are compatible with this restriction, since,
9913 unlike most other restrictions, this is not a restriction on the
9914 source code, but a restriction on the generated object code. For
9915 example, if the source contains a declaration:
9917 @smallexample
9918    Val : constant Integer := X;
9919 @end smallexample
9921 @noindent
9922 where X is not a static constant, it may be possible, depending
9923 on complex optimization circuitry, for the compiler to figure
9924 out the value of X at compile time, in which case this initialization
9925 can be done by the loader, and requires no initialization code. It
9926 is not possible to document the precise conditions under which the
9927 optimizer can figure this out.
9929 Note that this the implementation of this restriction requires full
9930 code generation. If it is used in conjunction with "semantics only"
9931 checking, then some cases of violations may be missed.
9933 @node No_Entry_Queue
9934 @unnumberedsubsec No_Entry_Queue
9935 @findex No_Entry_Queue
9936 [GNAT] This restriction is a declaration that any protected entry compiled in
9937 the scope of the restriction has at most one task waiting on the entry
9938 at any one time, and so no queue is required.  This restriction is not
9939 checked at compile time.  A program execution is erroneous if an attempt
9940 is made to queue a second task on such an entry.
9942 @node No_Implementation_Aspect_Specifications
9943 @unnumberedsubsec No_Implementation_Aspect_Specifications
9944 @findex No_Implementation_Aspect_Specifications
9945 [RM 13.12.1] This restriction checks at compile time that no
9946 GNAT-defined aspects are present.  With this restriction, the only
9947 aspects that can be used are those defined in the Ada Reference Manual.
9949 @node No_Implementation_Attributes
9950 @unnumberedsubsec No_Implementation_Attributes
9951 @findex No_Implementation_Attributes
9952 [RM 13.12.1] This restriction checks at compile time that no
9953 GNAT-defined attributes are present.  With this restriction, the only
9954 attributes that can be used are those defined in the Ada Reference
9955 Manual.
9957 @node No_Implementation_Identifiers
9958 @unnumberedsubsec No_Implementation_Identifiers
9959 @findex No_Implementation_Identifiers
9960 [RM 13.12.1] This restriction checks at compile time that no
9961 implementation-defined identifiers (marked with pragma Implementation_Defined)
9962 occur within language-defined packages.
9964 @node No_Implementation_Pragmas
9965 @unnumberedsubsec No_Implementation_Pragmas
9966 @findex No_Implementation_Pragmas
9967 [RM 13.12.1] This restriction checks at compile time that no
9968 GNAT-defined pragmas are present.  With this restriction, the only
9969 pragmas that can be used are those defined in the Ada Reference Manual.
9971 @node No_Implementation_Restrictions
9972 @unnumberedsubsec No_Implementation_Restrictions
9973 @findex No_Implementation_Restrictions
9974 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
9975 identifiers (other than @code{No_Implementation_Restrictions} itself)
9976 are present.  With this restriction, the only other restriction identifiers
9977 that can be used are those defined in the Ada Reference Manual.
9979 @node No_Implementation_Units
9980 @unnumberedsubsec No_Implementation_Units
9981 @findex No_Implementation_Units
9982 [RM 13.12.1] This restriction checks at compile time that there is no
9983 mention in the context clause of any implementation-defined descendants
9984 of packages Ada, Interfaces, or System.
9986 @node No_Implicit_Aliasing
9987 @unnumberedsubsec No_Implicit_Aliasing
9988 @findex No_Implicit_Aliasing
9989 [GNAT] This restriction, which is not required to be partition-wide consistent,
9990 requires an explicit aliased keyword for an object to which 'Access,
9991 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
9992 the 'Unrestricted_Access attribute for objects. Note: the reason that
9993 Unrestricted_Access is forbidden is that it would require the prefix
9994 to be aliased, and in such cases, it can always be replaced by
9995 the standard attribute Unchecked_Access which is preferable.
9997 @node No_Obsolescent_Features
9998 @unnumberedsubsec No_Obsolescent_Features
9999 @findex No_Obsolescent_Features
10000 [RM 13.12.1] This restriction checks at compile time that no obsolescent
10001 features are used, as defined in Annex J of the Ada Reference Manual.
10003 @node No_Wide_Characters
10004 @unnumberedsubsec No_Wide_Characters
10005 @findex No_Wide_Characters
10006 [GNAT] This restriction ensures at compile time that no uses of the types
10007 @code{Wide_Character} or @code{Wide_String} or corresponding wide
10008 wide types
10009 appear, and that no wide or wide wide string or character literals
10010 appear in the program (that is literals representing characters not in
10011 type @code{Character}).
10013 @node SPARK_05
10014 @unnumberedsubsec SPARK_05
10015 @findex SPARK_05
10016 [GNAT] This restriction checks at compile time that some constructs
10017 forbidden in SPARK 2005 are not present. Error messages related to
10018 SPARK restriction have the form:
10020 @findex SPARK
10021 The restriction @code{SPARK} is recognized as a
10022 synonym for @code{SPARK_05}. This is retained for historical
10023 compatibility purposes (and an unconditional warning will be generated
10024 for its use, advising replacement by @code{SPARK}.
10026 @smallexample
10027 violation of restriction "SPARK" at <file>
10028  <error message>
10029 @end smallexample
10031 This is not a replacement for the semantic checks performed by the
10032 SPARK Examiner tool, as the compiler only deals currently with code,
10033 not at all with SPARK 2005 annotations and does not guarantee catching all
10034 cases of constructs forbidden by SPARK 2005.
10036 Thus it may well be the case that code which passes the compiler with
10037 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
10038 the different visibility rules of the Examiner based on SPARK 2005
10039 @code{inherit} annotations.
10041 This restriction can be useful in providing an initial filter for code
10042 developed using SPARK 2005, or in examining legacy code to see how far
10043 it is from meeting SPARK restrictions.
10045 Note that if a unit is compiled in Ada 95 mode with SPARK restriction,
10046 violations will be reported for constructs forbidden in SPARK 95,
10047 instead of SPARK 2005.
10049 @c ------------------------
10050 @node Implementation Advice
10051 @chapter Implementation Advice
10052 @noindent
10053 The main text of the Ada Reference Manual describes the required
10054 behavior of all Ada compilers, and the GNAT compiler conforms to
10055 these requirements.
10057 In addition, there are sections throughout the Ada Reference Manual headed
10058 by the phrase ``Implementation advice''.  These sections are not normative,
10059 i.e., they do not specify requirements that all compilers must
10060 follow.  Rather they provide advice on generally desirable behavior.  You
10061 may wonder why they are not requirements.  The most typical answer is
10062 that they describe behavior that seems generally desirable, but cannot
10063 be provided on all systems, or which may be undesirable on some systems.
10065 As far as practical, GNAT follows the implementation advice sections in
10066 the Ada Reference Manual.  This chapter contains a table giving the
10067 reference manual section number, paragraph number and several keywords
10068 for each advice.  Each entry consists of the text of the advice followed
10069 by the GNAT interpretation of this advice.  Most often, this simply says
10070 ``followed'', which means that GNAT follows the advice.  However, in a
10071 number of cases, GNAT deliberately deviates from this advice, in which
10072 case the text describes what GNAT does and why.
10074 @cindex Error detection
10075 @unnumberedsec 1.1.3(20): Error Detection
10076 @sp 1
10077 @cartouche
10078 If an implementation detects the use of an unsupported Specialized Needs
10079 Annex feature at run time, it should raise @code{Program_Error} if
10080 feasible.
10081 @end cartouche
10082 Not relevant.  All specialized needs annex features are either supported,
10083 or diagnosed at compile time.
10085 @cindex Child Units
10086 @unnumberedsec 1.1.3(31): Child Units
10087 @sp 1
10088 @cartouche
10089 If an implementation wishes to provide implementation-defined
10090 extensions to the functionality of a language-defined library unit, it
10091 should normally do so by adding children to the library unit.
10092 @end cartouche
10093 Followed.
10095 @cindex Bounded errors
10096 @unnumberedsec 1.1.5(12): Bounded Errors
10097 @sp 1
10098 @cartouche
10099 If an implementation detects a bounded error or erroneous
10100 execution, it should raise @code{Program_Error}.
10101 @end cartouche
10102 Followed in all cases in which the implementation detects a bounded
10103 error or erroneous execution.  Not all such situations are detected at
10104 runtime.
10106 @cindex Pragmas
10107 @unnumberedsec 2.8(16): Pragmas
10108 @sp 1
10109 @cartouche
10110 Normally, implementation-defined pragmas should have no semantic effect
10111 for error-free programs; that is, if the implementation-defined pragmas
10112 are removed from a working program, the program should still be legal,
10113 and should still have the same semantics.
10114 @end cartouche
10115 The following implementation defined pragmas are exceptions to this
10116 rule:
10118 @table @code
10119 @item Abort_Defer
10120 Affects semantics
10121 @item Ada_83
10122 Affects legality
10123 @item Assert
10124 Affects semantics
10125 @item CPP_Class
10126 Affects semantics
10127 @item CPP_Constructor
10128 Affects semantics
10129 @item Debug
10130 Affects semantics
10131 @item Interface_Name
10132 Affects semantics
10133 @item Machine_Attribute
10134 Affects semantics
10135 @item Unimplemented_Unit
10136 Affects legality
10137 @item Unchecked_Union
10138 Affects semantics
10139 @end table
10141 @noindent
10142 In each of the above cases, it is essential to the purpose of the pragma
10143 that this advice not be followed.  For details see the separate section
10144 on implementation defined pragmas.
10146 @unnumberedsec 2.8(17-19): Pragmas
10147 @sp 1
10148 @cartouche
10149 Normally, an implementation should not define pragmas that can
10150 make an illegal program legal, except as follows:
10151 @end cartouche
10152 @sp 1
10153 @cartouche
10154 A pragma used to complete a declaration, such as a pragma @code{Import};
10155 @end cartouche
10156 @sp 1
10157 @cartouche
10158 A pragma used to configure the environment by adding, removing, or
10159 replacing @code{library_items}.
10160 @end cartouche
10161 See response to paragraph 16 of this same section.
10163 @cindex Character Sets
10164 @cindex Alternative Character Sets
10165 @unnumberedsec 3.5.2(5): Alternative Character Sets
10166 @sp 1
10167 @cartouche
10168 If an implementation supports a mode with alternative interpretations
10169 for @code{Character} and @code{Wide_Character}, the set of graphic
10170 characters of @code{Character} should nevertheless remain a proper
10171 subset of the set of graphic characters of @code{Wide_Character}.  Any
10172 character set ``localizations'' should be reflected in the results of
10173 the subprograms defined in the language-defined package
10174 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
10175 an alternative interpretation of @code{Character}, the implementation should
10176 also support a corresponding change in what is a legal
10177 @code{identifier_letter}.
10178 @end cartouche
10179 Not all wide character modes follow this advice, in particular the JIS
10180 and IEC modes reflect standard usage in Japan, and in these encoding,
10181 the upper half of the Latin-1 set is not part of the wide-character
10182 subset, since the most significant bit is used for wide character
10183 encoding.  However, this only applies to the external forms.  Internally
10184 there is no such restriction.
10186 @cindex Integer types
10187 @unnumberedsec 3.5.4(28): Integer Types
10189 @sp 1
10190 @cartouche
10191 An implementation should support @code{Long_Integer} in addition to
10192 @code{Integer} if the target machine supports 32-bit (or longer)
10193 arithmetic.  No other named integer subtypes are recommended for package
10194 @code{Standard}.  Instead, appropriate named integer subtypes should be
10195 provided in the library package @code{Interfaces} (see B.2).
10196 @end cartouche
10197 @code{Long_Integer} is supported.  Other standard integer types are supported
10198 so this advice is not fully followed.  These types
10199 are supported for convenient interface to C, and so that all hardware
10200 types of the machine are easily available.
10201 @unnumberedsec 3.5.4(29): Integer Types
10203 @sp 1
10204 @cartouche
10205 An implementation for a two's complement machine should support
10206 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
10207 implementation should support a non-binary modules up to @code{Integer'Last}.
10208 @end cartouche
10209 Followed.
10211 @cindex Enumeration values
10212 @unnumberedsec 3.5.5(8): Enumeration Values
10213 @sp 1
10214 @cartouche
10215 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
10216 subtype, if the value of the operand does not correspond to the internal
10217 code for any enumeration literal of its type (perhaps due to an
10218 un-initialized variable), then the implementation should raise
10219 @code{Program_Error}.  This is particularly important for enumeration
10220 types with noncontiguous internal codes specified by an
10221 enumeration_representation_clause.
10222 @end cartouche
10223 Followed.
10225 @cindex Float types
10226 @unnumberedsec 3.5.7(17): Float Types
10227 @sp 1
10228 @cartouche
10229 An implementation should support @code{Long_Float} in addition to
10230 @code{Float} if the target machine supports 11 or more digits of
10231 precision.  No other named floating point subtypes are recommended for
10232 package @code{Standard}.  Instead, appropriate named floating point subtypes
10233 should be provided in the library package @code{Interfaces} (see B.2).
10234 @end cartouche
10235 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
10236 former provides improved compatibility with other implementations
10237 supporting this type.  The latter corresponds to the highest precision
10238 floating-point type supported by the hardware.  On most machines, this
10239 will be the same as @code{Long_Float}, but on some machines, it will
10240 correspond to the IEEE extended form.  The notable case is all ia32
10241 (x86) implementations, where @code{Long_Long_Float} corresponds to
10242 the 80-bit extended precision format supported in hardware on this
10243 processor.  Note that the 128-bit format on SPARC is not supported,
10244 since this is a software rather than a hardware format.
10246 @cindex Multidimensional arrays
10247 @cindex Arrays, multidimensional
10248 @unnumberedsec 3.6.2(11): Multidimensional Arrays
10249 @sp 1
10250 @cartouche
10251 An implementation should normally represent multidimensional arrays in
10252 row-major order, consistent with the notation used for multidimensional
10253 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
10254 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
10255 column-major order should be used instead (see B.5, ``Interfacing with
10256 Fortran'').
10257 @end cartouche
10258 Followed.
10260 @findex Duration'Small
10261 @unnumberedsec 9.6(30-31): Duration'Small
10262 @sp 1
10263 @cartouche
10264 Whenever possible in an implementation, the value of @code{Duration'Small}
10265 should be no greater than 100 microseconds.
10266 @end cartouche
10267 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
10269 @sp 1
10270 @cartouche
10271 The time base for @code{delay_relative_statements} should be monotonic;
10272 it need not be the same time base as used for @code{Calendar.Clock}.
10273 @end cartouche
10274 Followed.
10276 @unnumberedsec 10.2.1(12): Consistent Representation
10277 @sp 1
10278 @cartouche
10279 In an implementation, a type declared in a pre-elaborated package should
10280 have the same representation in every elaboration of a given version of
10281 the package, whether the elaborations occur in distinct executions of
10282 the same program, or in executions of distinct programs or partitions
10283 that include the given version.
10284 @end cartouche
10285 Followed, except in the case of tagged types.  Tagged types involve
10286 implicit pointers to a local copy of a dispatch table, and these pointers
10287 have representations which thus depend on a particular elaboration of the
10288 package.  It is not easy to see how it would be possible to follow this
10289 advice without severely impacting efficiency of execution.
10291 @cindex Exception information
10292 @unnumberedsec 11.4.1(19): Exception Information
10293 @sp 1
10294 @cartouche
10295 @code{Exception_Message} by default and @code{Exception_Information}
10296 should produce information useful for
10297 debugging.  @code{Exception_Message} should be short, about one
10298 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
10299 should not include the
10300 @code{Exception_Name}.  @code{Exception_Information} should include both
10301 the @code{Exception_Name} and the @code{Exception_Message}.
10302 @end cartouche
10303 Followed.  For each exception that doesn't have a specified
10304 @code{Exception_Message}, the compiler generates one containing the location
10305 of the raise statement.  This location has the form ``file:line'', where
10306 file is the short file name (without path information) and line is the line
10307 number in the file.  Note that in the case of the Zero Cost Exception
10308 mechanism, these messages become redundant with the Exception_Information that
10309 contains a full backtrace of the calling sequence, so they are disabled.
10310 To disable explicitly the generation of the source location message, use the
10311 Pragma @code{Discard_Names}.
10313 @cindex Suppression of checks
10314 @cindex Checks, suppression of
10315 @unnumberedsec 11.5(28): Suppression of Checks
10316 @sp 1
10317 @cartouche
10318 The implementation should minimize the code executed for checks that
10319 have been suppressed.
10320 @end cartouche
10321 Followed.
10323 @cindex Representation clauses
10324 @unnumberedsec 13.1 (21-24): Representation Clauses
10325 @sp 1
10326 @cartouche
10327 The recommended level of support for all representation items is
10328 qualified as follows:
10329 @end cartouche
10330 @sp 1
10331 @cartouche
10332 An implementation need not support representation items containing
10333 non-static expressions, except that an implementation should support a
10334 representation item for a given entity if each non-static expression in
10335 the representation item is a name that statically denotes a constant
10336 declared before the entity.
10337 @end cartouche
10338 Followed.  In fact, GNAT goes beyond the recommended level of support
10339 by allowing nonstatic expressions in some representation clauses even
10340 without the need to declare constants initialized with the values of
10341 such expressions.
10342 For example:
10344 @smallexample @c ada
10345   X : Integer;
10346   Y : Float;
10347   for Y'Address use X'Address;>>
10348 @end smallexample
10350 @sp 1
10351 @cartouche
10352 An implementation need not support a specification for the @code{Size}
10353 for a given composite subtype, nor the size or storage place for an
10354 object (including a component) of a given composite subtype, unless the
10355 constraints on the subtype and its composite subcomponents (if any) are
10356 all static constraints.
10357 @end cartouche
10358 Followed.  Size Clauses are not permitted on non-static components, as
10359 described above.
10361 @sp 1
10362 @cartouche
10363 An aliased component, or a component whose type is by-reference, should
10364 always be allocated at an addressable location.
10365 @end cartouche
10366 Followed.
10368 @cindex Packed types
10369 @unnumberedsec 13.2(6-8): Packed Types
10370 @sp 1
10371 @cartouche
10372 If a type is packed, then the implementation should try to minimize
10373 storage allocated to objects of the type, possibly at the expense of
10374 speed of accessing components, subject to reasonable complexity in
10375 addressing calculations.
10376 @end cartouche
10377 @sp 1
10378 @cartouche
10379 The recommended level of support pragma @code{Pack} is:
10381 For a packed record type, the components should be packed as tightly as
10382 possible subject to the Sizes of the component subtypes, and subject to
10383 any @code{record_representation_clause} that applies to the type; the
10384 implementation may, but need not, reorder components or cross aligned
10385 word boundaries to improve the packing.  A component whose @code{Size} is
10386 greater than the word size may be allocated an integral number of words.
10387 @end cartouche
10388 Followed.  Tight packing of arrays is supported for all component sizes
10389 up to 64-bits. If the array component size is 1 (that is to say, if
10390 the component is a boolean type or an enumeration type with two values)
10391 then values of the type are implicitly initialized to zero. This
10392 happens both for objects of the packed type, and for objects that have a
10393 subcomponent of the packed type.
10395 @sp 1
10396 @cartouche
10397 An implementation should support Address clauses for imported
10398 subprograms.
10399 @end cartouche
10400 Followed.
10401 @cindex @code{Address} clauses
10402 @unnumberedsec 13.3(14-19): Address Clauses
10404 @sp 1
10405 @cartouche
10406 For an array @var{X}, @code{@var{X}'Address} should point at the first
10407 component of the array, and not at the array bounds.
10408 @end cartouche
10409 Followed.
10411 @sp 1
10412 @cartouche
10413 The recommended level of support for the @code{Address} attribute is:
10415 @code{@var{X}'Address} should produce a useful result if @var{X} is an
10416 object that is aliased or of a by-reference type, or is an entity whose
10417 @code{Address} has been specified.
10418 @end cartouche
10419 Followed.  A valid address will be produced even if none of those
10420 conditions have been met.  If necessary, the object is forced into
10421 memory to ensure the address is valid.
10423 @sp 1
10424 @cartouche
10425 An implementation should support @code{Address} clauses for imported
10426 subprograms.
10427 @end cartouche
10428 Followed.
10430 @sp 1
10431 @cartouche
10432 Objects (including subcomponents) that are aliased or of a by-reference
10433 type should be allocated on storage element boundaries.
10434 @end cartouche
10435 Followed.
10437 @sp 1
10438 @cartouche
10439 If the @code{Address} of an object is specified, or it is imported or exported,
10440 then the implementation should not perform optimizations based on
10441 assumptions of no aliases.
10442 @end cartouche
10443 Followed.
10445 @cindex @code{Alignment} clauses
10446 @unnumberedsec 13.3(29-35): Alignment Clauses
10447 @sp 1
10448 @cartouche
10449 The recommended level of support for the @code{Alignment} attribute for
10450 subtypes is:
10452 An implementation should support specified Alignments that are factors
10453 and multiples of the number of storage elements per word, subject to the
10454 following:
10455 @end cartouche
10456 Followed.
10458 @sp 1
10459 @cartouche
10460 An implementation need not support specified @code{Alignment}s for
10461 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
10462 loaded and stored by available machine instructions.
10463 @end cartouche
10464 Followed.
10466 @sp 1
10467 @cartouche
10468 An implementation need not support specified @code{Alignment}s that are
10469 greater than the maximum @code{Alignment} the implementation ever returns by
10470 default.
10471 @end cartouche
10472 Followed.
10474 @sp 1
10475 @cartouche
10476 The recommended level of support for the @code{Alignment} attribute for
10477 objects is:
10479 Same as above, for subtypes, but in addition:
10480 @end cartouche
10481 Followed.
10483 @sp 1
10484 @cartouche
10485 For stand-alone library-level objects of statically constrained
10486 subtypes, the implementation should support all @code{Alignment}s
10487 supported by the target linker.  For example, page alignment is likely to
10488 be supported for such objects, but not for subtypes.
10489 @end cartouche
10490 Followed.
10492 @cindex @code{Size} clauses
10493 @unnumberedsec 13.3(42-43): Size Clauses
10494 @sp 1
10495 @cartouche
10496 The recommended level of support for the @code{Size} attribute of
10497 objects is:
10499 A @code{Size} clause should be supported for an object if the specified
10500 @code{Size} is at least as large as its subtype's @code{Size}, and
10501 corresponds to a size in storage elements that is a multiple of the
10502 object's @code{Alignment} (if the @code{Alignment} is nonzero).
10503 @end cartouche
10504 Followed.
10506 @unnumberedsec 13.3(50-56): Size Clauses
10507 @sp 1
10508 @cartouche
10509 If the @code{Size} of a subtype is specified, and allows for efficient
10510 independent addressability (see 9.10) on the target architecture, then
10511 the @code{Size} of the following objects of the subtype should equal the
10512 @code{Size} of the subtype:
10514 Aliased objects (including components).
10515 @end cartouche
10516 Followed.
10518 @sp 1
10519 @cartouche
10520 @code{Size} clause on a composite subtype should not affect the
10521 internal layout of components.
10522 @end cartouche
10523 Followed. But note that this can be overridden by use of the implementation
10524 pragma Implicit_Packing in the case of packed arrays.
10526 @sp 1
10527 @cartouche
10528 The recommended level of support for the @code{Size} attribute of subtypes is:
10529 @end cartouche
10530 @sp 1
10531 @cartouche
10532 The @code{Size} (if not specified) of a static discrete or fixed point
10533 subtype should be the number of bits needed to represent each value
10534 belonging to the subtype using an unbiased representation, leaving space
10535 for a sign bit only if the subtype contains negative values.  If such a
10536 subtype is a first subtype, then an implementation should support a
10537 specified @code{Size} for it that reflects this representation.
10538 @end cartouche
10539 Followed.
10541 @sp 1
10542 @cartouche
10543 For a subtype implemented with levels of indirection, the @code{Size}
10544 should include the size of the pointers, but not the size of what they
10545 point at.
10546 @end cartouche
10547 Followed.
10549 @cindex @code{Component_Size} clauses
10550 @unnumberedsec 13.3(71-73): Component Size Clauses
10551 @sp 1
10552 @cartouche
10553 The recommended level of support for the @code{Component_Size}
10554 attribute is:
10555 @end cartouche
10556 @sp 1
10557 @cartouche
10558 An implementation need not support specified @code{Component_Sizes} that are
10559 less than the @code{Size} of the component subtype.
10560 @end cartouche
10561 Followed.
10563 @sp 1
10564 @cartouche
10565 An implementation should support specified @code{Component_Size}s that
10566 are factors and multiples of the word size.  For such
10567 @code{Component_Size}s, the array should contain no gaps between
10568 components.  For other @code{Component_Size}s (if supported), the array
10569 should contain no gaps between components when packing is also
10570 specified; the implementation should forbid this combination in cases
10571 where it cannot support a no-gaps representation.
10572 @end cartouche
10573 Followed.
10575 @cindex Enumeration representation clauses
10576 @cindex Representation clauses, enumeration
10577 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
10578 @sp 1
10579 @cartouche
10580 The recommended level of support for enumeration representation clauses
10583 An implementation need not support enumeration representation clauses
10584 for boolean types, but should at minimum support the internal codes in
10585 the range @code{System.Min_Int.System.Max_Int}.
10586 @end cartouche
10587 Followed.
10589 @cindex Record representation clauses
10590 @cindex Representation clauses, records
10591 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
10592 @sp 1
10593 @cartouche
10594 The recommended level of support for
10595 @*@code{record_representation_clauses} is:
10597 An implementation should support storage places that can be extracted
10598 with a load, mask, shift sequence of machine code, and set with a load,
10599 shift, mask, store sequence, given the available machine instructions
10600 and run-time model.
10601 @end cartouche
10602 Followed.
10604 @sp 1
10605 @cartouche
10606 A storage place should be supported if its size is equal to the
10607 @code{Size} of the component subtype, and it starts and ends on a
10608 boundary that obeys the @code{Alignment} of the component subtype.
10609 @end cartouche
10610 Followed.
10612 @sp 1
10613 @cartouche
10614 If the default bit ordering applies to the declaration of a given type,
10615 then for a component whose subtype's @code{Size} is less than the word
10616 size, any storage place that does not cross an aligned word boundary
10617 should be supported.
10618 @end cartouche
10619 Followed.
10621 @sp 1
10622 @cartouche
10623 An implementation may reserve a storage place for the tag field of a
10624 tagged type, and disallow other components from overlapping that place.
10625 @end cartouche
10626 Followed.  The storage place for the tag field is the beginning of the tagged
10627 record, and its size is Address'Size.  GNAT will reject an explicit component
10628 clause for the tag field.
10630 @sp 1
10631 @cartouche
10632 An implementation need not support a @code{component_clause} for a
10633 component of an extension part if the storage place is not after the
10634 storage places of all components of the parent type, whether or not
10635 those storage places had been specified.
10636 @end cartouche
10637 Followed.  The above advice on record representation clauses is followed,
10638 and all mentioned features are implemented.
10640 @cindex Storage place attributes
10641 @unnumberedsec 13.5.2(5): Storage Place Attributes
10642 @sp 1
10643 @cartouche
10644 If a component is represented using some form of pointer (such as an
10645 offset) to the actual data of the component, and this data is contiguous
10646 with the rest of the object, then the storage place attributes should
10647 reflect the place of the actual data, not the pointer.  If a component is
10648 allocated discontinuously from the rest of the object, then a warning
10649 should be generated upon reference to one of its storage place
10650 attributes.
10651 @end cartouche
10652 Followed.  There are no such components in GNAT@.
10654 @cindex Bit ordering
10655 @unnumberedsec 13.5.3(7-8): Bit Ordering
10656 @sp 1
10657 @cartouche
10658 The recommended level of support for the non-default bit ordering is:
10659 @end cartouche
10660 @sp 1
10661 @cartouche
10662 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
10663 should support the non-default bit ordering in addition to the default
10664 bit ordering.
10665 @end cartouche
10666 Followed.  Word size does not equal storage size in this implementation.
10667 Thus non-default bit ordering is not supported.
10669 @cindex @code{Address}, as private type
10670 @unnumberedsec 13.7(37): Address as Private
10671 @sp 1
10672 @cartouche
10673 @code{Address} should be of a private type.
10674 @end cartouche
10675 Followed.
10677 @cindex Operations, on @code{Address}
10678 @cindex @code{Address}, operations of
10679 @unnumberedsec 13.7.1(16): Address Operations
10680 @sp 1
10681 @cartouche
10682 Operations in @code{System} and its children should reflect the target
10683 environment semantics as closely as is reasonable.  For example, on most
10684 machines, it makes sense for address arithmetic to ``wrap around''.
10685 Operations that do not make sense should raise @code{Program_Error}.
10686 @end cartouche
10687 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
10688 operation raises @code{Program_Error}, since all operations make sense.
10690 @cindex Unchecked conversion
10691 @unnumberedsec 13.9(14-17): Unchecked Conversion
10692 @sp 1
10693 @cartouche
10694 The @code{Size} of an array object should not include its bounds; hence,
10695 the bounds should not be part of the converted data.
10696 @end cartouche
10697 Followed.
10699 @sp 1
10700 @cartouche
10701 The implementation should not generate unnecessary run-time checks to
10702 ensure that the representation of @var{S} is a representation of the
10703 target type.  It should take advantage of the permission to return by
10704 reference when possible.  Restrictions on unchecked conversions should be
10705 avoided unless required by the target environment.
10706 @end cartouche
10707 Followed.  There are no restrictions on unchecked conversion.  A warning is
10708 generated if the source and target types do not have the same size since
10709 the semantics in this case may be target dependent.
10711 @sp 1
10712 @cartouche
10713 The recommended level of support for unchecked conversions is:
10714 @end cartouche
10715 @sp 1
10716 @cartouche
10717 Unchecked conversions should be supported and should be reversible in
10718 the cases where this clause defines the result.  To enable meaningful use
10719 of unchecked conversion, a contiguous representation should be used for
10720 elementary subtypes, for statically constrained array subtypes whose
10721 component subtype is one of the subtypes described in this paragraph,
10722 and for record subtypes without discriminants whose component subtypes
10723 are described in this paragraph.
10724 @end cartouche
10725 Followed.
10727 @cindex Heap usage, implicit
10728 @unnumberedsec 13.11(23-25): Implicit Heap Usage
10729 @sp 1
10730 @cartouche
10731 An implementation should document any cases in which it dynamically
10732 allocates heap storage for a purpose other than the evaluation of an
10733 allocator.
10734 @end cartouche
10735 Followed, the only other points at which heap storage is dynamically
10736 allocated are as follows:
10738 @itemize @bullet
10739 @item
10740 At initial elaboration time, to allocate dynamically sized global
10741 objects.
10743 @item
10744 To allocate space for a task when a task is created.
10746 @item
10747 To extend the secondary stack dynamically when needed.  The secondary
10748 stack is used for returning variable length results.
10749 @end itemize
10751 @sp 1
10752 @cartouche
10753 A default (implementation-provided) storage pool for an
10754 access-to-constant type should not have overhead to support deallocation of
10755 individual objects.
10756 @end cartouche
10757 Followed.
10759 @sp 1
10760 @cartouche
10761 A storage pool for an anonymous access type should be created at the
10762 point of an allocator for the type, and be reclaimed when the designated
10763 object becomes inaccessible.
10764 @end cartouche
10765 Followed.
10767 @cindex Unchecked deallocation
10768 @unnumberedsec 13.11.2(17): Unchecked De-allocation
10769 @sp 1
10770 @cartouche
10771 For a standard storage pool, @code{Free} should actually reclaim the
10772 storage.
10773 @end cartouche
10774 Followed.
10776 @cindex Stream oriented attributes
10777 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
10778 @sp 1
10779 @cartouche
10780 If a stream element is the same size as a storage element, then the
10781 normal in-memory representation should be used by @code{Read} and
10782 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
10783 should use the smallest number of stream elements needed to represent
10784 all values in the base range of the scalar type.
10785 @end cartouche
10787 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
10788 which specifies using the size of the first subtype.
10789 However, such an implementation is based on direct binary
10790 representations and is therefore target- and endianness-dependent.
10791 To address this issue, GNAT also supplies an alternate implementation
10792 of the stream attributes @code{Read} and @code{Write},
10793 which uses the target-independent XDR standard representation
10794 for scalar types.
10795 @cindex XDR representation
10796 @cindex @code{Read} attribute
10797 @cindex @code{Write} attribute
10798 @cindex Stream oriented attributes
10799 The XDR implementation is provided as an alternative body of the
10800 @code{System.Stream_Attributes} package, in the file
10801 @file{s-stratt-xdr.adb} in the GNAT library.
10802 There is no @file{s-stratt-xdr.ads} file.
10803 In order to install the XDR implementation, do the following:
10804 @enumerate
10805 @item Replace the default implementation of the
10806 @code{System.Stream_Attributes} package with the XDR implementation.
10807 For example on a Unix platform issue the commands:
10808 @smallexample
10809 $ mv s-stratt.adb s-stratt-default.adb
10810 $ mv s-stratt-xdr.adb s-stratt.adb
10811 @end smallexample
10813 @item
10814 Rebuild the GNAT run-time library as documented in
10815 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
10816 @end enumerate
10818 @unnumberedsec A.1(52): Names of Predefined Numeric Types
10819 @sp 1
10820 @cartouche
10821 If an implementation provides additional named predefined integer types,
10822 then the names should end with @samp{Integer} as in
10823 @samp{Long_Integer}.  If an implementation provides additional named
10824 predefined floating point types, then the names should end with
10825 @samp{Float} as in @samp{Long_Float}.
10826 @end cartouche
10827 Followed.
10829 @findex Ada.Characters.Handling
10830 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
10831 @sp 1
10832 @cartouche
10833 If an implementation provides a localized definition of @code{Character}
10834 or @code{Wide_Character}, then the effects of the subprograms in
10835 @code{Characters.Handling} should reflect the localizations.  See also
10836 3.5.2.
10837 @end cartouche
10838 Followed.  GNAT provides no such localized definitions.
10840 @cindex Bounded-length strings
10841 @unnumberedsec A.4.4(106): Bounded-Length String Handling
10842 @sp 1
10843 @cartouche
10844 Bounded string objects should not be implemented by implicit pointers
10845 and dynamic allocation.
10846 @end cartouche
10847 Followed.  No implicit pointers or dynamic allocation are used.
10849 @cindex Random number generation
10850 @unnumberedsec A.5.2(46-47): Random Number Generation
10851 @sp 1
10852 @cartouche
10853 Any storage associated with an object of type @code{Generator} should be
10854 reclaimed on exit from the scope of the object.
10855 @end cartouche
10856 Followed.
10858 @sp 1
10859 @cartouche
10860 If the generator period is sufficiently long in relation to the number
10861 of distinct initiator values, then each possible value of
10862 @code{Initiator} passed to @code{Reset} should initiate a sequence of
10863 random numbers that does not, in a practical sense, overlap the sequence
10864 initiated by any other value.  If this is not possible, then the mapping
10865 between initiator values and generator states should be a rapidly
10866 varying function of the initiator value.
10867 @end cartouche
10868 Followed.  The generator period is sufficiently long for the first
10869 condition here to hold true.
10871 @findex Get_Immediate
10872 @unnumberedsec A.10.7(23): @code{Get_Immediate}
10873 @sp 1
10874 @cartouche
10875 The @code{Get_Immediate} procedures should be implemented with
10876 unbuffered input.  For a device such as a keyboard, input should be
10877 @dfn{available} if a key has already been typed, whereas for a disk
10878 file, input should always be available except at end of file.  For a file
10879 associated with a keyboard-like device, any line-editing features of the
10880 underlying operating system should be disabled during the execution of
10881 @code{Get_Immediate}.
10882 @end cartouche
10883 Followed on all targets except VxWorks. For VxWorks, there is no way to
10884 provide this functionality that does not result in the input buffer being
10885 flushed before the @code{Get_Immediate} call. A special unit
10886 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
10887 this functionality.
10889 @findex Export
10890 @unnumberedsec B.1(39-41): Pragma @code{Export}
10891 @sp 1
10892 @cartouche
10893 If an implementation supports pragma @code{Export} to a given language,
10894 then it should also allow the main subprogram to be written in that
10895 language.  It should support some mechanism for invoking the elaboration
10896 of the Ada library units included in the system, and for invoking the
10897 finalization of the environment task.  On typical systems, the
10898 recommended mechanism is to provide two subprograms whose link names are
10899 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
10900 elaboration code for library units.  @code{adafinal} should contain the
10901 finalization code.  These subprograms should have no effect the second
10902 and subsequent time they are called.
10903 @end cartouche
10904 Followed.
10906 @sp 1
10907 @cartouche
10908 Automatic elaboration of pre-elaborated packages should be
10909 provided when pragma @code{Export} is supported.
10910 @end cartouche
10911 Followed when the main program is in Ada.  If the main program is in a
10912 foreign language, then
10913 @code{adainit} must be called to elaborate pre-elaborated
10914 packages.
10916 @sp 1
10917 @cartouche
10918 For each supported convention @var{L} other than @code{Intrinsic}, an
10919 implementation should support @code{Import} and @code{Export} pragmas
10920 for objects of @var{L}-compatible types and for subprograms, and pragma
10921 @code{Convention} for @var{L}-eligible types and for subprograms,
10922 presuming the other language has corresponding features.  Pragma
10923 @code{Convention} need not be supported for scalar types.
10924 @end cartouche
10925 Followed.
10927 @cindex Package @code{Interfaces}
10928 @findex Interfaces
10929 @unnumberedsec B.2(12-13): Package @code{Interfaces}
10930 @sp 1
10931 @cartouche
10932 For each implementation-defined convention identifier, there should be a
10933 child package of package Interfaces with the corresponding name.  This
10934 package should contain any declarations that would be useful for
10935 interfacing to the language (implementation) represented by the
10936 convention.  Any declarations useful for interfacing to any language on
10937 the given hardware architecture should be provided directly in
10938 @code{Interfaces}.
10939 @end cartouche
10940 Followed. An additional package not defined
10941 in the Ada Reference Manual is @code{Interfaces.CPP}, used
10942 for interfacing to C++.
10944 @sp 1
10945 @cartouche
10946 An implementation supporting an interface to C, COBOL, or Fortran should
10947 provide the corresponding package or packages described in the following
10948 clauses.
10949 @end cartouche
10950 Followed.  GNAT provides all the packages described in this section.
10952 @cindex C, interfacing with
10953 @unnumberedsec B.3(63-71): Interfacing with C
10954 @sp 1
10955 @cartouche
10956 An implementation should support the following interface correspondences
10957 between Ada and C@.
10958 @end cartouche
10959 Followed.
10961 @sp 1
10962 @cartouche
10963 An Ada procedure corresponds to a void-returning C function.
10964 @end cartouche
10965 Followed.
10967 @sp 1
10968 @cartouche
10969 An Ada function corresponds to a non-void C function.
10970 @end cartouche
10971 Followed.
10973 @sp 1
10974 @cartouche
10975 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
10976 function.
10977 @end cartouche
10978 Followed.
10980 @sp 1
10981 @cartouche
10982 An Ada @code{in} parameter of an access-to-object type with designated
10983 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
10984 where @var{t} is the C type corresponding to the Ada type @var{T}.
10985 @end cartouche
10986 Followed.
10988 @sp 1
10989 @cartouche
10990 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
10991 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
10992 argument to a C function, where @var{t} is the C type corresponding to
10993 the Ada type @var{T}.  In the case of an elementary @code{out} or
10994 @code{in out} parameter, a pointer to a temporary copy is used to
10995 preserve by-copy semantics.
10996 @end cartouche
10997 Followed.
10999 @sp 1
11000 @cartouche
11001 An Ada parameter of a record type @var{T}, of any mode, is passed as a
11002 @code{@var{t}*} argument to a C function, where @var{t} is the C
11003 structure corresponding to the Ada type @var{T}.
11004 @end cartouche
11005 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
11006 pragma, or Convention, or by explicitly specifying the mechanism for a given
11007 call using an extended import or export pragma.
11009 @sp 1
11010 @cartouche
11011 An Ada parameter of an array type with component type @var{T}, of any
11012 mode, is passed as a @code{@var{t}*} argument to a C function, where
11013 @var{t} is the C type corresponding to the Ada type @var{T}.
11014 @end cartouche
11015 Followed.
11017 @sp 1
11018 @cartouche
11019 An Ada parameter of an access-to-subprogram type is passed as a pointer
11020 to a C function whose prototype corresponds to the designated
11021 subprogram's specification.
11022 @end cartouche
11023 Followed.
11025 @cindex COBOL, interfacing with
11026 @unnumberedsec B.4(95-98): Interfacing with COBOL
11027 @sp 1
11028 @cartouche
11029 An Ada implementation should support the following interface
11030 correspondences between Ada and COBOL@.
11031 @end cartouche
11032 Followed.
11034 @sp 1
11035 @cartouche
11036 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
11037 the COBOL type corresponding to @var{T}.
11038 @end cartouche
11039 Followed.
11041 @sp 1
11042 @cartouche
11043 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
11044 the corresponding COBOL type.
11045 @end cartouche
11046 Followed.
11048 @sp 1
11049 @cartouche
11050 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
11051 COBOL type corresponding to the Ada parameter type; for scalars, a local
11052 copy is used if necessary to ensure by-copy semantics.
11053 @end cartouche
11054 Followed.
11056 @cindex Fortran, interfacing with
11057 @unnumberedsec B.5(22-26): Interfacing with Fortran
11058 @sp 1
11059 @cartouche
11060 An Ada implementation should support the following interface
11061 correspondences between Ada and Fortran:
11062 @end cartouche
11063 Followed.
11065 @sp 1
11066 @cartouche
11067 An Ada procedure corresponds to a Fortran subroutine.
11068 @end cartouche
11069 Followed.
11071 @sp 1
11072 @cartouche
11073 An Ada function corresponds to a Fortran function.
11074 @end cartouche
11075 Followed.
11077 @sp 1
11078 @cartouche
11079 An Ada parameter of an elementary, array, or record type @var{T} is
11080 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
11081 the Fortran type corresponding to the Ada type @var{T}, and where the
11082 INTENT attribute of the corresponding dummy argument matches the Ada
11083 formal parameter mode; the Fortran implementation's parameter passing
11084 conventions are used.  For elementary types, a local copy is used if
11085 necessary to ensure by-copy semantics.
11086 @end cartouche
11087 Followed.
11089 @sp 1
11090 @cartouche
11091 An Ada parameter of an access-to-subprogram type is passed as a
11092 reference to a Fortran procedure whose interface corresponds to the
11093 designated subprogram's specification.
11094 @end cartouche
11095 Followed.
11097 @cindex Machine operations
11098 @unnumberedsec C.1(3-5): Access to Machine Operations
11099 @sp 1
11100 @cartouche
11101 The machine code or intrinsic support should allow access to all
11102 operations normally available to assembly language programmers for the
11103 target environment, including privileged instructions, if any.
11104 @end cartouche
11105 Followed.
11107 @sp 1
11108 @cartouche
11109 The interfacing pragmas (see Annex B) should support interface to
11110 assembler; the default assembler should be associated with the
11111 convention identifier @code{Assembler}.
11112 @end cartouche
11113 Followed.
11115 @sp 1
11116 @cartouche
11117 If an entity is exported to assembly language, then the implementation
11118 should allocate it at an addressable location, and should ensure that it
11119 is retained by the linking process, even if not otherwise referenced
11120 from the Ada code.  The implementation should assume that any call to a
11121 machine code or assembler subprogram is allowed to read or update every
11122 object that is specified as exported.
11123 @end cartouche
11124 Followed.
11126 @unnumberedsec C.1(10-16): Access to Machine Operations
11127 @sp 1
11128 @cartouche
11129 The implementation should ensure that little or no overhead is
11130 associated with calling intrinsic and machine-code subprograms.
11131 @end cartouche
11132 Followed for both intrinsics and machine-code subprograms.
11134 @sp 1
11135 @cartouche
11136 It is recommended that intrinsic subprograms be provided for convenient
11137 access to any machine operations that provide special capabilities or
11138 efficiency and that are not otherwise available through the language
11139 constructs.
11140 @end cartouche
11141 Followed.  A full set of machine operation intrinsic subprograms is provided.
11143 @sp 1
11144 @cartouche
11145 Atomic read-modify-write operations---e.g.@:, test and set, compare and
11146 swap, decrement and test, enqueue/dequeue.
11147 @end cartouche
11148 Followed on any target supporting such operations.
11150 @sp 1
11151 @cartouche
11152 Standard numeric functions---e.g.@:, sin, log.
11153 @end cartouche
11154 Followed on any target supporting such operations.
11156 @sp 1
11157 @cartouche
11158 String manipulation operations---e.g.@:, translate and test.
11159 @end cartouche
11160 Followed on any target supporting such operations.
11162 @sp 1
11163 @cartouche
11164 Vector operations---e.g.@:, compare vector against thresholds.
11165 @end cartouche
11166 Followed on any target supporting such operations.
11168 @sp 1
11169 @cartouche
11170 Direct operations on I/O ports.
11171 @end cartouche
11172 Followed on any target supporting such operations.
11174 @cindex Interrupt support
11175 @unnumberedsec C.3(28): Interrupt Support
11176 @sp 1
11177 @cartouche
11178 If the @code{Ceiling_Locking} policy is not in effect, the
11179 implementation should provide means for the application to specify which
11180 interrupts are to be blocked during protected actions, if the underlying
11181 system allows for a finer-grain control of interrupt blocking.
11182 @end cartouche
11183 Followed.  The underlying system does not allow for finer-grain control
11184 of interrupt blocking.
11186 @cindex Protected procedure handlers
11187 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
11188 @sp 1
11189 @cartouche
11190 Whenever possible, the implementation should allow interrupt handlers to
11191 be called directly by the hardware.
11192 @end cartouche
11193 Followed on any target where the underlying operating system permits
11194 such direct calls.
11196 @sp 1
11197 @cartouche
11198 Whenever practical, violations of any
11199 implementation-defined restrictions should be detected before run time.
11200 @end cartouche
11201 Followed.  Compile time warnings are given when possible.
11203 @cindex Package @code{Interrupts}
11204 @findex Interrupts
11205 @unnumberedsec C.3.2(25): Package @code{Interrupts}
11207 @sp 1
11208 @cartouche
11209 If implementation-defined forms of interrupt handler procedures are
11210 supported, such as protected procedures with parameters, then for each
11211 such form of a handler, a type analogous to @code{Parameterless_Handler}
11212 should be specified in a child package of @code{Interrupts}, with the
11213 same operations as in the predefined package Interrupts.
11214 @end cartouche
11215 Followed.
11217 @cindex Pre-elaboration requirements
11218 @unnumberedsec C.4(14): Pre-elaboration Requirements
11219 @sp 1
11220 @cartouche
11221 It is recommended that pre-elaborated packages be implemented in such a
11222 way that there should be little or no code executed at run time for the
11223 elaboration of entities not already covered by the Implementation
11224 Requirements.
11225 @end cartouche
11226 Followed.  Executable code is generated in some cases, e.g.@: loops
11227 to initialize large arrays.
11229 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
11230 @sp 1
11231 @cartouche
11232 If the pragma applies to an entity, then the implementation should
11233 reduce the amount of storage used for storing names associated with that
11234 entity.
11235 @end cartouche
11236 Followed.
11238 @cindex Package @code{Task_Attributes}
11239 @findex Task_Attributes
11240 @unnumberedsec C.7.2(30): The Package Task_Attributes
11241 @sp 1
11242 @cartouche
11243 Some implementations are targeted to domains in which memory use at run
11244 time must be completely deterministic.  For such implementations, it is
11245 recommended that the storage for task attributes will be pre-allocated
11246 statically and not from the heap.  This can be accomplished by either
11247 placing restrictions on the number and the size of the task's
11248 attributes, or by using the pre-allocated storage for the first @var{N}
11249 attribute objects, and the heap for the others.  In the latter case,
11250 @var{N} should be documented.
11251 @end cartouche
11252 Not followed.  This implementation is not targeted to such a domain.
11254 @cindex Locking Policies
11255 @unnumberedsec D.3(17): Locking Policies
11257 @sp 1
11258 @cartouche
11259 The implementation should use names that end with @samp{_Locking} for
11260 locking policies defined by the implementation.
11261 @end cartouche
11262 Followed.  Two implementation-defined locking policies are defined,
11263 whose names (@code{Inheritance_Locking} and
11264 @code{Concurrent_Readers_Locking}) follow this suggestion.
11266 @cindex Entry queuing policies
11267 @unnumberedsec D.4(16): Entry Queuing Policies
11268 @sp 1
11269 @cartouche
11270 Names that end with @samp{_Queuing} should be used
11271 for all implementation-defined queuing policies.
11272 @end cartouche
11273 Followed.  No such implementation-defined queuing policies exist.
11275 @cindex Preemptive abort
11276 @unnumberedsec D.6(9-10): Preemptive Abort
11277 @sp 1
11278 @cartouche
11279 Even though the @code{abort_statement} is included in the list of
11280 potentially blocking operations (see 9.5.1), it is recommended that this
11281 statement be implemented in a way that never requires the task executing
11282 the @code{abort_statement} to block.
11283 @end cartouche
11284 Followed.
11286 @sp 1
11287 @cartouche
11288 On a multi-processor, the delay associated with aborting a task on
11289 another processor should be bounded; the implementation should use
11290 periodic polling, if necessary, to achieve this.
11291 @end cartouche
11292 Followed.
11294 @cindex Tasking restrictions
11295 @unnumberedsec D.7(21): Tasking Restrictions
11296 @sp 1
11297 @cartouche
11298 When feasible, the implementation should take advantage of the specified
11299 restrictions to produce a more efficient implementation.
11300 @end cartouche
11301 GNAT currently takes advantage of these restrictions by providing an optimized
11302 run time when the Ravenscar profile and the GNAT restricted run time set
11303 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
11304 pragma @code{Profile (Restricted)} for more details.
11306 @cindex Time, monotonic
11307 @unnumberedsec D.8(47-49): Monotonic Time
11308 @sp 1
11309 @cartouche
11310 When appropriate, implementations should provide configuration
11311 mechanisms to change the value of @code{Tick}.
11312 @end cartouche
11313 Such configuration mechanisms are not appropriate to this implementation
11314 and are thus not supported.
11316 @sp 1
11317 @cartouche
11318 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
11319 be implemented as transformations of the same time base.
11320 @end cartouche
11321 Followed.
11323 @sp 1
11324 @cartouche
11325 It is recommended that the @dfn{best} time base which exists in
11326 the underlying system be available to the application through
11327 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
11328 @end cartouche
11329 Followed.
11331 @cindex Partition communication subsystem
11332 @cindex PCS
11333 @unnumberedsec E.5(28-29): Partition Communication Subsystem
11334 @sp 1
11335 @cartouche
11336 Whenever possible, the PCS on the called partition should allow for
11337 multiple tasks to call the RPC-receiver with different messages and
11338 should allow them to block until the corresponding subprogram body
11339 returns.
11340 @end cartouche
11341 Followed by GLADE, a separately supplied PCS that can be used with
11342 GNAT.
11344 @sp 1
11345 @cartouche
11346 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
11347 should raise @code{Storage_Error} if it runs out of space trying to
11348 write the @code{Item} into the stream.
11349 @end cartouche
11350 Followed by GLADE, a separately supplied PCS that can be used with
11351 GNAT@.
11353 @cindex COBOL support
11354 @unnumberedsec F(7): COBOL Support
11355 @sp 1
11356 @cartouche
11357 If COBOL (respectively, C) is widely supported in the target
11358 environment, implementations supporting the Information Systems Annex
11359 should provide the child package @code{Interfaces.COBOL} (respectively,
11360 @code{Interfaces.C}) specified in Annex B and should support a
11361 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
11362 pragmas (see Annex B), thus allowing Ada programs to interface with
11363 programs written in that language.
11364 @end cartouche
11365 Followed.
11367 @cindex Decimal radix support
11368 @unnumberedsec F.1(2): Decimal Radix Support
11369 @sp 1
11370 @cartouche
11371 Packed decimal should be used as the internal representation for objects
11372 of subtype @var{S} when @var{S}'Machine_Radix = 10.
11373 @end cartouche
11374 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
11375 representations.
11377 @cindex Numerics
11378 @unnumberedsec G: Numerics
11379 @sp 2
11380 @cartouche
11381 If Fortran (respectively, C) is widely supported in the target
11382 environment, implementations supporting the Numerics Annex
11383 should provide the child package @code{Interfaces.Fortran} (respectively,
11384 @code{Interfaces.C}) specified in Annex B and should support a
11385 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
11386 pragmas (see Annex B), thus allowing Ada programs to interface with
11387 programs written in that language.
11388 @end cartouche
11389 Followed.
11391 @cindex Complex types
11392 @unnumberedsec G.1.1(56-58): Complex Types
11393 @sp 2
11394 @cartouche
11395 Because the usual mathematical meaning of multiplication of a complex
11396 operand and a real operand is that of the scaling of both components of
11397 the former by the latter, an implementation should not perform this
11398 operation by first promoting the real operand to complex type and then
11399 performing a full complex multiplication.  In systems that, in the
11400 future, support an Ada binding to IEC 559:1989, the latter technique
11401 will not generate the required result when one of the components of the
11402 complex operand is infinite.  (Explicit multiplication of the infinite
11403 component by the zero component obtained during promotion yields a NaN
11404 that propagates into the final result.) Analogous advice applies in the
11405 case of multiplication of a complex operand and a pure-imaginary
11406 operand, and in the case of division of a complex operand by a real or
11407 pure-imaginary operand.
11408 @end cartouche
11409 Not followed.
11411 @sp 1
11412 @cartouche
11413 Similarly, because the usual mathematical meaning of addition of a
11414 complex operand and a real operand is that the imaginary operand remains
11415 unchanged, an implementation should not perform this operation by first
11416 promoting the real operand to complex type and then performing a full
11417 complex addition.  In implementations in which the @code{Signed_Zeros}
11418 attribute of the component type is @code{True} (and which therefore
11419 conform to IEC 559:1989 in regard to the handling of the sign of zero in
11420 predefined arithmetic operations), the latter technique will not
11421 generate the required result when the imaginary component of the complex
11422 operand is a negatively signed zero.  (Explicit addition of the negative
11423 zero to the zero obtained during promotion yields a positive zero.)
11424 Analogous advice applies in the case of addition of a complex operand
11425 and a pure-imaginary operand, and in the case of subtraction of a
11426 complex operand and a real or pure-imaginary operand.
11427 @end cartouche
11428 Not followed.
11430 @sp 1
11431 @cartouche
11432 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
11433 attempt to provide a rational treatment of the signs of zero results and
11434 result components.  As one example, the result of the @code{Argument}
11435 function should have the sign of the imaginary component of the
11436 parameter @code{X} when the point represented by that parameter lies on
11437 the positive real axis; as another, the sign of the imaginary component
11438 of the @code{Compose_From_Polar} function should be the same as
11439 (respectively, the opposite of) that of the @code{Argument} parameter when that
11440 parameter has a value of zero and the @code{Modulus} parameter has a
11441 nonnegative (respectively, negative) value.
11442 @end cartouche
11443 Followed.
11445 @cindex Complex elementary functions
11446 @unnumberedsec G.1.2(49): Complex Elementary Functions
11447 @sp 1
11448 @cartouche
11449 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
11450 @code{True} should attempt to provide a rational treatment of the signs
11451 of zero results and result components.  For example, many of the complex
11452 elementary functions have components that are odd functions of one of
11453 the parameter components; in these cases, the result component should
11454 have the sign of the parameter component at the origin.  Other complex
11455 elementary functions have zero components whose sign is opposite that of
11456 a parameter component at the origin, or is always positive or always
11457 negative.
11458 @end cartouche
11459 Followed.
11461 @cindex Accuracy requirements
11462 @unnumberedsec G.2.4(19): Accuracy Requirements
11463 @sp 1
11464 @cartouche
11465 The versions of the forward trigonometric functions without a
11466 @code{Cycle} parameter should not be implemented by calling the
11467 corresponding version with a @code{Cycle} parameter of
11468 @code{2.0*Numerics.Pi}, since this will not provide the required
11469 accuracy in some portions of the domain.  For the same reason, the
11470 version of @code{Log} without a @code{Base} parameter should not be
11471 implemented by calling the corresponding version with a @code{Base}
11472 parameter of @code{Numerics.e}.
11473 @end cartouche
11474 Followed.
11476 @cindex Complex arithmetic accuracy
11477 @cindex Accuracy, complex arithmetic
11478 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
11480 @sp 1
11481 @cartouche
11482 The version of the @code{Compose_From_Polar} function without a
11483 @code{Cycle} parameter should not be implemented by calling the
11484 corresponding version with a @code{Cycle} parameter of
11485 @code{2.0*Numerics.Pi}, since this will not provide the required
11486 accuracy in some portions of the domain.
11487 @end cartouche
11488 Followed.
11490 @cindex Sequential elaboration policy
11491 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
11493 @sp 1
11494 @cartouche
11495 If the partition elaboration policy is @code{Sequential} and the
11496 Environment task becomes permanently blocked during elaboration then the
11497 partition is deadlocked and it is recommended that the partition be
11498 immediately terminated.
11499 @end cartouche
11500 Not followed.
11502 @c -----------------------------------------
11503 @node Implementation Defined Characteristics
11504 @chapter Implementation Defined Characteristics
11506 @noindent
11507 In addition to the implementation dependent pragmas and attributes, and the
11508 implementation advice, there are a number of other Ada features that are
11509 potentially implementation dependent and are designated as
11510 implementation-defined. These are mentioned throughout the Ada Reference
11511 Manual, and are summarized in Annex M@.
11513 A requirement for conforming Ada compilers is that they provide
11514 documentation describing how the implementation deals with each of these
11515 issues.  In this chapter, you will find each point in Annex M listed
11516 followed by a description in italic font of how GNAT
11517 handles the implementation dependence.
11519 You can use this chapter as a guide to minimizing implementation
11520 dependent features in your programs if portability to other compilers
11521 and other operating systems is an important consideration.  The numbers
11522 in each section below correspond to the paragraph number in the Ada
11523 Reference Manual.
11525 @sp 1
11526 @cartouche
11527 @noindent
11528 @strong{2}.  Whether or not each recommendation given in Implementation
11529 Advice is followed.  See 1.1.2(37).
11530 @end cartouche
11531 @noindent
11532 @xref{Implementation Advice}.
11534 @sp 1
11535 @cartouche
11536 @noindent
11537 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
11538 @end cartouche
11539 @noindent
11540 The complexity of programs that can be processed is limited only by the
11541 total amount of available virtual memory, and disk space for the
11542 generated object files.
11544 @sp 1
11545 @cartouche
11546 @noindent
11547 @strong{4}.  Variations from the standard that are impractical to avoid
11548 given the implementation's execution environment.  See 1.1.3(6).
11549 @end cartouche
11550 @noindent
11551 There are no variations from the standard.
11553 @sp 1
11554 @cartouche
11555 @noindent
11556 @strong{5}.  Which @code{code_statement}s cause external
11557 interactions.  See 1.1.3(10).
11558 @end cartouche
11559 @noindent
11560 Any @code{code_statement} can potentially cause external interactions.
11562 @sp 1
11563 @cartouche
11564 @noindent
11565 @strong{6}.  The coded representation for the text of an Ada
11566 program.  See 2.1(4).
11567 @end cartouche
11568 @noindent
11569 See separate section on source representation.
11571 @sp 1
11572 @cartouche
11573 @noindent
11574 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
11575 @end cartouche
11576 @noindent
11577 See separate section on source representation.
11579 @sp 1
11580 @cartouche
11581 @noindent
11582 @strong{8}.  The representation for an end of line.  See 2.2(2).
11583 @end cartouche
11584 @noindent
11585 See separate section on source representation.
11587 @sp 1
11588 @cartouche
11589 @noindent
11590 @strong{9}.  Maximum supported line length and lexical element
11591 length.  See 2.2(15).
11592 @end cartouche
11593 @noindent
11594 The maximum line length is 255 characters and the maximum length of
11595 a lexical element is also 255 characters. This is the default setting
11596 if not overridden by the use of compiler switch @option{-gnaty} (which
11597 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
11598 line length to be specified to be any value up to 32767. The maximum
11599 length of a lexical element is the same as the maximum line length.
11601 @sp 1
11602 @cartouche
11603 @noindent
11604 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
11605 @end cartouche
11606 @noindent
11608 @xref{Implementation Defined Pragmas}.
11610 @sp 1
11611 @cartouche
11612 @noindent
11613 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
11614 @end cartouche
11615 @noindent
11616 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
11617 parameter, checks that the optimization flag is set, and aborts if it is
11618 not.
11620 @sp 1
11621 @cartouche
11622 @noindent
11623 @strong{12}.  The sequence of characters of the value returned by
11624 @code{@var{S}'Image} when some of the graphic characters of
11625 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
11626 3.5(37).
11627 @end cartouche
11628 @noindent
11629 The sequence of characters is as defined by the wide character encoding
11630 method used for the source.  See section on source representation for
11631 further details.
11633 @sp 1
11634 @cartouche
11635 @noindent
11636 @strong{13}.  The predefined integer types declared in
11637 @code{Standard}.  See 3.5.4(25).
11638 @end cartouche
11639 @noindent
11640 @table @code
11641 @item Short_Short_Integer
11642 8 bit signed
11643 @item Short_Integer
11644 (Short) 16 bit signed
11645 @item Integer
11646 32 bit signed
11647 @item Long_Integer
11648 64 bit signed (on most 64 bit targets, depending on the C definition of long).
11649 32 bit signed (all other targets)
11650 @item Long_Long_Integer
11651 64 bit signed
11652 @end table
11654 @sp 1
11655 @cartouche
11656 @noindent
11657 @strong{14}.  Any nonstandard integer types and the operators defined
11658 for them.  See 3.5.4(26).
11659 @end cartouche
11660 @noindent
11661 There are no nonstandard integer types.
11663 @sp 1
11664 @cartouche
11665 @noindent
11666 @strong{15}.  Any nonstandard real types and the operators defined for
11667 them.  See 3.5.6(8).
11668 @end cartouche
11669 @noindent
11670 There are no nonstandard real types.
11672 @sp 1
11673 @cartouche
11674 @noindent
11675 @strong{16}.  What combinations of requested decimal precision and range
11676 are supported for floating point types.  See 3.5.7(7).
11677 @end cartouche
11678 @noindent
11679 The precision and range is as defined by the IEEE standard.
11681 @sp 1
11682 @cartouche
11683 @noindent
11684 @strong{17}.  The predefined floating point types declared in
11685 @code{Standard}.  See 3.5.7(16).
11686 @end cartouche
11687 @noindent
11688 @table @code
11689 @item Short_Float
11690 32 bit IEEE short
11691 @item Float
11692 (Short) 32 bit IEEE short
11693 @item Long_Float
11694 64 bit IEEE long
11695 @item Long_Long_Float
11696 64 bit IEEE long (80 bit IEEE long on x86 processors)
11697 @end table
11699 @sp 1
11700 @cartouche
11701 @noindent
11702 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
11703 @end cartouche
11704 @noindent
11705 @code{Fine_Delta} is 2**(@minus{}63)
11707 @sp 1
11708 @cartouche
11709 @noindent
11710 @strong{19}.  What combinations of small, range, and digits are
11711 supported for fixed point types.  See 3.5.9(10).
11712 @end cartouche
11713 @noindent
11714 Any combinations are permitted that do not result in a small less than
11715 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
11716 If the mantissa is larger than 53 bits on machines where Long_Long_Float
11717 is 64 bits (true of all architectures except ia32), then the output from
11718 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
11719 is because floating-point conversions are used to convert fixed point.
11721 @sp 1
11722 @cartouche
11723 @noindent
11724 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
11725 within an unnamed @code{block_statement}.  See 3.9(10).
11726 @end cartouche
11727 @noindent
11728 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
11729 decimal integer are allocated.
11731 @sp 1
11732 @cartouche
11733 @noindent
11734 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
11735 @end cartouche
11736 @noindent
11737 @xref{Implementation Defined Attributes}.
11739 @sp 1
11740 @cartouche
11741 @noindent
11742 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
11743 @end cartouche
11744 @noindent
11745 There are no implementation-defined time types.
11747 @sp 1
11748 @cartouche
11749 @noindent
11750 @strong{23}.  The time base associated with relative delays.
11751 @end cartouche
11752 @noindent
11753 See 9.6(20).  The time base used is that provided by the C library
11754 function @code{gettimeofday}.
11756 @sp 1
11757 @cartouche
11758 @noindent
11759 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
11760 9.6(23).
11761 @end cartouche
11762 @noindent
11763 The time base used is that provided by the C library function
11764 @code{gettimeofday}.
11766 @sp 1
11767 @cartouche
11768 @noindent
11769 @strong{25}.  The time zone used for package @code{Calendar}
11770 operations.  See 9.6(24).
11771 @end cartouche
11772 @noindent
11773 The time zone used by package @code{Calendar} is the current system time zone
11774 setting for local time, as accessed by the C library function
11775 @code{localtime}.
11777 @sp 1
11778 @cartouche
11779 @noindent
11780 @strong{26}.  Any limit on @code{delay_until_statements} of
11781 @code{select_statements}.  See 9.6(29).
11782 @end cartouche
11783 @noindent
11784 There are no such limits.
11786 @sp 1
11787 @cartouche
11788 @noindent
11789 @strong{27}.  Whether or not two non-overlapping parts of a composite
11790 object are independently addressable, in the case where packing, record
11791 layout, or @code{Component_Size} is specified for the object.  See
11792 9.10(1).
11793 @end cartouche
11794 @noindent
11795 Separate components are independently addressable if they do not share
11796 overlapping storage units.
11798 @sp 1
11799 @cartouche
11800 @noindent
11801 @strong{28}.  The representation for a compilation.  See 10.1(2).
11802 @end cartouche
11803 @noindent
11804 A compilation is represented by a sequence of files presented to the
11805 compiler in a single invocation of the @command{gcc} command.
11807 @sp 1
11808 @cartouche
11809 @noindent
11810 @strong{29}.  Any restrictions on compilations that contain multiple
11811 compilation_units.  See 10.1(4).
11812 @end cartouche
11813 @noindent
11814 No single file can contain more than one compilation unit, but any
11815 sequence of files can be presented to the compiler as a single
11816 compilation.
11818 @sp 1
11819 @cartouche
11820 @noindent
11821 @strong{30}.  The mechanisms for creating an environment and for adding
11822 and replacing compilation units.  See 10.1.4(3).
11823 @end cartouche
11824 @noindent
11825 See separate section on compilation model.
11827 @sp 1
11828 @cartouche
11829 @noindent
11830 @strong{31}.  The manner of explicitly assigning library units to a
11831 partition.  See 10.2(2).
11832 @end cartouche
11833 @noindent
11834 If a unit contains an Ada main program, then the Ada units for the partition
11835 are determined by recursive application of the rules in the Ada Reference
11836 Manual section 10.2(2-6).  In other words, the Ada units will be those that
11837 are needed by the main program, and then this definition of need is applied
11838 recursively to those units, and the partition contains the transitive
11839 closure determined by this relationship.  In short, all the necessary units
11840 are included, with no need to explicitly specify the list.  If additional
11841 units are required, e.g.@: by foreign language units, then all units must be
11842 mentioned in the context clause of one of the needed Ada units.
11844 If the partition contains no main program, or if the main program is in
11845 a language other than Ada, then GNAT
11846 provides the binder options @option{-z} and @option{-n} respectively, and in
11847 this case a list of units can be explicitly supplied to the binder for
11848 inclusion in the partition (all units needed by these units will also
11849 be included automatically).  For full details on the use of these
11850 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
11851 @value{EDITION} User's Guide}.
11853 @sp 1
11854 @cartouche
11855 @noindent
11856 @strong{32}.  The implementation-defined means, if any, of specifying
11857 which compilation units are needed by a given compilation unit.  See
11858 10.2(2).
11859 @end cartouche
11860 @noindent
11861 The units needed by a given compilation unit are as defined in
11862 the Ada Reference Manual section 10.2(2-6).  There are no
11863 implementation-defined pragmas or other implementation-defined
11864 means for specifying needed units.
11866 @sp 1
11867 @cartouche
11868 @noindent
11869 @strong{33}.  The manner of designating the main subprogram of a
11870 partition.  See 10.2(7).
11871 @end cartouche
11872 @noindent
11873 The main program is designated by providing the name of the
11874 corresponding @file{ALI} file as the input parameter to the binder.
11876 @sp 1
11877 @cartouche
11878 @noindent
11879 @strong{34}.  The order of elaboration of @code{library_items}.  See
11880 10.2(18).
11881 @end cartouche
11882 @noindent
11883 The first constraint on ordering is that it meets the requirements of
11884 Chapter 10 of the Ada Reference Manual.  This still leaves some
11885 implementation dependent choices, which are resolved by first
11886 elaborating bodies as early as possible (i.e., in preference to specs
11887 where there is a choice), and second by evaluating the immediate with
11888 clauses of a unit to determine the probably best choice, and
11889 third by elaborating in alphabetical order of unit names
11890 where a choice still remains.
11892 @sp 1
11893 @cartouche
11894 @noindent
11895 @strong{35}.  Parameter passing and function return for the main
11896 subprogram.  See 10.2(21).
11897 @end cartouche
11898 @noindent
11899 The main program has no parameters.  It may be a procedure, or a function
11900 returning an integer type.  In the latter case, the returned integer
11901 value is the return code of the program (overriding any value that
11902 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
11904 @sp 1
11905 @cartouche
11906 @noindent
11907 @strong{36}.  The mechanisms for building and running partitions.  See
11908 10.2(24).
11909 @end cartouche
11910 @noindent
11911 GNAT itself supports programs with only a single partition.  The GNATDIST
11912 tool provided with the GLADE package (which also includes an implementation
11913 of the PCS) provides a completely flexible method for building and running
11914 programs consisting of multiple partitions.  See the separate GLADE manual
11915 for details.
11917 @sp 1
11918 @cartouche
11919 @noindent
11920 @strong{37}.  The details of program execution, including program
11921 termination.  See 10.2(25).
11922 @end cartouche
11923 @noindent
11924 See separate section on compilation model.
11926 @sp 1
11927 @cartouche
11928 @noindent
11929 @strong{38}.  The semantics of any non-active partitions supported by the
11930 implementation.  See 10.2(28).
11931 @end cartouche
11932 @noindent
11933 Passive partitions are supported on targets where shared memory is
11934 provided by the operating system.  See the GLADE reference manual for
11935 further details.
11937 @sp 1
11938 @cartouche
11939 @noindent
11940 @strong{39}.  The information returned by @code{Exception_Message}.  See
11941 11.4.1(10).
11942 @end cartouche
11943 @noindent
11944 Exception message returns the null string unless a specific message has
11945 been passed by the program.
11947 @sp 1
11948 @cartouche
11949 @noindent
11950 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
11951 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
11952 @end cartouche
11953 @noindent
11954 Blocks have implementation defined names of the form @code{B@var{nnn}}
11955 where @var{nnn} is an integer.
11957 @sp 1
11958 @cartouche
11959 @noindent
11960 @strong{41}.  The information returned by
11961 @code{Exception_Information}.  See 11.4.1(13).
11962 @end cartouche
11963 @noindent
11964 @code{Exception_Information} returns a string in the following format:
11966 @smallexample
11967 @emph{Exception_Name:} nnnnn
11968 @emph{Message:} mmmmm
11969 @emph{PID:} ppp
11970 @emph{Load address:} 0xhhhh
11971 @emph{Call stack traceback locations:}
11972 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
11973 @end smallexample
11975 @noindent
11976 where
11978 @itemize @bullet
11979 @item
11980 @code{nnnn} is the fully qualified name of the exception in all upper
11981 case letters. This line is always present.
11983 @item
11984 @code{mmmm} is the message (this line present only if message is non-null)
11986 @item
11987 @code{ppp} is the Process Id value as a decimal integer (this line is
11988 present only if the Process Id is nonzero). Currently we are
11989 not making use of this field.
11991 @item
11992 The Load address line, the Call stack traceback locations line and the
11993 following values are present only if at least one traceback location was
11994 recorded. The Load address indicates the address at which the main executable
11995 was loaded; this line may not be present if operating system hasn't relocated
11996 the main executable. The values are given in C style format, with lower case
11997 letters for a-f, and only as many digits present as are necessary.
11998 @end itemize
12000 @noindent
12001 The line terminator sequence at the end of each line, including
12002 the last line is a single @code{LF} character (@code{16#0A#}).
12004 @sp 1
12005 @cartouche
12006 @noindent
12007 @strong{42}.  Implementation-defined check names.  See 11.5(27).
12008 @end cartouche
12009 @noindent
12010 The implementation defined check name Alignment_Check controls checking of
12011 address clause values for proper alignment (that is, the address supplied
12012 must be consistent with the alignment of the type).
12014 The implementation defined check name Predicate_Check controls whether
12015 predicate checks are generated.
12017 The implementation defined check name Validity_Check controls whether
12018 validity checks are generated.
12020 In addition, a user program can add implementation-defined check names
12021 by means of the pragma Check_Name.
12023 @sp 1
12024 @cartouche
12025 @noindent
12026 @strong{43}.  The interpretation of each aspect of representation.  See
12027 13.1(20).
12028 @end cartouche
12029 @noindent
12030 See separate section on data representations.
12032 @sp 1
12033 @cartouche
12034 @noindent
12035 @strong{44}.  Any restrictions placed upon representation items.  See
12036 13.1(20).
12037 @end cartouche
12038 @noindent
12039 See separate section on data representations.
12041 @sp 1
12042 @cartouche
12043 @noindent
12044 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
12045 13.3(48).
12046 @end cartouche
12047 @noindent
12048 Size for an indefinite subtype is the maximum possible size, except that
12049 for the case of a subprogram parameter, the size of the parameter object
12050 is the actual size.
12052 @sp 1
12053 @cartouche
12054 @noindent
12055 @strong{46}.  The default external representation for a type tag.  See
12056 13.3(75).
12057 @end cartouche
12058 @noindent
12059 The default external representation for a type tag is the fully expanded
12060 name of the type in upper case letters.
12062 @sp 1
12063 @cartouche
12064 @noindent
12065 @strong{47}.  What determines whether a compilation unit is the same in
12066 two different partitions.  See 13.3(76).
12067 @end cartouche
12068 @noindent
12069 A compilation unit is the same in two different partitions if and only
12070 if it derives from the same source file.
12072 @sp 1
12073 @cartouche
12074 @noindent
12075 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
12076 @end cartouche
12077 @noindent
12078 The only implementation defined component is the tag for a tagged type,
12079 which contains a pointer to the dispatching table.
12081 @sp 1
12082 @cartouche
12083 @noindent
12084 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
12085 ordering.  See 13.5.3(5).
12086 @end cartouche
12087 @noindent
12088 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
12089 implementation, so no non-default bit ordering is supported.  The default
12090 bit ordering corresponds to the natural endianness of the target architecture.
12092 @sp 1
12093 @cartouche
12094 @noindent
12095 @strong{50}.  The contents of the visible part of package @code{System}
12096 and its language-defined children.  See 13.7(2).
12097 @end cartouche
12098 @noindent
12099 See the definition of these packages in files @file{system.ads} and
12100 @file{s-stoele.ads}.
12102 @sp 1
12103 @cartouche
12104 @noindent
12105 @strong{51}.  The contents of the visible part of package
12106 @code{System.Machine_Code}, and the meaning of
12107 @code{code_statements}.  See 13.8(7).
12108 @end cartouche
12109 @noindent
12110 See the definition and documentation in file @file{s-maccod.ads}.
12112 @sp 1
12113 @cartouche
12114 @noindent
12115 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
12116 @end cartouche
12117 @noindent
12118 Unchecked conversion between types of the same size
12119 results in an uninterpreted transmission of the bits from one type
12120 to the other.  If the types are of unequal sizes, then in the case of
12121 discrete types, a shorter source is first zero or sign extended as
12122 necessary, and a shorter target is simply truncated on the left.
12123 For all non-discrete types, the source is first copied if necessary
12124 to ensure that the alignment requirements of the target are met, then
12125 a pointer is constructed to the source value, and the result is obtained
12126 by dereferencing this pointer after converting it to be a pointer to the
12127 target type. Unchecked conversions where the target subtype is an
12128 unconstrained array are not permitted. If the target alignment is
12129 greater than the source alignment, then a copy of the result is
12130 made with appropriate alignment
12132 @sp 1
12133 @cartouche
12134 @noindent
12135 @strong{53}. The semantics of operations on invalid representations.
12136 See 13.9.2(10-11).
12137 @end cartouche
12138 @noindent
12139 For assignments and other operations where the use of invalid values cannot
12140 result in erroneous behavior, the compiler ignores the possibility of invalid
12141 values. An exception is raised at the point where an invalid value would
12142 result in erroneous behavior. For example executing:
12144 @smallexample @c ada
12145 procedure invalidvals is
12146    X : Integer := -1;
12147    Y : Natural range 1 .. 10;
12148    for Y'Address use X'Address;
12149    Z : Natural range 1 .. 10;
12150    A : array (Natural range 1 .. 10) of Integer;
12151 begin
12152    Z := Y;     -- no exception
12153    A (Z) := 3; -- exception raised;
12154 end;
12155 @end smallexample
12157 @noindent
12158 As indicated, an exception is raised on the array assignment, but not
12159 on the simple assignment of the invalid negative value from Y to Z.
12161 @sp 1
12162 @cartouche
12163 @noindent
12164 @strong{53}.  The manner of choosing a storage pool for an access type
12165 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
12166 @end cartouche
12167 @noindent
12168 There are 3 different standard pools used by the compiler when
12169 @code{Storage_Pool} is not specified depending whether the type is local
12170 to a subprogram or defined at the library level and whether
12171 @code{Storage_Size}is specified or not.  See documentation in the runtime
12172 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
12173 @code{System.Pool_Local} in files @file{s-poosiz.ads},
12174 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
12175 default pools used.
12177 @sp 1
12178 @cartouche
12179 @noindent
12180 @strong{54}.  Whether or not the implementation provides user-accessible
12181 names for the standard pool type(s).  See 13.11(17).
12182 @end cartouche
12183 @noindent
12185 See documentation in the sources of the run time mentioned in paragraph
12186 @strong{53} .  All these pools are accessible by means of @code{with}'ing
12187 these units.
12189 @sp 1
12190 @cartouche
12191 @noindent
12192 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
12193 @end cartouche
12194 @noindent
12195 @code{Storage_Size} is measured in storage units, and refers to the
12196 total space available for an access type collection, or to the primary
12197 stack space for a task.
12199 @sp 1
12200 @cartouche
12201 @noindent
12202 @strong{56}.  Implementation-defined aspects of storage pools.  See
12203 13.11(22).
12204 @end cartouche
12205 @noindent
12206 See documentation in the sources of the run time mentioned in paragraph
12207 @strong{53} for details on GNAT-defined aspects of storage pools.
12209 @sp 1
12210 @cartouche
12211 @noindent
12212 @strong{57}.  The set of restrictions allowed in a pragma
12213 @code{Restrictions}.  See 13.12(7).
12214 @end cartouche
12215 @noindent
12216 @xref{Standard and Implementation Defined Restrictions}.
12218 @sp 1
12219 @cartouche
12220 @noindent
12221 @strong{58}.  The consequences of violating limitations on
12222 @code{Restrictions} pragmas.  See 13.12(9).
12223 @end cartouche
12224 @noindent
12225 Restrictions that can be checked at compile time result in illegalities
12226 if violated.  Currently there are no other consequences of violating
12227 restrictions.
12229 @sp 1
12230 @cartouche
12231 @noindent
12232 @strong{59}.  The representation used by the @code{Read} and
12233 @code{Write} attributes of elementary types in terms of stream
12234 elements.  See 13.13.2(9).
12235 @end cartouche
12236 @noindent
12237 The representation is the in-memory representation of the base type of
12238 the type, using the number of bits corresponding to the
12239 @code{@var{type}'Size} value, and the natural ordering of the machine.
12241 @sp 1
12242 @cartouche
12243 @noindent
12244 @strong{60}.  The names and characteristics of the numeric subtypes
12245 declared in the visible part of package @code{Standard}.  See A.1(3).
12246 @end cartouche
12247 @noindent
12248 See items describing the integer and floating-point types supported.
12250 @sp 1
12251 @cartouche
12252 @noindent
12253 @strong{61}. The string returned by @code{Character_Set_Version}.
12254 See A.3.5(3).
12255 @end cartouche
12256 @noindent
12257 @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns
12258 the string "Unicode 6.2", referring to version 6.2.x of the
12259 Unicode specification.
12261 @sp 1
12262 @cartouche
12263 @noindent
12264 @strong{62}.  The accuracy actually achieved by the elementary
12265 functions.  See A.5.1(1).
12266 @end cartouche
12267 @noindent
12268 The elementary functions correspond to the functions available in the C
12269 library.  Only fast math mode is implemented.
12271 @sp 1
12272 @cartouche
12273 @noindent
12274 @strong{63}.  The sign of a zero result from some of the operators or
12275 functions in @code{Numerics.Generic_Elementary_Functions}, when
12276 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
12277 @end cartouche
12278 @noindent
12279 The sign of zeroes follows the requirements of the IEEE 754 standard on
12280 floating-point.
12282 @sp 1
12283 @cartouche
12284 @noindent
12285 @strong{64}.  The value of
12286 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
12287 @end cartouche
12288 @noindent
12289 Maximum image width is 6864, see library file @file{s-rannum.ads}.
12291 @sp 1
12292 @cartouche
12293 @noindent
12294 @strong{65}.  The value of
12295 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
12296 @end cartouche
12297 @noindent
12298 Maximum image width is 6864, see library file @file{s-rannum.ads}.
12300 @sp 1
12301 @cartouche
12302 @noindent
12303 @strong{66}.  The algorithms for random number generation.  See
12304 A.5.2(32).
12305 @end cartouche
12306 @noindent
12307 The algorithm is the Mersenne Twister, as documented in the source file
12308 @file{s-rannum.adb}. This version of the algorithm has a period of
12309 2**19937-1.
12311 @sp 1
12312 @cartouche
12313 @noindent
12314 @strong{67}.  The string representation of a random number generator's
12315 state.  See A.5.2(38).
12316 @end cartouche
12317 @noindent
12318 The value returned by the Image function is the concatenation of
12319 the fixed-width decimal representations of the 624 32-bit integers
12320 of the state vector.
12322 @sp 1
12323 @cartouche
12324 @noindent
12325 @strong{68}.  The minimum time interval between calls to the
12326 time-dependent Reset procedure that are guaranteed to initiate different
12327 random number sequences.  See A.5.2(45).
12328 @end cartouche
12329 @noindent
12330 The minimum period between reset calls to guarantee distinct series of
12331 random numbers is one microsecond.
12333 @sp 1
12334 @cartouche
12335 @noindent
12336 @strong{69}.  The values of the @code{Model_Mantissa},
12337 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
12338 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
12339 Annex is not supported.  See A.5.3(72).
12340 @end cartouche
12341 @noindent
12342 Run the compiler with @option{-gnatS} to produce a listing of package
12343 @code{Standard}, has the values of all numeric attributes.
12345 @sp 1
12346 @cartouche
12347 @noindent
12348 @strong{70}.  Any implementation-defined characteristics of the
12349 input-output packages.  See A.7(14).
12350 @end cartouche
12351 @noindent
12352 There are no special implementation defined characteristics for these
12353 packages.
12355 @sp 1
12356 @cartouche
12357 @noindent
12358 @strong{71}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
12359 A.9(10).
12360 @end cartouche
12361 @noindent
12362 All type representations are contiguous, and the @code{Buffer_Size} is
12363 the value of @code{@var{type}'Size} rounded up to the next storage unit
12364 boundary.
12366 @sp 1
12367 @cartouche
12368 @noindent
12369 @strong{72}.  External files for standard input, standard output, and
12370 standard error See A.10(5).
12371 @end cartouche
12372 @noindent
12373 These files are mapped onto the files provided by the C streams
12374 libraries.  See source file @file{i-cstrea.ads} for further details.
12376 @sp 1
12377 @cartouche
12378 @noindent
12379 @strong{73}.  The accuracy of the value produced by @code{Put}.  See
12380 A.10.9(36).
12381 @end cartouche
12382 @noindent
12383 If more digits are requested in the output than are represented by the
12384 precision of the value, zeroes are output in the corresponding least
12385 significant digit positions.
12387 @sp 1
12388 @cartouche
12389 @noindent
12390 @strong{74}.  The meaning of @code{Argument_Count}, @code{Argument}, and
12391 @code{Command_Name}.  See A.15(1).
12392 @end cartouche
12393 @noindent
12394 These are mapped onto the @code{argv} and @code{argc} parameters of the
12395 main program in the natural manner.
12397 @sp 1
12398 @cartouche
12399 @noindent
12400 @strong{75}.  The interpretation of the @code{Form} parameter in procedure
12401 @code{Create_Directory}.  See A.16(56).
12402 @end cartouche
12403 @noindent
12404 The @code{Form} parameter is not used.
12406 @sp 1
12407 @cartouche
12408 @noindent
12409 @strong{76}.  The interpretation of the @code{Form} parameter in procedure
12410 @code{Create_Path}.  See A.16(60).
12411 @end cartouche
12412 @noindent
12413 The @code{Form} parameter is not used.
12415 @sp 1
12416 @cartouche
12417 @noindent
12418 @strong{77}.  The interpretation of the @code{Form} parameter in procedure
12419 @code{Copy_File}.  See A.16(68).
12420 @end cartouche
12421 @noindent
12422 The @code{Form} parameter is case-insensitive.
12424 Two fields are recognized in the @code{Form} parameter:
12426 @table @code
12428 @item preserve=<value>
12430 @item mode=<value>
12432 @end table
12434 @noindent
12435 <value> starts immediately after the character '=' and ends with the
12436 character immediately preceding the next comma (',') or with the last
12437 character of the parameter.
12439 The only possible values for preserve= are:
12441 @table @code
12443 @item no_attributes
12444 Do not try to preserve any file attributes. This is the default if no
12445 preserve= is found in Form.
12447 @item all_attributes
12448 Try to preserve all file attributes (timestamps, access rights).
12450 @item timestamps
12451 Preserve the timestamp of the copied file, but not the other file attributes.
12453 @end table
12455 @noindent
12456 The only possible values for mode= are:
12458 @table @code
12460 @item copy
12461 Only do the copy if the destination file does not already exist. If it already
12462 exists, Copy_File fails.
12464 @item overwrite
12465 Copy the file in all cases. Overwrite an already existing destination file.
12467 @item append
12468 Append the original file to the destination file. If the destination file does
12469 not exist, the destination file is a copy of the source file. When mode=append,
12470 the field preserve=, if it exists, is not taken into account.
12472 @end table
12474 @noindent
12475 If the Form parameter includes one or both of the fields and the value or
12476 values are incorrect, Copy_file fails with Use_Error.
12478 Examples of correct Forms:
12480 @smallexample
12481 Form => "preserve=no_attributes,mode=overwrite" (the default)
12482 Form => "mode=append"
12483 Form => "mode=copy, preserve=all_attributes"
12484 @end smallexample
12486 @noindent
12487 Examples of incorrect Forms
12489 @smallexample
12490 Form => "preserve=junk"
12491 Form => "mode=internal, preserve=timestamps"
12492 @end smallexample
12494 @sp 1
12495 @cartouche
12496 @noindent
12497 @strong{78}.  Implementation-defined convention names.  See B.1(11).
12498 @end cartouche
12499 @noindent
12500 The following convention names are supported
12502 @table @code
12503 @item  Ada
12505 @item Ada_Pass_By_Copy
12506 Allowed for any types except by-reference types such as limited
12507 records. Compatible with convention Ada, but causes any parameters
12508 with this convention to be passed by copy.
12509 @item Ada_Pass_By_Reference
12510 Allowed for any types except by-copy types such as scalars.
12511 Compatible with convention Ada, but causes any parameters
12512 with this convention to be passed by reference.
12513 @item Assembler
12514 Assembly language
12515 @item Asm
12516 Synonym for Assembler
12517 @item Assembly
12518 Synonym for Assembler
12519 @item C
12521 @item C_Pass_By_Copy
12522 Allowed only for record types, like C, but also notes that record
12523 is to be passed by copy rather than reference.
12524 @item COBOL
12525 COBOL
12526 @item C_Plus_Plus (or CPP)
12528 @item Default
12529 Treated the same as C
12530 @item External
12531 Treated the same as C
12532 @item Fortran
12533 Fortran
12534 @item Intrinsic
12535 For support of pragma @code{Import} with convention Intrinsic, see
12536 separate section on Intrinsic Subprograms.
12537 @item Stdcall
12538 Stdcall (used for Windows implementations only).  This convention correspond
12539 to the WINAPI (previously called Pascal convention) C/C++ convention under
12540 Windows.  A routine with this convention cleans the stack before
12541 exit. This pragma cannot be applied to a dispatching call.
12542 @item DLL
12543 Synonym for Stdcall
12544 @item Win32
12545 Synonym for Stdcall
12546 @item Stubbed
12547 Stubbed is a special convention used to indicate that the body of the
12548 subprogram will be entirely ignored.  Any call to the subprogram
12549 is converted into a raise of the @code{Program_Error} exception.  If a
12550 pragma @code{Import} specifies convention @code{stubbed} then no body need
12551 be present at all.  This convention is useful during development for the
12552 inclusion of subprograms whose body has not yet been written.
12554 @end table
12555 @noindent
12556 In addition, all otherwise unrecognized convention names are also
12557 treated as being synonymous with convention C@.  In all implementations
12558 except for VMS, use of such other names results in a warning.  In VMS
12559 implementations, these names are accepted silently.
12561 @sp 1
12562 @cartouche
12563 @noindent
12564 @strong{79}.  The meaning of link names.  See B.1(36).
12565 @end cartouche
12566 @noindent
12567 Link names are the actual names used by the linker.
12569 @sp 1
12570 @cartouche
12571 @noindent
12572 @strong{80}.  The manner of choosing link names when neither the link
12573 name nor the address of an imported or exported entity is specified.  See
12574 B.1(36).
12575 @end cartouche
12576 @noindent
12577 The default linker name is that which would be assigned by the relevant
12578 external language, interpreting the Ada name as being in all lower case
12579 letters.
12581 @sp 1
12582 @cartouche
12583 @noindent
12584 @strong{81}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
12585 @end cartouche
12586 @noindent
12587 The string passed to @code{Linker_Options} is presented uninterpreted as
12588 an argument to the link command, unless it contains ASCII.NUL characters.
12589 NUL characters if they appear act as argument separators, so for example
12591 @smallexample @c ada
12592 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
12593 @end smallexample
12595 @noindent
12596 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
12597 linker. The order of linker options is preserved for a given unit. The final
12598 list of options passed to the linker is in reverse order of the elaboration
12599 order. For example, linker options for a body always appear before the options
12600 from the corresponding package spec.
12602 @sp 1
12603 @cartouche
12604 @noindent
12605 @strong{82}.  The contents of the visible part of package
12606 @code{Interfaces} and its language-defined descendants.  See B.2(1).
12607 @end cartouche
12608 @noindent
12609 See files with prefix @file{i-} in the distributed library.
12611 @sp 1
12612 @cartouche
12613 @noindent
12614 @strong{83}.  Implementation-defined children of package
12615 @code{Interfaces}.  The contents of the visible part of package
12616 @code{Interfaces}.  See B.2(11).
12617 @end cartouche
12618 @noindent
12619 See files with prefix @file{i-} in the distributed library.
12621 @sp 1
12622 @cartouche
12623 @noindent
12624 @strong{84}.  The types @code{Floating}, @code{Long_Floating},
12625 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
12626 @code{COBOL_Character}; and the initialization of the variables
12627 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
12628 @code{Interfaces.COBOL}.  See B.4(50).
12629 @end cartouche
12630 @noindent
12631 @table @code
12632 @item Floating
12633 Float
12634 @item Long_Floating
12635 (Floating) Long_Float
12636 @item Binary
12637 Integer
12638 @item Long_Binary
12639 Long_Long_Integer
12640 @item Decimal_Element
12641 Character
12642 @item COBOL_Character
12643 Character
12644 @end table
12646 @noindent
12647 For initialization, see the file @file{i-cobol.ads} in the distributed library.
12649 @sp 1
12650 @cartouche
12651 @noindent
12652 @strong{85}.  Support for access to machine instructions.  See C.1(1).
12653 @end cartouche
12654 @noindent
12655 See documentation in file @file{s-maccod.ads} in the distributed library.
12657 @sp 1
12658 @cartouche
12659 @noindent
12660 @strong{86}.  Implementation-defined aspects of access to machine
12661 operations.  See C.1(9).
12662 @end cartouche
12663 @noindent
12664 See documentation in file @file{s-maccod.ads} in the distributed library.
12666 @sp 1
12667 @cartouche
12668 @noindent
12669 @strong{87}.  Implementation-defined aspects of interrupts.  See C.3(2).
12670 @end cartouche
12671 @noindent
12672 Interrupts are mapped to signals or conditions as appropriate.  See
12673 definition of unit
12674 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
12675 on the interrupts supported on a particular target.
12677 @sp 1
12678 @cartouche
12679 @noindent
12680 @strong{88}.  Implementation-defined aspects of pre-elaboration.  See
12681 C.4(13).
12682 @end cartouche
12683 @noindent
12684 GNAT does not permit a partition to be restarted without reloading,
12685 except under control of the debugger.
12687 @sp 1
12688 @cartouche
12689 @noindent
12690 @strong{89}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
12691 @end cartouche
12692 @noindent
12693 Pragma @code{Discard_Names} causes names of enumeration literals to
12694 be suppressed.  In the presence of this pragma, the Image attribute
12695 provides the image of the Pos of the literal, and Value accepts
12696 Pos values.
12698 @sp 1
12699 @cartouche
12700 @noindent
12701 @strong{90}.  The result of the @code{Task_Identification.Image}
12702 attribute.  See C.7.1(7).
12703 @end cartouche
12704 @noindent
12705 The result of this attribute is a string that identifies
12706 the object or component that denotes a given task. If a variable @code{Var}
12707 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
12708 where the suffix
12709 is the hexadecimal representation of the virtual address of the corresponding
12710 task control block. If the variable is an array of tasks, the image of each
12711 task will have the form of an indexed component indicating the position of a
12712 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
12713 component of a record, the image of the task will have the form of a selected
12714 component. These rules are fully recursive, so that the image of a task that
12715 is a subcomponent of a composite object corresponds to the expression that
12716 designates this task.
12717 @noindent
12718 If a task is created by an allocator, its image depends on the context. If the
12719 allocator is part of an object declaration, the rules described above are used
12720 to construct its image, and this image is not affected by subsequent
12721 assignments. If the allocator appears within an expression, the image
12722 includes only the name of the task type.
12723 @noindent
12724 If the configuration pragma Discard_Names is present, or if the restriction
12725 No_Implicit_Heap_Allocation is in effect,  the image reduces to
12726 the numeric suffix, that is to say the hexadecimal representation of the
12727 virtual address of the control block of the task.
12728 @sp 1
12729 @cartouche
12730 @noindent
12731 @strong{91}.  The value of @code{Current_Task} when in a protected entry
12732 or interrupt handler.  See C.7.1(17).
12733 @end cartouche
12734 @noindent
12735 Protected entries or interrupt handlers can be executed by any
12736 convenient thread, so the value of @code{Current_Task} is undefined.
12738 @sp 1
12739 @cartouche
12740 @noindent
12741 @strong{92}.  The effect of calling @code{Current_Task} from an entry
12742 body or interrupt handler.  See C.7.1(19).
12743 @end cartouche
12744 @noindent
12745 The effect of calling @code{Current_Task} from an entry body or
12746 interrupt handler is to return the identification of the task currently
12747 executing the code.
12749 @sp 1
12750 @cartouche
12751 @noindent
12752 @strong{93}.  Implementation-defined aspects of
12753 @code{Task_Attributes}.  See C.7.2(19).
12754 @end cartouche
12755 @noindent
12756 There are no implementation-defined aspects of @code{Task_Attributes}.
12758 @sp 1
12759 @cartouche
12760 @noindent
12761 @strong{94}.  Values of all @code{Metrics}.  See D(2).
12762 @end cartouche
12763 @noindent
12764 The metrics information for GNAT depends on the performance of the
12765 underlying operating system.  The sources of the run-time for tasking
12766 implementation, together with the output from @option{-gnatG} can be
12767 used to determine the exact sequence of operating systems calls made
12768 to implement various tasking constructs.  Together with appropriate
12769 information on the performance of the underlying operating system,
12770 on the exact target in use, this information can be used to determine
12771 the required metrics.
12773 @sp 1
12774 @cartouche
12775 @noindent
12776 @strong{95}.  The declarations of @code{Any_Priority} and
12777 @code{Priority}.  See D.1(11).
12778 @end cartouche
12779 @noindent
12780 See declarations in file @file{system.ads}.
12782 @sp 1
12783 @cartouche
12784 @noindent
12785 @strong{96}.  Implementation-defined execution resources.  See D.1(15).
12786 @end cartouche
12787 @noindent
12788 There are no implementation-defined execution resources.
12790 @sp 1
12791 @cartouche
12792 @noindent
12793 @strong{97}.  Whether, on a multiprocessor, a task that is waiting for
12794 access to a protected object keeps its processor busy.  See D.2.1(3).
12795 @end cartouche
12796 @noindent
12797 On a multi-processor, a task that is waiting for access to a protected
12798 object does not keep its processor busy.
12800 @sp 1
12801 @cartouche
12802 @noindent
12803 @strong{98}.  The affect of implementation defined execution resources
12804 on task dispatching.  See D.2.1(9).
12805 @end cartouche
12806 @noindent
12807 Tasks map to threads in the threads package used by GNAT@.  Where possible
12808 and appropriate, these threads correspond to native threads of the
12809 underlying operating system.
12811 @sp 1
12812 @cartouche
12813 @noindent
12814 @strong{99}.  Implementation-defined @code{policy_identifiers} allowed
12815 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
12816 @end cartouche
12817 @noindent
12818 There are no implementation-defined policy-identifiers allowed in this
12819 pragma.
12821 @sp 1
12822 @cartouche
12823 @noindent
12824 @strong{100}.  Implementation-defined aspects of priority inversion.  See
12825 D.2.2(16).
12826 @end cartouche
12827 @noindent
12828 Execution of a task cannot be preempted by the implementation processing
12829 of delay expirations for lower priority tasks.
12831 @sp 1
12832 @cartouche
12833 @noindent
12834 @strong{101}.  Implementation-defined task dispatching.  See D.2.2(18).
12835 @end cartouche
12836 @noindent
12837 The policy is the same as that of the underlying threads implementation.
12839 @sp 1
12840 @cartouche
12841 @noindent
12842 @strong{102}.  Implementation-defined @code{policy_identifiers} allowed
12843 in a pragma @code{Locking_Policy}.  See D.3(4).
12844 @end cartouche
12845 @noindent
12846 The two implementation defined policies permitted in GNAT are
12847 @code{Inheritance_Locking} and  @code{Conccurent_Readers_Locking}.  On
12848 targets that support the @code{Inheritance_Locking} policy, locking is
12849 implemented by inheritance, i.e.@: the task owning the lock operates
12850 at a priority equal to the highest priority of any task currently
12851 requesting the lock.  On targets that support the
12852 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
12853 read/write lock allowing multiple propected object functions to enter
12854 concurrently.
12856 @sp 1
12857 @cartouche
12858 @noindent
12859 @strong{103}.  Default ceiling priorities.  See D.3(10).
12860 @end cartouche
12861 @noindent
12862 The ceiling priority of protected objects of the type
12863 @code{System.Interrupt_Priority'Last} as described in the Ada
12864 Reference Manual D.3(10),
12866 @sp 1
12867 @cartouche
12868 @noindent
12869 @strong{104}.  The ceiling of any protected object used internally by
12870 the implementation.  See D.3(16).
12871 @end cartouche
12872 @noindent
12873 The ceiling priority of internal protected objects is
12874 @code{System.Priority'Last}.
12876 @sp 1
12877 @cartouche
12878 @noindent
12879 @strong{105}.  Implementation-defined queuing policies.  See D.4(1).
12880 @end cartouche
12881 @noindent
12882 There are no implementation-defined queuing policies.
12884 @sp 1
12885 @cartouche
12886 @noindent
12887 @strong{106}.  On a multiprocessor, any conditions that cause the
12888 completion of an aborted construct to be delayed later than what is
12889 specified for a single processor.  See D.6(3).
12890 @end cartouche
12891 @noindent
12892 The semantics for abort on a multi-processor is the same as on a single
12893 processor, there are no further delays.
12895 @sp 1
12896 @cartouche
12897 @noindent
12898 @strong{107}.  Any operations that implicitly require heap storage
12899 allocation.  See D.7(8).
12900 @end cartouche
12901 @noindent
12902 The only operation that implicitly requires heap storage allocation is
12903 task creation.
12905 @sp 1
12906 @cartouche
12907 @noindent
12908 @strong{108}.  Implementation-defined aspects of pragma
12909 @code{Restrictions}.  See D.7(20).
12910 @end cartouche
12911 @noindent
12912 There are no such implementation-defined aspects.
12914 @sp 1
12915 @cartouche
12916 @noindent
12917 @strong{109}.  Implementation-defined aspects of package
12918 @code{Real_Time}.  See D.8(17).
12919 @end cartouche
12920 @noindent
12921 There are no implementation defined aspects of package @code{Real_Time}.
12923 @sp 1
12924 @cartouche
12925 @noindent
12926 @strong{110}.  Implementation-defined aspects of
12927 @code{delay_statements}.  See D.9(8).
12928 @end cartouche
12929 @noindent
12930 Any difference greater than one microsecond will cause the task to be
12931 delayed (see D.9(7)).
12933 @sp 1
12934 @cartouche
12935 @noindent
12936 @strong{111}.  The upper bound on the duration of interrupt blocking
12937 caused by the implementation.  See D.12(5).
12938 @end cartouche
12939 @noindent
12940 The upper bound is determined by the underlying operating system.  In
12941 no cases is it more than 10 milliseconds.
12943 @sp 1
12944 @cartouche
12945 @noindent
12946 @strong{112}.  The means for creating and executing distributed
12947 programs.  See E(5).
12948 @end cartouche
12949 @noindent
12950 The GLADE package provides a utility GNATDIST for creating and executing
12951 distributed programs.  See the GLADE reference manual for further details.
12953 @sp 1
12954 @cartouche
12955 @noindent
12956 @strong{113}.  Any events that can result in a partition becoming
12957 inaccessible.  See E.1(7).
12958 @end cartouche
12959 @noindent
12960 See the GLADE reference manual for full details on such events.
12962 @sp 1
12963 @cartouche
12964 @noindent
12965 @strong{114}.  The scheduling policies, treatment of priorities, and
12966 management of shared resources between partitions in certain cases.  See
12967 E.1(11).
12968 @end cartouche
12969 @noindent
12970 See the GLADE reference manual for full details on these aspects of
12971 multi-partition execution.
12973 @sp 1
12974 @cartouche
12975 @noindent
12976 @strong{115}.  Events that cause the version of a compilation unit to
12977 change.  See E.3(5).
12978 @end cartouche
12979 @noindent
12980 Editing the source file of a compilation unit, or the source files of
12981 any units on which it is dependent in a significant way cause the version
12982 to change.  No other actions cause the version number to change.  All changes
12983 are significant except those which affect only layout, capitalization or
12984 comments.
12986 @sp 1
12987 @cartouche
12988 @noindent
12989 @strong{116}.  Whether the execution of the remote subprogram is
12990 immediately aborted as a result of cancellation.  See E.4(13).
12991 @end cartouche
12992 @noindent
12993 See the GLADE reference manual for details on the effect of abort in
12994 a distributed application.
12996 @sp 1
12997 @cartouche
12998 @noindent
12999 @strong{117}.  Implementation-defined aspects of the PCS@.  See E.5(25).
13000 @end cartouche
13001 @noindent
13002 See the GLADE reference manual for a full description of all implementation
13003 defined aspects of the PCS@.
13005 @sp 1
13006 @cartouche
13007 @noindent
13008 @strong{118}.  Implementation-defined interfaces in the PCS@.  See
13009 E.5(26).
13010 @end cartouche
13011 @noindent
13012 See the GLADE reference manual for a full description of all
13013 implementation defined interfaces.
13015 @sp 1
13016 @cartouche
13017 @noindent
13018 @strong{119}.  The values of named numbers in the package
13019 @code{Decimal}.  See F.2(7).
13020 @end cartouche
13021 @noindent
13022 @table @code
13023 @item Max_Scale
13025 @item Min_Scale
13027 @item Min_Delta
13028 1.0E-18
13029 @item Max_Delta
13030 1.0E+18
13031 @item Max_Decimal_Digits
13033 @end table
13035 @sp 1
13036 @cartouche
13037 @noindent
13038 @strong{120}.  The value of @code{Max_Picture_Length} in the package
13039 @code{Text_IO.Editing}.  See F.3.3(16).
13040 @end cartouche
13041 @noindent
13044 @sp 1
13045 @cartouche
13046 @noindent
13047 @strong{121}.  The value of @code{Max_Picture_Length} in the package
13048 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
13049 @end cartouche
13050 @noindent
13053 @sp 1
13054 @cartouche
13055 @noindent
13056 @strong{122}.  The accuracy actually achieved by the complex elementary
13057 functions and by other complex arithmetic operations.  See G.1(1).
13058 @end cartouche
13059 @noindent
13060 Standard library functions are used for the complex arithmetic
13061 operations.  Only fast math mode is currently supported.
13063 @sp 1
13064 @cartouche
13065 @noindent
13066 @strong{123}.  The sign of a zero result (or a component thereof) from
13067 any operator or function in @code{Numerics.Generic_Complex_Types}, when
13068 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
13069 @end cartouche
13070 @noindent
13071 The signs of zero values are as recommended by the relevant
13072 implementation advice.
13074 @sp 1
13075 @cartouche
13076 @noindent
13077 @strong{124}.  The sign of a zero result (or a component thereof) from
13078 any operator or function in
13079 @code{Numerics.Generic_Complex_Elementary_Functions}, when
13080 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
13081 @end cartouche
13082 @noindent
13083 The signs of zero values are as recommended by the relevant
13084 implementation advice.
13086 @sp 1
13087 @cartouche
13088 @noindent
13089 @strong{125}.  Whether the strict mode or the relaxed mode is the
13090 default.  See G.2(2).
13091 @end cartouche
13092 @noindent
13093 The strict mode is the default.  There is no separate relaxed mode.  GNAT
13094 provides a highly efficient implementation of strict mode.
13096 @sp 1
13097 @cartouche
13098 @noindent
13099 @strong{126}.  The result interval in certain cases of fixed-to-float
13100 conversion.  See G.2.1(10).
13101 @end cartouche
13102 @noindent
13103 For cases where the result interval is implementation dependent, the
13104 accuracy is that provided by performing all operations in 64-bit IEEE
13105 floating-point format.
13107 @sp 1
13108 @cartouche
13109 @noindent
13110 @strong{127}.  The result of a floating point arithmetic operation in
13111 overflow situations, when the @code{Machine_Overflows} attribute of the
13112 result type is @code{False}.  See G.2.1(13).
13113 @end cartouche
13114 @noindent
13115 Infinite and NaN values are produced as dictated by the IEEE
13116 floating-point standard.
13118 Note that on machines that are not fully compliant with the IEEE
13119 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
13120 must be used for achieving IEEE conforming behavior (although at the cost
13121 of a significant performance penalty), so infinite and NaN values are
13122 properly generated.
13124 @sp 1
13125 @cartouche
13126 @noindent
13127 @strong{128}.  The result interval for division (or exponentiation by a
13128 negative exponent), when the floating point hardware implements division
13129 as multiplication by a reciprocal.  See G.2.1(16).
13130 @end cartouche
13131 @noindent
13132 Not relevant, division is IEEE exact.
13134 @sp 1
13135 @cartouche
13136 @noindent
13137 @strong{129}.  The definition of close result set, which determines the
13138 accuracy of certain fixed point multiplications and divisions.  See
13139 G.2.3(5).
13140 @end cartouche
13141 @noindent
13142 Operations in the close result set are performed using IEEE long format
13143 floating-point arithmetic.  The input operands are converted to
13144 floating-point, the operation is done in floating-point, and the result
13145 is converted to the target type.
13147 @sp 1
13148 @cartouche
13149 @noindent
13150 @strong{130}.  Conditions on a @code{universal_real} operand of a fixed
13151 point multiplication or division for which the result shall be in the
13152 perfect result set.  See G.2.3(22).
13153 @end cartouche
13154 @noindent
13155 The result is only defined to be in the perfect result set if the result
13156 can be computed by a single scaling operation involving a scale factor
13157 representable in 64-bits.
13159 @sp 1
13160 @cartouche
13161 @noindent
13162 @strong{131}.  The result of a fixed point arithmetic operation in
13163 overflow situations, when the @code{Machine_Overflows} attribute of the
13164 result type is @code{False}.  See G.2.3(27).
13165 @end cartouche
13166 @noindent
13167 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
13168 types.
13170 @sp 1
13171 @cartouche
13172 @noindent
13173 @strong{132}.  The result of an elementary function reference in
13174 overflow situations, when the @code{Machine_Overflows} attribute of the
13175 result type is @code{False}.  See G.2.4(4).
13176 @end cartouche
13177 @noindent
13178 IEEE infinite and Nan values are produced as appropriate.
13180 @sp 1
13181 @cartouche
13182 @noindent
13183 @strong{133}.  The value of the angle threshold, within which certain
13184 elementary functions, complex arithmetic operations, and complex
13185 elementary functions yield results conforming to a maximum relative
13186 error bound.  See G.2.4(10).
13187 @end cartouche
13188 @noindent
13189 Information on this subject is not yet available.
13191 @sp 1
13192 @cartouche
13193 @noindent
13194 @strong{134}.  The accuracy of certain elementary functions for
13195 parameters beyond the angle threshold.  See G.2.4(10).
13196 @end cartouche
13197 @noindent
13198 Information on this subject is not yet available.
13200 @sp 1
13201 @cartouche
13202 @noindent
13203 @strong{135}.  The result of a complex arithmetic operation or complex
13204 elementary function reference in overflow situations, when the
13205 @code{Machine_Overflows} attribute of the corresponding real type is
13206 @code{False}.  See G.2.6(5).
13207 @end cartouche
13208 @noindent
13209 IEEE infinite and Nan values are produced as appropriate.
13211 @sp 1
13212 @cartouche
13213 @noindent
13214 @strong{136}.  The accuracy of certain complex arithmetic operations and
13215 certain complex elementary functions for parameters (or components
13216 thereof) beyond the angle threshold.  See G.2.6(8).
13217 @end cartouche
13218 @noindent
13219 Information on those subjects is not yet available.
13221 @sp 1
13222 @cartouche
13223 @noindent
13224 @strong{137}.  Information regarding bounded errors and erroneous
13225 execution.  See H.2(1).
13226 @end cartouche
13227 @noindent
13228 Information on this subject is not yet available.
13230 @sp 1
13231 @cartouche
13232 @noindent
13233 @strong{138}.  Implementation-defined aspects of pragma
13234 @code{Inspection_Point}.  See H.3.2(8).
13235 @end cartouche
13236 @noindent
13237 Pragma @code{Inspection_Point} ensures that the variable is live and can
13238 be examined by the debugger at the inspection point.
13240 @sp 1
13241 @cartouche
13242 @noindent
13243 @strong{139}.  Implementation-defined aspects of pragma
13244 @code{Restrictions}.  See H.4(25).
13245 @end cartouche
13246 @noindent
13247 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
13248 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
13249 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
13251 @sp 1
13252 @cartouche
13253 @noindent
13254 @strong{140}.  Any restrictions on pragma @code{Restrictions}.  See
13255 H.4(27).
13256 @end cartouche
13257 @noindent
13258 There are no restrictions on pragma @code{Restrictions}.
13260 @node Intrinsic Subprograms
13261 @chapter Intrinsic Subprograms
13262 @cindex Intrinsic Subprograms
13264 @menu
13265 * Intrinsic Operators::
13266 * Enclosing_Entity::
13267 * Exception_Information::
13268 * Exception_Message::
13269 * Exception_Name::
13270 * File::
13271 * Line::
13272 * Shifts and Rotates::
13273 * Source_Location::
13274 @end menu
13276 @noindent
13277 GNAT allows a user application program to write the declaration:
13279 @smallexample @c ada
13280    pragma Import (Intrinsic, name);
13281 @end smallexample
13283 @noindent
13284 providing that the name corresponds to one of the implemented intrinsic
13285 subprograms in GNAT, and that the parameter profile of the referenced
13286 subprogram meets the requirements.  This chapter describes the set of
13287 implemented intrinsic subprograms, and the requirements on parameter profiles.
13288 Note that no body is supplied; as with other uses of pragma Import, the
13289 body is supplied elsewhere (in this case by the compiler itself).  Note
13290 that any use of this feature is potentially non-portable, since the
13291 Ada standard does not require Ada compilers to implement this feature.
13293 @node Intrinsic Operators
13294 @section Intrinsic Operators
13295 @cindex Intrinsic operator
13297 @noindent
13298 All the predefined numeric operators in package Standard
13299 in @code{pragma Import (Intrinsic,..)}
13300 declarations.  In the binary operator case, the operands must have the same
13301 size.  The operand or operands must also be appropriate for
13302 the operator.  For example, for addition, the operands must
13303 both be floating-point or both be fixed-point, and the
13304 right operand for @code{"**"} must have a root type of
13305 @code{Standard.Integer'Base}.
13306 You can use an intrinsic operator declaration as in the following example:
13308 @smallexample @c ada
13309    type Int1 is new Integer;
13310    type Int2 is new Integer;
13312    function "+" (X1 : Int1; X2 : Int2) return Int1;
13313    function "+" (X1 : Int1; X2 : Int2) return Int2;
13314    pragma Import (Intrinsic, "+");
13315 @end smallexample
13317 @noindent
13318 This declaration would permit ``mixed mode'' arithmetic on items
13319 of the differing types @code{Int1} and @code{Int2}.
13320 It is also possible to specify such operators for private types, if the
13321 full views are appropriate arithmetic types.
13323 @node Enclosing_Entity
13324 @section Enclosing_Entity
13325 @cindex Enclosing_Entity
13326 @noindent
13327 This intrinsic subprogram is used in the implementation of the
13328 library routine @code{GNAT.Source_Info}.  The only useful use of the
13329 intrinsic import in this case is the one in this unit, so an
13330 application program should simply call the function
13331 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
13332 the current subprogram, package, task, entry, or protected subprogram.
13334 @node Exception_Information
13335 @section Exception_Information
13336 @cindex Exception_Information'
13337 @noindent
13338 This intrinsic subprogram is used in the implementation of the
13339 library routine @code{GNAT.Current_Exception}.  The only useful
13340 use of the intrinsic import in this case is the one in this unit,
13341 so an application program should simply call the function
13342 @code{GNAT.Current_Exception.Exception_Information} to obtain
13343 the exception information associated with the current exception.
13345 @node Exception_Message
13346 @section Exception_Message
13347 @cindex Exception_Message
13348 @noindent
13349 This intrinsic subprogram is used in the implementation of the
13350 library routine @code{GNAT.Current_Exception}.  The only useful
13351 use of the intrinsic import in this case is the one in this unit,
13352 so an application program should simply call the function
13353 @code{GNAT.Current_Exception.Exception_Message} to obtain
13354 the message associated with the current exception.
13356 @node Exception_Name
13357 @section Exception_Name
13358 @cindex Exception_Name
13359 @noindent
13360 This intrinsic subprogram is used in the implementation of the
13361 library routine @code{GNAT.Current_Exception}.  The only useful
13362 use of the intrinsic import in this case is the one in this unit,
13363 so an application program should simply call the function
13364 @code{GNAT.Current_Exception.Exception_Name} to obtain
13365 the name of the current exception.
13367 @node File
13368 @section File
13369 @cindex File
13370 @noindent
13371 This intrinsic subprogram is used in the implementation of the
13372 library routine @code{GNAT.Source_Info}.  The only useful use of the
13373 intrinsic import in this case is the one in this unit, so an
13374 application program should simply call the function
13375 @code{GNAT.Source_Info.File} to obtain the name of the current
13376 file.
13378 @node Line
13379 @section Line
13380 @cindex Line
13381 @noindent
13382 This intrinsic subprogram is used in the implementation of the
13383 library routine @code{GNAT.Source_Info}.  The only useful use of the
13384 intrinsic import in this case is the one in this unit, so an
13385 application program should simply call the function
13386 @code{GNAT.Source_Info.Line} to obtain the number of the current
13387 source line.
13389 @node Shifts and Rotates
13390 @section Shifts and Rotates
13391 @cindex Shift_Left
13392 @cindex Shift_Right
13393 @cindex Shift_Right_Arithmetic
13394 @cindex Rotate_Left
13395 @cindex Rotate_Right
13396 @noindent
13397 In standard Ada, the shift and rotate functions are available only
13398 for the predefined modular types in package @code{Interfaces}.  However, in
13399 GNAT it is possible to define these functions for any integer
13400 type (signed or modular), as in this example:
13402 @smallexample @c ada
13403    function Shift_Left
13404      (Value  : T;
13405       Amount : Natural)
13406       return   T;
13407 @end smallexample
13409 @noindent
13410 The function name must be one of
13411 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
13412 Rotate_Right. T must be an integer type. T'Size must be
13413 8, 16, 32 or 64 bits; if T is modular, the modulus
13414 must be 2**8, 2**16, 2**32 or 2**64.
13415 The result type must be the same as the type of @code{Value}.
13416 The shift amount must be Natural.
13417 The formal parameter names can be anything.
13419 @node Source_Location
13420 @section Source_Location
13421 @cindex Source_Location
13422 @noindent
13423 This intrinsic subprogram is used in the implementation of the
13424 library routine @code{GNAT.Source_Info}.  The only useful use of the
13425 intrinsic import in this case is the one in this unit, so an
13426 application program should simply call the function
13427 @code{GNAT.Source_Info.Source_Location} to obtain the current
13428 source file location.
13430 @node Representation Clauses and Pragmas
13431 @chapter Representation Clauses and Pragmas
13432 @cindex Representation Clauses
13434 @menu
13435 * Alignment Clauses::
13436 * Size Clauses::
13437 * Storage_Size Clauses::
13438 * Size of Variant Record Objects::
13439 * Biased Representation ::
13440 * Value_Size and Object_Size Clauses::
13441 * Component_Size Clauses::
13442 * Bit_Order Clauses::
13443 * Effect of Bit_Order on Byte Ordering::
13444 * Pragma Pack for Arrays::
13445 * Pragma Pack for Records::
13446 * Record Representation Clauses::
13447 * Enumeration Clauses::
13448 * Address Clauses::
13449 * Effect of Convention on Representation::
13450 * Determining the Representations chosen by GNAT::
13451 @end menu
13453 @noindent
13454 @cindex Representation Clause
13455 @cindex Representation Pragma
13456 @cindex Pragma, representation
13457 This section describes the representation clauses accepted by GNAT, and
13458 their effect on the representation of corresponding data objects.
13460 GNAT fully implements Annex C (Systems Programming).  This means that all
13461 the implementation advice sections in chapter 13 are fully implemented.
13462 However, these sections only require a minimal level of support for
13463 representation clauses.  GNAT provides much more extensive capabilities,
13464 and this section describes the additional capabilities provided.
13466 @node Alignment Clauses
13467 @section Alignment Clauses
13468 @cindex Alignment Clause
13470 @noindent
13471 GNAT requires that all alignment clauses specify a power of 2, and all
13472 default alignments are always a power of 2.  The default alignment
13473 values are as follows:
13475 @itemize @bullet
13476 @item @emph{Primitive Types}.
13477 For primitive types, the alignment is the minimum of the actual size of
13478 objects of the type divided by @code{Storage_Unit},
13479 and the maximum alignment supported by the target.
13480 (This maximum alignment is given by the GNAT-specific attribute
13481 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
13482 @cindex @code{Maximum_Alignment} attribute
13483 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
13484 default alignment will be 8 on any target that supports alignments
13485 this large, but on some targets, the maximum alignment may be smaller
13486 than 8, in which case objects of type @code{Long_Float} will be maximally
13487 aligned.
13489 @item @emph{Arrays}.
13490 For arrays, the alignment is equal to the alignment of the component type
13491 for the normal case where no packing or component size is given.  If the
13492 array is packed, and the packing is effective (see separate section on
13493 packed arrays), then the alignment will be one for long packed arrays,
13494 or arrays whose length is not known at compile time.  For short packed
13495 arrays, which are handled internally as modular types, the alignment
13496 will be as described for primitive types, e.g.@: a packed array of length
13497 31 bits will have an object size of four bytes, and an alignment of 4.
13499 @item @emph{Records}.
13500 For the normal non-packed case, the alignment of a record is equal to
13501 the maximum alignment of any of its components.  For tagged records, this
13502 includes the implicit access type used for the tag.  If a pragma @code{Pack}
13503 is used and all components are packable (see separate section on pragma
13504 @code{Pack}), then the resulting alignment is 1, unless the layout of the
13505 record makes it profitable to increase it.
13507 A special case is when:
13508 @itemize @bullet
13509 @item
13510 the size of the record is given explicitly, or a
13511 full record representation clause is given, and
13512 @item
13513 the size of the record is 2, 4, or 8 bytes.
13514 @end itemize
13515 @noindent
13516 In this case, an alignment is chosen to match the
13517 size of the record. For example, if we have:
13519 @smallexample @c ada
13520    type Small is record
13521       A, B : Character;
13522    end record;
13523    for Small'Size use 16;
13524 @end smallexample
13526 @noindent
13527 then the default alignment of the record type @code{Small} is 2, not 1. This
13528 leads to more efficient code when the record is treated as a unit, and also
13529 allows the type to specified as @code{Atomic} on architectures requiring
13530 strict alignment.
13532 @end itemize
13534 @noindent
13535 An alignment clause may specify a larger alignment than the default value
13536 up to some maximum value dependent on the target (obtainable by using the
13537 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
13538 a smaller alignment than the default value for enumeration, integer and
13539 fixed point types, as well as for record types, for example
13541 @smallexample @c ada
13542   type V is record
13543      A : Integer;
13544   end record;
13546   for V'alignment use 1;
13547 @end smallexample
13549 @noindent
13550 @cindex Alignment, default
13551 The default alignment for the type @code{V} is 4, as a result of the
13552 Integer field in the record, but it is permissible, as shown, to
13553 override the default alignment of the record with a smaller value.
13555 @cindex Alignment, subtypes
13556 Note that according to the Ada standard, an alignment clause applies only
13557 to the first named subtype. If additional subtypes are declared, then the
13558 compiler is allowed to choose any alignment it likes, and there is no way
13559 to control this choice. Consider:
13561 @smallexample @c ada
13562    type R is range 1 .. 10_000;
13563    for R'Alignment use 1;
13564    subtype RS is R range 1 .. 1000;
13565 @end smallexample
13567 @noindent
13568 The alignment clause specifies an alignment of 1 for the first named subtype
13569 @code{R} but this does not necessarily apply to @code{RS}. When writing
13570 portable Ada code, you should avoid writing code that explicitly or
13571 implicitly relies on the alignment of such subtypes.
13573 For the GNAT compiler, if an explicit alignment clause is given, this
13574 value is also used for any subsequent subtypes. So for GNAT, in the
13575 above example, you can count on the alignment of @code{RS} being 1. But this
13576 assumption is non-portable, and other compilers may choose different
13577 alignments for the subtype @code{RS}.
13579 @node Size Clauses
13580 @section Size Clauses
13581 @cindex Size Clause
13583 @noindent
13584 The default size for a type @code{T} is obtainable through the
13585 language-defined attribute @code{T'Size} and also through the
13586 equivalent GNAT-defined attribute @code{T'Value_Size}.
13587 For objects of type @code{T}, GNAT will generally increase the type size
13588 so that the object size (obtainable through the GNAT-defined attribute
13589 @code{T'Object_Size})
13590 is a multiple of @code{T'Alignment * Storage_Unit}.
13591 For example
13593 @smallexample @c ada
13594    type Smallint is range 1 .. 6;
13596    type Rec is record
13597       Y1 : integer;
13598       Y2 : boolean;
13599    end record;
13600 @end smallexample
13602 @noindent
13603 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
13604 as specified by the RM rules,
13605 but objects of this type will have a size of 8
13606 (@code{Smallint'Object_Size} = 8),
13607 since objects by default occupy an integral number
13608 of storage units.  On some targets, notably older
13609 versions of the Digital Alpha, the size of stand
13610 alone objects of this type may be 32, reflecting
13611 the inability of the hardware to do byte load/stores.
13613 Similarly, the size of type @code{Rec} is 40 bits
13614 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
13615 the alignment is 4, so objects of this type will have
13616 their size increased to 64 bits so that it is a multiple
13617 of the alignment (in bits).  This decision is
13618 in accordance with the specific Implementation Advice in RM 13.3(43):
13620 @quotation
13621 A @code{Size} clause should be supported for an object if the specified
13622 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
13623 to a size in storage elements that is a multiple of the object's
13624 @code{Alignment} (if the @code{Alignment} is nonzero).
13625 @end quotation
13627 @noindent
13628 An explicit size clause may be used to override the default size by
13629 increasing it.  For example, if we have:
13631 @smallexample @c ada
13632    type My_Boolean is new Boolean;
13633    for My_Boolean'Size use 32;
13634 @end smallexample
13636 @noindent
13637 then values of this type will always be 32 bits long.  In the case of
13638 discrete types, the size can be increased up to 64 bits, with the effect
13639 that the entire specified field is used to hold the value, sign- or
13640 zero-extended as appropriate.  If more than 64 bits is specified, then
13641 padding space is allocated after the value, and a warning is issued that
13642 there are unused bits.
13644 Similarly the size of records and arrays may be increased, and the effect
13645 is to add padding bits after the value.  This also causes a warning message
13646 to be generated.
13648 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
13649 Size in bits, this corresponds to an object of size 256 megabytes (minus
13650 one).  This limitation is true on all targets.  The reason for this
13651 limitation is that it improves the quality of the code in many cases
13652 if it is known that a Size value can be accommodated in an object of
13653 type Integer.
13655 @node Storage_Size Clauses
13656 @section Storage_Size Clauses
13657 @cindex Storage_Size Clause
13659 @noindent
13660 For tasks, the @code{Storage_Size} clause specifies the amount of space
13661 to be allocated for the task stack.  This cannot be extended, and if the
13662 stack is exhausted, then @code{Storage_Error} will be raised (if stack
13663 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
13664 or a @code{Storage_Size} pragma in the task definition to set the
13665 appropriate required size.  A useful technique is to include in every
13666 task definition a pragma of the form:
13668 @smallexample @c ada
13669    pragma Storage_Size (Default_Stack_Size);
13670 @end smallexample
13672 @noindent
13673 Then @code{Default_Stack_Size} can be defined in a global package, and
13674 modified as required. Any tasks requiring stack sizes different from the
13675 default can have an appropriate alternative reference in the pragma.
13677 You can also use the @option{-d} binder switch to modify the default stack
13678 size.
13680 For access types, the @code{Storage_Size} clause specifies the maximum
13681 space available for allocation of objects of the type.  If this space is
13682 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
13683 In the case where the access type is declared local to a subprogram, the
13684 use of a @code{Storage_Size} clause triggers automatic use of a special
13685 predefined storage pool (@code{System.Pool_Size}) that ensures that all
13686 space for the pool is automatically reclaimed on exit from the scope in
13687 which the type is declared.
13689 A special case recognized by the compiler is the specification of a
13690 @code{Storage_Size} of zero for an access type.  This means that no
13691 items can be allocated from the pool, and this is recognized at compile
13692 time, and all the overhead normally associated with maintaining a fixed
13693 size storage pool is eliminated.  Consider the following example:
13695 @smallexample @c ada
13696    procedure p is
13697       type R is array (Natural) of Character;
13698       type P is access all R;
13699       for P'Storage_Size use 0;
13700       --  Above access type intended only for interfacing purposes
13702       y : P;
13704       procedure g (m : P);
13705       pragma Import (C, g);
13707       --  @dots{}
13709    begin
13710       --  @dots{}
13711       y := new R;
13712    end;
13713 @end smallexample
13715 @noindent
13716 As indicated in this example, these dummy storage pools are often useful in
13717 connection with interfacing where no object will ever be allocated.  If you
13718 compile the above example, you get the warning:
13720 @smallexample
13721    p.adb:16:09: warning: allocation from empty storage pool
13722    p.adb:16:09: warning: Storage_Error will be raised at run time
13723 @end smallexample
13725 @noindent
13726 Of course in practice, there will not be any explicit allocators in the
13727 case of such an access declaration.
13729 @node Size of Variant Record Objects
13730 @section Size of Variant Record Objects
13731 @cindex Size, variant record objects
13732 @cindex Variant record objects, size
13734 @noindent
13735 In the case of variant record objects, there is a question whether Size gives
13736 information about a particular variant, or the maximum size required
13737 for any variant.  Consider the following program
13739 @smallexample @c ada
13740 with Text_IO; use Text_IO;
13741 procedure q is
13742    type R1 (A : Boolean := False) is record
13743      case A is
13744        when True  => X : Character;
13745        when False => null;
13746      end case;
13747    end record;
13749    V1 : R1 (False);
13750    V2 : R1;
13752 begin
13753    Put_Line (Integer'Image (V1'Size));
13754    Put_Line (Integer'Image (V2'Size));
13755 end q;
13756 @end smallexample
13758 @noindent
13759 Here we are dealing with a variant record, where the True variant
13760 requires 16 bits, and the False variant requires 8 bits.
13761 In the above example, both V1 and V2 contain the False variant,
13762 which is only 8 bits long.  However, the result of running the
13763 program is:
13765 @smallexample
13768 @end smallexample
13770 @noindent
13771 The reason for the difference here is that the discriminant value of
13772 V1 is fixed, and will always be False.  It is not possible to assign
13773 a True variant value to V1, therefore 8 bits is sufficient.  On the
13774 other hand, in the case of V2, the initial discriminant value is
13775 False (from the default), but it is possible to assign a True
13776 variant value to V2, therefore 16 bits must be allocated for V2
13777 in the general case, even fewer bits may be needed at any particular
13778 point during the program execution.
13780 As can be seen from the output of this program, the @code{'Size}
13781 attribute applied to such an object in GNAT gives the actual allocated
13782 size of the variable, which is the largest size of any of the variants.
13783 The Ada Reference Manual is not completely clear on what choice should
13784 be made here, but the GNAT behavior seems most consistent with the
13785 language in the RM@.
13787 In some cases, it may be desirable to obtain the size of the current
13788 variant, rather than the size of the largest variant.  This can be
13789 achieved in GNAT by making use of the fact that in the case of a
13790 subprogram parameter, GNAT does indeed return the size of the current
13791 variant (because a subprogram has no way of knowing how much space
13792 is actually allocated for the actual).
13794 Consider the following modified version of the above program:
13796 @smallexample @c ada
13797 with Text_IO; use Text_IO;
13798 procedure q is
13799    type R1 (A : Boolean := False) is record
13800      case A is
13801        when True  => X : Character;
13802        when False => null;
13803      end case;
13804    end record;
13806    V2 : R1;
13808    function Size (V : R1) return Integer is
13809    begin
13810       return V'Size;
13811    end Size;
13813 begin
13814    Put_Line (Integer'Image (V2'Size));
13815    Put_Line (Integer'IMage (Size (V2)));
13816    V2 := (True, 'x');
13817    Put_Line (Integer'Image (V2'Size));
13818    Put_Line (Integer'IMage (Size (V2)));
13819 end q;
13820 @end smallexample
13822 @noindent
13823 The output from this program is
13825 @smallexample
13830 @end smallexample
13832 @noindent
13833 Here we see that while the @code{'Size} attribute always returns
13834 the maximum size, regardless of the current variant value, the
13835 @code{Size} function does indeed return the size of the current
13836 variant value.
13838 @node Biased Representation
13839 @section Biased Representation
13840 @cindex Size for biased representation
13841 @cindex Biased representation
13843 @noindent
13844 In the case of scalars with a range starting at other than zero, it is
13845 possible in some cases to specify a size smaller than the default minimum
13846 value, and in such cases, GNAT uses an unsigned biased representation,
13847 in which zero is used to represent the lower bound, and successive values
13848 represent successive values of the type.
13850 For example, suppose we have the declaration:
13852 @smallexample @c ada
13853    type Small is range -7 .. -4;
13854    for Small'Size use 2;
13855 @end smallexample
13857 @noindent
13858 Although the default size of type @code{Small} is 4, the @code{Size}
13859 clause is accepted by GNAT and results in the following representation
13860 scheme:
13862 @smallexample
13863   -7 is represented as 2#00#
13864   -6 is represented as 2#01#
13865   -5 is represented as 2#10#
13866   -4 is represented as 2#11#
13867 @end smallexample
13869 @noindent
13870 Biased representation is only used if the specified @code{Size} clause
13871 cannot be accepted in any other manner.  These reduced sizes that force
13872 biased representation can be used for all discrete types except for
13873 enumeration types for which a representation clause is given.
13875 @node Value_Size and Object_Size Clauses
13876 @section Value_Size and Object_Size Clauses
13877 @findex Value_Size
13878 @findex Object_Size
13879 @cindex Size, of objects
13881 @noindent
13882 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
13883 number of bits required to hold values of type @code{T}.
13884 Although this interpretation was allowed in Ada 83, it was not required,
13885 and this requirement in practice can cause some significant difficulties.
13886 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
13887 However, in Ada 95 and Ada 2005,
13888 @code{Natural'Size} is
13889 typically 31.  This means that code may change in behavior when moving
13890 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
13892 @smallexample @c ada
13893    type Rec is record;
13894       A : Natural;
13895       B : Natural;
13896    end record;
13898    for Rec use record
13899       at 0  range 0 .. Natural'Size - 1;
13900       at 0  range Natural'Size .. 2 * Natural'Size - 1;
13901    end record;
13902 @end smallexample
13904 @noindent
13905 In the above code, since the typical size of @code{Natural} objects
13906 is 32 bits and @code{Natural'Size} is 31, the above code can cause
13907 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
13908 there are cases where the fact that the object size can exceed the
13909 size of the type causes surprises.
13911 To help get around this problem GNAT provides two implementation
13912 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
13913 applied to a type, these attributes yield the size of the type
13914 (corresponding to the RM defined size attribute), and the size of
13915 objects of the type respectively.
13917 The @code{Object_Size} is used for determining the default size of
13918 objects and components.  This size value can be referred to using the
13919 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
13920 the basis of the determination of the size.  The backend is free to
13921 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
13922 character might be stored in 32 bits on a machine with no efficient
13923 byte access instructions such as the Alpha.
13925 The default rules for the value of @code{Object_Size} for
13926 discrete types are as follows:
13928 @itemize @bullet
13929 @item
13930 The @code{Object_Size} for base subtypes reflect the natural hardware
13931 size in bits (run the compiler with @option{-gnatS} to find those values
13932 for numeric types). Enumeration types and fixed-point base subtypes have
13933 8, 16, 32 or 64 bits for this size, depending on the range of values
13934 to be stored.
13936 @item
13937 The @code{Object_Size} of a subtype is the same as the
13938 @code{Object_Size} of
13939 the type from which it is obtained.
13941 @item
13942 The @code{Object_Size} of a derived base type is copied from the parent
13943 base type, and the @code{Object_Size} of a derived first subtype is copied
13944 from the parent first subtype.
13945 @end itemize
13947 @noindent
13948 The @code{Value_Size} attribute
13949 is the (minimum) number of bits required to store a value
13950 of the type.
13951 This value is used to determine how tightly to pack
13952 records or arrays with components of this type, and also affects
13953 the semantics of unchecked conversion (unchecked conversions where
13954 the @code{Value_Size} values differ generate a warning, and are potentially
13955 target dependent).
13957 The default rules for the value of @code{Value_Size} are as follows:
13959 @itemize @bullet
13960 @item
13961 The @code{Value_Size} for a base subtype is the minimum number of bits
13962 required to store all values of the type (including the sign bit
13963 only if negative values are possible).
13965 @item
13966 If a subtype statically matches the first subtype of a given type, then it has
13967 by default the same @code{Value_Size} as the first subtype.  This is a
13968 consequence of RM 13.1(14) (``if two subtypes statically match,
13969 then their subtype-specific aspects are the same''.)
13971 @item
13972 All other subtypes have a @code{Value_Size} corresponding to the minimum
13973 number of bits required to store all values of the subtype.  For
13974 dynamic bounds, it is assumed that the value can range down or up
13975 to the corresponding bound of the ancestor
13976 @end itemize
13978 @noindent
13979 The RM defined attribute @code{Size} corresponds to the
13980 @code{Value_Size} attribute.
13982 The @code{Size} attribute may be defined for a first-named subtype.  This sets
13983 the @code{Value_Size} of
13984 the first-named subtype to the given value, and the
13985 @code{Object_Size} of this first-named subtype to the given value padded up
13986 to an appropriate boundary.  It is a consequence of the default rules
13987 above that this @code{Object_Size} will apply to all further subtypes.  On the
13988 other hand, @code{Value_Size} is affected only for the first subtype, any
13989 dynamic subtypes obtained from it directly, and any statically matching
13990 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
13992 @code{Value_Size} and
13993 @code{Object_Size} may be explicitly set for any subtype using
13994 an attribute definition clause.  Note that the use of these attributes
13995 can cause the RM 13.1(14) rule to be violated.  If two access types
13996 reference aliased objects whose subtypes have differing @code{Object_Size}
13997 values as a result of explicit attribute definition clauses, then it
13998 is erroneous to convert from one access subtype to the other.
14000 At the implementation level, Esize stores the Object_Size and the
14001 RM_Size field stores the @code{Value_Size} (and hence the value of the
14002 @code{Size} attribute,
14003 which, as noted above, is equivalent to @code{Value_Size}).
14005 To get a feel for the difference, consider the following examples (note
14006 that in each case the base is @code{Short_Short_Integer} with a size of 8):
14008 @smallexample
14009                                        Object_Size     Value_Size
14011 type x1 is range 0 .. 5;                    8               3
14013 type x2 is range 0 .. 5;
14014 for x2'size use 12;                        16              12
14016 subtype x3 is x2 range 0 .. 3;             16               2
14018 subtype x4 is x2'base range 0 .. 10;        8               4
14020 subtype x5 is x2 range 0 .. dynamic;       16               3*
14022 subtype x6 is x2'base range 0 .. dynamic;   8               3*
14024 @end smallexample
14026 @noindent
14027 Note: the entries marked ``3*'' are not actually specified by the Ada
14028 Reference Manual, but it seems in the spirit of the RM rules to allocate
14029 the minimum number of bits (here 3, given the range for @code{x2})
14030 known to be large enough to hold the given range of values.
14032 So far, so good, but GNAT has to obey the RM rules, so the question is
14033 under what conditions must the RM @code{Size} be used.
14034 The following is a list
14035 of the occasions on which the RM @code{Size} must be used:
14037 @itemize @bullet
14038 @item
14039 Component size for packed arrays or records
14041 @item
14042 Value of the attribute @code{Size} for a type
14044 @item
14045 Warning about sizes not matching for unchecked conversion
14046 @end itemize
14048 @noindent
14049 For record types, the @code{Object_Size} is always a multiple of the
14050 alignment of the type (this is true for all types). In some cases the
14051 @code{Value_Size} can be smaller. Consider:
14053 @smallexample
14054    type R is record
14055      X : Integer;
14056      Y : Character;
14057    end record;
14058 @end smallexample
14060 @noindent
14061 On a typical 32-bit architecture, the X component will be four bytes, and
14062 require four-byte alignment, and the Y component will be one byte. In this
14063 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
14064 required to store a value of this type, and for example, it is permissible
14065 to have a component of type R in an outer array whose component size is
14066 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
14067 since it must be rounded up so that this value is a multiple of the
14068 alignment (4 bytes = 32 bits).
14070 @noindent
14071 For all other types, the @code{Object_Size}
14072 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
14073 Only @code{Size} may be specified for such types.
14075 @node Component_Size Clauses
14076 @section Component_Size Clauses
14077 @cindex Component_Size Clause
14079 @noindent
14080 Normally, the value specified in a component size clause must be consistent
14081 with the subtype of the array component with regard to size and alignment.
14082 In other words, the value specified must be at least equal to the size
14083 of this subtype, and must be a multiple of the alignment value.
14085 In addition, component size clauses are allowed which cause the array
14086 to be packed, by specifying a smaller value.  A first case is for
14087 component size values in the range 1 through 63.  The value specified
14088 must not be smaller than the Size of the subtype.  GNAT will accurately
14089 honor all packing requests in this range.  For example, if we have:
14091 @smallexample @c ada
14092 type r is array (1 .. 8) of Natural;
14093 for r'Component_Size use 31;
14094 @end smallexample
14096 @noindent
14097 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
14098 Of course access to the components of such an array is considerably
14099 less efficient than if the natural component size of 32 is used.
14100 A second case is when the subtype of the component is a record type
14101 padded because of its default alignment.  For example, if we have:
14103 @smallexample @c ada
14104 type r is record
14105   i : Integer;
14106   j : Integer;
14107   b : Boolean;
14108 end record;
14110 type a is array (1 .. 8) of r;
14111 for a'Component_Size use 72;
14112 @end smallexample
14114 @noindent
14115 then the resulting array has a length of 72 bytes, instead of 96 bytes
14116 if the alignment of the record (4) was obeyed.
14118 Note that there is no point in giving both a component size clause
14119 and a pragma Pack for the same array type. if such duplicate
14120 clauses are given, the pragma Pack will be ignored.
14122 @node Bit_Order Clauses
14123 @section Bit_Order Clauses
14124 @cindex Bit_Order Clause
14125 @cindex bit ordering
14126 @cindex ordering, of bits
14128 @noindent
14129 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
14130 attribute.  The specification may either correspond to the default bit
14131 order for the target, in which case the specification has no effect and
14132 places no additional restrictions, or it may be for the non-standard
14133 setting (that is the opposite of the default).
14135 In the case where the non-standard value is specified, the effect is
14136 to renumber bits within each byte, but the ordering of bytes is not
14137 affected.  There are certain
14138 restrictions placed on component clauses as follows:
14140 @itemize @bullet
14142 @item Components fitting within a single storage unit.
14143 @noindent
14144 These are unrestricted, and the effect is merely to renumber bits.  For
14145 example if we are on a little-endian machine with @code{Low_Order_First}
14146 being the default, then the following two declarations have exactly
14147 the same effect:
14149 @smallexample @c ada
14150    type R1 is record
14151       A : Boolean;
14152       B : Integer range 1 .. 120;
14153    end record;
14155    for R1 use record
14156       A at 0 range 0 .. 0;
14157       B at 0 range 1 .. 7;
14158    end record;
14160    type R2 is record
14161       A : Boolean;
14162       B : Integer range 1 .. 120;
14163    end record;
14165    for R2'Bit_Order use High_Order_First;
14167    for R2 use record
14168       A at 0 range 7 .. 7;
14169       B at 0 range 0 .. 6;
14170    end record;
14171 @end smallexample
14173 @noindent
14174 The useful application here is to write the second declaration with the
14175 @code{Bit_Order} attribute definition clause, and know that it will be treated
14176 the same, regardless of whether the target is little-endian or big-endian.
14178 @item Components occupying an integral number of bytes.
14179 @noindent
14180 These are components that exactly fit in two or more bytes.  Such component
14181 declarations are allowed, but have no effect, since it is important to realize
14182 that the @code{Bit_Order} specification does not affect the ordering of bytes.
14183 In particular, the following attempt at getting an endian-independent integer
14184 does not work:
14186 @smallexample @c ada
14187    type R2 is record
14188       A : Integer;
14189    end record;
14191    for R2'Bit_Order use High_Order_First;
14193    for R2 use record
14194       A at 0 range 0 .. 31;
14195    end record;
14196 @end smallexample
14198 @noindent
14199 This declaration will result in a little-endian integer on a
14200 little-endian machine, and a big-endian integer on a big-endian machine.
14201 If byte flipping is required for interoperability between big- and
14202 little-endian machines, this must be explicitly programmed.  This capability
14203 is not provided by @code{Bit_Order}.
14205 @item Components that are positioned across byte boundaries
14206 @noindent
14207 but do not occupy an integral number of bytes.  Given that bytes are not
14208 reordered, such fields would occupy a non-contiguous sequence of bits
14209 in memory, requiring non-trivial code to reassemble.  They are for this
14210 reason not permitted, and any component clause specifying such a layout
14211 will be flagged as illegal by GNAT@.
14213 @end itemize
14215 @noindent
14216 Since the misconception that Bit_Order automatically deals with all
14217 endian-related incompatibilities is a common one, the specification of
14218 a component field that is an integral number of bytes will always
14219 generate a warning.  This warning may be suppressed using @code{pragma
14220 Warnings (Off)} if desired.  The following section contains additional
14221 details regarding the issue of byte ordering.
14223 @node Effect of Bit_Order on Byte Ordering
14224 @section Effect of Bit_Order on Byte Ordering
14225 @cindex byte ordering
14226 @cindex ordering, of bytes
14228 @noindent
14229 In this section we will review the effect of the @code{Bit_Order} attribute
14230 definition clause on byte ordering.  Briefly, it has no effect at all, but
14231 a detailed example will be helpful.  Before giving this
14232 example, let us review the precise
14233 definition of the effect of defining @code{Bit_Order}.  The effect of a
14234 non-standard bit order is described in section 15.5.3 of the Ada
14235 Reference Manual:
14237 @quotation
14238 2   A bit ordering is a method of interpreting the meaning of
14239 the storage place attributes.
14240 @end quotation
14242 @noindent
14243 To understand the precise definition of storage place attributes in
14244 this context, we visit section 13.5.1 of the manual:
14246 @quotation
14247 13   A record_representation_clause (without the mod_clause)
14248 specifies the layout.  The storage place attributes (see 13.5.2)
14249 are taken from the values of the position, first_bit, and last_bit
14250 expressions after normalizing those values so that first_bit is
14251 less than Storage_Unit.
14252 @end quotation
14254 @noindent
14255 The critical point here is that storage places are taken from
14256 the values after normalization, not before.  So the @code{Bit_Order}
14257 interpretation applies to normalized values.  The interpretation
14258 is described in the later part of the 15.5.3 paragraph:
14260 @quotation
14261 2   A bit ordering is a method of interpreting the meaning of
14262 the storage place attributes.  High_Order_First (known in the
14263 vernacular as ``big endian'') means that the first bit of a
14264 storage element (bit 0) is the most significant bit (interpreting
14265 the sequence of bits that represent a component as an unsigned
14266 integer value).  Low_Order_First (known in the vernacular as
14267 ``little endian'') means the opposite: the first bit is the
14268 least significant.
14269 @end quotation
14271 @noindent
14272 Note that the numbering is with respect to the bits of a storage
14273 unit.  In other words, the specification affects only the numbering
14274 of bits within a single storage unit.
14276 We can make the effect clearer by giving an example.
14278 Suppose that we have an external device which presents two bytes, the first
14279 byte presented, which is the first (low addressed byte) of the two byte
14280 record is called Master, and the second byte is called Slave.
14282 The left most (most significant bit is called Control for each byte, and
14283 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
14284 (least significant) bit.
14286 On a big-endian machine, we can write the following representation clause
14288 @smallexample @c ada
14289    type Data is record
14290       Master_Control : Bit;
14291       Master_V1      : Bit;
14292       Master_V2      : Bit;
14293       Master_V3      : Bit;
14294       Master_V4      : Bit;
14295       Master_V5      : Bit;
14296       Master_V6      : Bit;
14297       Master_V7      : Bit;
14298       Slave_Control  : Bit;
14299       Slave_V1       : Bit;
14300       Slave_V2       : Bit;
14301       Slave_V3       : Bit;
14302       Slave_V4       : Bit;
14303       Slave_V5       : Bit;
14304       Slave_V6       : Bit;
14305       Slave_V7       : Bit;
14306    end record;
14308    for Data use record
14309       Master_Control at 0 range 0 .. 0;
14310       Master_V1      at 0 range 1 .. 1;
14311       Master_V2      at 0 range 2 .. 2;
14312       Master_V3      at 0 range 3 .. 3;
14313       Master_V4      at 0 range 4 .. 4;
14314       Master_V5      at 0 range 5 .. 5;
14315       Master_V6      at 0 range 6 .. 6;
14316       Master_V7      at 0 range 7 .. 7;
14317       Slave_Control  at 1 range 0 .. 0;
14318       Slave_V1       at 1 range 1 .. 1;
14319       Slave_V2       at 1 range 2 .. 2;
14320       Slave_V3       at 1 range 3 .. 3;
14321       Slave_V4       at 1 range 4 .. 4;
14322       Slave_V5       at 1 range 5 .. 5;
14323       Slave_V6       at 1 range 6 .. 6;
14324       Slave_V7       at 1 range 7 .. 7;
14325    end record;
14326 @end smallexample
14328 @noindent
14329 Now if we move this to a little endian machine, then the bit ordering within
14330 the byte is backwards, so we have to rewrite the record rep clause as:
14332 @smallexample @c ada
14333    for Data use record
14334       Master_Control at 0 range 7 .. 7;
14335       Master_V1      at 0 range 6 .. 6;
14336       Master_V2      at 0 range 5 .. 5;
14337       Master_V3      at 0 range 4 .. 4;
14338       Master_V4      at 0 range 3 .. 3;
14339       Master_V5      at 0 range 2 .. 2;
14340       Master_V6      at 0 range 1 .. 1;
14341       Master_V7      at 0 range 0 .. 0;
14342       Slave_Control  at 1 range 7 .. 7;
14343       Slave_V1       at 1 range 6 .. 6;
14344       Slave_V2       at 1 range 5 .. 5;
14345       Slave_V3       at 1 range 4 .. 4;
14346       Slave_V4       at 1 range 3 .. 3;
14347       Slave_V5       at 1 range 2 .. 2;
14348       Slave_V6       at 1 range 1 .. 1;
14349       Slave_V7       at 1 range 0 .. 0;
14350    end record;
14351 @end smallexample
14353 @noindent
14354 It is a nuisance to have to rewrite the clause, especially if
14355 the code has to be maintained on both machines.  However,
14356 this is a case that we can handle with the
14357 @code{Bit_Order} attribute if it is implemented.
14358 Note that the implementation is not required on byte addressed
14359 machines, but it is indeed implemented in GNAT.
14360 This means that we can simply use the
14361 first record clause, together with the declaration
14363 @smallexample @c ada
14364    for Data'Bit_Order use High_Order_First;
14365 @end smallexample
14367 @noindent
14368 and the effect is what is desired, namely the layout is exactly the same,
14369 independent of whether the code is compiled on a big-endian or little-endian
14370 machine.
14372 The important point to understand is that byte ordering is not affected.
14373 A @code{Bit_Order} attribute definition never affects which byte a field
14374 ends up in, only where it ends up in that byte.
14375 To make this clear, let us rewrite the record rep clause of the previous
14376 example as:
14378 @smallexample @c ada
14379    for Data'Bit_Order use High_Order_First;
14380    for Data use record
14381       Master_Control at 0 range  0 .. 0;
14382       Master_V1      at 0 range  1 .. 1;
14383       Master_V2      at 0 range  2 .. 2;
14384       Master_V3      at 0 range  3 .. 3;
14385       Master_V4      at 0 range  4 .. 4;
14386       Master_V5      at 0 range  5 .. 5;
14387       Master_V6      at 0 range  6 .. 6;
14388       Master_V7      at 0 range  7 .. 7;
14389       Slave_Control  at 0 range  8 .. 8;
14390       Slave_V1       at 0 range  9 .. 9;
14391       Slave_V2       at 0 range 10 .. 10;
14392       Slave_V3       at 0 range 11 .. 11;
14393       Slave_V4       at 0 range 12 .. 12;
14394       Slave_V5       at 0 range 13 .. 13;
14395       Slave_V6       at 0 range 14 .. 14;
14396       Slave_V7       at 0 range 15 .. 15;
14397    end record;
14398 @end smallexample
14400 @noindent
14401 This is exactly equivalent to saying (a repeat of the first example):
14403 @smallexample @c ada
14404    for Data'Bit_Order use High_Order_First;
14405    for Data use record
14406       Master_Control at 0 range 0 .. 0;
14407       Master_V1      at 0 range 1 .. 1;
14408       Master_V2      at 0 range 2 .. 2;
14409       Master_V3      at 0 range 3 .. 3;
14410       Master_V4      at 0 range 4 .. 4;
14411       Master_V5      at 0 range 5 .. 5;
14412       Master_V6      at 0 range 6 .. 6;
14413       Master_V7      at 0 range 7 .. 7;
14414       Slave_Control  at 1 range 0 .. 0;
14415       Slave_V1       at 1 range 1 .. 1;
14416       Slave_V2       at 1 range 2 .. 2;
14417       Slave_V3       at 1 range 3 .. 3;
14418       Slave_V4       at 1 range 4 .. 4;
14419       Slave_V5       at 1 range 5 .. 5;
14420       Slave_V6       at 1 range 6 .. 6;
14421       Slave_V7       at 1 range 7 .. 7;
14422    end record;
14423 @end smallexample
14425 @noindent
14426 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
14427 field.  The storage place attributes are obtained by normalizing the
14428 values given so that the @code{First_Bit} value is less than 8.  After
14429 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
14430 we specified in the other case.
14432 Now one might expect that the @code{Bit_Order} attribute might affect
14433 bit numbering within the entire record component (two bytes in this
14434 case, thus affecting which byte fields end up in), but that is not
14435 the way this feature is defined, it only affects numbering of bits,
14436 not which byte they end up in.
14438 Consequently it never makes sense to specify a starting bit number
14439 greater than 7 (for a byte addressable field) if an attribute
14440 definition for @code{Bit_Order} has been given, and indeed it
14441 may be actively confusing to specify such a value, so the compiler
14442 generates a warning for such usage.
14444 If you do need to control byte ordering then appropriate conditional
14445 values must be used.  If in our example, the slave byte came first on
14446 some machines we might write:
14448 @smallexample @c ada
14449    Master_Byte_First constant Boolean := @dots{};
14451    Master_Byte : constant Natural :=
14452                    1 - Boolean'Pos (Master_Byte_First);
14453    Slave_Byte  : constant Natural :=
14454                    Boolean'Pos (Master_Byte_First);
14456    for Data'Bit_Order use High_Order_First;
14457    for Data use record
14458       Master_Control at Master_Byte range 0 .. 0;
14459       Master_V1      at Master_Byte range 1 .. 1;
14460       Master_V2      at Master_Byte range 2 .. 2;
14461       Master_V3      at Master_Byte range 3 .. 3;
14462       Master_V4      at Master_Byte range 4 .. 4;
14463       Master_V5      at Master_Byte range 5 .. 5;
14464       Master_V6      at Master_Byte range 6 .. 6;
14465       Master_V7      at Master_Byte range 7 .. 7;
14466       Slave_Control  at Slave_Byte  range 0 .. 0;
14467       Slave_V1       at Slave_Byte  range 1 .. 1;
14468       Slave_V2       at Slave_Byte  range 2 .. 2;
14469       Slave_V3       at Slave_Byte  range 3 .. 3;
14470       Slave_V4       at Slave_Byte  range 4 .. 4;
14471       Slave_V5       at Slave_Byte  range 5 .. 5;
14472       Slave_V6       at Slave_Byte  range 6 .. 6;
14473       Slave_V7       at Slave_Byte  range 7 .. 7;
14474    end record;
14475 @end smallexample
14477 @noindent
14478 Now to switch between machines, all that is necessary is
14479 to set the boolean constant @code{Master_Byte_First} in
14480 an appropriate manner.
14482 @node Pragma Pack for Arrays
14483 @section Pragma Pack for Arrays
14484 @cindex Pragma Pack (for arrays)
14486 @noindent
14487 Pragma @code{Pack} applied to an array has no effect unless the component type
14488 is packable.  For a component type to be packable, it must be one of the
14489 following cases:
14491 @itemize @bullet
14492 @item
14493 Any scalar type
14494 @item
14495 Any type whose size is specified with a size clause
14496 @item
14497 Any packed array type with a static size
14498 @item
14499 Any record type padded because of its default alignment
14500 @end itemize
14502 @noindent
14503 For all these cases, if the component subtype size is in the range
14504 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
14505 component size were specified giving the component subtype size.
14506 For example if we have:
14508 @smallexample @c ada
14509    type r is range 0 .. 17;
14511    type ar is array (1 .. 8) of r;
14512    pragma Pack (ar);
14513 @end smallexample
14515 @noindent
14516 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
14517 and the size of the array @code{ar} will be exactly 40 bits.
14519 Note that in some cases this rather fierce approach to packing can produce
14520 unexpected effects.  For example, in Ada 95 and Ada 2005,
14521 subtype @code{Natural} typically has a size of 31, meaning that if you
14522 pack an array of @code{Natural}, you get 31-bit
14523 close packing, which saves a few bits, but results in far less efficient
14524 access.  Since many other Ada compilers will ignore such a packing request,
14525 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
14526 might not be what is intended.  You can easily remove this warning by
14527 using an explicit @code{Component_Size} setting instead, which never generates
14528 a warning, since the intention of the programmer is clear in this case.
14530 GNAT treats packed arrays in one of two ways.  If the size of the array is
14531 known at compile time and is less than 64 bits, then internally the array
14532 is represented as a single modular type, of exactly the appropriate number
14533 of bits.  If the length is greater than 63 bits, or is not known at compile
14534 time, then the packed array is represented as an array of bytes, and the
14535 length is always a multiple of 8 bits.
14537 Note that to represent a packed array as a modular type, the alignment must
14538 be suitable for the modular type involved. For example, on typical machines
14539 a 32-bit packed array will be represented by a 32-bit modular integer with
14540 an alignment of four bytes. If you explicitly override the default alignment
14541 with an alignment clause that is too small, the modular representation
14542 cannot be used. For example, consider the following set of declarations:
14544 @smallexample @c ada
14545    type R is range 1 .. 3;
14546    type S is array (1 .. 31) of R;
14547    for S'Component_Size use 2;
14548    for S'Size use 62;
14549    for S'Alignment use 1;
14550 @end smallexample
14552 @noindent
14553 If the alignment clause were not present, then a 62-bit modular
14554 representation would be chosen (typically with an alignment of 4 or 8
14555 bytes depending on the target). But the default alignment is overridden
14556 with the explicit alignment clause. This means that the modular
14557 representation cannot be used, and instead the array of bytes
14558 representation must be used, meaning that the length must be a multiple
14559 of 8. Thus the above set of declarations will result in a diagnostic
14560 rejecting the size clause and noting that the minimum size allowed is 64.
14562 @cindex Pragma Pack (for type Natural)
14563 @cindex Pragma Pack warning
14565 One special case that is worth noting occurs when the base type of the
14566 component size is 8/16/32 and the subtype is one bit less. Notably this
14567 occurs with subtype @code{Natural}. Consider:
14569 @smallexample @c ada
14570    type Arr is array (1 .. 32) of Natural;
14571    pragma Pack (Arr);
14572 @end smallexample
14574 @noindent
14575 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
14576 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
14577 Ada 83 compilers did not attempt 31 bit packing.
14579 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
14580 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
14581 substantial unintended performance penalty when porting legacy Ada 83 code.
14582 To help prevent this, GNAT generates a warning in such cases. If you really
14583 want 31 bit packing in a case like this, you can set the component size
14584 explicitly:
14586 @smallexample @c ada
14587    type Arr is array (1 .. 32) of Natural;
14588    for Arr'Component_Size use 31;
14589 @end smallexample
14591 @noindent
14592 Here 31-bit packing is achieved as required, and no warning is generated,
14593 since in this case the programmer intention is clear.
14595 @node Pragma Pack for Records
14596 @section Pragma Pack for Records
14597 @cindex Pragma Pack (for records)
14599 @noindent
14600 Pragma @code{Pack} applied to a record will pack the components to reduce
14601 wasted space from alignment gaps and by reducing the amount of space
14602 taken by components.  We distinguish between @emph{packable} components and
14603 @emph{non-packable} components.
14604 Components of the following types are considered packable:
14605 @itemize @bullet
14606 @item
14607 All primitive types are packable.
14609 @item
14610 Small packed arrays, whose size does not exceed 64 bits, and where the
14611 size is statically known at compile time, are represented internally
14612 as modular integers, and so they are also packable.
14614 @end itemize
14616 @noindent
14617 All packable components occupy the exact number of bits corresponding to
14618 their @code{Size} value, and are packed with no padding bits, i.e.@: they
14619 can start on an arbitrary bit boundary.
14621 All other types are non-packable, they occupy an integral number of
14622 storage units, and
14623 are placed at a boundary corresponding to their alignment requirements.
14625 For example, consider the record
14627 @smallexample @c ada
14628    type Rb1 is array (1 .. 13) of Boolean;
14629    pragma Pack (rb1);
14631    type Rb2 is array (1 .. 65) of Boolean;
14632    pragma Pack (rb2);
14634    type x2 is record
14635       l1 : Boolean;
14636       l2 : Duration;
14637       l3 : Float;
14638       l4 : Boolean;
14639       l5 : Rb1;
14640       l6 : Rb2;
14641    end record;
14642    pragma Pack (x2);
14643 @end smallexample
14645 @noindent
14646 The representation for the record x2 is as follows:
14648 @smallexample @c ada
14649 for x2'Size use 224;
14650 for x2 use record
14651    l1 at  0 range  0 .. 0;
14652    l2 at  0 range  1 .. 64;
14653    l3 at 12 range  0 .. 31;
14654    l4 at 16 range  0 .. 0;
14655    l5 at 16 range  1 .. 13;
14656    l6 at 18 range  0 .. 71;
14657 end record;
14658 @end smallexample
14660 @noindent
14661 Studying this example, we see that the packable fields @code{l1}
14662 and @code{l2} are
14663 of length equal to their sizes, and placed at specific bit boundaries (and
14664 not byte boundaries) to
14665 eliminate padding.  But @code{l3} is of a non-packable float type, so
14666 it is on the next appropriate alignment boundary.
14668 The next two fields are fully packable, so @code{l4} and @code{l5} are
14669 minimally packed with no gaps.  However, type @code{Rb2} is a packed
14670 array that is longer than 64 bits, so it is itself non-packable.  Thus
14671 the @code{l6} field is aligned to the next byte boundary, and takes an
14672 integral number of bytes, i.e.@: 72 bits.
14674 @node Record Representation Clauses
14675 @section Record Representation Clauses
14676 @cindex Record Representation Clause
14678 @noindent
14679 Record representation clauses may be given for all record types, including
14680 types obtained by record extension.  Component clauses are allowed for any
14681 static component.  The restrictions on component clauses depend on the type
14682 of the component.
14684 @cindex Component Clause
14685 For all components of an elementary type, the only restriction on component
14686 clauses is that the size must be at least the 'Size value of the type
14687 (actually the Value_Size).  There are no restrictions due to alignment,
14688 and such components may freely cross storage boundaries.
14690 Packed arrays with a size up to and including 64 bits are represented
14691 internally using a modular type with the appropriate number of bits, and
14692 thus the same lack of restriction applies.  For example, if you declare:
14694 @smallexample @c ada
14695    type R is array (1 .. 49) of Boolean;
14696    pragma Pack (R);
14697    for R'Size use 49;
14698 @end smallexample
14700 @noindent
14701 then a component clause for a component of type R may start on any
14702 specified bit boundary, and may specify a value of 49 bits or greater.
14704 For packed bit arrays that are longer than 64 bits, there are two
14705 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
14706 including the important case of single bits or boolean values, then
14707 there are no limitations on placement of such components, and they
14708 may start and end at arbitrary bit boundaries.
14710 If the component size is not a power of 2 (e.g.@: 3 or 5), then
14711 an array of this type longer than 64 bits must always be placed on
14712 on a storage unit (byte) boundary and occupy an integral number
14713 of storage units (bytes). Any component clause that does not
14714 meet this requirement will be rejected.
14716 Any aliased component, or component of an aliased type, must
14717 have its normal alignment and size. A component clause that
14718 does not meet this requirement will be rejected.
14720 The tag field of a tagged type always occupies an address sized field at
14721 the start of the record.  No component clause may attempt to overlay this
14722 tag. When a tagged type appears as a component, the tag field must have
14723 proper alignment
14725 In the case of a record extension T1, of a type T, no component clause applied
14726 to the type T1 can specify a storage location that would overlap the first
14727 T'Size bytes of the record.
14729 For all other component types, including non-bit-packed arrays,
14730 the component can be placed at an arbitrary bit boundary,
14731 so for example, the following is permitted:
14733 @smallexample @c ada
14734    type R is array (1 .. 10) of Boolean;
14735    for R'Size use 80;
14737    type Q is record
14738       G, H : Boolean;
14739       L, M : R;
14740    end record;
14742    for Q use record
14743       G at 0 range  0 ..   0;
14744       H at 0 range  1 ..   1;
14745       L at 0 range  2 ..  81;
14746       R at 0 range 82 .. 161;
14747    end record;
14748 @end smallexample
14750 @noindent
14751 Note: the above rules apply to recent releases of GNAT 5.
14752 In GNAT 3, there are more severe restrictions on larger components.
14753 For non-primitive types, including packed arrays with a size greater than
14754 64 bits, component clauses must respect the alignment requirement of the
14755 type, in particular, always starting on a byte boundary, and the length
14756 must be a multiple of the storage unit.
14758 @node Enumeration Clauses
14759 @section Enumeration Clauses
14761 The only restriction on enumeration clauses is that the range of values
14762 must be representable.  For the signed case, if one or more of the
14763 representation values are negative, all values must be in the range:
14765 @smallexample @c ada
14766    System.Min_Int .. System.Max_Int
14767 @end smallexample
14769 @noindent
14770 For the unsigned case, where all values are nonnegative, the values must
14771 be in the range:
14773 @smallexample @c ada
14774    0 .. System.Max_Binary_Modulus;
14775 @end smallexample
14777 @noindent
14778 A @emph{confirming} representation clause is one in which the values range
14779 from 0 in sequence, i.e.@: a clause that confirms the default representation
14780 for an enumeration type.
14781 Such a confirming representation
14782 is permitted by these rules, and is specially recognized by the compiler so
14783 that no extra overhead results from the use of such a clause.
14785 If an array has an index type which is an enumeration type to which an
14786 enumeration clause has been applied, then the array is stored in a compact
14787 manner.  Consider the declarations:
14789 @smallexample @c ada
14790    type r is (A, B, C);
14791    for r use (A => 1, B => 5, C => 10);
14792    type t is array (r) of Character;
14793 @end smallexample
14795 @noindent
14796 The array type t corresponds to a vector with exactly three elements and
14797 has a default size equal to @code{3*Character'Size}.  This ensures efficient
14798 use of space, but means that accesses to elements of the array will incur
14799 the overhead of converting representation values to the corresponding
14800 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
14802 @node Address Clauses
14803 @section Address Clauses
14804 @cindex Address Clause
14806 The reference manual allows a general restriction on representation clauses,
14807 as found in RM 13.1(22):
14809 @quotation
14810 An implementation need not support representation
14811 items containing nonstatic expressions, except that
14812 an implementation should support a representation item
14813 for a given entity if each nonstatic expression in the
14814 representation item is a name that statically denotes
14815 a constant declared before the entity.
14816 @end quotation
14818 @noindent
14819 In practice this is applicable only to address clauses, since this is the
14820 only case in which a non-static expression is permitted by the syntax.  As
14821 the AARM notes in sections 13.1 (22.a-22.h):
14823 @display
14824   22.a   Reason: This is to avoid the following sort of thing:
14826   22.b        X : Integer := F(@dots{});
14827               Y : Address := G(@dots{});
14828               for X'Address use Y;
14830   22.c   In the above, we have to evaluate the
14831          initialization expression for X before we
14832          know where to put the result.  This seems
14833          like an unreasonable implementation burden.
14835   22.d   The above code should instead be written
14836          like this:
14838   22.e        Y : constant Address := G(@dots{});
14839               X : Integer := F(@dots{});
14840               for X'Address use Y;
14842   22.f   This allows the expression ``Y'' to be safely
14843          evaluated before X is created.
14845   22.g   The constant could be a formal parameter of mode in.
14847   22.h   An implementation can support other nonstatic
14848          expressions if it wants to.  Expressions of type
14849          Address are hardly ever static, but their value
14850          might be known at compile time anyway in many
14851          cases.
14852 @end display
14854 @noindent
14855 GNAT does indeed permit many additional cases of non-static expressions.  In
14856 particular, if the type involved is elementary there are no restrictions
14857 (since in this case, holding a temporary copy of the initialization value,
14858 if one is present, is inexpensive).  In addition, if there is no implicit or
14859 explicit initialization, then there are no restrictions.  GNAT will reject
14860 only the case where all three of these conditions hold:
14862 @itemize @bullet
14864 @item
14865 The type of the item is non-elementary (e.g.@: a record or array).
14867 @item
14868 There is explicit or implicit initialization required for the object.
14869 Note that access values are always implicitly initialized.
14871 @item
14872 The address value is non-static.  Here GNAT is more permissive than the
14873 RM, and allows the address value to be the address of a previously declared
14874 stand-alone variable, as long as it does not itself have an address clause.
14876 @smallexample @c ada
14877            Anchor  : Some_Initialized_Type;
14878            Overlay : Some_Initialized_Type;
14879            for Overlay'Address use Anchor'Address;
14880 @end smallexample
14882 @noindent
14883 However, the prefix of the address clause cannot be an array component, or
14884 a component of a discriminated record.
14886 @end itemize
14888 @noindent
14889 As noted above in section 22.h, address values are typically non-static.  In
14890 particular the To_Address function, even if applied to a literal value, is
14891 a non-static function call.  To avoid this minor annoyance, GNAT provides
14892 the implementation defined attribute 'To_Address.  The following two
14893 expressions have identical values:
14895 @findex Attribute
14896 @findex To_Address
14897 @smallexample @c ada
14898    To_Address (16#1234_0000#)
14899    System'To_Address (16#1234_0000#);
14900 @end smallexample
14902 @noindent
14903 except that the second form is considered to be a static expression, and
14904 thus when used as an address clause value is always permitted.
14906 @noindent
14907 Additionally, GNAT treats as static an address clause that is an
14908 unchecked_conversion of a static integer value.  This simplifies the porting
14909 of legacy code, and provides a portable equivalent to the GNAT attribute
14910 @code{To_Address}.
14912 Another issue with address clauses is the interaction with alignment
14913 requirements.  When an address clause is given for an object, the address
14914 value must be consistent with the alignment of the object (which is usually
14915 the same as the alignment of the type of the object).  If an address clause
14916 is given that specifies an inappropriately aligned address value, then the
14917 program execution is erroneous.
14919 Since this source of erroneous behavior can have unfortunate effects, GNAT
14920 checks (at compile time if possible, generating a warning, or at execution
14921 time with a run-time check) that the alignment is appropriate.  If the
14922 run-time check fails, then @code{Program_Error} is raised.  This run-time
14923 check is suppressed if range checks are suppressed, or if the special GNAT
14924 check Alignment_Check is suppressed, or if
14925 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
14927 Finally, GNAT does not permit overlaying of objects of controlled types or
14928 composite types containing a controlled component. In most cases, the compiler
14929 can detect an attempt at such overlays and will generate a warning at compile
14930 time and a Program_Error exception at run time.
14932 @findex Export
14933 An address clause cannot be given for an exported object.  More
14934 understandably the real restriction is that objects with an address
14935 clause cannot be exported.  This is because such variables are not
14936 defined by the Ada program, so there is no external object to export.
14938 @findex Import
14939 It is permissible to give an address clause and a pragma Import for the
14940 same object.  In this case, the variable is not really defined by the
14941 Ada program, so there is no external symbol to be linked.  The link name
14942 and the external name are ignored in this case.  The reason that we allow this
14943 combination is that it provides a useful idiom to avoid unwanted
14944 initializations on objects with address clauses.
14946 When an address clause is given for an object that has implicit or
14947 explicit initialization, then by default initialization takes place.  This
14948 means that the effect of the object declaration is to overwrite the
14949 memory at the specified address.  This is almost always not what the
14950 programmer wants, so GNAT will output a warning:
14952 @smallexample
14953   with System;
14954   package G is
14955      type R is record
14956         M : Integer := 0;
14957      end record;
14959      Ext : R;
14960      for Ext'Address use System'To_Address (16#1234_1234#);
14961          |
14962   >>> warning: implicit initialization of "Ext" may
14963       modify overlaid storage
14964   >>> warning: use pragma Import for "Ext" to suppress
14965       initialization (RM B(24))
14967   end G;
14968 @end smallexample
14970 @noindent
14971 As indicated by the warning message, the solution is to use a (dummy) pragma
14972 Import to suppress this initialization.  The pragma tell the compiler that the
14973 object is declared and initialized elsewhere.  The following package compiles
14974 without warnings (and the initialization is suppressed):
14976 @smallexample @c ada
14977    with System;
14978    package G is
14979       type R is record
14980          M : Integer := 0;
14981       end record;
14983       Ext : R;
14984       for Ext'Address use System'To_Address (16#1234_1234#);
14985       pragma Import (Ada, Ext);
14986    end G;
14987 @end smallexample
14989 @noindent
14990 A final issue with address clauses involves their use for overlaying
14991 variables, as in the following example:
14992 @cindex Overlaying of objects
14994 @smallexample @c ada
14995   A : Integer;
14996   B : Integer;
14997   for B'Address use A'Address;
14998 @end smallexample
15000 @noindent
15001 or alternatively, using the form recommended by the RM:
15003 @smallexample @c ada
15004   A    : Integer;
15005   Addr : constant Address := A'Address;
15006   B    : Integer;
15007   for B'Address use Addr;
15008 @end smallexample
15010 @noindent
15011 In both of these cases, @code{A}
15012 and @code{B} become aliased to one another via the
15013 address clause. This use of address clauses to overlay
15014 variables, achieving an effect similar to unchecked
15015 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
15016 the effect is implementation defined. Furthermore, the
15017 Ada RM specifically recommends that in a situation
15018 like this, @code{B} should be subject to the following
15019 implementation advice (RM 13.3(19)):
15021 @quotation
15022 19  If the Address of an object is specified, or it is imported
15023     or exported, then the implementation should not perform
15024     optimizations based on assumptions of no aliases.
15025 @end quotation
15027 @noindent
15028 GNAT follows this recommendation, and goes further by also applying
15029 this recommendation to the overlaid variable (@code{A}
15030 in the above example) in this case. This means that the overlay
15031 works "as expected", in that a modification to one of the variables
15032 will affect the value of the other.
15034 @node Effect of Convention on Representation
15035 @section Effect of Convention on Representation
15036 @cindex Convention, effect on representation
15038 @noindent
15039 Normally the specification of a foreign language convention for a type or
15040 an object has no effect on the chosen representation.  In particular, the
15041 representation chosen for data in GNAT generally meets the standard system
15042 conventions, and for example records are laid out in a manner that is
15043 consistent with C@.  This means that specifying convention C (for example)
15044 has no effect.
15046 There are four exceptions to this general rule:
15048 @itemize @bullet
15050 @item Convention Fortran and array subtypes
15051 If pragma Convention Fortran is specified for an array subtype, then in
15052 accordance with the implementation advice in section 3.6.2(11) of the
15053 Ada Reference Manual, the array will be stored in a Fortran-compatible
15054 column-major manner, instead of the normal default row-major order.
15056 @item Convention C and enumeration types
15057 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
15058 to accommodate all values of the type.  For example, for the enumeration
15059 type declared by:
15061 @smallexample @c ada
15062    type Color is (Red, Green, Blue);
15063 @end smallexample
15065 @noindent
15066 8 bits is sufficient to store all values of the type, so by default, objects
15067 of type @code{Color} will be represented using 8 bits.  However, normal C
15068 convention is to use 32 bits for all enum values in C, since enum values
15069 are essentially of type int.  If pragma @code{Convention C} is specified for an
15070 Ada enumeration type, then the size is modified as necessary (usually to
15071 32 bits) to be consistent with the C convention for enum values.
15073 Note that this treatment applies only to types. If Convention C is given for
15074 an enumeration object, where the enumeration type is not Convention C, then
15075 Object_Size bits are allocated. For example, for a normal enumeration type,
15076 with less than 256 elements, only 8 bits will be allocated for the object.
15077 Since this may be a surprise in terms of what C expects, GNAT will issue a
15078 warning in this situation. The warning can be suppressed by giving an explicit
15079 size clause specifying the desired size.
15081 @item Convention C/Fortran and Boolean types
15082 In C, the usual convention for boolean values, that is values used for
15083 conditions, is that zero represents false, and nonzero values represent
15084 true.  In Ada, the normal convention is that two specific values, typically
15085 0/1, are used to represent false/true respectively.
15087 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
15088 value represents true).
15090 To accommodate the Fortran and C conventions, if a pragma Convention specifies
15091 C or Fortran convention for a derived Boolean, as in the following example:
15093 @smallexample @c ada
15094    type C_Switch is new Boolean;
15095    pragma Convention (C, C_Switch);
15096 @end smallexample
15098 @noindent
15099 then the GNAT generated code will treat any nonzero value as true.  For truth
15100 values generated by GNAT, the conventional value 1 will be used for True, but
15101 when one of these values is read, any nonzero value is treated as True.
15103 @item Access types on OpenVMS
15104 For 64-bit OpenVMS systems, access types (other than those for unconstrained
15105 arrays) are 64-bits long. An exception to this rule is for the case of
15106 C-convention access types where there is no explicit size clause present (or
15107 inherited for derived types). In this case, GNAT chooses to make these
15108 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
15109 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
15111 @end itemize
15113 @node Determining the Representations chosen by GNAT
15114 @section Determining the Representations chosen by GNAT
15115 @cindex Representation, determination of
15116 @cindex @option{-gnatR} switch
15118 @noindent
15119 Although the descriptions in this section are intended to be complete, it is
15120 often easier to simply experiment to see what GNAT accepts and what the
15121 effect is on the layout of types and objects.
15123 As required by the Ada RM, if a representation clause is not accepted, then
15124 it must be rejected as illegal by the compiler.  However, when a
15125 representation clause or pragma is accepted, there can still be questions
15126 of what the compiler actually does.  For example, if a partial record
15127 representation clause specifies the location of some components and not
15128 others, then where are the non-specified components placed? Or if pragma
15129 @code{Pack} is used on a record, then exactly where are the resulting
15130 fields placed? The section on pragma @code{Pack} in this chapter can be
15131 used to answer the second question, but it is often easier to just see
15132 what the compiler does.
15134 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
15135 with this option, then the compiler will output information on the actual
15136 representations chosen, in a format similar to source representation
15137 clauses.  For example, if we compile the package:
15139 @smallexample @c ada
15140 package q is
15141    type r (x : boolean) is tagged record
15142       case x is
15143          when True => S : String (1 .. 100);
15144          when False => null;
15145       end case;
15146    end record;
15148    type r2 is new r (false) with record
15149       y2 : integer;
15150    end record;
15152    for r2 use record
15153       y2 at 16 range 0 .. 31;
15154    end record;
15156    type x is record
15157       y : character;
15158    end record;
15160    type x1 is array (1 .. 10) of x;
15161    for x1'component_size use 11;
15163    type ia is access integer;
15165    type Rb1 is array (1 .. 13) of Boolean;
15166    pragma Pack (rb1);
15168    type Rb2 is array (1 .. 65) of Boolean;
15169    pragma Pack (rb2);
15171    type x2 is record
15172       l1 : Boolean;
15173       l2 : Duration;
15174       l3 : Float;
15175       l4 : Boolean;
15176       l5 : Rb1;
15177       l6 : Rb2;
15178    end record;
15179    pragma Pack (x2);
15180 end q;
15181 @end smallexample
15183 @noindent
15184 using the switch @option{-gnatR} we obtain the following output:
15186 @smallexample
15187 Representation information for unit q
15188 -------------------------------------
15190 for r'Size use ??;
15191 for r'Alignment use 4;
15192 for r use record
15193    x    at 4 range  0 .. 7;
15194    _tag at 0 range  0 .. 31;
15195    s    at 5 range  0 .. 799;
15196 end record;
15198 for r2'Size use 160;
15199 for r2'Alignment use 4;
15200 for r2 use record
15201    x       at  4 range  0 .. 7;
15202    _tag    at  0 range  0 .. 31;
15203    _parent at  0 range  0 .. 63;
15204    y2      at 16 range  0 .. 31;
15205 end record;
15207 for x'Size use 8;
15208 for x'Alignment use 1;
15209 for x use record
15210    y at 0 range  0 .. 7;
15211 end record;
15213 for x1'Size use 112;
15214 for x1'Alignment use 1;
15215 for x1'Component_Size use 11;
15217 for rb1'Size use 13;
15218 for rb1'Alignment use 2;
15219 for rb1'Component_Size use 1;
15221 for rb2'Size use 72;
15222 for rb2'Alignment use 1;
15223 for rb2'Component_Size use 1;
15225 for x2'Size use 224;
15226 for x2'Alignment use 4;
15227 for x2 use record
15228    l1 at  0 range  0 .. 0;
15229    l2 at  0 range  1 .. 64;
15230    l3 at 12 range  0 .. 31;
15231    l4 at 16 range  0 .. 0;
15232    l5 at 16 range  1 .. 13;
15233    l6 at 18 range  0 .. 71;
15234 end record;
15235 @end smallexample
15237 @noindent
15238 The Size values are actually the Object_Size, i.e.@: the default size that
15239 will be allocated for objects of the type.
15240 The ?? size for type r indicates that we have a variant record, and the
15241 actual size of objects will depend on the discriminant value.
15243 The Alignment values show the actual alignment chosen by the compiler
15244 for each record or array type.
15246 The record representation clause for type r shows where all fields
15247 are placed, including the compiler generated tag field (whose location
15248 cannot be controlled by the programmer).
15250 The record representation clause for the type extension r2 shows all the
15251 fields present, including the parent field, which is a copy of the fields
15252 of the parent type of r2, i.e.@: r1.
15254 The component size and size clauses for types rb1 and rb2 show
15255 the exact effect of pragma @code{Pack} on these arrays, and the record
15256 representation clause for type x2 shows how pragma @code{Pack} affects
15257 this record type.
15259 In some cases, it may be useful to cut and paste the representation clauses
15260 generated by the compiler into the original source to fix and guarantee
15261 the actual representation to be used.
15263 @node Standard Library Routines
15264 @chapter Standard Library Routines
15266 @noindent
15267 The Ada Reference Manual contains in Annex A a full description of an
15268 extensive set of standard library routines that can be used in any Ada
15269 program, and which must be provided by all Ada compilers.  They are
15270 analogous to the standard C library used by C programs.
15272 GNAT implements all of the facilities described in annex A, and for most
15273 purposes the description in the Ada Reference Manual, or appropriate Ada
15274 text book, will be sufficient for making use of these facilities.
15276 In the case of the input-output facilities,
15277 @xref{The Implementation of Standard I/O},
15278 gives details on exactly how GNAT interfaces to the
15279 file system.  For the remaining packages, the Ada Reference Manual
15280 should be sufficient.  The following is a list of the packages included,
15281 together with a brief description of the functionality that is provided.
15283 For completeness, references are included to other predefined library
15284 routines defined in other sections of the Ada Reference Manual (these are
15285 cross-indexed from Annex A).
15287 @table @code
15288 @item Ada (A.2)
15289 This is a parent package for all the standard library packages.  It is
15290 usually included implicitly in your program, and itself contains no
15291 useful data or routines.
15293 @item Ada.Calendar (9.6)
15294 @code{Calendar} provides time of day access, and routines for
15295 manipulating times and durations.
15297 @item Ada.Characters (A.3.1)
15298 This is a dummy parent package that contains no useful entities
15300 @item Ada.Characters.Handling (A.3.2)
15301 This package provides some basic character handling capabilities,
15302 including classification functions for classes of characters (e.g.@: test
15303 for letters, or digits).
15305 @item Ada.Characters.Latin_1 (A.3.3)
15306 This package includes a complete set of definitions of the characters
15307 that appear in type CHARACTER@.  It is useful for writing programs that
15308 will run in international environments.  For example, if you want an
15309 upper case E with an acute accent in a string, it is often better to use
15310 the definition of @code{UC_E_Acute} in this package.  Then your program
15311 will print in an understandable manner even if your environment does not
15312 support these extended characters.
15314 @item Ada.Command_Line (A.15)
15315 This package provides access to the command line parameters and the name
15316 of the current program (analogous to the use of @code{argc} and @code{argv}
15317 in C), and also allows the exit status for the program to be set in a
15318 system-independent manner.
15320 @item Ada.Decimal (F.2)
15321 This package provides constants describing the range of decimal numbers
15322 implemented, and also a decimal divide routine (analogous to the COBOL
15323 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
15325 @item Ada.Direct_IO (A.8.4)
15326 This package provides input-output using a model of a set of records of
15327 fixed-length, containing an arbitrary definite Ada type, indexed by an
15328 integer record number.
15330 @item Ada.Dynamic_Priorities (D.5)
15331 This package allows the priorities of a task to be adjusted dynamically
15332 as the task is running.
15334 @item Ada.Exceptions (11.4.1)
15335 This package provides additional information on exceptions, and also
15336 contains facilities for treating exceptions as data objects, and raising
15337 exceptions with associated messages.
15339 @item Ada.Finalization (7.6)
15340 This package contains the declarations and subprograms to support the
15341 use of controlled types, providing for automatic initialization and
15342 finalization (analogous to the constructors and destructors of C++)
15344 @item Ada.Interrupts (C.3.2)
15345 This package provides facilities for interfacing to interrupts, which
15346 includes the set of signals or conditions that can be raised and
15347 recognized as interrupts.
15349 @item Ada.Interrupts.Names (C.3.2)
15350 This package provides the set of interrupt names (actually signal
15351 or condition names) that can be handled by GNAT@.
15353 @item Ada.IO_Exceptions (A.13)
15354 This package defines the set of exceptions that can be raised by use of
15355 the standard IO packages.
15357 @item Ada.Numerics
15358 This package contains some standard constants and exceptions used
15359 throughout the numerics packages.  Note that the constants pi and e are
15360 defined here, and it is better to use these definitions than rolling
15361 your own.
15363 @item Ada.Numerics.Complex_Elementary_Functions
15364 Provides the implementation of standard elementary functions (such as
15365 log and trigonometric functions) operating on complex numbers using the
15366 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
15367 created by the package @code{Numerics.Complex_Types}.
15369 @item Ada.Numerics.Complex_Types
15370 This is a predefined instantiation of
15371 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
15372 build the type @code{Complex} and @code{Imaginary}.
15374 @item Ada.Numerics.Discrete_Random
15375 This generic package provides a random number generator suitable for generating
15376 uniformly distributed values of a specified discrete subtype.
15378 @item Ada.Numerics.Float_Random
15379 This package provides a random number generator suitable for generating
15380 uniformly distributed floating point values in the unit interval.
15382 @item Ada.Numerics.Generic_Complex_Elementary_Functions
15383 This is a generic version of the package that provides the
15384 implementation of standard elementary functions (such as log and
15385 trigonometric functions) for an arbitrary complex type.
15387 The following predefined instantiations of this package are provided:
15389 @table @code
15390 @item Short_Float
15391 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
15392 @item Float
15393 @code{Ada.Numerics.Complex_Elementary_Functions}
15394 @item Long_Float
15395 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
15396 @end table
15398 @item Ada.Numerics.Generic_Complex_Types
15399 This is a generic package that allows the creation of complex types,
15400 with associated complex arithmetic operations.
15402 The following predefined instantiations of this package exist
15403 @table @code
15404 @item Short_Float
15405 @code{Ada.Numerics.Short_Complex_Complex_Types}
15406 @item Float
15407 @code{Ada.Numerics.Complex_Complex_Types}
15408 @item Long_Float
15409 @code{Ada.Numerics.Long_Complex_Complex_Types}
15410 @end table
15412 @item Ada.Numerics.Generic_Elementary_Functions
15413 This is a generic package that provides the implementation of standard
15414 elementary functions (such as log an trigonometric functions) for an
15415 arbitrary float type.
15417 The following predefined instantiations of this package exist
15419 @table @code
15420 @item Short_Float
15421 @code{Ada.Numerics.Short_Elementary_Functions}
15422 @item Float
15423 @code{Ada.Numerics.Elementary_Functions}
15424 @item Long_Float
15425 @code{Ada.Numerics.Long_Elementary_Functions}
15426 @end table
15428 @item Ada.Real_Time (D.8)
15429 This package provides facilities similar to those of @code{Calendar}, but
15430 operating with a finer clock suitable for real time control. Note that
15431 annex D requires that there be no backward clock jumps, and GNAT generally
15432 guarantees this behavior, but of course if the external clock on which
15433 the GNAT runtime depends is deliberately reset by some external event,
15434 then such a backward jump may occur.
15436 @item Ada.Sequential_IO (A.8.1)
15437 This package provides input-output facilities for sequential files,
15438 which can contain a sequence of values of a single type, which can be
15439 any Ada type, including indefinite (unconstrained) types.
15441 @item Ada.Storage_IO (A.9)
15442 This package provides a facility for mapping arbitrary Ada types to and
15443 from a storage buffer.  It is primarily intended for the creation of new
15444 IO packages.
15446 @item Ada.Streams (13.13.1)
15447 This is a generic package that provides the basic support for the
15448 concept of streams as used by the stream attributes (@code{Input},
15449 @code{Output}, @code{Read} and @code{Write}).
15451 @item Ada.Streams.Stream_IO (A.12.1)
15452 This package is a specialization of the type @code{Streams} defined in
15453 package @code{Streams} together with a set of operations providing
15454 Stream_IO capability.  The Stream_IO model permits both random and
15455 sequential access to a file which can contain an arbitrary set of values
15456 of one or more Ada types.
15458 @item Ada.Strings (A.4.1)
15459 This package provides some basic constants used by the string handling
15460 packages.
15462 @item Ada.Strings.Bounded (A.4.4)
15463 This package provides facilities for handling variable length
15464 strings.  The bounded model requires a maximum length.  It is thus
15465 somewhat more limited than the unbounded model, but avoids the use of
15466 dynamic allocation or finalization.
15468 @item Ada.Strings.Fixed (A.4.3)
15469 This package provides facilities for handling fixed length strings.
15471 @item Ada.Strings.Maps (A.4.2)
15472 This package provides facilities for handling character mappings and
15473 arbitrarily defined subsets of characters.  For instance it is useful in
15474 defining specialized translation tables.
15476 @item Ada.Strings.Maps.Constants (A.4.6)
15477 This package provides a standard set of predefined mappings and
15478 predefined character sets.  For example, the standard upper to lower case
15479 conversion table is found in this package.  Note that upper to lower case
15480 conversion is non-trivial if you want to take the entire set of
15481 characters, including extended characters like E with an acute accent,
15482 into account.  You should use the mappings in this package (rather than
15483 adding 32 yourself) to do case mappings.
15485 @item Ada.Strings.Unbounded (A.4.5)
15486 This package provides facilities for handling variable length
15487 strings.  The unbounded model allows arbitrary length strings, but
15488 requires the use of dynamic allocation and finalization.
15490 @item Ada.Strings.Wide_Bounded (A.4.7)
15491 @itemx Ada.Strings.Wide_Fixed (A.4.7)
15492 @itemx Ada.Strings.Wide_Maps (A.4.7)
15493 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
15494 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
15495 These packages provide analogous capabilities to the corresponding
15496 packages without @samp{Wide_} in the name, but operate with the types
15497 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
15498 and @code{Character}.
15500 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
15501 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
15502 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
15503 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
15504 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
15505 These packages provide analogous capabilities to the corresponding
15506 packages without @samp{Wide_} in the name, but operate with the types
15507 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
15508 of @code{String} and @code{Character}.
15510 @item Ada.Synchronous_Task_Control (D.10)
15511 This package provides some standard facilities for controlling task
15512 communication in a synchronous manner.
15514 @item Ada.Tags
15515 This package contains definitions for manipulation of the tags of tagged
15516 values.
15518 @item Ada.Task_Attributes
15519 This package provides the capability of associating arbitrary
15520 task-specific data with separate tasks.
15522 @item Ada.Text_IO
15523 This package provides basic text input-output capabilities for
15524 character, string and numeric data.  The subpackages of this
15525 package are listed next.
15527 @item Ada.Text_IO.Decimal_IO
15528 Provides input-output facilities for decimal fixed-point types
15530 @item Ada.Text_IO.Enumeration_IO
15531 Provides input-output facilities for enumeration types.
15533 @item Ada.Text_IO.Fixed_IO
15534 Provides input-output facilities for ordinary fixed-point types.
15536 @item Ada.Text_IO.Float_IO
15537 Provides input-output facilities for float types.  The following
15538 predefined instantiations of this generic package are available:
15540 @table @code
15541 @item Short_Float
15542 @code{Short_Float_Text_IO}
15543 @item Float
15544 @code{Float_Text_IO}
15545 @item Long_Float
15546 @code{Long_Float_Text_IO}
15547 @end table
15549 @item Ada.Text_IO.Integer_IO
15550 Provides input-output facilities for integer types.  The following
15551 predefined instantiations of this generic package are available:
15553 @table @code
15554 @item Short_Short_Integer
15555 @code{Ada.Short_Short_Integer_Text_IO}
15556 @item Short_Integer
15557 @code{Ada.Short_Integer_Text_IO}
15558 @item Integer
15559 @code{Ada.Integer_Text_IO}
15560 @item Long_Integer
15561 @code{Ada.Long_Integer_Text_IO}
15562 @item Long_Long_Integer
15563 @code{Ada.Long_Long_Integer_Text_IO}
15564 @end table
15566 @item Ada.Text_IO.Modular_IO
15567 Provides input-output facilities for modular (unsigned) types
15569 @item Ada.Text_IO.Complex_IO (G.1.3)
15570 This package provides basic text input-output capabilities for complex
15571 data.
15573 @item Ada.Text_IO.Editing (F.3.3)
15574 This package contains routines for edited output, analogous to the use
15575 of pictures in COBOL@.  The picture formats used by this package are a
15576 close copy of the facility in COBOL@.
15578 @item Ada.Text_IO.Text_Streams (A.12.2)
15579 This package provides a facility that allows Text_IO files to be treated
15580 as streams, so that the stream attributes can be used for writing
15581 arbitrary data, including binary data, to Text_IO files.
15583 @item Ada.Unchecked_Conversion (13.9)
15584 This generic package allows arbitrary conversion from one type to
15585 another of the same size, providing for breaking the type safety in
15586 special circumstances.
15588 If the types have the same Size (more accurately the same Value_Size),
15589 then the effect is simply to transfer the bits from the source to the
15590 target type without any modification.  This usage is well defined, and
15591 for simple types whose representation is typically the same across
15592 all implementations, gives a portable method of performing such
15593 conversions.
15595 If the types do not have the same size, then the result is implementation
15596 defined, and thus may be non-portable.  The following describes how GNAT
15597 handles such unchecked conversion cases.
15599 If the types are of different sizes, and are both discrete types, then
15600 the effect is of a normal type conversion without any constraint checking.
15601 In particular if the result type has a larger size, the result will be
15602 zero or sign extended.  If the result type has a smaller size, the result
15603 will be truncated by ignoring high order bits.
15605 If the types are of different sizes, and are not both discrete types,
15606 then the conversion works as though pointers were created to the source
15607 and target, and the pointer value is converted.  The effect is that bits
15608 are copied from successive low order storage units and bits of the source
15609 up to the length of the target type.
15611 A warning is issued if the lengths differ, since the effect in this
15612 case is implementation dependent, and the above behavior may not match
15613 that of some other compiler.
15615 A pointer to one type may be converted to a pointer to another type using
15616 unchecked conversion.  The only case in which the effect is undefined is
15617 when one or both pointers are pointers to unconstrained array types.  In
15618 this case, the bounds information may get incorrectly transferred, and in
15619 particular, GNAT uses double size pointers for such types, and it is
15620 meaningless to convert between such pointer types.  GNAT will issue a
15621 warning if the alignment of the target designated type is more strict
15622 than the alignment of the source designated type (since the result may
15623 be unaligned in this case).
15625 A pointer other than a pointer to an unconstrained array type may be
15626 converted to and from System.Address.  Such usage is common in Ada 83
15627 programs, but note that Ada.Address_To_Access_Conversions is the
15628 preferred method of performing such conversions in Ada 95 and Ada 2005.
15629 Neither
15630 unchecked conversion nor Ada.Address_To_Access_Conversions should be
15631 used in conjunction with pointers to unconstrained objects, since
15632 the bounds information cannot be handled correctly in this case.
15634 @item Ada.Unchecked_Deallocation (13.11.2)
15635 This generic package allows explicit freeing of storage previously
15636 allocated by use of an allocator.
15638 @item Ada.Wide_Text_IO (A.11)
15639 This package is similar to @code{Ada.Text_IO}, except that the external
15640 file supports wide character representations, and the internal types are
15641 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
15642 and @code{String}.  It contains generic subpackages listed next.
15644 @item Ada.Wide_Text_IO.Decimal_IO
15645 Provides input-output facilities for decimal fixed-point types
15647 @item Ada.Wide_Text_IO.Enumeration_IO
15648 Provides input-output facilities for enumeration types.
15650 @item Ada.Wide_Text_IO.Fixed_IO
15651 Provides input-output facilities for ordinary fixed-point types.
15653 @item Ada.Wide_Text_IO.Float_IO
15654 Provides input-output facilities for float types.  The following
15655 predefined instantiations of this generic package are available:
15657 @table @code
15658 @item Short_Float
15659 @code{Short_Float_Wide_Text_IO}
15660 @item Float
15661 @code{Float_Wide_Text_IO}
15662 @item Long_Float
15663 @code{Long_Float_Wide_Text_IO}
15664 @end table
15666 @item Ada.Wide_Text_IO.Integer_IO
15667 Provides input-output facilities for integer types.  The following
15668 predefined instantiations of this generic package are available:
15670 @table @code
15671 @item Short_Short_Integer
15672 @code{Ada.Short_Short_Integer_Wide_Text_IO}
15673 @item Short_Integer
15674 @code{Ada.Short_Integer_Wide_Text_IO}
15675 @item Integer
15676 @code{Ada.Integer_Wide_Text_IO}
15677 @item Long_Integer
15678 @code{Ada.Long_Integer_Wide_Text_IO}
15679 @item Long_Long_Integer
15680 @code{Ada.Long_Long_Integer_Wide_Text_IO}
15681 @end table
15683 @item Ada.Wide_Text_IO.Modular_IO
15684 Provides input-output facilities for modular (unsigned) types
15686 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
15687 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
15688 external file supports wide character representations.
15690 @item Ada.Wide_Text_IO.Editing (F.3.4)
15691 This package is similar to @code{Ada.Text_IO.Editing}, except that the
15692 types are @code{Wide_Character} and @code{Wide_String} instead of
15693 @code{Character} and @code{String}.
15695 @item Ada.Wide_Text_IO.Streams (A.12.3)
15696 This package is similar to @code{Ada.Text_IO.Streams}, except that the
15697 types are @code{Wide_Character} and @code{Wide_String} instead of
15698 @code{Character} and @code{String}.
15700 @item Ada.Wide_Wide_Text_IO (A.11)
15701 This package is similar to @code{Ada.Text_IO}, except that the external
15702 file supports wide character representations, and the internal types are
15703 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
15704 and @code{String}.  It contains generic subpackages listed next.
15706 @item Ada.Wide_Wide_Text_IO.Decimal_IO
15707 Provides input-output facilities for decimal fixed-point types
15709 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
15710 Provides input-output facilities for enumeration types.
15712 @item Ada.Wide_Wide_Text_IO.Fixed_IO
15713 Provides input-output facilities for ordinary fixed-point types.
15715 @item Ada.Wide_Wide_Text_IO.Float_IO
15716 Provides input-output facilities for float types.  The following
15717 predefined instantiations of this generic package are available:
15719 @table @code
15720 @item Short_Float
15721 @code{Short_Float_Wide_Wide_Text_IO}
15722 @item Float
15723 @code{Float_Wide_Wide_Text_IO}
15724 @item Long_Float
15725 @code{Long_Float_Wide_Wide_Text_IO}
15726 @end table
15728 @item Ada.Wide_Wide_Text_IO.Integer_IO
15729 Provides input-output facilities for integer types.  The following
15730 predefined instantiations of this generic package are available:
15732 @table @code
15733 @item Short_Short_Integer
15734 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
15735 @item Short_Integer
15736 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
15737 @item Integer
15738 @code{Ada.Integer_Wide_Wide_Text_IO}
15739 @item Long_Integer
15740 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
15741 @item Long_Long_Integer
15742 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
15743 @end table
15745 @item Ada.Wide_Wide_Text_IO.Modular_IO
15746 Provides input-output facilities for modular (unsigned) types
15748 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
15749 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
15750 external file supports wide character representations.
15752 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
15753 This package is similar to @code{Ada.Text_IO.Editing}, except that the
15754 types are @code{Wide_Character} and @code{Wide_String} instead of
15755 @code{Character} and @code{String}.
15757 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
15758 This package is similar to @code{Ada.Text_IO.Streams}, except that the
15759 types are @code{Wide_Character} and @code{Wide_String} instead of
15760 @code{Character} and @code{String}.
15761 @end table
15763 @node The Implementation of Standard I/O
15764 @chapter The Implementation of Standard I/O
15766 @noindent
15767 GNAT implements all the required input-output facilities described in
15768 A.6 through A.14.  These sections of the Ada Reference Manual describe the
15769 required behavior of these packages from the Ada point of view, and if
15770 you are writing a portable Ada program that does not need to know the
15771 exact manner in which Ada maps to the outside world when it comes to
15772 reading or writing external files, then you do not need to read this
15773 chapter.  As long as your files are all regular files (not pipes or
15774 devices), and as long as you write and read the files only from Ada, the
15775 description in the Ada Reference Manual is sufficient.
15777 However, if you want to do input-output to pipes or other devices, such
15778 as the keyboard or screen, or if the files you are dealing with are
15779 either generated by some other language, or to be read by some other
15780 language, then you need to know more about the details of how the GNAT
15781 implementation of these input-output facilities behaves.
15783 In this chapter we give a detailed description of exactly how GNAT
15784 interfaces to the file system.  As always, the sources of the system are
15785 available to you for answering questions at an even more detailed level,
15786 but for most purposes the information in this chapter will suffice.
15788 Another reason that you may need to know more about how input-output is
15789 implemented arises when you have a program written in mixed languages
15790 where, for example, files are shared between the C and Ada sections of
15791 the same program.  GNAT provides some additional facilities, in the form
15792 of additional child library packages, that facilitate this sharing, and
15793 these additional facilities are also described in this chapter.
15795 @menu
15796 * Standard I/O Packages::
15797 * FORM Strings::
15798 * Direct_IO::
15799 * Sequential_IO::
15800 * Text_IO::
15801 * Wide_Text_IO::
15802 * Wide_Wide_Text_IO::
15803 * Stream_IO::
15804 * Text Translation::
15805 * Shared Files::
15806 * Filenames encoding::
15807 * Open Modes::
15808 * Operations on C Streams::
15809 * Interfacing to C Streams::
15810 @end menu
15812 @node Standard I/O Packages
15813 @section Standard I/O Packages
15815 @noindent
15816 The Standard I/O packages described in Annex A for
15818 @itemize @bullet
15819 @item
15820 Ada.Text_IO
15821 @item
15822 Ada.Text_IO.Complex_IO
15823 @item
15824 Ada.Text_IO.Text_Streams
15825 @item
15826 Ada.Wide_Text_IO
15827 @item
15828 Ada.Wide_Text_IO.Complex_IO
15829 @item
15830 Ada.Wide_Text_IO.Text_Streams
15831 @item
15832 Ada.Wide_Wide_Text_IO
15833 @item
15834 Ada.Wide_Wide_Text_IO.Complex_IO
15835 @item
15836 Ada.Wide_Wide_Text_IO.Text_Streams
15837 @item
15838 Ada.Stream_IO
15839 @item
15840 Ada.Sequential_IO
15841 @item
15842 Ada.Direct_IO
15843 @end itemize
15845 @noindent
15846 are implemented using the C
15847 library streams facility; where
15849 @itemize @bullet
15850 @item
15851 All files are opened using @code{fopen}.
15852 @item
15853 All input/output operations use @code{fread}/@code{fwrite}.
15854 @end itemize
15856 @noindent
15857 There is no internal buffering of any kind at the Ada library level. The only
15858 buffering is that provided at the system level in the implementation of the
15859 library routines that support streams. This facilitates shared use of these
15860 streams by mixed language programs. Note though that system level buffering is
15861 explicitly enabled at elaboration of the standard I/O packages and that can
15862 have an impact on mixed language programs, in particular those using I/O before
15863 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
15864 the Ada elaboration routine before performing any I/O or when impractical,
15865 flush the common I/O streams and in particular Standard_Output before
15866 elaborating the Ada code.
15868 @node FORM Strings
15869 @section FORM Strings
15871 @noindent
15872 The format of a FORM string in GNAT is:
15874 @smallexample
15875 "keyword=value,keyword=value,@dots{},keyword=value"
15876 @end smallexample
15878 @noindent
15879 where letters may be in upper or lower case, and there are no spaces
15880 between values.  The order of the entries is not important.  Currently
15881 the following keywords defined.
15883 @smallexample
15884 TEXT_TRANSLATION=[YES|NO]
15885 SHARED=[YES|NO]
15886 WCEM=[n|h|u|s|e|8|b]
15887 ENCODING=[UTF8|8BITS]
15888 @end smallexample
15890 @noindent
15891 The use of these parameters is described later in this section. If an
15892 unrecognized keyword appears in a form string, it is silently ignored
15893 and not considered invalid.
15895 @noindent
15896 For OpenVMS additional FORM string keywords are available for use with
15897 RMS services.  The syntax is:
15899 @smallexample
15900 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
15901 @end smallexample
15903 @noindent
15904 The following RMS keywords and values are currently defined:
15906 @smallexample
15907 Context=Force_Stream_Mode|Force_Record_Mode
15908 @end smallexample
15910 @noindent
15911 VMS RMS keys are silently ignored on non-VMS systems.  On OpenVMS
15912 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
15914 @node Direct_IO
15915 @section Direct_IO
15917 @noindent
15918 Direct_IO can only be instantiated for definite types.  This is a
15919 restriction of the Ada language, which means that the records are fixed
15920 length (the length being determined by @code{@var{type}'Size}, rounded
15921 up to the next storage unit boundary if necessary).
15923 The records of a Direct_IO file are simply written to the file in index
15924 sequence, with the first record starting at offset zero, and subsequent
15925 records following.  There is no control information of any kind.  For
15926 example, if 32-bit integers are being written, each record takes
15927 4-bytes, so the record at index @var{K} starts at offset
15928 (@var{K}@minus{}1)*4.
15930 There is no limit on the size of Direct_IO files, they are expanded as
15931 necessary to accommodate whatever records are written to the file.
15933 @node Sequential_IO
15934 @section Sequential_IO
15936 @noindent
15937 Sequential_IO may be instantiated with either a definite (constrained)
15938 or indefinite (unconstrained) type.
15940 For the definite type case, the elements written to the file are simply
15941 the memory images of the data values with no control information of any
15942 kind.  The resulting file should be read using the same type, no validity
15943 checking is performed on input.
15945 For the indefinite type case, the elements written consist of two
15946 parts.  First is the size of the data item, written as the memory image
15947 of a @code{Interfaces.C.size_t} value, followed by the memory image of
15948 the data value.  The resulting file can only be read using the same
15949 (unconstrained) type.  Normal assignment checks are performed on these
15950 read operations, and if these checks fail, @code{Data_Error} is
15951 raised.  In particular, in the array case, the lengths must match, and in
15952 the variant record case, if the variable for a particular read operation
15953 is constrained, the discriminants must match.
15955 Note that it is not possible to use Sequential_IO to write variable
15956 length array items, and then read the data back into different length
15957 arrays.  For example, the following will raise @code{Data_Error}:
15959 @smallexample @c ada
15960  package IO is new Sequential_IO (String);
15961  F : IO.File_Type;
15962  S : String (1..4);
15963  @dots{}
15964  IO.Create (F)
15965  IO.Write (F, "hello!")
15966  IO.Reset (F, Mode=>In_File);
15967  IO.Read (F, S);
15968  Put_Line (S);
15970 @end smallexample
15972 @noindent
15973 On some Ada implementations, this will print @code{hell}, but the program is
15974 clearly incorrect, since there is only one element in the file, and that
15975 element is the string @code{hello!}.
15977 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
15978 using Stream_IO, and this is the preferred mechanism.  In particular, the
15979 above program fragment rewritten to use Stream_IO will work correctly.
15981 @node Text_IO
15982 @section Text_IO
15984 @noindent
15985 Text_IO files consist of a stream of characters containing the following
15986 special control characters:
15988 @smallexample
15989 LF (line feed, 16#0A#) Line Mark
15990 FF (form feed, 16#0C#) Page Mark
15991 @end smallexample
15993 @noindent
15994 A canonical Text_IO file is defined as one in which the following
15995 conditions are met:
15997 @itemize @bullet
15998 @item
15999 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
16000 of the line.
16002 @item
16003 The character @code{FF} is used only as a page mark, i.e.@: to mark the
16004 end of a page and consequently can appear only immediately following a
16005 @code{LF} (line mark) character.
16007 @item
16008 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
16009 (line mark, page mark).  In the former case, the page mark is implicitly
16010 assumed to be present.
16011 @end itemize
16013 @noindent
16014 A file written using Text_IO will be in canonical form provided that no
16015 explicit @code{LF} or @code{FF} characters are written using @code{Put}
16016 or @code{Put_Line}.  There will be no @code{FF} character at the end of
16017 the file unless an explicit @code{New_Page} operation was performed
16018 before closing the file.
16020 A canonical Text_IO file that is a regular file (i.e., not a device or a
16021 pipe) can be read using any of the routines in Text_IO@.  The
16022 semantics in this case will be exactly as defined in the Ada Reference
16023 Manual, and all the routines in Text_IO are fully implemented.
16025 A text file that does not meet the requirements for a canonical Text_IO
16026 file has one of the following:
16028 @itemize @bullet
16029 @item
16030 The file contains @code{FF} characters not immediately following a
16031 @code{LF} character.
16033 @item
16034 The file contains @code{LF} or @code{FF} characters written by
16035 @code{Put} or @code{Put_Line}, which are not logically considered to be
16036 line marks or page marks.
16038 @item
16039 The file ends in a character other than @code{LF} or @code{FF},
16040 i.e.@: there is no explicit line mark or page mark at the end of the file.
16041 @end itemize
16043 @noindent
16044 Text_IO can be used to read such non-standard text files but subprograms
16045 to do with line or page numbers do not have defined meanings.  In
16046 particular, a @code{FF} character that does not follow a @code{LF}
16047 character may or may not be treated as a page mark from the point of
16048 view of page and line numbering.  Every @code{LF} character is considered
16049 to end a line, and there is an implied @code{LF} character at the end of
16050 the file.
16052 @menu
16053 * Text_IO Stream Pointer Positioning::
16054 * Text_IO Reading and Writing Non-Regular Files::
16055 * Get_Immediate::
16056 * Treating Text_IO Files as Streams::
16057 * Text_IO Extensions::
16058 * Text_IO Facilities for Unbounded Strings::
16059 @end menu
16061 @node Text_IO Stream Pointer Positioning
16062 @subsection Stream Pointer Positioning
16064 @noindent
16065 @code{Ada.Text_IO} has a definition of current position for a file that
16066 is being read.  No internal buffering occurs in Text_IO, and usually the
16067 physical position in the stream used to implement the file corresponds
16068 to this logical position defined by Text_IO@.  There are two exceptions:
16070 @itemize @bullet
16071 @item
16072 After a call to @code{End_Of_Page} that returns @code{True}, the stream
16073 is positioned past the @code{LF} (line mark) that precedes the page
16074 mark.  Text_IO maintains an internal flag so that subsequent read
16075 operations properly handle the logical position which is unchanged by
16076 the @code{End_Of_Page} call.
16078 @item
16079 After a call to @code{End_Of_File} that returns @code{True}, if the
16080 Text_IO file was positioned before the line mark at the end of file
16081 before the call, then the logical position is unchanged, but the stream
16082 is physically positioned right at the end of file (past the line mark,
16083 and past a possible page mark following the line mark.  Again Text_IO
16084 maintains internal flags so that subsequent read operations properly
16085 handle the logical position.
16086 @end itemize
16088 @noindent
16089 These discrepancies have no effect on the observable behavior of
16090 Text_IO, but if a single Ada stream is shared between a C program and
16091 Ada program, or shared (using @samp{shared=yes} in the form string)
16092 between two Ada files, then the difference may be observable in some
16093 situations.
16095 @node Text_IO Reading and Writing Non-Regular Files
16096 @subsection Reading and Writing Non-Regular Files
16098 @noindent
16099 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
16100 can be used for reading and writing.  Writing is not affected and the
16101 sequence of characters output is identical to the normal file case, but
16102 for reading, the behavior of Text_IO is modified to avoid undesirable
16103 look-ahead as follows:
16105 An input file that is not a regular file is considered to have no page
16106 marks.  Any @code{Ascii.FF} characters (the character normally used for a
16107 page mark) appearing in the file are considered to be data
16108 characters.  In particular:
16110 @itemize @bullet
16111 @item
16112 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
16113 following a line mark.  If a page mark appears, it will be treated as a
16114 data character.
16116 @item
16117 This avoids the need to wait for an extra character to be typed or
16118 entered from the pipe to complete one of these operations.
16120 @item
16121 @code{End_Of_Page} always returns @code{False}
16123 @item
16124 @code{End_Of_File} will return @code{False} if there is a page mark at
16125 the end of the file.
16126 @end itemize
16128 @noindent
16129 Output to non-regular files is the same as for regular files.  Page marks
16130 may be written to non-regular files using @code{New_Page}, but as noted
16131 above they will not be treated as page marks on input if the output is
16132 piped to another Ada program.
16134 Another important discrepancy when reading non-regular files is that the end
16135 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
16136 pressing the @key{EOT} key,
16137 then end of file
16138 is signaled once (i.e.@: the test @code{End_Of_File}
16139 will yield @code{True}, or a read will
16140 raise @code{End_Error}), but then reading can resume
16141 to read data past that end of
16142 file indication, until another end of file indication is entered.
16144 @node Get_Immediate
16145 @subsection Get_Immediate
16146 @cindex Get_Immediate
16148 @noindent
16149 Get_Immediate returns the next character (including control characters)
16150 from the input file.  In particular, Get_Immediate will return LF or FF
16151 characters used as line marks or page marks.  Such operations leave the
16152 file positioned past the control character, and it is thus not treated
16153 as having its normal function.  This means that page, line and column
16154 counts after this kind of Get_Immediate call are set as though the mark
16155 did not occur.  In the case where a Get_Immediate leaves the file
16156 positioned between the line mark and page mark (which is not normally
16157 possible), it is undefined whether the FF character will be treated as a
16158 page mark.
16160 @node Treating Text_IO Files as Streams
16161 @subsection Treating Text_IO Files as Streams
16162 @cindex Stream files
16164 @noindent
16165 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
16166 as a stream.  Data written to a Text_IO file in this stream mode is
16167 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
16168 16#0C# (@code{FF}), the resulting file may have non-standard
16169 format.  Similarly if read operations are used to read from a Text_IO
16170 file treated as a stream, then @code{LF} and @code{FF} characters may be
16171 skipped and the effect is similar to that described above for
16172 @code{Get_Immediate}.
16174 @node Text_IO Extensions
16175 @subsection Text_IO Extensions
16176 @cindex Text_IO extensions
16178 @noindent
16179 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
16180 to the standard @code{Text_IO} package:
16182 @itemize @bullet
16183 @item function File_Exists (Name : String) return Boolean;
16184 Determines if a file of the given name exists.
16186 @item function Get_Line return String;
16187 Reads a string from the standard input file.  The value returned is exactly
16188 the length of the line that was read.
16190 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
16191 Similar, except that the parameter File specifies the file from which
16192 the string is to be read.
16194 @end itemize
16196 @node Text_IO Facilities for Unbounded Strings
16197 @subsection Text_IO Facilities for Unbounded Strings
16198 @cindex Text_IO for unbounded strings
16199 @cindex Unbounded_String, Text_IO operations
16201 @noindent
16202 The package @code{Ada.Strings.Unbounded.Text_IO}
16203 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
16204 subprograms useful for Text_IO operations on unbounded strings:
16206 @itemize @bullet
16208 @item function Get_Line (File : File_Type) return Unbounded_String;
16209 Reads a line from the specified file
16210 and returns the result as an unbounded string.
16212 @item procedure Put (File : File_Type; U : Unbounded_String);
16213 Writes the value of the given unbounded string to the specified file
16214 Similar to the effect of
16215 @code{Put (To_String (U))} except that an extra copy is avoided.
16217 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
16218 Writes the value of the given unbounded string to the specified file,
16219 followed by a @code{New_Line}.
16220 Similar to the effect of @code{Put_Line (To_String (U))} except
16221 that an extra copy is avoided.
16222 @end itemize
16224 @noindent
16225 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
16226 and is optional.  If the parameter is omitted, then the standard input or
16227 output file is referenced as appropriate.
16229 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
16230 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
16231 @code{Wide_Text_IO} functionality for unbounded wide strings.
16233 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
16234 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
16235 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
16237 @node Wide_Text_IO
16238 @section Wide_Text_IO
16240 @noindent
16241 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
16242 both input and output files may contain special sequences that represent
16243 wide character values.  The encoding scheme for a given file may be
16244 specified using a FORM parameter:
16246 @smallexample
16247 WCEM=@var{x}
16248 @end smallexample
16250 @noindent
16251 as part of the FORM string (WCEM = wide character encoding method),
16252 where @var{x} is one of the following characters
16254 @table @samp
16255 @item h
16256 Hex ESC encoding
16257 @item u
16258 Upper half encoding
16259 @item s
16260 Shift-JIS encoding
16261 @item e
16262 EUC Encoding
16263 @item 8
16264 UTF-8 encoding
16265 @item b
16266 Brackets encoding
16267 @end table
16269 @noindent
16270 The encoding methods match those that
16271 can be used in a source
16272 program, but there is no requirement that the encoding method used for
16273 the source program be the same as the encoding method used for files,
16274 and different files may use different encoding methods.
16276 The default encoding method for the standard files, and for opened files
16277 for which no WCEM parameter is given in the FORM string matches the
16278 wide character encoding specified for the main program (the default
16279 being brackets encoding if no coding method was specified with -gnatW).
16281 @table @asis
16282 @item Hex Coding
16283 In this encoding, a wide character is represented by a five character
16284 sequence:
16286 @smallexample
16287 ESC a b c d
16288 @end smallexample
16290 @noindent
16291 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
16292 characters (using upper case letters) of the wide character code.  For
16293 example, ESC A345 is used to represent the wide character with code
16294 16#A345#.  This scheme is compatible with use of the full
16295 @code{Wide_Character} set.
16297 @item Upper Half Coding
16298 The wide character with encoding 16#abcd#, where the upper bit is on
16299 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
16300 16#cd#.  The second byte may never be a format control character, but is
16301 not required to be in the upper half.  This method can be also used for
16302 shift-JIS or EUC where the internal coding matches the external coding.
16304 @item Shift JIS Coding
16305 A wide character is represented by a two character sequence 16#ab# and
16306 16#cd#, with the restrictions described for upper half encoding as
16307 described above.  The internal character code is the corresponding JIS
16308 character according to the standard algorithm for Shift-JIS
16309 conversion.  Only characters defined in the JIS code set table can be
16310 used with this encoding method.
16312 @item EUC Coding
16313 A wide character is represented by a two character sequence 16#ab# and
16314 16#cd#, with both characters being in the upper half.  The internal
16315 character code is the corresponding JIS character according to the EUC
16316 encoding algorithm.  Only characters defined in the JIS code set table
16317 can be used with this encoding method.
16319 @item UTF-8 Coding
16320 A wide character is represented using
16321 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
16322 10646-1/Am.2.  Depending on the character value, the representation
16323 is a one, two, or three byte sequence:
16325 @smallexample
16326 16#0000#-16#007f#: 2#0xxxxxxx#
16327 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
16328 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
16329 @end smallexample
16331 @noindent
16332 where the @var{xxx} bits correspond to the left-padded bits of the
16333 16-bit character value.  Note that all lower half ASCII characters
16334 are represented as ASCII bytes and all upper half characters and
16335 other wide characters are represented as sequences of upper-half
16336 (The full UTF-8 scheme allows for encoding 31-bit characters as
16337 6-byte sequences, but in this implementation, all UTF-8 sequences
16338 of four or more bytes length will raise a Constraint_Error, as
16339 will all invalid UTF-8 sequences.)
16341 @item Brackets Coding
16342 In this encoding, a wide character is represented by the following eight
16343 character sequence:
16345 @smallexample
16346 [ " a b c d " ]
16347 @end smallexample
16349 @noindent
16350 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
16351 characters (using uppercase letters) of the wide character code.  For
16352 example, @code{["A345"]} is used to represent the wide character with code
16353 @code{16#A345#}.
16354 This scheme is compatible with use of the full Wide_Character set.
16355 On input, brackets coding can also be used for upper half characters,
16356 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
16357 is only used for wide characters with a code greater than @code{16#FF#}.
16359 Note that brackets coding is not normally used in the context of
16360 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
16361 a portable way of encoding source files. In the context of Wide_Text_IO
16362 or Wide_Wide_Text_IO, it can only be used if the file does not contain
16363 any instance of the left bracket character other than to encode wide
16364 character values using the brackets encoding method. In practice it is
16365 expected that some standard wide character encoding method such
16366 as UTF-8 will be used for text input output.
16368 If brackets notation is used, then any occurrence of a left bracket
16369 in the input file which is not the start of a valid wide character
16370 sequence will cause Constraint_Error to be raised. It is possible to
16371 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
16372 input will interpret this as a left bracket.
16374 However, when a left bracket is output, it will be output as a left bracket
16375 and not as ["5B"]. We make this decision because for normal use of
16376 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
16377 brackets. For example, if we write:
16379 @smallexample
16380    Put_Line ("Start of output [first run]");
16381 @end smallexample
16383 @noindent
16384 we really do not want to have the left bracket in this message clobbered so
16385 that the output reads:
16387 @smallexample
16388    Start of output ["5B"]first run]
16389 @end smallexample
16391 @noindent
16392 In practice brackets encoding is reasonably useful for normal Put_Line use
16393 since we won't get confused between left brackets and wide character
16394 sequences in the output. But for input, or when files are written out
16395 and read back in, it really makes better sense to use one of the standard
16396 encoding methods such as UTF-8.
16398 @end table
16400 @noindent
16401 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
16402 not all wide character
16403 values can be represented.  An attempt to output a character that cannot
16404 be represented using the encoding scheme for the file causes
16405 Constraint_Error to be raised.  An invalid wide character sequence on
16406 input also causes Constraint_Error to be raised.
16408 @menu
16409 * Wide_Text_IO Stream Pointer Positioning::
16410 * Wide_Text_IO Reading and Writing Non-Regular Files::
16411 @end menu
16413 @node Wide_Text_IO Stream Pointer Positioning
16414 @subsection Stream Pointer Positioning
16416 @noindent
16417 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
16418 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
16419 case:
16421 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
16422 normal lower ASCII set (i.e.@: a character in the range:
16424 @smallexample @c ada
16425 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
16426 @end smallexample
16428 @noindent
16429 then although the logical position of the file pointer is unchanged by
16430 the @code{Look_Ahead} call, the stream is physically positioned past the
16431 wide character sequence.  Again this is to avoid the need for buffering
16432 or backup, and all @code{Wide_Text_IO} routines check the internal
16433 indication that this situation has occurred so that this is not visible
16434 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
16435 can be observed if the wide text file shares a stream with another file.
16437 @node Wide_Text_IO Reading and Writing Non-Regular Files
16438 @subsection Reading and Writing Non-Regular Files
16440 @noindent
16441 As in the case of Text_IO, when a non-regular file is read, it is
16442 assumed that the file contains no page marks (any form characters are
16443 treated as data characters), and @code{End_Of_Page} always returns
16444 @code{False}.  Similarly, the end of file indication is not sticky, so
16445 it is possible to read beyond an end of file.
16447 @node Wide_Wide_Text_IO
16448 @section Wide_Wide_Text_IO
16450 @noindent
16451 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
16452 both input and output files may contain special sequences that represent
16453 wide wide character values.  The encoding scheme for a given file may be
16454 specified using a FORM parameter:
16456 @smallexample
16457 WCEM=@var{x}
16458 @end smallexample
16460 @noindent
16461 as part of the FORM string (WCEM = wide character encoding method),
16462 where @var{x} is one of the following characters
16464 @table @samp
16465 @item h
16466 Hex ESC encoding
16467 @item u
16468 Upper half encoding
16469 @item s
16470 Shift-JIS encoding
16471 @item e
16472 EUC Encoding
16473 @item 8
16474 UTF-8 encoding
16475 @item b
16476 Brackets encoding
16477 @end table
16479 @noindent
16480 The encoding methods match those that
16481 can be used in a source
16482 program, but there is no requirement that the encoding method used for
16483 the source program be the same as the encoding method used for files,
16484 and different files may use different encoding methods.
16486 The default encoding method for the standard files, and for opened files
16487 for which no WCEM parameter is given in the FORM string matches the
16488 wide character encoding specified for the main program (the default
16489 being brackets encoding if no coding method was specified with -gnatW).
16491 @table @asis
16493 @item UTF-8 Coding
16494 A wide character is represented using
16495 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
16496 10646-1/Am.2.  Depending on the character value, the representation
16497 is a one, two, three, or four byte sequence:
16499 @smallexample
16500 16#000000#-16#00007f#: 2#0xxxxxxx#
16501 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
16502 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
16503 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
16504 @end smallexample
16506 @noindent
16507 where the @var{xxx} bits correspond to the left-padded bits of the
16508 21-bit character value.  Note that all lower half ASCII characters
16509 are represented as ASCII bytes and all upper half characters and
16510 other wide characters are represented as sequences of upper-half
16511 characters.
16513 @item Brackets Coding
16514 In this encoding, a wide wide character is represented by the following eight
16515 character sequence if is in wide character range
16517 @smallexample
16518 [ " a b c d " ]
16519 @end smallexample
16521 and by the following ten character sequence if not
16523 @smallexample
16524 [ " a b c d e f " ]
16525 @end smallexample
16527 @noindent
16528 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
16529 are the four or six hexadecimal
16530 characters (using uppercase letters) of the wide wide character code.  For
16531 example, @code{["01A345"]} is used to represent the wide wide character
16532 with code @code{16#01A345#}.
16534 This scheme is compatible with use of the full Wide_Wide_Character set.
16535 On input, brackets coding can also be used for upper half characters,
16536 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
16537 is only used for wide characters with a code greater than @code{16#FF#}.
16539 @end table
16541 @noindent
16542 If is also possible to use the other Wide_Character encoding methods,
16543 such as Shift-JIS, but the other schemes cannot support the full range
16544 of wide wide characters.
16545 An attempt to output a character that cannot
16546 be represented using the encoding scheme for the file causes
16547 Constraint_Error to be raised.  An invalid wide character sequence on
16548 input also causes Constraint_Error to be raised.
16550 @menu
16551 * Wide_Wide_Text_IO Stream Pointer Positioning::
16552 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
16553 @end menu
16555 @node Wide_Wide_Text_IO Stream Pointer Positioning
16556 @subsection Stream Pointer Positioning
16558 @noindent
16559 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
16560 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
16561 case:
16563 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
16564 normal lower ASCII set (i.e.@: a character in the range:
16566 @smallexample @c ada
16567 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
16568 @end smallexample
16570 @noindent
16571 then although the logical position of the file pointer is unchanged by
16572 the @code{Look_Ahead} call, the stream is physically positioned past the
16573 wide character sequence.  Again this is to avoid the need for buffering
16574 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
16575 indication that this situation has occurred so that this is not visible
16576 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
16577 can be observed if the wide text file shares a stream with another file.
16579 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
16580 @subsection Reading and Writing Non-Regular Files
16582 @noindent
16583 As in the case of Text_IO, when a non-regular file is read, it is
16584 assumed that the file contains no page marks (any form characters are
16585 treated as data characters), and @code{End_Of_Page} always returns
16586 @code{False}.  Similarly, the end of file indication is not sticky, so
16587 it is possible to read beyond an end of file.
16589 @node Stream_IO
16590 @section Stream_IO
16592 @noindent
16593 A stream file is a sequence of bytes, where individual elements are
16594 written to the file as described in the Ada Reference Manual.  The type
16595 @code{Stream_Element} is simply a byte.  There are two ways to read or
16596 write a stream file.
16598 @itemize @bullet
16599 @item
16600 The operations @code{Read} and @code{Write} directly read or write a
16601 sequence of stream elements with no control information.
16603 @item
16604 The stream attributes applied to a stream file transfer data in the
16605 manner described for stream attributes.
16606 @end itemize
16608 @node Text Translation
16609 @section Text Translation
16611 @noindent
16612 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
16613 passed to Text_IO.Create and Text_IO.Open:
16614 @samp{Text_Translation=@var{Yes}} is the default, which means to
16615 translate LF to/from CR/LF on Windows systems.
16616 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
16617 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
16618 may be used to create Unix-style files on
16619 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
16620 systems.
16622 @node Shared Files
16623 @section Shared Files
16625 @noindent
16626 Section A.14 of the Ada Reference Manual allows implementations to
16627 provide a wide variety of behavior if an attempt is made to access the
16628 same external file with two or more internal files.
16630 To provide a full range of functionality, while at the same time
16631 minimizing the problems of portability caused by this implementation
16632 dependence, GNAT handles file sharing as follows:
16634 @itemize @bullet
16635 @item
16636 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
16637 to open two or more files with the same full name is considered an error
16638 and is not supported.  The exception @code{Use_Error} will be
16639 raised.  Note that a file that is not explicitly closed by the program
16640 remains open until the program terminates.
16642 @item
16643 If the form parameter @samp{shared=no} appears in the form string, the
16644 file can be opened or created with its own separate stream identifier,
16645 regardless of whether other files sharing the same external file are
16646 opened.  The exact effect depends on how the C stream routines handle
16647 multiple accesses to the same external files using separate streams.
16649 @item
16650 If the form parameter @samp{shared=yes} appears in the form string for
16651 each of two or more files opened using the same full name, the same
16652 stream is shared between these files, and the semantics are as described
16653 in Ada Reference Manual, Section A.14.
16654 @end itemize
16656 @noindent
16657 When a program that opens multiple files with the same name is ported
16658 from another Ada compiler to GNAT, the effect will be that
16659 @code{Use_Error} is raised.
16661 The documentation of the original compiler and the documentation of the
16662 program should then be examined to determine if file sharing was
16663 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
16664 and @code{Create} calls as required.
16666 When a program is ported from GNAT to some other Ada compiler, no
16667 special attention is required unless the @samp{shared=@var{xxx}} form
16668 parameter is used in the program.  In this case, you must examine the
16669 documentation of the new compiler to see if it supports the required
16670 file sharing semantics, and form strings modified appropriately.  Of
16671 course it may be the case that the program cannot be ported if the
16672 target compiler does not support the required functionality.  The best
16673 approach in writing portable code is to avoid file sharing (and hence
16674 the use of the @samp{shared=@var{xxx}} parameter in the form string)
16675 completely.
16677 One common use of file sharing in Ada 83 is the use of instantiations of
16678 Sequential_IO on the same file with different types, to achieve
16679 heterogeneous input-output.  Although this approach will work in GNAT if
16680 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
16681 for this purpose (using the stream attributes)
16683 @node Filenames encoding
16684 @section Filenames encoding
16686 @noindent
16687 An encoding form parameter can be used to specify the filename
16688 encoding @samp{encoding=@var{xxx}}.
16690 @itemize @bullet
16691 @item
16692 If the form parameter @samp{encoding=utf8} appears in the form string, the
16693 filename must be encoded in UTF-8.
16695 @item
16696 If the form parameter @samp{encoding=8bits} appears in the form
16697 string, the filename must be a standard 8bits string.
16698 @end itemize
16700 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
16701 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
16702 variable. And if not set @samp{utf8} is assumed.
16704 @table @samp
16705 @item CP_ACP
16706 The current system Windows ANSI code page.
16707 @item CP_UTF8
16708 UTF-8 encoding
16709 @end table
16711 This encoding form parameter is only supported on the Windows
16712 platform. On the other Operating Systems the run-time is supporting
16713 UTF-8 natively.
16715 @node Open Modes
16716 @section Open Modes
16718 @noindent
16719 @code{Open} and @code{Create} calls result in a call to @code{fopen}
16720 using the mode shown in the following table:
16722 @sp 2
16723 @center @code{Open} and @code{Create} Call Modes
16724 @smallexample
16725                                @b{OPEN }           @b{CREATE}
16726 Append_File                    "r+"             "w+"
16727 In_File                        "r"              "w+"
16728 Out_File (Direct_IO)           "r+"             "w"
16729 Out_File (all other cases)     "w"              "w"
16730 Inout_File                     "r+"             "w+"
16731 @end smallexample
16733 @noindent
16734 If text file translation is required, then either @samp{b} or @samp{t}
16735 is added to the mode, depending on the setting of Text.  Text file
16736 translation refers to the mapping of CR/LF sequences in an external file
16737 to LF characters internally.  This mapping only occurs in DOS and
16738 DOS-like systems, and is not relevant to other systems.
16740 A special case occurs with Stream_IO@.  As shown in the above table, the
16741 file is initially opened in @samp{r} or @samp{w} mode for the
16742 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
16743 subsequently requires switching from reading to writing or vice-versa,
16744 then the file is reopened in @samp{r+} mode to permit the required operation.
16746 @node Operations on C Streams
16747 @section Operations on C Streams
16748 The package @code{Interfaces.C_Streams} provides an Ada program with direct
16749 access to the C library functions for operations on C streams:
16751 @smallexample @c adanocomment
16752 package Interfaces.C_Streams is
16753   -- Note: the reason we do not use the types that are in
16754   -- Interfaces.C is that we want to avoid dragging in the
16755   -- code in this unit if possible.
16756   subtype chars is System.Address;
16757   -- Pointer to null-terminated array of characters
16758   subtype FILEs is System.Address;
16759   -- Corresponds to the C type FILE*
16760   subtype voids is System.Address;
16761   -- Corresponds to the C type void*
16762   subtype int is Integer;
16763   subtype long is Long_Integer;
16764   -- Note: the above types are subtypes deliberately, and it
16765   -- is part of this spec that the above correspondences are
16766   -- guaranteed.  This means that it is legitimate to, for
16767   -- example, use Integer instead of int.  We provide these
16768   -- synonyms for clarity, but in some cases it may be
16769   -- convenient to use the underlying types (for example to
16770   -- avoid an unnecessary dependency of a spec on the spec
16771   -- of this unit).
16772   type size_t is mod 2 ** Standard'Address_Size;
16773   NULL_Stream : constant FILEs;
16774   -- Value returned (NULL in C) to indicate an
16775   -- fdopen/fopen/tmpfile error
16776   ----------------------------------
16777   -- Constants Defined in stdio.h --
16778   ----------------------------------
16779   EOF : constant int;
16780   -- Used by a number of routines to indicate error or
16781   -- end of file
16782   IOFBF : constant int;
16783   IOLBF : constant int;
16784   IONBF : constant int;
16785   -- Used to indicate buffering mode for setvbuf call
16786   SEEK_CUR : constant int;
16787   SEEK_END : constant int;
16788   SEEK_SET : constant int;
16789   -- Used to indicate origin for fseek call
16790   function stdin return FILEs;
16791   function stdout return FILEs;
16792   function stderr return FILEs;
16793   -- Streams associated with standard files
16794   --------------------------
16795   -- Standard C functions --
16796   --------------------------
16797   -- The functions selected below are ones that are
16798   -- available in UNIX (but not necessarily in ANSI C).
16799   -- These are very thin interfaces
16800   -- which copy exactly the C headers.  For more
16801   -- documentation on these functions, see the Microsoft C
16802   -- "Run-Time Library Reference" (Microsoft Press, 1990,
16803   -- ISBN 1-55615-225-6), which includes useful information
16804   -- on system compatibility.
16805   procedure clearerr (stream : FILEs);
16806   function fclose (stream : FILEs) return int;
16807   function fdopen (handle : int; mode : chars) return FILEs;
16808   function feof (stream : FILEs) return int;
16809   function ferror (stream : FILEs) return int;
16810   function fflush (stream : FILEs) return int;
16811   function fgetc (stream : FILEs) return int;
16812   function fgets (strng : chars; n : int; stream : FILEs)
16813       return chars;
16814   function fileno (stream : FILEs) return int;
16815   function fopen (filename : chars; Mode : chars)
16816       return FILEs;
16817   -- Note: to maintain target independence, use
16818   -- text_translation_required, a boolean variable defined in
16819   -- a-sysdep.c to deal with the target dependent text
16820   -- translation requirement.  If this variable is set,
16821   -- then  b/t should be appended to the standard mode
16822   -- argument to set the text translation mode off or on
16823   -- as required.
16824   function fputc (C : int; stream : FILEs) return int;
16825   function fputs (Strng : chars; Stream : FILEs) return int;
16826   function fread
16827      (buffer : voids;
16828       size : size_t;
16829       count : size_t;
16830       stream : FILEs)
16831       return size_t;
16832   function freopen
16833      (filename : chars;
16834       mode : chars;
16835       stream : FILEs)
16836       return FILEs;
16837   function fseek
16838      (stream : FILEs;
16839       offset : long;
16840       origin : int)
16841       return int;
16842   function ftell (stream : FILEs) return long;
16843   function fwrite
16844      (buffer : voids;
16845       size : size_t;
16846       count : size_t;
16847       stream : FILEs)
16848       return size_t;
16849   function isatty (handle : int) return int;
16850   procedure mktemp (template : chars);
16851   -- The return value (which is just a pointer to template)
16852   -- is discarded
16853   procedure rewind (stream : FILEs);
16854   function rmtmp return int;
16855   function setvbuf
16856      (stream : FILEs;
16857       buffer : chars;
16858       mode : int;
16859       size : size_t)
16860       return int;
16862   function tmpfile return FILEs;
16863   function ungetc (c : int; stream : FILEs) return int;
16864   function unlink (filename : chars) return int;
16865   ---------------------
16866   -- Extra functions --
16867   ---------------------
16868   -- These functions supply slightly thicker bindings than
16869   -- those above.  They are derived from functions in the
16870   -- C Run-Time Library, but may do a bit more work than
16871   -- just directly calling one of the Library functions.
16872   function is_regular_file (handle : int) return int;
16873   -- Tests if given handle is for a regular file (result 1)
16874   -- or for a non-regular file (pipe or device, result 0).
16875   ---------------------------------
16876   -- Control of Text/Binary Mode --
16877   ---------------------------------
16878   -- If text_translation_required is true, then the following
16879   -- functions may be used to dynamically switch a file from
16880   -- binary to text mode or vice versa.  These functions have
16881   -- no effect if text_translation_required is false (i.e.@: in
16882   -- normal UNIX mode).  Use fileno to get a stream handle.
16883   procedure set_binary_mode (handle : int);
16884   procedure set_text_mode (handle : int);
16885   ----------------------------
16886   -- Full Path Name support --
16887   ----------------------------
16888   procedure full_name (nam : chars; buffer : chars);
16889   -- Given a NUL terminated string representing a file
16890   -- name, returns in buffer a NUL terminated string
16891   -- representing the full path name for the file name.
16892   -- On systems where it is relevant the   drive is also
16893   -- part of the full path name.  It is the responsibility
16894   -- of the caller to pass an actual parameter for buffer
16895   -- that is big enough for any full path name.  Use
16896   -- max_path_len given below as the size of buffer.
16897   max_path_len : integer;
16898   -- Maximum length of an allowable full path name on the
16899   -- system, including a terminating NUL character.
16900 end Interfaces.C_Streams;
16901 @end smallexample
16903 @node Interfacing to C Streams
16904 @section Interfacing to C Streams
16906 @noindent
16907 The packages in this section permit interfacing Ada files to C Stream
16908 operations.
16910 @smallexample @c ada
16911  with Interfaces.C_Streams;
16912  package Ada.Sequential_IO.C_Streams is
16913     function C_Stream (F : File_Type)
16914        return Interfaces.C_Streams.FILEs;
16915     procedure Open
16916       (File : in out File_Type;
16917        Mode : in File_Mode;
16918        C_Stream : in Interfaces.C_Streams.FILEs;
16919        Form : in String := "");
16920  end Ada.Sequential_IO.C_Streams;
16922   with Interfaces.C_Streams;
16923   package Ada.Direct_IO.C_Streams is
16924      function C_Stream (F : File_Type)
16925         return Interfaces.C_Streams.FILEs;
16926      procedure Open
16927        (File : in out File_Type;
16928         Mode : in File_Mode;
16929         C_Stream : in Interfaces.C_Streams.FILEs;
16930         Form : in String := "");
16931   end Ada.Direct_IO.C_Streams;
16933   with Interfaces.C_Streams;
16934   package Ada.Text_IO.C_Streams is
16935      function C_Stream (F : File_Type)
16936         return Interfaces.C_Streams.FILEs;
16937      procedure Open
16938        (File : in out File_Type;
16939         Mode : in File_Mode;
16940         C_Stream : in Interfaces.C_Streams.FILEs;
16941         Form : in String := "");
16942   end Ada.Text_IO.C_Streams;
16944   with Interfaces.C_Streams;
16945   package Ada.Wide_Text_IO.C_Streams is
16946      function C_Stream (F : File_Type)
16947         return Interfaces.C_Streams.FILEs;
16948      procedure Open
16949        (File : in out File_Type;
16950         Mode : in File_Mode;
16951         C_Stream : in Interfaces.C_Streams.FILEs;
16952         Form : in String := "");
16953  end Ada.Wide_Text_IO.C_Streams;
16955   with Interfaces.C_Streams;
16956   package Ada.Wide_Wide_Text_IO.C_Streams is
16957      function C_Stream (F : File_Type)
16958         return Interfaces.C_Streams.FILEs;
16959      procedure Open
16960        (File : in out File_Type;
16961         Mode : in File_Mode;
16962         C_Stream : in Interfaces.C_Streams.FILEs;
16963         Form : in String := "");
16964  end Ada.Wide_Wide_Text_IO.C_Streams;
16966  with Interfaces.C_Streams;
16967  package Ada.Stream_IO.C_Streams is
16968     function C_Stream (F : File_Type)
16969        return Interfaces.C_Streams.FILEs;
16970     procedure Open
16971       (File : in out File_Type;
16972        Mode : in File_Mode;
16973        C_Stream : in Interfaces.C_Streams.FILEs;
16974        Form : in String := "");
16975  end Ada.Stream_IO.C_Streams;
16976 @end smallexample
16978 @noindent
16979 In each of these six packages, the @code{C_Stream} function obtains the
16980 @code{FILE} pointer from a currently opened Ada file.  It is then
16981 possible to use the @code{Interfaces.C_Streams} package to operate on
16982 this stream, or the stream can be passed to a C program which can
16983 operate on it directly.  Of course the program is responsible for
16984 ensuring that only appropriate sequences of operations are executed.
16986 One particular use of relevance to an Ada program is that the
16987 @code{setvbuf} function can be used to control the buffering of the
16988 stream used by an Ada file.  In the absence of such a call the standard
16989 default buffering is used.
16991 The @code{Open} procedures in these packages open a file giving an
16992 existing C Stream instead of a file name.  Typically this stream is
16993 imported from a C program, allowing an Ada file to operate on an
16994 existing C file.
16996 @node The GNAT Library
16997 @chapter The GNAT Library
16999 @noindent
17000 The GNAT library contains a number of general and special purpose packages.
17001 It represents functionality that the GNAT developers have found useful, and
17002 which is made available to GNAT users.  The packages described here are fully
17003 supported, and upwards compatibility will be maintained in future releases,
17004 so you can use these facilities with the confidence that the same functionality
17005 will be available in future releases.
17007 The chapter here simply gives a brief summary of the facilities available.
17008 The full documentation is found in the spec file for the package.  The full
17009 sources of these library packages, including both spec and body, are provided
17010 with all GNAT releases.  For example, to find out the full specifications of
17011 the SPITBOL pattern matching capability, including a full tutorial and
17012 extensive examples, look in the @file{g-spipat.ads} file in the library.
17014 For each entry here, the package name (as it would appear in a @code{with}
17015 clause) is given, followed by the name of the corresponding spec file in
17016 parentheses.  The packages are children in four hierarchies, @code{Ada},
17017 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
17018 GNAT-specific hierarchy.
17020 Note that an application program should only use packages in one of these
17021 four hierarchies if the package is defined in the Ada Reference Manual,
17022 or is listed in this section of the GNAT Programmers Reference Manual.
17023 All other units should be considered internal implementation units and
17024 should not be directly @code{with}'ed by application code.  The use of
17025 a @code{with} statement that references one of these internal implementation
17026 units makes an application potentially dependent on changes in versions
17027 of GNAT, and will generate a warning message.
17029 @menu
17030 * Ada.Characters.Latin_9 (a-chlat9.ads)::
17031 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
17032 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
17033 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
17034 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
17035 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
17036 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
17037 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
17038 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
17039 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
17040 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
17041 * Ada.Command_Line.Environment (a-colien.ads)::
17042 * Ada.Command_Line.Remove (a-colire.ads)::
17043 * Ada.Command_Line.Response_File (a-clrefi.ads)::
17044 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
17045 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
17046 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
17047 * Ada.Exceptions.Traceback (a-exctra.ads)::
17048 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
17049 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
17050 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
17051 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
17052 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
17053 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
17054 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
17055 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
17056 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
17057 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
17058 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
17059 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
17060 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
17061 * GNAT.Altivec (g-altive.ads)::
17062 * GNAT.Altivec.Conversions (g-altcon.ads)::
17063 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
17064 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
17065 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
17066 * GNAT.Array_Split (g-arrspl.ads)::
17067 * GNAT.AWK (g-awk.ads)::
17068 * GNAT.Bounded_Buffers (g-boubuf.ads)::
17069 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
17070 * GNAT.Bubble_Sort (g-bubsor.ads)::
17071 * GNAT.Bubble_Sort_A (g-busora.ads)::
17072 * GNAT.Bubble_Sort_G (g-busorg.ads)::
17073 * GNAT.Byte_Order_Mark (g-byorma.ads)::
17074 * GNAT.Byte_Swapping (g-bytswa.ads)::
17075 * GNAT.Calendar (g-calend.ads)::
17076 * GNAT.Calendar.Time_IO (g-catiio.ads)::
17077 * GNAT.Case_Util (g-casuti.ads)::
17078 * GNAT.CGI (g-cgi.ads)::
17079 * GNAT.CGI.Cookie (g-cgicoo.ads)::
17080 * GNAT.CGI.Debug (g-cgideb.ads)::
17081 * GNAT.Command_Line (g-comlin.ads)::
17082 * GNAT.Compiler_Version (g-comver.ads)::
17083 * GNAT.Ctrl_C (g-ctrl_c.ads)::
17084 * GNAT.CRC32 (g-crc32.ads)::
17085 * GNAT.Current_Exception (g-curexc.ads)::
17086 * GNAT.Debug_Pools (g-debpoo.ads)::
17087 * GNAT.Debug_Utilities (g-debuti.ads)::
17088 * GNAT.Decode_String (g-decstr.ads)::
17089 * GNAT.Decode_UTF8_String (g-deutst.ads)::
17090 * GNAT.Directory_Operations (g-dirope.ads)::
17091 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
17092 * GNAT.Dynamic_HTables (g-dynhta.ads)::
17093 * GNAT.Dynamic_Tables (g-dyntab.ads)::
17094 * GNAT.Encode_String (g-encstr.ads)::
17095 * GNAT.Encode_UTF8_String (g-enutst.ads)::
17096 * GNAT.Exception_Actions (g-excact.ads)::
17097 * GNAT.Exception_Traces (g-exctra.ads)::
17098 * GNAT.Exceptions (g-except.ads)::
17099 * GNAT.Expect (g-expect.ads)::
17100 * GNAT.Expect.TTY (g-exptty.ads)::
17101 * GNAT.Float_Control (g-flocon.ads)::
17102 * GNAT.Heap_Sort (g-heasor.ads)::
17103 * GNAT.Heap_Sort_A (g-hesora.ads)::
17104 * GNAT.Heap_Sort_G (g-hesorg.ads)::
17105 * GNAT.HTable (g-htable.ads)::
17106 * GNAT.IO (g-io.ads)::
17107 * GNAT.IO_Aux (g-io_aux.ads)::
17108 * GNAT.Lock_Files (g-locfil.ads)::
17109 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
17110 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
17111 * GNAT.MD5 (g-md5.ads)::
17112 * GNAT.Memory_Dump (g-memdum.ads)::
17113 * GNAT.Most_Recent_Exception (g-moreex.ads)::
17114 * GNAT.OS_Lib (g-os_lib.ads)::
17115 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
17116 * GNAT.Random_Numbers (g-rannum.ads)::
17117 * GNAT.Regexp (g-regexp.ads)::
17118 * GNAT.Registry (g-regist.ads)::
17119 * GNAT.Regpat (g-regpat.ads)::
17120 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
17121 * GNAT.Semaphores (g-semaph.ads)::
17122 * GNAT.Serial_Communications (g-sercom.ads)::
17123 * GNAT.SHA1 (g-sha1.ads)::
17124 * GNAT.SHA224 (g-sha224.ads)::
17125 * GNAT.SHA256 (g-sha256.ads)::
17126 * GNAT.SHA384 (g-sha384.ads)::
17127 * GNAT.SHA512 (g-sha512.ads)::
17128 * GNAT.Signals (g-signal.ads)::
17129 * GNAT.Sockets (g-socket.ads)::
17130 * GNAT.Source_Info (g-souinf.ads)::
17131 * GNAT.Spelling_Checker (g-speche.ads)::
17132 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
17133 * GNAT.Spitbol.Patterns (g-spipat.ads)::
17134 * GNAT.Spitbol (g-spitbo.ads)::
17135 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
17136 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
17137 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
17138 * GNAT.SSE (g-sse.ads)::
17139 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
17140 * GNAT.Strings (g-string.ads)::
17141 * GNAT.String_Split (g-strspl.ads)::
17142 * GNAT.Table (g-table.ads)::
17143 * GNAT.Task_Lock (g-tasloc.ads)::
17144 * GNAT.Threads (g-thread.ads)::
17145 * GNAT.Time_Stamp (g-timsta.ads)::
17146 * GNAT.Traceback (g-traceb.ads)::
17147 * GNAT.Traceback.Symbolic (g-trasym.ads)::
17148 * GNAT.UTF_32 (g-utf_32.ads)::
17149 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
17150 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
17151 * GNAT.Wide_String_Split (g-wistsp.ads)::
17152 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
17153 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
17154 * Interfaces.C.Extensions (i-cexten.ads)::
17155 * Interfaces.C.Streams (i-cstrea.ads)::
17156 * Interfaces.CPP (i-cpp.ads)::
17157 * Interfaces.Packed_Decimal (i-pacdec.ads)::
17158 * Interfaces.VxWorks (i-vxwork.ads)::
17159 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
17160 * System.Address_Image (s-addima.ads)::
17161 * System.Assertions (s-assert.ads)::
17162 * System.Memory (s-memory.ads)::
17163 * System.Multiprocessors (s-multip.ads)::
17164 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
17165 * System.Partition_Interface (s-parint.ads)::
17166 * System.Pool_Global (s-pooglo.ads)::
17167 * System.Pool_Local (s-pooloc.ads)::
17168 * System.Restrictions (s-restri.ads)::
17169 * System.Rident (s-rident.ads)::
17170 * System.Strings.Stream_Ops (s-ststop.ads)::
17171 * System.Task_Info (s-tasinf.ads)::
17172 * System.Wch_Cnv (s-wchcnv.ads)::
17173 * System.Wch_Con (s-wchcon.ads)::
17174 @end menu
17176 @node Ada.Characters.Latin_9 (a-chlat9.ads)
17177 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
17178 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
17179 @cindex Latin_9 constants for Character
17181 @noindent
17182 This child of @code{Ada.Characters}
17183 provides a set of definitions corresponding to those in the
17184 RM-defined package @code{Ada.Characters.Latin_1} but with the
17185 few modifications required for @code{Latin-9}
17186 The provision of such a package
17187 is specifically authorized by the Ada Reference Manual
17188 (RM A.3.3(27)).
17190 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
17191 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
17192 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
17193 @cindex Latin_1 constants for Wide_Character
17195 @noindent
17196 This child of @code{Ada.Characters}
17197 provides a set of definitions corresponding to those in the
17198 RM-defined package @code{Ada.Characters.Latin_1} but with the
17199 types of the constants being @code{Wide_Character}
17200 instead of @code{Character}.  The provision of such a package
17201 is specifically authorized by the Ada Reference Manual
17202 (RM A.3.3(27)).
17204 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
17205 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
17206 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
17207 @cindex Latin_9 constants for Wide_Character
17209 @noindent
17210 This child of @code{Ada.Characters}
17211 provides a set of definitions corresponding to those in the
17212 GNAT defined package @code{Ada.Characters.Latin_9} but with the
17213 types of the constants being @code{Wide_Character}
17214 instead of @code{Character}.  The provision of such a package
17215 is specifically authorized by the Ada Reference Manual
17216 (RM A.3.3(27)).
17218 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
17219 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
17220 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
17221 @cindex Latin_1 constants for Wide_Wide_Character
17223 @noindent
17224 This child of @code{Ada.Characters}
17225 provides a set of definitions corresponding to those in the
17226 RM-defined package @code{Ada.Characters.Latin_1} but with the
17227 types of the constants being @code{Wide_Wide_Character}
17228 instead of @code{Character}.  The provision of such a package
17229 is specifically authorized by the Ada Reference Manual
17230 (RM A.3.3(27)).
17232 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
17233 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
17234 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
17235 @cindex Latin_9 constants for Wide_Wide_Character
17237 @noindent
17238 This child of @code{Ada.Characters}
17239 provides a set of definitions corresponding to those in the
17240 GNAT defined package @code{Ada.Characters.Latin_9} but with the
17241 types of the constants being @code{Wide_Wide_Character}
17242 instead of @code{Character}.  The provision of such a package
17243 is specifically authorized by the Ada Reference Manual
17244 (RM A.3.3(27)).
17246 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
17247 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
17248 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
17249 @cindex Formal container for doubly linked lists
17251 @noindent
17252 This child of @code{Ada.Containers} defines a modified version of the
17253 Ada 2005 container for doubly linked lists, meant to facilitate formal
17254 verification of code using such containers. The specification of this
17255 unit is compatible with SPARK 2014. Note that the API of this unit may
17256 be subject to incompatible changes as SPARK 2014 evolves.
17258 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
17259 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
17260 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
17261 @cindex Formal container for hashed maps
17263 @noindent
17264 This child of @code{Ada.Containers} defines a modified version of the
17265 Ada 2005 container for hashed maps, meant to facilitate formal
17266 verification of code using such containers. The specification of this
17267 unit is compatible with SPARK 2014. Note that the API of this unit may
17268 be subject to incompatible changes as SPARK 2014 evolves.
17270 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
17271 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
17272 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
17273 @cindex Formal container for hashed sets
17275 @noindent
17276 This child of @code{Ada.Containers} defines a modified version of the
17277 Ada 2005 container for hashed sets, meant to facilitate formal
17278 verification of code using such containers. The specification of this
17279 unit is compatible with SPARK 2014. Note that the API of this unit may
17280 be subject to incompatible changes as SPARK 2014 evolves.
17282 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
17283 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
17284 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
17285 @cindex Formal container for ordered maps
17287 @noindent
17288 This child of @code{Ada.Containers} defines a modified version of the
17289 Ada 2005 container for ordered maps, meant to facilitate formal
17290 verification of code using such containers. The specification of this
17291 unit is compatible with SPARK 2014. Note that the API of this unit may
17292 be subject to incompatible changes as SPARK 2014 evolves.
17294 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
17295 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
17296 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
17297 @cindex Formal container for ordered sets
17299 @noindent
17300 This child of @code{Ada.Containers} defines a modified version of the
17301 Ada 2005 container for ordered sets, meant to facilitate formal
17302 verification of code using such containers. The specification of this
17303 unit is compatible with SPARK 2014. Note that the API of this unit may
17304 be subject to incompatible changes as SPARK 2014 evolves.
17306 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
17307 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
17308 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
17309 @cindex Formal container for vectors
17311 @noindent
17312 This child of @code{Ada.Containers} defines a modified version of the
17313 Ada 2005 container for vectors, meant to facilitate formal
17314 verification of code using such containers. The specification of this
17315 unit is compatible with SPARK 2014. Note that the API of this unit may
17316 be subject to incompatible changes as SPARK 2014 evolves.
17318 @node Ada.Command_Line.Environment (a-colien.ads)
17319 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
17320 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
17321 @cindex Environment entries
17323 @noindent
17324 This child of @code{Ada.Command_Line}
17325 provides a mechanism for obtaining environment values on systems
17326 where this concept makes sense.
17328 @node Ada.Command_Line.Remove (a-colire.ads)
17329 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
17330 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
17331 @cindex Removing command line arguments
17332 @cindex Command line, argument removal
17334 @noindent
17335 This child of @code{Ada.Command_Line}
17336 provides a mechanism for logically removing
17337 arguments from the argument list.  Once removed, an argument is not visible
17338 to further calls on the subprograms in @code{Ada.Command_Line} will not
17339 see the removed argument.
17341 @node Ada.Command_Line.Response_File (a-clrefi.ads)
17342 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
17343 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
17344 @cindex Response file for command line
17345 @cindex Command line, response file
17346 @cindex Command line, handling long command lines
17348 @noindent
17349 This child of @code{Ada.Command_Line} provides a mechanism facilities for
17350 getting command line arguments from a text file, called a "response file".
17351 Using a response file allow passing a set of arguments to an executable longer
17352 than the maximum allowed by the system on the command line.
17354 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
17355 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
17356 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
17357 @cindex C Streams, Interfacing with Direct_IO
17359 @noindent
17360 This package provides subprograms that allow interfacing between
17361 C streams and @code{Direct_IO}.  The stream identifier can be
17362 extracted from a file opened on the Ada side, and an Ada file
17363 can be constructed from a stream opened on the C side.
17365 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
17366 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
17367 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
17368 @cindex Null_Occurrence, testing for
17370 @noindent
17371 This child subprogram provides a way of testing for the null
17372 exception occurrence (@code{Null_Occurrence}) without raising
17373 an exception.
17375 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
17376 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
17377 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
17378 @cindex Null_Occurrence, testing for
17380 @noindent
17381 This child subprogram is used for handling otherwise unhandled
17382 exceptions (hence the name last chance), and perform clean ups before
17383 terminating the program. Note that this subprogram never returns.
17385 @node Ada.Exceptions.Traceback (a-exctra.ads)
17386 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
17387 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
17388 @cindex Traceback for Exception Occurrence
17390 @noindent
17391 This child package provides the subprogram (@code{Tracebacks}) to
17392 give a traceback array of addresses based on an exception
17393 occurrence.
17395 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
17396 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
17397 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
17398 @cindex C Streams, Interfacing with Sequential_IO
17400 @noindent
17401 This package provides subprograms that allow interfacing between
17402 C streams and @code{Sequential_IO}.  The stream identifier can be
17403 extracted from a file opened on the Ada side, and an Ada file
17404 can be constructed from a stream opened on the C side.
17406 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
17407 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
17408 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
17409 @cindex C Streams, Interfacing with Stream_IO
17411 @noindent
17412 This package provides subprograms that allow interfacing between
17413 C streams and @code{Stream_IO}.  The stream identifier can be
17414 extracted from a file opened on the Ada side, and an Ada file
17415 can be constructed from a stream opened on the C side.
17417 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
17418 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
17419 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
17420 @cindex @code{Unbounded_String}, IO support
17421 @cindex @code{Text_IO}, extensions for unbounded strings
17423 @noindent
17424 This package provides subprograms for Text_IO for unbounded
17425 strings, avoiding the necessity for an intermediate operation
17426 with ordinary strings.
17428 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
17429 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
17430 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
17431 @cindex @code{Unbounded_Wide_String}, IO support
17432 @cindex @code{Text_IO}, extensions for unbounded wide strings
17434 @noindent
17435 This package provides subprograms for Text_IO for unbounded
17436 wide strings, avoiding the necessity for an intermediate operation
17437 with ordinary wide strings.
17439 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
17440 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
17441 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
17442 @cindex @code{Unbounded_Wide_Wide_String}, IO support
17443 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
17445 @noindent
17446 This package provides subprograms for Text_IO for unbounded
17447 wide wide strings, avoiding the necessity for an intermediate operation
17448 with ordinary wide wide strings.
17450 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
17451 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
17452 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
17453 @cindex C Streams, Interfacing with @code{Text_IO}
17455 @noindent
17456 This package provides subprograms that allow interfacing between
17457 C streams and @code{Text_IO}.  The stream identifier can be
17458 extracted from a file opened on the Ada side, and an Ada file
17459 can be constructed from a stream opened on the C side.
17461 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
17462 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
17463 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
17464 @cindex @code{Text_IO} resetting standard files
17466 @noindent
17467 This procedure is used to reset the status of the standard files used
17468 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
17469 embedded application) where the status of the files may change during
17470 execution (for example a standard input file may be redefined to be
17471 interactive).
17473 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
17474 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
17475 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
17476 @cindex Unicode categorization, Wide_Character
17478 @noindent
17479 This package provides subprograms that allow categorization of
17480 Wide_Character values according to Unicode categories.
17482 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
17483 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
17484 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
17485 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
17487 @noindent
17488 This package provides subprograms that allow interfacing between
17489 C streams and @code{Wide_Text_IO}.  The stream identifier can be
17490 extracted from a file opened on the Ada side, and an Ada file
17491 can be constructed from a stream opened on the C side.
17493 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
17494 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
17495 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
17496 @cindex @code{Wide_Text_IO} resetting standard files
17498 @noindent
17499 This procedure is used to reset the status of the standard files used
17500 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
17501 embedded application) where the status of the files may change during
17502 execution (for example a standard input file may be redefined to be
17503 interactive).
17505 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
17506 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
17507 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
17508 @cindex Unicode categorization, Wide_Wide_Character
17510 @noindent
17511 This package provides subprograms that allow categorization of
17512 Wide_Wide_Character values according to Unicode categories.
17514 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
17515 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
17516 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
17517 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
17519 @noindent
17520 This package provides subprograms that allow interfacing between
17521 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
17522 extracted from a file opened on the Ada side, and an Ada file
17523 can be constructed from a stream opened on the C side.
17525 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
17526 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
17527 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
17528 @cindex @code{Wide_Wide_Text_IO} resetting standard files
17530 @noindent
17531 This procedure is used to reset the status of the standard files used
17532 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
17533 restart in an embedded application) where the status of the files may
17534 change during execution (for example a standard input file may be
17535 redefined to be interactive).
17537 @node GNAT.Altivec (g-altive.ads)
17538 @section @code{GNAT.Altivec} (@file{g-altive.ads})
17539 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
17540 @cindex AltiVec
17542 @noindent
17543 This is the root package of the GNAT AltiVec binding. It provides
17544 definitions of constants and types common to all the versions of the
17545 binding.
17547 @node GNAT.Altivec.Conversions (g-altcon.ads)
17548 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
17549 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
17550 @cindex AltiVec
17552 @noindent
17553 This package provides the Vector/View conversion routines.
17555 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
17556 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
17557 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
17558 @cindex AltiVec
17560 @noindent
17561 This package exposes the Ada interface to the AltiVec operations on
17562 vector objects. A soft emulation is included by default in the GNAT
17563 library. The hard binding is provided as a separate package. This unit
17564 is common to both bindings.
17566 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
17567 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
17568 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
17569 @cindex AltiVec
17571 @noindent
17572 This package exposes the various vector types part of the Ada binding
17573 to AltiVec facilities.
17575 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
17576 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
17577 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
17578 @cindex AltiVec
17580 @noindent
17581 This package provides public 'View' data types from/to which private
17582 vector representations can be converted via
17583 GNAT.Altivec.Conversions. This allows convenient access to individual
17584 vector elements and provides a simple way to initialize vector
17585 objects.
17587 @node GNAT.Array_Split (g-arrspl.ads)
17588 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
17589 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
17590 @cindex Array splitter
17592 @noindent
17593 Useful array-manipulation routines: given a set of separators, split
17594 an array wherever the separators appear, and provide direct access
17595 to the resulting slices.
17597 @node GNAT.AWK (g-awk.ads)
17598 @section @code{GNAT.AWK} (@file{g-awk.ads})
17599 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
17600 @cindex Parsing
17601 @cindex AWK
17603 @noindent
17604 Provides AWK-like parsing functions, with an easy interface for parsing one
17605 or more files containing formatted data.  The file is viewed as a database
17606 where each record is a line and a field is a data element in this line.
17608 @node GNAT.Bounded_Buffers (g-boubuf.ads)
17609 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
17610 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
17611 @cindex Parsing
17612 @cindex Bounded Buffers
17614 @noindent
17615 Provides a concurrent generic bounded buffer abstraction.  Instances are
17616 useful directly or as parts of the implementations of other abstractions,
17617 such as mailboxes.
17619 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
17620 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
17621 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
17622 @cindex Parsing
17623 @cindex Mailboxes
17625 @noindent
17626 Provides a thread-safe asynchronous intertask mailbox communication facility.
17628 @node GNAT.Bubble_Sort (g-bubsor.ads)
17629 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
17630 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
17631 @cindex Sorting
17632 @cindex Bubble sort
17634 @noindent
17635 Provides a general implementation of bubble sort usable for sorting arbitrary
17636 data items.  Exchange and comparison procedures are provided by passing
17637 access-to-procedure values.
17639 @node GNAT.Bubble_Sort_A (g-busora.ads)
17640 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
17641 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
17642 @cindex Sorting
17643 @cindex Bubble sort
17645 @noindent
17646 Provides a general implementation of bubble sort usable for sorting arbitrary
17647 data items.  Move and comparison procedures are provided by passing
17648 access-to-procedure values. This is an older version, retained for
17649 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
17651 @node GNAT.Bubble_Sort_G (g-busorg.ads)
17652 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
17653 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
17654 @cindex Sorting
17655 @cindex Bubble sort
17657 @noindent
17658 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
17659 are provided as generic parameters, this improves efficiency, especially
17660 if the procedures can be inlined, at the expense of duplicating code for
17661 multiple instantiations.
17663 @node GNAT.Byte_Order_Mark (g-byorma.ads)
17664 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
17665 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
17666 @cindex UTF-8 representation
17667 @cindex Wide characte representations
17669 @noindent
17670 Provides a routine which given a string, reads the start of the string to
17671 see whether it is one of the standard byte order marks (BOM's) which signal
17672 the encoding of the string. The routine includes detection of special XML
17673 sequences for various UCS input formats.
17675 @node GNAT.Byte_Swapping (g-bytswa.ads)
17676 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
17677 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
17678 @cindex Byte swapping
17679 @cindex Endianness
17681 @noindent
17682 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
17683 Machine-specific implementations are available in some cases.
17685 @node GNAT.Calendar (g-calend.ads)
17686 @section @code{GNAT.Calendar} (@file{g-calend.ads})
17687 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
17688 @cindex @code{Calendar}
17690 @noindent
17691 Extends the facilities provided by @code{Ada.Calendar} to include handling
17692 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
17693 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
17694 C @code{timeval} format.
17696 @node GNAT.Calendar.Time_IO (g-catiio.ads)
17697 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
17698 @cindex @code{Calendar}
17699 @cindex Time
17700 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
17702 @node GNAT.CRC32 (g-crc32.ads)
17703 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
17704 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
17705 @cindex CRC32
17706 @cindex Cyclic Redundancy Check
17708 @noindent
17709 This package implements the CRC-32 algorithm.  For a full description
17710 of this algorithm see
17711 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
17712 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
17713 Aug.@: 1988.  Sarwate, D.V@.
17715 @node GNAT.Case_Util (g-casuti.ads)
17716 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
17717 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
17718 @cindex Casing utilities
17719 @cindex Character handling (@code{GNAT.Case_Util})
17721 @noindent
17722 A set of simple routines for handling upper and lower casing of strings
17723 without the overhead of the full casing tables
17724 in @code{Ada.Characters.Handling}.
17726 @node GNAT.CGI (g-cgi.ads)
17727 @section @code{GNAT.CGI} (@file{g-cgi.ads})
17728 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
17729 @cindex CGI (Common Gateway Interface)
17731 @noindent
17732 This is a package for interfacing a GNAT program with a Web server via the
17733 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
17734 parameters, which are a set of key/value pairs sent by the Web server.  It
17735 builds a table whose index is the key and provides some services to deal
17736 with this table.
17738 @node GNAT.CGI.Cookie (g-cgicoo.ads)
17739 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
17740 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
17741 @cindex CGI (Common Gateway Interface) cookie support
17742 @cindex Cookie support in CGI
17744 @noindent
17745 This is a package to interface a GNAT program with a Web server via the
17746 Common Gateway Interface (CGI).  It exports services to deal with Web
17747 cookies (piece of information kept in the Web client software).
17749 @node GNAT.CGI.Debug (g-cgideb.ads)
17750 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
17751 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
17752 @cindex CGI (Common Gateway Interface) debugging
17754 @noindent
17755 This is a package to help debugging CGI (Common Gateway Interface)
17756 programs written in Ada.
17758 @node GNAT.Command_Line (g-comlin.ads)
17759 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
17760 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
17761 @cindex Command line
17763 @noindent
17764 Provides a high level interface to @code{Ada.Command_Line} facilities,
17765 including the ability to scan for named switches with optional parameters
17766 and expand file names using wild card notations.
17768 @node GNAT.Compiler_Version (g-comver.ads)
17769 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
17770 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
17771 @cindex Compiler Version
17772 @cindex Version, of compiler
17774 @noindent
17775 Provides a routine for obtaining the version of the compiler used to
17776 compile the program. More accurately this is the version of the binder
17777 used to bind the program (this will normally be the same as the version
17778 of the compiler if a consistent tool set is used to compile all units
17779 of a partition).
17781 @node GNAT.Ctrl_C (g-ctrl_c.ads)
17782 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
17783 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
17784 @cindex Interrupt
17786 @noindent
17787 Provides a simple interface to handle Ctrl-C keyboard events.
17789 @node GNAT.Current_Exception (g-curexc.ads)
17790 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
17791 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
17792 @cindex Current exception
17793 @cindex Exception retrieval
17795 @noindent
17796 Provides access to information on the current exception that has been raised
17797 without the need for using the Ada 95 / Ada 2005 exception choice parameter
17798 specification syntax.
17799 This is particularly useful in simulating typical facilities for
17800 obtaining information about exceptions provided by Ada 83 compilers.
17802 @node GNAT.Debug_Pools (g-debpoo.ads)
17803 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
17804 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
17805 @cindex Debugging
17806 @cindex Debug pools
17807 @cindex Memory corruption debugging
17809 @noindent
17810 Provide a debugging storage pools that helps tracking memory corruption
17811 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
17812 @value{EDITION} User's Guide}.
17814 @node GNAT.Debug_Utilities (g-debuti.ads)
17815 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
17816 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
17817 @cindex Debugging
17819 @noindent
17820 Provides a few useful utilities for debugging purposes, including conversion
17821 to and from string images of address values. Supports both C and Ada formats
17822 for hexadecimal literals.
17824 @node GNAT.Decode_String (g-decstr.ads)
17825 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
17826 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
17827 @cindex Decoding strings
17828 @cindex String decoding
17829 @cindex Wide character encoding
17830 @cindex UTF-8
17831 @cindex Unicode
17833 @noindent
17834 A generic package providing routines for decoding wide character and wide wide
17835 character strings encoded as sequences of 8-bit characters using a specified
17836 encoding method. Includes validation routines, and also routines for stepping
17837 to next or previous encoded character in an encoded string.
17838 Useful in conjunction with Unicode character coding. Note there is a
17839 preinstantiation for UTF-8. See next entry.
17841 @node GNAT.Decode_UTF8_String (g-deutst.ads)
17842 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
17843 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
17844 @cindex Decoding strings
17845 @cindex Decoding UTF-8 strings
17846 @cindex UTF-8 string decoding
17847 @cindex Wide character decoding
17848 @cindex UTF-8
17849 @cindex Unicode
17851 @noindent
17852 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
17854 @node GNAT.Directory_Operations (g-dirope.ads)
17855 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
17856 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
17857 @cindex Directory operations
17859 @noindent
17860 Provides a set of routines for manipulating directories, including changing
17861 the current directory, making new directories, and scanning the files in a
17862 directory.
17864 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
17865 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
17866 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
17867 @cindex Directory operations iteration
17869 @noindent
17870 A child unit of GNAT.Directory_Operations providing additional operations
17871 for iterating through directories.
17873 @node GNAT.Dynamic_HTables (g-dynhta.ads)
17874 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
17875 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
17876 @cindex Hash tables
17878 @noindent
17879 A generic implementation of hash tables that can be used to hash arbitrary
17880 data.  Provided in two forms, a simple form with built in hash functions,
17881 and a more complex form in which the hash function is supplied.
17883 @noindent
17884 This package provides a facility similar to that of @code{GNAT.HTable},
17885 except that this package declares a type that can be used to define
17886 dynamic instances of the hash table, while an instantiation of
17887 @code{GNAT.HTable} creates a single instance of the hash table.
17889 @node GNAT.Dynamic_Tables (g-dyntab.ads)
17890 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
17891 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
17892 @cindex Table implementation
17893 @cindex Arrays, extendable
17895 @noindent
17896 A generic package providing a single dimension array abstraction where the
17897 length of the array can be dynamically modified.
17899 @noindent
17900 This package provides a facility similar to that of @code{GNAT.Table},
17901 except that this package declares a type that can be used to define
17902 dynamic instances of the table, while an instantiation of
17903 @code{GNAT.Table} creates a single instance of the table type.
17905 @node GNAT.Encode_String (g-encstr.ads)
17906 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
17907 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
17908 @cindex Encoding strings
17909 @cindex String encoding
17910 @cindex Wide character encoding
17911 @cindex UTF-8
17912 @cindex Unicode
17914 @noindent
17915 A generic package providing routines for encoding wide character and wide
17916 wide character strings as sequences of 8-bit characters using a specified
17917 encoding method. Useful in conjunction with Unicode character coding.
17918 Note there is a preinstantiation for UTF-8. See next entry.
17920 @node GNAT.Encode_UTF8_String (g-enutst.ads)
17921 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
17922 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
17923 @cindex Encoding strings
17924 @cindex Encoding UTF-8 strings
17925 @cindex UTF-8 string encoding
17926 @cindex Wide character encoding
17927 @cindex UTF-8
17928 @cindex Unicode
17930 @noindent
17931 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
17933 @node GNAT.Exception_Actions (g-excact.ads)
17934 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
17935 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
17936 @cindex Exception actions
17938 @noindent
17939 Provides callbacks when an exception is raised. Callbacks can be registered
17940 for specific exceptions, or when any exception is raised. This
17941 can be used for instance to force a core dump to ease debugging.
17943 @node GNAT.Exception_Traces (g-exctra.ads)
17944 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
17945 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
17946 @cindex Exception traces
17947 @cindex Debugging
17949 @noindent
17950 Provides an interface allowing to control automatic output upon exception
17951 occurrences.
17953 @node GNAT.Exceptions (g-except.ads)
17954 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
17955 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
17956 @cindex Exceptions, Pure
17957 @cindex Pure packages, exceptions
17959 @noindent
17960 Normally it is not possible to raise an exception with
17961 a message from a subprogram in a pure package, since the
17962 necessary types and subprograms are in @code{Ada.Exceptions}
17963 which is not a pure unit. @code{GNAT.Exceptions} provides a
17964 facility for getting around this limitation for a few
17965 predefined exceptions, and for example allow raising
17966 @code{Constraint_Error} with a message from a pure subprogram.
17968 @node GNAT.Expect (g-expect.ads)
17969 @section @code{GNAT.Expect} (@file{g-expect.ads})
17970 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
17972 @noindent
17973 Provides a set of subprograms similar to what is available
17974 with the standard Tcl Expect tool.
17975 It allows you to easily spawn and communicate with an external process.
17976 You can send commands or inputs to the process, and compare the output
17977 with some expected regular expression. Currently @code{GNAT.Expect}
17978 is implemented on all native GNAT ports except for OpenVMS@.
17979 It is not implemented for cross ports, and in particular is not
17980 implemented for VxWorks or LynxOS@.
17982 @node GNAT.Expect.TTY (g-exptty.ads)
17983 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
17984 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
17986 @noindent
17987 As GNAT.Expect but using pseudo-terminal.
17988 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
17989 ports except for OpenVMS@. It is not implemented for cross ports, and
17990 in particular is not implemented for VxWorks or LynxOS@.
17992 @node GNAT.Float_Control (g-flocon.ads)
17993 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
17994 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
17995 @cindex Floating-Point Processor
17997 @noindent
17998 Provides an interface for resetting the floating-point processor into the
17999 mode required for correct semantic operation in Ada.  Some third party
18000 library calls may cause this mode to be modified, and the Reset procedure
18001 in this package can be used to reestablish the required mode.
18003 @node GNAT.Heap_Sort (g-heasor.ads)
18004 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
18005 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
18006 @cindex Sorting
18008 @noindent
18009 Provides a general implementation of heap sort usable for sorting arbitrary
18010 data items. Exchange and comparison procedures are provided by passing
18011 access-to-procedure values.  The algorithm used is a modified heap sort
18012 that performs approximately N*log(N) comparisons in the worst case.
18014 @node GNAT.Heap_Sort_A (g-hesora.ads)
18015 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
18016 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
18017 @cindex Sorting
18019 @noindent
18020 Provides a general implementation of heap sort usable for sorting arbitrary
18021 data items. Move and comparison procedures are provided by passing
18022 access-to-procedure values.  The algorithm used is a modified heap sort
18023 that performs approximately N*log(N) comparisons in the worst case.
18024 This differs from @code{GNAT.Heap_Sort} in having a less convenient
18025 interface, but may be slightly more efficient.
18027 @node GNAT.Heap_Sort_G (g-hesorg.ads)
18028 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
18029 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
18030 @cindex Sorting
18032 @noindent
18033 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
18034 are provided as generic parameters, this improves efficiency, especially
18035 if the procedures can be inlined, at the expense of duplicating code for
18036 multiple instantiations.
18038 @node GNAT.HTable (g-htable.ads)
18039 @section @code{GNAT.HTable} (@file{g-htable.ads})
18040 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
18041 @cindex Hash tables
18043 @noindent
18044 A generic implementation of hash tables that can be used to hash arbitrary
18045 data.  Provides two approaches, one a simple static approach, and the other
18046 allowing arbitrary dynamic hash tables.
18048 @node GNAT.IO (g-io.ads)
18049 @section @code{GNAT.IO} (@file{g-io.ads})
18050 @cindex @code{GNAT.IO} (@file{g-io.ads})
18051 @cindex Simple I/O
18052 @cindex Input/Output facilities
18054 @noindent
18055 A simple preelaborable input-output package that provides a subset of
18056 simple Text_IO functions for reading characters and strings from
18057 Standard_Input, and writing characters, strings and integers to either
18058 Standard_Output or Standard_Error.
18060 @node GNAT.IO_Aux (g-io_aux.ads)
18061 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
18062 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
18063 @cindex Text_IO
18064 @cindex Input/Output facilities
18066 Provides some auxiliary functions for use with Text_IO, including a test
18067 for whether a file exists, and functions for reading a line of text.
18069 @node GNAT.Lock_Files (g-locfil.ads)
18070 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
18071 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
18072 @cindex File locking
18073 @cindex Locking using files
18075 @noindent
18076 Provides a general interface for using files as locks.  Can be used for
18077 providing program level synchronization.
18079 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
18080 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
18081 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
18082 @cindex Random number generation
18084 @noindent
18085 The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
18086 a modified version of the Blum-Blum-Shub generator.
18088 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
18089 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
18090 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
18091 @cindex Random number generation
18093 @noindent
18094 The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
18095 a modified version of the Blum-Blum-Shub generator.
18097 @node GNAT.MD5 (g-md5.ads)
18098 @section @code{GNAT.MD5} (@file{g-md5.ads})
18099 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
18100 @cindex Message Digest MD5
18102 @noindent
18103 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
18105 @node GNAT.Memory_Dump (g-memdum.ads)
18106 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
18107 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
18108 @cindex Dump Memory
18110 @noindent
18111 Provides a convenient routine for dumping raw memory to either the
18112 standard output or standard error files. Uses GNAT.IO for actual
18113 output.
18115 @node GNAT.Most_Recent_Exception (g-moreex.ads)
18116 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
18117 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
18118 @cindex Exception, obtaining most recent
18120 @noindent
18121 Provides access to the most recently raised exception.  Can be used for
18122 various logging purposes, including duplicating functionality of some
18123 Ada 83 implementation dependent extensions.
18125 @node GNAT.OS_Lib (g-os_lib.ads)
18126 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
18127 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
18128 @cindex Operating System interface
18129 @cindex Spawn capability
18131 @noindent
18132 Provides a range of target independent operating system interface functions,
18133 including time/date management, file operations, subprocess management,
18134 including a portable spawn procedure, and access to environment variables
18135 and error return codes.
18137 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
18138 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
18139 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
18140 @cindex Hash functions
18142 @noindent
18143 Provides a generator of static minimal perfect hash functions. No
18144 collisions occur and each item can be retrieved from the table in one
18145 probe (perfect property). The hash table size corresponds to the exact
18146 size of the key set and no larger (minimal property). The key set has to
18147 be know in advance (static property). The hash functions are also order
18148 preserving. If w2 is inserted after w1 in the generator, their
18149 hashcode are in the same order. These hashing functions are very
18150 convenient for use with realtime applications.
18152 @node GNAT.Random_Numbers (g-rannum.ads)
18153 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
18154 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
18155 @cindex Random number generation
18157 @noindent
18158 Provides random number capabilities which extend those available in the
18159 standard Ada library and are more convenient to use.
18161 @node GNAT.Regexp (g-regexp.ads)
18162 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
18163 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
18164 @cindex Regular expressions
18165 @cindex Pattern matching
18167 @noindent
18168 A simple implementation of regular expressions, using a subset of regular
18169 expression syntax copied from familiar Unix style utilities.  This is the
18170 simples of the three pattern matching packages provided, and is particularly
18171 suitable for ``file globbing'' applications.
18173 @node GNAT.Registry (g-regist.ads)
18174 @section @code{GNAT.Registry} (@file{g-regist.ads})
18175 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
18176 @cindex Windows Registry
18178 @noindent
18179 This is a high level binding to the Windows registry.  It is possible to
18180 do simple things like reading a key value, creating a new key.  For full
18181 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
18182 package provided with the Win32Ada binding
18184 @node GNAT.Regpat (g-regpat.ads)
18185 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
18186 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
18187 @cindex Regular expressions
18188 @cindex Pattern matching
18190 @noindent
18191 A complete implementation of Unix-style regular expression matching, copied
18192 from the original V7 style regular expression library written in C by
18193 Henry Spencer (and binary compatible with this C library).
18195 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
18196 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
18197 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
18198 @cindex Secondary Stack Info
18200 @noindent
18201 Provide the capability to query the high water mark of the current task's
18202 secondary stack.
18204 @node GNAT.Semaphores (g-semaph.ads)
18205 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
18206 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
18207 @cindex Semaphores
18209 @noindent
18210 Provides classic counting and binary semaphores using protected types.
18212 @node GNAT.Serial_Communications (g-sercom.ads)
18213 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
18214 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
18215 @cindex Serial_Communications
18217 @noindent
18218 Provides a simple interface to send and receive data over a serial
18219 port. This is only supported on GNU/Linux and Windows.
18221 @node GNAT.SHA1 (g-sha1.ads)
18222 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
18223 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
18224 @cindex Secure Hash Algorithm SHA-1
18226 @noindent
18227 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
18228 and RFC 3174.
18230 @node GNAT.SHA224 (g-sha224.ads)
18231 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
18232 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
18233 @cindex Secure Hash Algorithm SHA-224
18235 @noindent
18236 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
18238 @node GNAT.SHA256 (g-sha256.ads)
18239 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
18240 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
18241 @cindex Secure Hash Algorithm SHA-256
18243 @noindent
18244 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
18246 @node GNAT.SHA384 (g-sha384.ads)
18247 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
18248 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
18249 @cindex Secure Hash Algorithm SHA-384
18251 @noindent
18252 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
18254 @node GNAT.SHA512 (g-sha512.ads)
18255 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
18256 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
18257 @cindex Secure Hash Algorithm SHA-512
18259 @noindent
18260 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
18262 @node GNAT.Signals (g-signal.ads)
18263 @section @code{GNAT.Signals} (@file{g-signal.ads})
18264 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
18265 @cindex Signals
18267 @noindent
18268 Provides the ability to manipulate the blocked status of signals on supported
18269 targets.
18271 @node GNAT.Sockets (g-socket.ads)
18272 @section @code{GNAT.Sockets} (@file{g-socket.ads})
18273 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
18274 @cindex Sockets
18276 @noindent
18277 A high level and portable interface to develop sockets based applications.
18278 This package is based on the sockets thin binding found in
18279 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
18280 on all native GNAT ports except for OpenVMS@.  It is not implemented
18281 for the LynxOS@ cross port.
18283 @node GNAT.Source_Info (g-souinf.ads)
18284 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
18285 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
18286 @cindex Source Information
18288 @noindent
18289 Provides subprograms that give access to source code information known at
18290 compile time, such as the current file name and line number.
18292 @node GNAT.Spelling_Checker (g-speche.ads)
18293 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
18294 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
18295 @cindex Spell checking
18297 @noindent
18298 Provides a function for determining whether one string is a plausible
18299 near misspelling of another string.
18301 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
18302 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
18303 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
18304 @cindex Spell checking
18306 @noindent
18307 Provides a generic function that can be instantiated with a string type for
18308 determining whether one string is a plausible near misspelling of another
18309 string.
18311 @node GNAT.Spitbol.Patterns (g-spipat.ads)
18312 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
18313 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
18314 @cindex SPITBOL pattern matching
18315 @cindex Pattern matching
18317 @noindent
18318 A complete implementation of SNOBOL4 style pattern matching.  This is the
18319 most elaborate of the pattern matching packages provided.  It fully duplicates
18320 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
18321 efficient algorithm developed by Robert Dewar for the SPITBOL system.
18323 @node GNAT.Spitbol (g-spitbo.ads)
18324 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
18325 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
18326 @cindex SPITBOL interface
18328 @noindent
18329 The top level package of the collection of SPITBOL-style functionality, this
18330 package provides basic SNOBOL4 string manipulation functions, such as
18331 Pad, Reverse, Trim, Substr capability, as well as a generic table function
18332 useful for constructing arbitrary mappings from strings in the style of
18333 the SNOBOL4 TABLE function.
18335 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
18336 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
18337 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
18338 @cindex Sets of strings
18339 @cindex SPITBOL Tables
18341 @noindent
18342 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
18343 for type @code{Standard.Boolean}, giving an implementation of sets of
18344 string values.
18346 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
18347 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
18348 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
18349 @cindex Integer maps
18350 @cindex Maps
18351 @cindex SPITBOL Tables
18353 @noindent
18354 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
18355 for type @code{Standard.Integer}, giving an implementation of maps
18356 from string to integer values.
18358 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
18359 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
18360 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
18361 @cindex String maps
18362 @cindex Maps
18363 @cindex SPITBOL Tables
18365 @noindent
18366 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
18367 a variable length string type, giving an implementation of general
18368 maps from strings to strings.
18370 @node GNAT.SSE (g-sse.ads)
18371 @section @code{GNAT.SSE} (@file{g-sse.ads})
18372 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
18374 @noindent
18375 Root of a set of units aimed at offering Ada bindings to a subset of
18376 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
18377 targets.  It exposes vector component types together with a general
18378 introduction to the binding contents and use.
18380 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
18381 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
18382 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
18384 @noindent
18385 SSE vector types for use with SSE related intrinsics.
18387 @node GNAT.Strings (g-string.ads)
18388 @section @code{GNAT.Strings} (@file{g-string.ads})
18389 @cindex @code{GNAT.Strings} (@file{g-string.ads})
18391 @noindent
18392 Common String access types and related subprograms. Basically it
18393 defines a string access and an array of string access types.
18395 @node GNAT.String_Split (g-strspl.ads)
18396 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
18397 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
18398 @cindex String splitter
18400 @noindent
18401 Useful string manipulation routines: given a set of separators, split
18402 a string wherever the separators appear, and provide direct access
18403 to the resulting slices. This package is instantiated from
18404 @code{GNAT.Array_Split}.
18406 @node GNAT.Table (g-table.ads)
18407 @section @code{GNAT.Table} (@file{g-table.ads})
18408 @cindex @code{GNAT.Table} (@file{g-table.ads})
18409 @cindex Table implementation
18410 @cindex Arrays, extendable
18412 @noindent
18413 A generic package providing a single dimension array abstraction where the
18414 length of the array can be dynamically modified.
18416 @noindent
18417 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
18418 except that this package declares a single instance of the table type,
18419 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
18420 used to define dynamic instances of the table.
18422 @node GNAT.Task_Lock (g-tasloc.ads)
18423 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
18424 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
18425 @cindex Task synchronization
18426 @cindex Task locking
18427 @cindex Locking
18429 @noindent
18430 A very simple facility for locking and unlocking sections of code using a
18431 single global task lock.  Appropriate for use in situations where contention
18432 between tasks is very rarely expected.
18434 @node GNAT.Time_Stamp (g-timsta.ads)
18435 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
18436 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
18437 @cindex Time stamp
18438 @cindex Current time
18440 @noindent
18441 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
18442 represents the current date and time in ISO 8601 format. This is a very simple
18443 routine with minimal code and there are no dependencies on any other unit.
18445 @node GNAT.Threads (g-thread.ads)
18446 @section @code{GNAT.Threads} (@file{g-thread.ads})
18447 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
18448 @cindex Foreign threads
18449 @cindex Threads, foreign
18451 @noindent
18452 Provides facilities for dealing with foreign threads which need to be known
18453 by the GNAT run-time system. Consult the documentation of this package for
18454 further details if your program has threads that are created by a non-Ada
18455 environment which then accesses Ada code.
18457 @node GNAT.Traceback (g-traceb.ads)
18458 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
18459 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
18460 @cindex Trace back facilities
18462 @noindent
18463 Provides a facility for obtaining non-symbolic traceback information, useful
18464 in various debugging situations.
18466 @node GNAT.Traceback.Symbolic (g-trasym.ads)
18467 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
18468 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
18469 @cindex Trace back facilities
18471 @node GNAT.UTF_32 (g-utf_32.ads)
18472 @section @code{GNAT.UTF_32} (@file{g-table.ads})
18473 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
18474 @cindex Wide character codes
18476 @noindent
18477 This is a package intended to be used in conjunction with the
18478 @code{Wide_Character} type in Ada 95 and the
18479 @code{Wide_Wide_Character} type in Ada 2005 (available
18480 in @code{GNAT} in Ada 2005 mode). This package contains
18481 Unicode categorization routines, as well as lexical
18482 categorization routines corresponding to the Ada 2005
18483 lexical rules for identifiers and strings, and also a
18484 lower case to upper case fold routine corresponding to
18485 the Ada 2005 rules for identifier equivalence.
18487 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
18488 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
18489 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
18490 @cindex Spell checking
18492 @noindent
18493 Provides a function for determining whether one wide wide string is a plausible
18494 near misspelling of another wide wide string, where the strings are represented
18495 using the UTF_32_String type defined in System.Wch_Cnv.
18497 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
18498 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
18499 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
18500 @cindex Spell checking
18502 @noindent
18503 Provides a function for determining whether one wide string is a plausible
18504 near misspelling of another wide string.
18506 @node GNAT.Wide_String_Split (g-wistsp.ads)
18507 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
18508 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
18509 @cindex Wide_String splitter
18511 @noindent
18512 Useful wide string manipulation routines: given a set of separators, split
18513 a wide string wherever the separators appear, and provide direct access
18514 to the resulting slices. This package is instantiated from
18515 @code{GNAT.Array_Split}.
18517 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
18518 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
18519 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
18520 @cindex Spell checking
18522 @noindent
18523 Provides a function for determining whether one wide wide string is a plausible
18524 near misspelling of another wide wide string.
18526 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
18527 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
18528 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
18529 @cindex Wide_Wide_String splitter
18531 @noindent
18532 Useful wide wide string manipulation routines: given a set of separators, split
18533 a wide wide string wherever the separators appear, and provide direct access
18534 to the resulting slices. This package is instantiated from
18535 @code{GNAT.Array_Split}.
18537 @node Interfaces.C.Extensions (i-cexten.ads)
18538 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
18539 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
18541 @noindent
18542 This package contains additional C-related definitions, intended
18543 for use with either manually or automatically generated bindings
18544 to C libraries.
18546 @node Interfaces.C.Streams (i-cstrea.ads)
18547 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
18548 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
18549 @cindex  C streams, interfacing
18551 @noindent
18552 This package is a binding for the most commonly used operations
18553 on C streams.
18555 @node Interfaces.CPP (i-cpp.ads)
18556 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
18557 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
18558 @cindex  C++ interfacing
18559 @cindex  Interfacing, to C++
18561 @noindent
18562 This package provides facilities for use in interfacing to C++.  It
18563 is primarily intended to be used in connection with automated tools
18564 for the generation of C++ interfaces.
18566 @node Interfaces.Packed_Decimal (i-pacdec.ads)
18567 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
18568 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
18569 @cindex  IBM Packed Format
18570 @cindex  Packed Decimal
18572 @noindent
18573 This package provides a set of routines for conversions to and
18574 from a packed decimal format compatible with that used on IBM
18575 mainframes.
18577 @node Interfaces.VxWorks (i-vxwork.ads)
18578 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
18579 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
18580 @cindex Interfacing to VxWorks
18581 @cindex VxWorks, interfacing
18583 @noindent
18584 This package provides a limited binding to the VxWorks API.
18585 In particular, it interfaces with the
18586 VxWorks hardware interrupt facilities.
18588 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
18589 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
18590 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
18591 @cindex Interfacing to VxWorks' I/O
18592 @cindex VxWorks, I/O interfacing
18593 @cindex VxWorks, Get_Immediate
18594 @cindex Get_Immediate, VxWorks
18596 @noindent
18597 This package provides a binding to the ioctl (IO/Control)
18598 function of VxWorks, defining a set of option values and
18599 function codes. A particular use of this package is
18600 to enable the use of Get_Immediate under VxWorks.
18602 @node System.Address_Image (s-addima.ads)
18603 @section @code{System.Address_Image} (@file{s-addima.ads})
18604 @cindex @code{System.Address_Image} (@file{s-addima.ads})
18605 @cindex Address image
18606 @cindex Image, of an address
18608 @noindent
18609 This function provides a useful debugging
18610 function that gives an (implementation dependent)
18611 string which identifies an address.
18613 @node System.Assertions (s-assert.ads)
18614 @section @code{System.Assertions} (@file{s-assert.ads})
18615 @cindex @code{System.Assertions} (@file{s-assert.ads})
18616 @cindex Assertions
18617 @cindex Assert_Failure, exception
18619 @noindent
18620 This package provides the declaration of the exception raised
18621 by an run-time assertion failure, as well as the routine that
18622 is used internally to raise this assertion.
18624 @node System.Memory (s-memory.ads)
18625 @section @code{System.Memory} (@file{s-memory.ads})
18626 @cindex @code{System.Memory} (@file{s-memory.ads})
18627 @cindex Memory allocation
18629 @noindent
18630 This package provides the interface to the low level routines used
18631 by the generated code for allocation and freeing storage for the
18632 default storage pool (analogous to the C routines malloc and free.
18633 It also provides a reallocation interface analogous to the C routine
18634 realloc. The body of this unit may be modified to provide alternative
18635 allocation mechanisms for the default pool, and in addition, direct
18636 calls to this unit may be made for low level allocation uses (for
18637 example see the body of @code{GNAT.Tables}).
18639 @node System.Multiprocessors (s-multip.ads)
18640 @section @code{System.Multiprocessors} (@file{s-multip.ads})
18641 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
18642 @cindex Multiprocessor interface
18643 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
18644 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
18645 technically an implementation-defined addition).
18647 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
18648 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
18649 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
18650 @cindex Multiprocessor interface
18651 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
18652 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
18653 technically an implementation-defined addition).
18655 @node System.Partition_Interface (s-parint.ads)
18656 @section @code{System.Partition_Interface} (@file{s-parint.ads})
18657 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
18658 @cindex Partition interfacing functions
18660 @noindent
18661 This package provides facilities for partition interfacing.  It
18662 is used primarily in a distribution context when using Annex E
18663 with @code{GLADE}.
18665 @node System.Pool_Global (s-pooglo.ads)
18666 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
18667 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
18668 @cindex Storage pool, global
18669 @cindex Global storage pool
18671 @noindent
18672 This package provides a storage pool that is equivalent to the default
18673 storage pool used for access types for which no pool is specifically
18674 declared. It uses malloc/free to allocate/free and does not attempt to
18675 do any automatic reclamation.
18677 @node System.Pool_Local (s-pooloc.ads)
18678 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
18679 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
18680 @cindex Storage pool, local
18681 @cindex Local storage pool
18683 @noindent
18684 This package provides a storage pool that is intended for use with locally
18685 defined access types. It uses malloc/free for allocate/free, and maintains
18686 a list of allocated blocks, so that all storage allocated for the pool can
18687 be freed automatically when the pool is finalized.
18689 @node System.Restrictions (s-restri.ads)
18690 @section @code{System.Restrictions} (@file{s-restri.ads})
18691 @cindex @code{System.Restrictions} (@file{s-restri.ads})
18692 @cindex Run-time restrictions access
18694 @noindent
18695 This package provides facilities for accessing at run time
18696 the status of restrictions specified at compile time for
18697 the partition. Information is available both with regard
18698 to actual restrictions specified, and with regard to
18699 compiler determined information on which restrictions
18700 are violated by one or more packages in the partition.
18702 @node System.Rident (s-rident.ads)
18703 @section @code{System.Rident} (@file{s-rident.ads})
18704 @cindex @code{System.Rident} (@file{s-rident.ads})
18705 @cindex Restrictions definitions
18707 @noindent
18708 This package provides definitions of the restrictions
18709 identifiers supported by GNAT, and also the format of
18710 the restrictions provided in package System.Restrictions.
18711 It is not normally necessary to @code{with} this generic package
18712 since the necessary instantiation is included in
18713 package System.Restrictions.
18715 @node System.Strings.Stream_Ops (s-ststop.ads)
18716 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
18717 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
18718 @cindex Stream operations
18719 @cindex String stream operations
18721 @noindent
18722 This package provides a set of stream subprograms for standard string types.
18723 It is intended primarily to support implicit use of such subprograms when
18724 stream attributes are applied to string types, but the subprograms in this
18725 package can be used directly by application programs.
18727 @node System.Task_Info (s-tasinf.ads)
18728 @section @code{System.Task_Info} (@file{s-tasinf.ads})
18729 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
18730 @cindex Task_Info pragma
18732 @noindent
18733 This package provides target dependent functionality that is used
18734 to support the @code{Task_Info} pragma
18736 @node System.Wch_Cnv (s-wchcnv.ads)
18737 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
18738 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
18739 @cindex Wide Character, Representation
18740 @cindex Wide String, Conversion
18741 @cindex Representation of wide characters
18743 @noindent
18744 This package provides routines for converting between
18745 wide and wide wide characters and a representation as a value of type
18746 @code{Standard.String}, using a specified wide character
18747 encoding method.  It uses definitions in
18748 package @code{System.Wch_Con}.
18750 @node System.Wch_Con (s-wchcon.ads)
18751 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
18752 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
18754 @noindent
18755 This package provides definitions and descriptions of
18756 the various methods used for encoding wide characters
18757 in ordinary strings.  These definitions are used by
18758 the package @code{System.Wch_Cnv}.
18760 @node Interfacing to Other Languages
18761 @chapter Interfacing to Other Languages
18762 @noindent
18763 The facilities in annex B of the Ada Reference Manual are fully
18764 implemented in GNAT, and in addition, a full interface to C++ is
18765 provided.
18767 @menu
18768 * Interfacing to C::
18769 * Interfacing to C++::
18770 * Interfacing to COBOL::
18771 * Interfacing to Fortran::
18772 * Interfacing to non-GNAT Ada code::
18773 @end menu
18775 @node Interfacing to C
18776 @section Interfacing to C
18778 @noindent
18779 Interfacing to C with GNAT can use one of two approaches:
18781 @itemize @bullet
18782 @item
18783 The types in the package @code{Interfaces.C} may be used.
18784 @item
18785 Standard Ada types may be used directly.  This may be less portable to
18786 other compilers, but will work on all GNAT compilers, which guarantee
18787 correspondence between the C and Ada types.
18788 @end itemize
18790 @noindent
18791 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
18792 effect, since this is the default.  The following table shows the
18793 correspondence between Ada scalar types and the corresponding C types.
18795 @table @code
18796 @item Integer
18797 @code{int}
18798 @item Short_Integer
18799 @code{short}
18800 @item Short_Short_Integer
18801 @code{signed char}
18802 @item Long_Integer
18803 @code{long}
18804 @item Long_Long_Integer
18805 @code{long long}
18806 @item Short_Float
18807 @code{float}
18808 @item Float
18809 @code{float}
18810 @item Long_Float
18811 @code{double}
18812 @item Long_Long_Float
18813 This is the longest floating-point type supported by the hardware.
18814 @end table
18816 @noindent
18817 Additionally, there are the following general correspondences between Ada
18818 and C types:
18819 @itemize @bullet
18820 @item
18821 Ada enumeration types map to C enumeration types directly if pragma
18822 @code{Convention C} is specified, which causes them to have int
18823 length.  Without pragma @code{Convention C}, Ada enumeration types map to
18824 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
18825 @code{int}, respectively) depending on the number of values passed.
18826 This is the only case in which pragma @code{Convention C} affects the
18827 representation of an Ada type.
18829 @item
18830 Ada access types map to C pointers, except for the case of pointers to
18831 unconstrained types in Ada, which have no direct C equivalent.
18833 @item
18834 Ada arrays map directly to C arrays.
18836 @item
18837 Ada records map directly to C structures.
18839 @item
18840 Packed Ada records map to C structures where all members are bit fields
18841 of the length corresponding to the @code{@var{type}'Size} value in Ada.
18842 @end itemize
18844 @node Interfacing to C++
18845 @section Interfacing to C++
18847 @noindent
18848 The interface to C++ makes use of the following pragmas, which are
18849 primarily intended to be constructed automatically using a binding generator
18850 tool, although it is possible to construct them by hand.
18852 Using these pragmas it is possible to achieve complete
18853 inter-operability between Ada tagged types and C++ class definitions.
18854 See @ref{Implementation Defined Pragmas}, for more details.
18856 @table @code
18857 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
18858 The argument denotes an entity in the current declarative region that is
18859 declared as a tagged or untagged record type. It indicates that the type
18860 corresponds to an externally declared C++ class type, and is to be laid
18861 out the same way that C++ would lay out the type.
18863 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
18864 for backward compatibility but its functionality is available
18865 using pragma @code{Import} with @code{Convention} = @code{CPP}.
18867 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
18868 This pragma identifies an imported function (imported in the usual way
18869 with pragma @code{Import}) as corresponding to a C++ constructor.
18870 @end table
18872 A few restrictions are placed on the use of the @code{Access} attribute
18873 in conjunction with subprograms subject to convention @code{CPP}: the
18874 attribute may be used neither on primitive operations of a tagged
18875 record type with convention @code{CPP}, imported or not, nor on
18876 subprograms imported with pragma @code{CPP_Constructor}.
18878 In addition, C++ exceptions are propagated and can be handled in an
18879 @code{others} choice of an exception handler. The corresponding Ada
18880 occurrence has no message, and the simple name of the exception identity
18881 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
18882 tasks works properly when such foreign exceptions are propagated.
18884 It is also possible to import a C++ exception using the following syntax:
18886 @smallexample @c ada
18887 LOCAL_NAME : exception;
18888 pragma Import (Cpp,
18889   [Entity =>] LOCAL_NAME,
18890   [External_Name =>] static_string_EXPRESSION);
18891 @end smallexample
18893 @noindent
18894 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
18895 cover a specific C++ exception in an exception handler.
18897 @node Interfacing to COBOL
18898 @section Interfacing to COBOL
18900 @noindent
18901 Interfacing to COBOL is achieved as described in section B.4 of
18902 the Ada Reference Manual.
18904 @node Interfacing to Fortran
18905 @section Interfacing to Fortran
18907 @noindent
18908 Interfacing to Fortran is achieved as described in section B.5 of the
18909 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
18910 multi-dimensional array causes the array to be stored in column-major
18911 order as required for convenient interface to Fortran.
18913 @node Interfacing to non-GNAT Ada code
18914 @section Interfacing to non-GNAT Ada code
18916 It is possible to specify the convention @code{Ada} in a pragma
18917 @code{Import} or pragma @code{Export}.  However this refers to
18918 the calling conventions used by GNAT, which may or may not be
18919 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
18920 compiler to allow interoperation.
18922 If arguments types are kept simple, and if the foreign compiler generally
18923 follows system calling conventions, then it may be possible to integrate
18924 files compiled by other Ada compilers, provided that the elaboration
18925 issues are adequately addressed (for example by eliminating the
18926 need for any load time elaboration).
18928 In particular, GNAT running on VMS is designed to
18929 be highly compatible with the DEC Ada 83 compiler, so this is one
18930 case in which it is possible to import foreign units of this type,
18931 provided that the data items passed are restricted to simple scalar
18932 values or simple record types without variants, or simple array
18933 types with fixed bounds.
18935 @node Specialized Needs Annexes
18936 @chapter Specialized Needs Annexes
18938 @noindent
18939 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
18940 required in all implementations.  However, as described in this chapter,
18941 GNAT implements all of these annexes:
18943 @table @asis
18944 @item Systems Programming (Annex C)
18945 The Systems Programming Annex is fully implemented.
18947 @item Real-Time Systems (Annex D)
18948 The Real-Time Systems Annex is fully implemented.
18950 @item Distributed Systems (Annex E)
18951 Stub generation is fully implemented in the GNAT compiler.  In addition,
18952 a complete compatible PCS is available as part of the GLADE system,
18953 a separate product.  When the two
18954 products are used in conjunction, this annex is fully implemented.
18956 @item Information Systems (Annex F)
18957 The Information Systems annex is fully implemented.
18959 @item Numerics (Annex G)
18960 The Numerics Annex is fully implemented.
18962 @item Safety and Security / High-Integrity Systems (Annex H)
18963 The Safety and Security Annex (termed the High-Integrity Systems Annex
18964 in Ada 2005) is fully implemented.
18965 @end table
18967 @node Implementation of Specific Ada Features
18968 @chapter Implementation of Specific Ada Features
18970 @noindent
18971 This chapter describes the GNAT implementation of several Ada language
18972 facilities.
18974 @menu
18975 * Machine Code Insertions::
18976 * GNAT Implementation of Tasking::
18977 * GNAT Implementation of Shared Passive Packages::
18978 * Code Generation for Array Aggregates::
18979 * The Size of Discriminated Records with Default Discriminants::
18980 * Strict Conformance to the Ada Reference Manual::
18981 @end menu
18983 @node Machine Code Insertions
18984 @section Machine Code Insertions
18985 @cindex Machine Code insertions
18987 @noindent
18988 Package @code{Machine_Code} provides machine code support as described
18989 in the Ada Reference Manual in two separate forms:
18990 @itemize @bullet
18991 @item
18992 Machine code statements, consisting of qualified expressions that
18993 fit the requirements of RM section 13.8.
18994 @item
18995 An intrinsic callable procedure, providing an alternative mechanism of
18996 including machine instructions in a subprogram.
18997 @end itemize
18999 @noindent
19000 The two features are similar, and both are closely related to the mechanism
19001 provided by the asm instruction in the GNU C compiler.  Full understanding
19002 and use of the facilities in this package requires understanding the asm
19003 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
19004 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
19006 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
19007 semantic restrictions and effects as described below.  Both are provided so
19008 that the procedure call can be used as a statement, and the function call
19009 can be used to form a code_statement.
19011 The first example given in the GCC documentation is the C @code{asm}
19012 instruction:
19013 @smallexample
19014    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
19015 @end smallexample
19017 @noindent
19018 The equivalent can be written for GNAT as:
19020 @smallexample @c ada
19021 Asm ("fsinx %1 %0",
19022      My_Float'Asm_Output ("=f", result),
19023      My_Float'Asm_Input  ("f",  angle));
19024 @end smallexample
19026 @noindent
19027 The first argument to @code{Asm} is the assembler template, and is
19028 identical to what is used in GNU C@.  This string must be a static
19029 expression.  The second argument is the output operand list.  It is
19030 either a single @code{Asm_Output} attribute reference, or a list of such
19031 references enclosed in parentheses (technically an array aggregate of
19032 such references).
19034 The @code{Asm_Output} attribute denotes a function that takes two
19035 parameters.  The first is a string, the second is the name of a variable
19036 of the type designated by the attribute prefix.  The first (string)
19037 argument is required to be a static expression and designates the
19038 constraint for the parameter (e.g.@: what kind of register is
19039 required).  The second argument is the variable to be updated with the
19040 result.  The possible values for constraint are the same as those used in
19041 the RTL, and are dependent on the configuration file used to build the
19042 GCC back end.  If there are no output operands, then this argument may
19043 either be omitted, or explicitly given as @code{No_Output_Operands}.
19045 The second argument of @code{@var{my_float}'Asm_Output} functions as
19046 though it were an @code{out} parameter, which is a little curious, but
19047 all names have the form of expressions, so there is no syntactic
19048 irregularity, even though normally functions would not be permitted
19049 @code{out} parameters.  The third argument is the list of input
19050 operands.  It is either a single @code{Asm_Input} attribute reference, or
19051 a list of such references enclosed in parentheses (technically an array
19052 aggregate of such references).
19054 The @code{Asm_Input} attribute denotes a function that takes two
19055 parameters.  The first is a string, the second is an expression of the
19056 type designated by the prefix.  The first (string) argument is required
19057 to be a static expression, and is the constraint for the parameter,
19058 (e.g.@: what kind of register is required).  The second argument is the
19059 value to be used as the input argument.  The possible values for the
19060 constant are the same as those used in the RTL, and are dependent on
19061 the configuration file used to built the GCC back end.
19063 If there are no input operands, this argument may either be omitted, or
19064 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
19065 present in the above example, is a list of register names, called the
19066 @dfn{clobber} argument.  This argument, if given, must be a static string
19067 expression, and is a space or comma separated list of names of registers
19068 that must be considered destroyed as a result of the @code{Asm} call.  If
19069 this argument is the null string (the default value), then the code
19070 generator assumes that no additional registers are destroyed.
19072 The fifth argument, not present in the above example, called the
19073 @dfn{volatile} argument, is by default @code{False}.  It can be set to
19074 the literal value @code{True} to indicate to the code generator that all
19075 optimizations with respect to the instruction specified should be
19076 suppressed, and that in particular, for an instruction that has outputs,
19077 the instruction will still be generated, even if none of the outputs are
19078 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
19079 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
19080 Generally it is strongly advisable to use Volatile for any ASM statement
19081 that is missing either input or output operands, or when two or more ASM
19082 statements appear in sequence, to avoid unwanted optimizations. A warning
19083 is generated if this advice is not followed.
19085 The @code{Asm} subprograms may be used in two ways.  First the procedure
19086 forms can be used anywhere a procedure call would be valid, and
19087 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
19088 be used to intersperse machine instructions with other Ada statements.
19089 Second, the function forms, which return a dummy value of the limited
19090 private type @code{Asm_Insn}, can be used in code statements, and indeed
19091 this is the only context where such calls are allowed.  Code statements
19092 appear as aggregates of the form:
19094 @smallexample @c ada
19095 Asm_Insn'(Asm (@dots{}));
19096 Asm_Insn'(Asm_Volatile (@dots{}));
19097 @end smallexample
19099 @noindent
19100 In accordance with RM rules, such code statements are allowed only
19101 within subprograms whose entire body consists of such statements.  It is
19102 not permissible to intermix such statements with other Ada statements.
19104 Typically the form using intrinsic procedure calls is more convenient
19105 and more flexible.  The code statement form is provided to meet the RM
19106 suggestion that such a facility should be made available.  The following
19107 is the exact syntax of the call to @code{Asm}. As usual, if named notation
19108 is used, the arguments may be given in arbitrary order, following the
19109 normal rules for use of positional and named arguments)
19111 @smallexample
19112 ASM_CALL ::= Asm (
19113                  [Template =>] static_string_EXPRESSION
19114                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
19115                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
19116                [,[Clobber  =>] static_string_EXPRESSION ]
19117                [,[Volatile =>] static_boolean_EXPRESSION] )
19119 OUTPUT_OPERAND_LIST ::=
19120   [PREFIX.]No_Output_Operands
19121 | OUTPUT_OPERAND_ATTRIBUTE
19122 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
19124 OUTPUT_OPERAND_ATTRIBUTE ::=
19125   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
19127 INPUT_OPERAND_LIST ::=
19128   [PREFIX.]No_Input_Operands
19129 | INPUT_OPERAND_ATTRIBUTE
19130 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
19132 INPUT_OPERAND_ATTRIBUTE ::=
19133   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
19134 @end smallexample
19136 @noindent
19137 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
19138 are declared in the package @code{Machine_Code} and must be referenced
19139 according to normal visibility rules. In particular if there is no
19140 @code{use} clause for this package, then appropriate package name
19141 qualification is required.
19143 @node GNAT Implementation of Tasking
19144 @section GNAT Implementation of Tasking
19146 @noindent
19147 This chapter outlines the basic GNAT approach to tasking (in particular,
19148 a multi-layered library for portability) and discusses issues related
19149 to compliance with the Real-Time Systems Annex.
19151 @menu
19152 * Mapping Ada Tasks onto the Underlying Kernel Threads::
19153 * Ensuring Compliance with the Real-Time Annex::
19154 @end menu
19156 @node Mapping Ada Tasks onto the Underlying Kernel Threads
19157 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
19159 @noindent
19160 GNAT's run-time support comprises two layers:
19162 @itemize @bullet
19163 @item GNARL (GNAT Run-time Layer)
19164 @item GNULL (GNAT Low-level Library)
19165 @end itemize
19167 @noindent
19168 In GNAT, Ada's tasking services rely on a platform and OS independent
19169 layer known as GNARL@.  This code is responsible for implementing the
19170 correct semantics of Ada's task creation, rendezvous, protected
19171 operations etc.
19173 GNARL decomposes Ada's tasking semantics into simpler lower level
19174 operations such as create a thread, set the priority of a thread,
19175 yield, create a lock, lock/unlock, etc.  The spec for these low-level
19176 operations constitutes GNULLI, the GNULL Interface.  This interface is
19177 directly inspired from the POSIX real-time API@.
19179 If the underlying executive or OS implements the POSIX standard
19180 faithfully, the GNULL Interface maps as is to the services offered by
19181 the underlying kernel.  Otherwise, some target dependent glue code maps
19182 the services offered by the underlying kernel to the semantics expected
19183 by GNARL@.
19185 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
19186 key point is that each Ada task is mapped on a thread in the underlying
19187 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
19189 In addition Ada task priorities map onto the underlying thread priorities.
19190 Mapping Ada tasks onto the underlying kernel threads has several advantages:
19192 @itemize @bullet
19193 @item
19194 The underlying scheduler is used to schedule the Ada tasks.  This
19195 makes Ada tasks as efficient as kernel threads from a scheduling
19196 standpoint.
19198 @item
19199 Interaction with code written in C containing threads is eased
19200 since at the lowest level Ada tasks and C threads map onto the same
19201 underlying kernel concept.
19203 @item
19204 When an Ada task is blocked during I/O the remaining Ada tasks are
19205 able to proceed.
19207 @item
19208 On multiprocessor systems Ada tasks can execute in parallel.
19209 @end itemize
19211 @noindent
19212 Some threads libraries offer a mechanism to fork a new process, with the
19213 child process duplicating the threads from the parent.
19214 GNAT does not
19215 support this functionality when the parent contains more than one task.
19216 @cindex Forking a new process
19218 @node Ensuring Compliance with the Real-Time Annex
19219 @subsection Ensuring Compliance with the Real-Time Annex
19220 @cindex Real-Time Systems Annex compliance
19222 @noindent
19223 Although mapping Ada tasks onto
19224 the underlying threads has significant advantages, it does create some
19225 complications when it comes to respecting the scheduling semantics
19226 specified in the real-time annex (Annex D).
19228 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
19229 scheduling policy states:
19231 @quotation
19232 @emph{When the active priority of a ready task that is not running
19233 changes, or the setting of its base priority takes effect, the
19234 task is removed from the ready queue for its old active priority
19235 and is added at the tail of the ready queue for its new active
19236 priority, except in the case where the active priority is lowered
19237 due to the loss of inherited priority, in which case the task is
19238 added at the head of the ready queue for its new active priority.}
19239 @end quotation
19241 @noindent
19242 While most kernels do put tasks at the end of the priority queue when
19243 a task changes its priority, (which respects the main
19244 FIFO_Within_Priorities requirement), almost none keep a thread at the
19245 beginning of its priority queue when its priority drops from the loss
19246 of inherited priority.
19248 As a result most vendors have provided incomplete Annex D implementations.
19250 The GNAT run-time, has a nice cooperative solution to this problem
19251 which ensures that accurate FIFO_Within_Priorities semantics are
19252 respected.
19254 The principle is as follows.  When an Ada task T is about to start
19255 running, it checks whether some other Ada task R with the same
19256 priority as T has been suspended due to the loss of priority
19257 inheritance.  If this is the case, T yields and is placed at the end of
19258 its priority queue.  When R arrives at the front of the queue it
19259 executes.
19261 Note that this simple scheme preserves the relative order of the tasks
19262 that were ready to execute in the priority queue where R has been
19263 placed at the end.
19265 @node GNAT Implementation of Shared Passive Packages
19266 @section GNAT Implementation of Shared Passive Packages
19267 @cindex Shared passive packages
19269 @noindent
19270 GNAT fully implements the pragma @code{Shared_Passive} for
19271 @cindex pragma @code{Shared_Passive}
19272 the purpose of designating shared passive packages.
19273 This allows the use of passive partitions in the
19274 context described in the Ada Reference Manual; i.e., for communication
19275 between separate partitions of a distributed application using the
19276 features in Annex E.
19277 @cindex Annex E
19278 @cindex Distribution Systems Annex
19280 However, the implementation approach used by GNAT provides for more
19281 extensive usage as follows:
19283 @table @emph
19284 @item Communication between separate programs
19286 This allows separate programs to access the data in passive
19287 partitions, using protected objects for synchronization where
19288 needed. The only requirement is that the two programs have a
19289 common shared file system. It is even possible for programs
19290 running on different machines with different architectures
19291 (e.g.@: different endianness) to communicate via the data in
19292 a passive partition.
19294 @item Persistence between program runs
19296 The data in a passive package can persist from one run of a
19297 program to another, so that a later program sees the final
19298 values stored by a previous run of the same program.
19300 @end table
19302 @noindent
19303 The implementation approach used is to store the data in files. A
19304 separate stream file is created for each object in the package, and
19305 an access to an object causes the corresponding file to be read or
19306 written.
19308 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
19309 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
19310 set to the directory to be used for these files.
19311 The files in this directory
19312 have names that correspond to their fully qualified names. For
19313 example, if we have the package
19315 @smallexample @c ada
19316 package X is
19317   pragma Shared_Passive (X);
19318   Y : Integer;
19319   Z : Float;
19320 end X;
19321 @end smallexample
19323 @noindent
19324 and the environment variable is set to @code{/stemp/}, then the files created
19325 will have the names:
19327 @smallexample
19328 /stemp/x.y
19329 /stemp/x.z
19330 @end smallexample
19332 @noindent
19333 These files are created when a value is initially written to the object, and
19334 the files are retained until manually deleted. This provides the persistence
19335 semantics. If no file exists, it means that no partition has assigned a value
19336 to the variable; in this case the initial value declared in the package
19337 will be used. This model ensures that there are no issues in synchronizing
19338 the elaboration process, since elaboration of passive packages elaborates the
19339 initial values, but does not create the files.
19341 The files are written using normal @code{Stream_IO} access.
19342 If you want to be able
19343 to communicate between programs or partitions running on different
19344 architectures, then you should use the XDR versions of the stream attribute
19345 routines, since these are architecture independent.
19347 If active synchronization is required for access to the variables in the
19348 shared passive package, then as described in the Ada Reference Manual, the
19349 package may contain protected objects used for this purpose. In this case
19350 a lock file (whose name is @file{___lock} (three underscores)
19351 is created in the shared memory directory.
19352 @cindex @file{___lock} file (for shared passive packages)
19353 This is used to provide the required locking
19354 semantics for proper protected object synchronization.
19356 As of January 2003, GNAT supports shared passive packages on all platforms
19357 except for OpenVMS.
19359 @node Code Generation for Array Aggregates
19360 @section Code Generation for Array Aggregates
19362 @menu
19363 * Static constant aggregates with static bounds::
19364 * Constant aggregates with unconstrained nominal types::
19365 * Aggregates with static bounds::
19366 * Aggregates with non-static bounds::
19367 * Aggregates in assignment statements::
19368 @end menu
19370 @noindent
19371 Aggregates have a rich syntax and allow the user to specify the values of
19372 complex data structures by means of a single construct.  As a result, the
19373 code generated for aggregates can be quite complex and involve loops, case
19374 statements and multiple assignments.  In the simplest cases, however, the
19375 compiler will recognize aggregates whose components and constraints are
19376 fully static, and in those cases the compiler will generate little or no
19377 executable code.  The following is an outline of the code that GNAT generates
19378 for various aggregate constructs.  For further details, you will find it
19379 useful to examine the output produced by the -gnatG flag to see the expanded
19380 source that is input to the code generator.  You may also want to examine
19381 the assembly code generated at various levels of optimization.
19383 The code generated for aggregates depends on the context, the component values,
19384 and the type.  In the context of an object declaration the code generated is
19385 generally simpler than in the case of an assignment.  As a general rule, static
19386 component values and static subtypes also lead to simpler code.
19388 @node Static constant aggregates with static bounds
19389 @subsection Static constant aggregates with static bounds
19391 @noindent
19392 For the declarations:
19393 @smallexample @c ada
19394     type One_Dim is array (1..10) of integer;
19395     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
19396 @end smallexample
19398 @noindent
19399 GNAT generates no executable code: the constant ar0 is placed in static memory.
19400 The same is true for constant aggregates with named associations:
19402 @smallexample @c ada
19403     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
19404     Cr3 : constant One_Dim := (others => 7777);
19405 @end smallexample
19407 @noindent
19408 The same is true for multidimensional constant arrays such as:
19410 @smallexample @c ada
19411     type two_dim is array (1..3, 1..3) of integer;
19412     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
19413 @end smallexample
19415 @noindent
19416 The same is true for arrays of one-dimensional arrays: the following are
19417 static:
19419 @smallexample @c ada
19420 type ar1b  is array (1..3) of boolean;
19421 type ar_ar is array (1..3) of ar1b;
19422 None  : constant ar1b := (others => false);     --  fully static
19423 None2 : constant ar_ar := (1..3 => None);       --  fully static
19424 @end smallexample
19426 @noindent
19427 However, for multidimensional aggregates with named associations, GNAT will
19428 generate assignments and loops, even if all associations are static.  The
19429 following two declarations generate a loop for the first dimension, and
19430 individual component assignments for the second dimension:
19432 @smallexample @c ada
19433 Zero1: constant two_dim := (1..3 => (1..3 => 0));
19434 Zero2: constant two_dim := (others => (others => 0));
19435 @end smallexample
19437 @node Constant aggregates with unconstrained nominal types
19438 @subsection Constant aggregates with unconstrained nominal types
19440 @noindent
19441 In such cases the aggregate itself establishes the subtype, so that
19442 associations with @code{others} cannot be used.  GNAT determines the
19443 bounds for the actual subtype of the aggregate, and allocates the
19444 aggregate statically as well.  No code is generated for the following:
19446 @smallexample @c ada
19447     type One_Unc is array (natural range <>) of integer;
19448     Cr_Unc : constant One_Unc := (12,24,36);
19449 @end smallexample
19451 @node Aggregates with static bounds
19452 @subsection Aggregates with static bounds
19454 @noindent
19455 In all previous examples the aggregate was the initial (and immutable) value
19456 of a constant.  If the aggregate initializes a variable, then code is generated
19457 for it as a combination of individual assignments and loops over the target
19458 object.  The declarations
19460 @smallexample @c ada
19461        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
19462        Cr_Var2 : One_Dim := (others > -1);
19463 @end smallexample
19465 @noindent
19466 generate the equivalent of
19468 @smallexample @c ada
19469        Cr_Var1 (1) := 2;
19470        Cr_Var1 (2) := 3;
19471        Cr_Var1 (3) := 5;
19472        Cr_Var1 (4) := 11;
19474        for I in Cr_Var2'range loop
19475           Cr_Var2 (I) := -1;
19476        end loop;
19477 @end smallexample
19479 @node Aggregates with non-static bounds
19480 @subsection Aggregates with non-static bounds
19482 @noindent
19483 If the bounds of the aggregate are not statically compatible with the bounds
19484 of the nominal subtype  of the target, then constraint checks have to be
19485 generated on the bounds.  For a multidimensional array, constraint checks may
19486 have to be applied to sub-arrays individually, if they do not have statically
19487 compatible subtypes.
19489 @node Aggregates in assignment statements
19490 @subsection Aggregates in assignment statements
19492 @noindent
19493 In general, aggregate assignment requires the construction of a temporary,
19494 and a copy from the temporary to the target of the assignment.  This is because
19495 it is not always possible to convert the assignment into a series of individual
19496 component assignments.  For example, consider the simple case:
19498 @smallexample @c ada
19499         A := (A(2), A(1));
19500 @end smallexample
19502 @noindent
19503 This cannot be converted into:
19505 @smallexample @c ada
19506         A(1) := A(2);
19507         A(2) := A(1);
19508 @end smallexample
19510 @noindent
19511 So the aggregate has to be built first in a separate location, and then
19512 copied into the target.  GNAT recognizes simple cases where this intermediate
19513 step is not required, and the assignments can be performed in place, directly
19514 into the target.  The following sufficient criteria are applied:
19516 @itemize @bullet
19517 @item
19518 The bounds of the aggregate are static, and the associations are static.
19519 @item
19520 The components of the aggregate are static constants, names of
19521 simple variables that are not renamings, or expressions not involving
19522 indexed components whose operands obey these rules.
19523 @end itemize
19525 @noindent
19526 If any of these conditions are violated, the aggregate will be built in
19527 a temporary (created either by the front-end or the code generator) and then
19528 that temporary will be copied onto the target.
19530 @node The Size of Discriminated Records with Default Discriminants
19531 @section The Size of Discriminated Records with Default Discriminants
19533 @noindent
19534 If a discriminated type @code{T} has discriminants with default values, it is
19535 possible to declare an object of this type without providing an explicit
19536 constraint:
19538 @smallexample @c ada
19539 @group
19540 type Size is range 1..100;
19542 type Rec (D : Size := 15) is record
19543    Name : String (1..D);
19544 end T;
19546 Word : Rec;
19547 @end group
19548 @end smallexample
19550 @noindent
19551 Such an object is said to be @emph{unconstrained}.
19552 The discriminant of the object
19553 can be modified by a full assignment to the object, as long as it preserves the
19554 relation between the value of the discriminant, and the value of the components
19555 that depend on it:
19557 @smallexample @c ada
19558 @group
19559 Word := (3, "yes");
19561 Word := (5, "maybe");
19563 Word := (5, "no"); -- raises Constraint_Error
19564 @end group
19565 @end smallexample
19567 @noindent
19568 In order to support this behavior efficiently, an unconstrained object is
19569 given the maximum size that any value of the type requires. In the case
19570 above, @code{Word} has storage for the discriminant and for
19571 a @code{String} of length 100.
19572 It is important to note that unconstrained objects do not require dynamic
19573 allocation. It would be an improper implementation to place on the heap those
19574 components whose size depends on discriminants. (This improper implementation
19575 was used by some Ada83 compilers, where the @code{Name} component above
19576 would have
19577 been stored as a pointer to a dynamic string). Following the principle that
19578 dynamic storage management should never be introduced implicitly,
19579 an Ada compiler should reserve the full size for an unconstrained declared
19580 object, and place it on the stack.
19582 This maximum size approach
19583 has been a source of surprise to some users, who expect the default
19584 values of the discriminants to determine the size reserved for an
19585 unconstrained object: ``If the default is 15, why should the object occupy
19586 a larger size?''
19587 The answer, of course, is that the discriminant may be later modified,
19588 and its full range of values must be taken into account. This is why the
19589 declaration:
19591 @smallexample
19592 @group
19593 type Rec (D : Positive := 15) is record
19594    Name : String (1..D);
19595 end record;
19597 Too_Large : Rec;
19598 @end group
19599 @end smallexample
19601 @noindent
19602 is flagged by the compiler with a warning:
19603 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
19604 because the required size includes @code{Positive'Last}
19605 bytes. As the first example indicates, the proper approach is to declare an
19606 index type of ``reasonable'' range so that unconstrained objects are not too
19607 large.
19609 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
19610 created in the heap by means of an allocator, then it is @emph{not}
19611 unconstrained:
19612 it is constrained by the default values of the discriminants, and those values
19613 cannot be modified by full assignment. This is because in the presence of
19614 aliasing all views of the object (which may be manipulated by different tasks,
19615 say) must be consistent, so it is imperative that the object, once created,
19616 remain invariant.
19618 @node Strict Conformance to the Ada Reference Manual
19619 @section Strict Conformance to the Ada Reference Manual
19621 @noindent
19622 The dynamic semantics defined by the Ada Reference Manual impose a set of
19623 run-time checks to be generated. By default, the GNAT compiler will insert many
19624 run-time checks into the compiled code, including most of those required by the
19625 Ada Reference Manual. However, there are three checks that are not enabled
19626 in the default mode for efficiency reasons: arithmetic overflow checking for
19627 integer operations (including division by zero), checks for access before
19628 elaboration on subprogram calls, and stack overflow checking (most operating
19629 systems do not perform this check by default).
19631 Strict conformance to the Ada Reference Manual can be achieved by adding
19632 three compiler options for overflow checking for integer operations
19633 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
19634 calls and generic instantiations (@option{-gnatE}), and stack overflow
19635 checking (@option{-fstack-check}).
19637 Note that the result of a floating point arithmetic operation in overflow and
19638 invalid situations, when the @code{Machine_Overflows} attribute of the result
19639 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
19640 case for machines compliant with the IEEE floating-point standard, but on
19641 machines that are not fully compliant with this standard, such as Alpha, the
19642 @option{-mieee} compiler flag must be used for achieving IEEE confirming
19643 behavior (although at the cost of a significant performance penalty), so
19644 infinite and NaN values are properly generated.
19647 @node Implementation of Ada 2012 Features
19648 @chapter Implementation of Ada 2012 Features
19649 @cindex Ada 2012 implementation status
19651 This chapter contains a complete list of Ada 2012 features that have been
19652 implemented as of GNAT version 6.4. Generally, these features are only
19653 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
19654 @cindex @option{-gnat12} option
19655 or if the configuration pragma @code{Ada_2012} is used.
19656 @cindex pragma @code{Ada_2012}
19657 @cindex configuration pragma @code{Ada_2012}
19658 @cindex @code{Ada_2012} configuration pragma
19659 However, new pragmas, attributes, and restrictions are
19660 unconditionally available, since the Ada 95 standard allows the addition of
19661 new pragmas, attributes, and restrictions (there are exceptions, which are
19662 documented in the individual descriptions), and also certain packages
19663 were made available in earlier versions of Ada.
19665 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
19666 This date shows the implementation date of the feature. Any wavefront
19667 subsequent to this date will contain the indicated feature, as will any
19668 subsequent releases. A date of 0000-00-00 means that GNAT has always
19669 implemented the feature, or implemented it as soon as it appeared as a
19670 binding interpretation.
19672 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
19673 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
19674 The features are ordered based on the relevant sections of the Ada
19675 Reference Manual (``RM'').  When a given AI relates to multiple points
19676 in the RM, the earliest is used.
19678 A complete description of the AIs may be found in
19679 @url{www.ada-auth.org/ai05-summary.html}.
19681 @itemize @bullet
19683 @item
19684 @emph{AI-0176 Quantified expressions (2010-09-29)}
19685 @cindex AI-0176 (Ada 2012 feature)
19687 @noindent
19688   Both universally and existentially quantified expressions are implemented.
19689   They use the new syntax for iterators proposed in AI05-139-2, as well as
19690   the standard Ada loop syntax.
19692 @noindent
19693   RM References:  1.01.04 (12)   2.09 (2/2)   4.04 (7)   4.05.09 (0)
19695 @item
19696 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
19697 @cindex AI-0079 (Ada 2012 feature)
19699 @noindent
19700   Wide characters in the unicode category @i{other_format} are now allowed in
19701   source programs between tokens, but not within a token such as an identifier.
19703 @noindent
19704   RM References:  2.01 (4/2)   2.02 (7)
19706 @item
19707 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
19708 @cindex AI-0091 (Ada 2012 feature)
19710 @noindent
19711   Wide characters in the unicode category @i{other_format} are not permitted
19712   within  an identifier, since this can be a security problem. The error
19713   message for this case has been improved to be more specific, but GNAT has
19714   never allowed such characters to appear in identifiers.
19716 @noindent
19717   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)
19719 @item
19720 @emph{AI-0100 Placement of pragmas  (2010-07-01)}
19721 @cindex AI-0100 (Ada 2012 feature)
19723 @noindent
19724   This AI is an earlier version of AI-163. It simplifies the rules
19725   for legal placement of pragmas. In the case of lists that allow pragmas, if
19726   the list may have no elements, then the list may consist solely of pragmas.
19728 @noindent
19729   RM References:  2.08 (7)
19731 @item
19732 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
19733 @cindex AI-0163 (Ada 2012 feature)
19735 @noindent
19736   A statement sequence may be composed entirely of pragmas. It is no longer
19737   necessary to add a dummy @code{null} statement to make the sequence legal.
19739 @noindent
19740   RM References:  2.08 (7)   2.08 (16)
19743 @item
19744 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
19745 @cindex AI-0080 (Ada 2012 feature)
19747 @noindent
19748   This is an editorial change only, described as non-testable in the AI.
19750 @noindent
19751   RM References:  3.01 (7)
19754 @item
19755 @emph{AI-0183 Aspect specifications (2010-08-16)}
19756 @cindex AI-0183 (Ada 2012 feature)
19758 @noindent
19759   Aspect specifications have been fully implemented except for pre and post-
19760   conditions, and type invariants, which have their own separate AI's. All
19761   forms of declarations listed in the AI are supported. The following is a
19762   list of the aspects supported (with GNAT implementation aspects marked)
19764 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
19765 @item @code{Ada_2005} @tab                      -- GNAT
19766 @item @code{Ada_2012} @tab                      -- GNAT
19767 @item @code{Address} @tab
19768 @item @code{Alignment} @tab
19769 @item @code{Atomic} @tab
19770 @item @code{Atomic_Components} @tab
19771 @item @code{Bit_Order} @tab
19772 @item @code{Component_Size} @tab
19773 @item @code{Contract_Cases} @tab                -- GNAT
19774 @item @code{Discard_Names} @tab
19775 @item @code{External_Tag} @tab
19776 @item @code{Favor_Top_Level} @tab               -- GNAT
19777 @item @code{Inline} @tab
19778 @item @code{Inline_Always} @tab                 -- GNAT
19779 @item @code{Invariant} @tab                     -- GNAT
19780 @item @code{Machine_Radix} @tab
19781 @item @code{No_Return} @tab
19782 @item @code{Object_Size} @tab                   -- GNAT
19783 @item @code{Pack} @tab
19784 @item @code{Persistent_BSS} @tab                -- GNAT
19785 @item @code{Post} @tab
19786 @item @code{Pre} @tab
19787 @item @code{Predicate} @tab
19788 @item @code{Preelaborable_Initialization} @tab
19789 @item @code{Pure_Function} @tab                 -- GNAT
19790 @item @code{Remote_Access_Type} @tab            -- GNAT
19791 @item @code{Shared} @tab                        -- GNAT
19792 @item @code{Size} @tab
19793 @item @code{Storage_Pool} @tab
19794 @item @code{Storage_Size} @tab
19795 @item @code{Stream_Size} @tab
19796 @item @code{Suppress} @tab
19797 @item @code{Suppress_Debug_Info} @tab           -- GNAT
19798 @item @code{Test_Case} @tab                     -- GNAT
19799 @item @code{Type_Invariant} @tab
19800 @item @code{Unchecked_Union} @tab
19801 @item @code{Universal_Aliasing} @tab            -- GNAT
19802 @item @code{Unmodified} @tab                    -- GNAT
19803 @item @code{Unreferenced} @tab                  -- GNAT
19804 @item @code{Unreferenced_Objects} @tab          -- GNAT
19805 @item @code{Unsuppress} @tab
19806 @item @code{Value_Size} @tab                    -- GNAT
19807 @item @code{Volatile} @tab
19808 @item @code{Volatile_Components}
19809 @item @code{Warnings} @tab                      -- GNAT
19810 @end multitable
19812 @noindent
19813   Note that for aspects with an expression, e.g. @code{Size}, the expression is
19814   treated like a default expression (visibility is analyzed at the point of
19815   occurrence of the aspect, but evaluation of the expression occurs at the
19816   freeze point of the entity involved).
19818 @noindent
19819   RM References:  3.02.01 (3)   3.02.02 (2)   3.03.01 (2/2)   3.08 (6)
19820   3.09.03 (1.1/2)   6.01 (2/2)   6.07 (2/2)   9.05.02 (2/2)   7.01 (3)   7.03
19821   (2)   7.03 (3)   9.01 (2/2)   9.01 (3/2)   9.04 (2/2)   9.04 (3/2)
19822   9.05.02 (2/2)   11.01 (2)   12.01 (3)   12.03 (2/2)   12.04 (2/2)   12.05 (2)
19823   12.06 (2.1/2)   12.06 (2.2/2)   12.07 (2)   13.01 (0.1/2)   13.03 (5/1)
19824   13.03.01 (0)
19827 @item
19828 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
19829 @cindex AI-0128 (Ada 2012 feature)
19831 @noindent
19832   If an equality operator ("=") is declared for a type, then the implicitly
19833   declared inequality operator ("/=") is a primitive operation of the type.
19834   This is the only reasonable interpretation, and is the one always implemented
19835   by GNAT, but the RM was not entirely clear in making this point.
19837 @noindent
19838   RM References:  3.02.03 (6)   6.06 (6)
19840 @item
19841 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
19842 @cindex AI-0003 (Ada 2012 feature)
19844 @noindent
19845    In Ada 2012, a qualified expression is considered to be syntactically a name,
19846    meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
19847    useful in disambiguating some cases of overloading.
19849 @noindent
19850   RM References:  3.03 (11)   3.03 (21)   4.01 (2)   4.04 (7)   4.07 (3)
19851   5.04 (7)
19853 @item
19854 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
19855 @cindex AI-0120 (Ada 2012 feature)
19857 @noindent
19858   This is an RM editorial change only. The section that lists objects that are
19859   constant failed to include the current instance of a protected object
19860   within a protected function. This has always been treated as a constant
19861   in GNAT.
19863 @noindent
19864   RM References:  3.03 (21)
19866 @item
19867 @emph{AI-0008 General access to constrained objects (0000-00-00)}
19868 @cindex AI-0008 (Ada 2012 feature)
19870 @noindent
19871   The wording in the RM implied that if you have a general access to a
19872   constrained object, it could be used to modify the discriminants. This was
19873   obviously not intended. @code{Constraint_Error} should be raised, and GNAT
19874   has always done so in this situation.
19876 @noindent
19877   RM References:  3.03 (23)   3.10.02 (26/2)   4.01 (9)   6.04.01 (17)   8.05.01 (5/2)
19880 @item
19881 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
19882 @cindex AI-0093 (Ada 2012 feature)
19884 @noindent
19885   This is an editorial change only, to make more widespread use of the Ada 2012
19886   ``immutably limited''.
19888 @noindent
19889   RM References:  3.03 (23.4/3)
19893 @item
19894 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
19895 @cindex AI-0096 (Ada 2012 feature)
19897 @noindent
19898   In general it is illegal for a type derived from a formal limited type to be
19899   nonlimited.  This AI makes an exception to this rule: derivation is legal
19900   if it appears in the private part of the generic, and the formal type is not
19901   tagged. If the type is tagged, the legality check must be applied to the
19902   private part of the package.
19904 @noindent
19905   RM References:  3.04 (5.1/2)   6.02 (7)
19908 @item
19909 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
19910 @cindex AI-0181 (Ada 2012 feature)
19912 @noindent
19913   From Ada 2005 on, soft hyphen is considered a non-graphic character, which
19914   means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
19915   @code{Image} and @code{Value} attributes for the character types. Strictly
19916   speaking this is an inconsistency with Ada 95, but in practice the use of
19917   these attributes is so obscure that it will not cause problems.
19919 @noindent
19920   RM References:  3.05.02 (2/2)   A.01 (35/2)   A.03.03 (21)
19923 @item
19924 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
19925 @cindex AI-0182 (Ada 2012 feature)
19927 @noindent
19928   This AI allows @code{Character'Value} to accept the string @code{'?'} where
19929   @code{?} is any character including non-graphic control characters. GNAT has
19930   always accepted such strings. It also allows strings such as
19931   @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
19932   permission and raises @code{Constraint_Error}, as is certainly still
19933   permitted.
19935 @noindent
19936   RM References:  3.05 (56/2)
19939 @item
19940 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
19941 @cindex AI-0214 (Ada 2012 feature)
19943 @noindent
19944   Ada 2012 relaxes the restriction that forbids discriminants of tagged types
19945   to have default expressions by allowing them when the type is limited. It
19946   is often useful to define a default value for a discriminant even though
19947   it can't be changed by assignment.
19949 @noindent
19950   RM References:  3.07 (9.1/2)   3.07.02 (3)
19953 @item
19954 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
19955 @cindex AI-0102 (Ada 2012 feature)
19957 @noindent
19958   It is illegal to assign an anonymous access constant to an anonymous access
19959   variable. The RM did not have a clear rule to prevent this, but GNAT has
19960   always generated an error for this usage.
19962 @noindent
19963   RM References:  3.07 (16)   3.07.01 (9)   6.04.01 (6)   8.06 (27/2)
19966 @item
19967 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
19968 @cindex AI-0158 (Ada 2012 feature)
19970 @noindent
19971   This AI extends the syntax of membership tests to simplify complex conditions
19972   that can be expressed as membership in a subset of values of any type. It
19973   introduces syntax for a list of expressions that may be used in loop contexts
19974   as well.
19976 @noindent
19977   RM References:  3.08.01 (5)   4.04 (3)   4.05.02 (3)   4.05.02 (5)   4.05.02 (27)
19980 @item
19981 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
19982 @cindex AI-0173 (Ada 2012 feature)
19984 @noindent
19985   The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
19986   with the tag of an abstract type, and @code{False} otherwise.
19988 @noindent
19989   RM References:  3.09 (7.4/2)   3.09 (12.4/2)
19993 @item
19994 @emph{AI-0076 function with controlling result (0000-00-00)}
19995 @cindex AI-0076 (Ada 2012 feature)
19997 @noindent
19998   This is an editorial change only. The RM defines calls with controlling
19999   results, but uses the term ``function with controlling result'' without an
20000   explicit definition.
20002 @noindent
20003   RM References:  3.09.02 (2/2)
20006 @item
20007 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
20008 @cindex AI-0126 (Ada 2012 feature)
20010 @noindent
20011   This AI clarifies dispatching rules, and simply confirms that dispatching
20012   executes the operation of the parent type when there is no explicitly or
20013   implicitly declared operation for the descendant type. This has always been
20014   the case in all versions of GNAT.
20016 @noindent
20017   RM References:  3.09.02 (20/2)   3.09.02 (20.1/2)   3.09.02 (20.2/2)
20020 @item
20021 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
20022 @cindex AI-0097 (Ada 2012 feature)
20024 @noindent
20025   The RM as written implied that in some cases it was possible to create an
20026   object of an abstract type, by having an abstract extension inherit a non-
20027   abstract constructor from its parent type. This mistake has been corrected
20028   in GNAT and in the RM, and this construct is now illegal.
20030 @noindent
20031   RM References:  3.09.03 (4/2)
20034 @item
20035 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
20036 @cindex AI-0203 (Ada 2012 feature)
20038 @noindent
20039   A return_subtype_indication cannot denote an abstract subtype. GNAT has never
20040   permitted such usage.
20042 @noindent
20043   RM References:  3.09.03 (8/3)
20046 @item
20047 @emph{AI-0198 Inheriting abstract operators  (0000-00-00)}
20048 @cindex AI-0198 (Ada 2012 feature)
20050 @noindent
20051   This AI resolves a conflict between two rules involving inherited abstract
20052   operations and predefined operators. If a derived numeric type inherits
20053   an abstract operator, it overrides the predefined one. This interpretation
20054   was always the one implemented in GNAT.
20056 @noindent
20057   RM References:  3.09.03 (4/3)
20059 @item
20060 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
20061 @cindex AI-0073 (Ada 2012 feature)
20063 @noindent
20064   This AI covers a number of issues regarding returning abstract types. In
20065   particular generic functions cannot have abstract result types or access
20066   result types designated an abstract type. There are some other cases which
20067   are detailed in the AI. Note that this binding interpretation has not been
20068   retrofitted to operate before Ada 2012 mode, since it caused a significant
20069   number of regressions.
20071 @noindent
20072   RM References:  3.09.03 (8)   3.09.03 (10)   6.05 (8/2)
20075 @item
20076 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
20077 @cindex AI-0070 (Ada 2012 feature)
20079 @noindent
20080   This is an editorial change only, there are no testable consequences short of
20081   checking for the absence of generated code for an interface declaration.
20083 @noindent
20084   RM References:  3.09.04 (18/2)
20087 @item
20088 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
20089 @cindex AI-0208 (Ada 2012 feature)
20091 @noindent
20092   The wording in the Ada 2005 RM concerning characteristics of incomplete views
20093   was incorrect and implied that some programs intended to be legal were now
20094   illegal. GNAT had never considered such programs illegal, so it has always
20095   implemented the intent of this AI.
20097 @noindent
20098   RM References:  3.10.01 (2.4/2)   3.10.01 (2.6/2)
20101 @item
20102 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
20103 @cindex AI-0162 (Ada 2012 feature)
20105 @noindent
20106   Incomplete types are made more useful by allowing them to be completed by
20107   private types and private extensions.
20109 @noindent
20110   RM References:  3.10.01 (2.5/2)   3.10.01 (2.6/2)   3.10.01 (3)   3.10.01 (4/2)
20114 @item
20115 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
20116 @cindex AI-0098 (Ada 2012 feature)
20118 @noindent
20119   An unintentional omission in the RM implied some inconsistent restrictions on
20120   the use of anonymous access to subprogram values. These restrictions were not
20121   intentional, and have never been enforced by GNAT.
20123 @noindent
20124   RM References:  3.10.01 (6)   3.10.01 (9.2/2)
20127 @item
20128 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
20129 @cindex AI-0199 (Ada 2012 feature)
20131 @noindent
20132   A choice list in a record aggregate can include several components of
20133   (distinct) anonymous access types as long as they have matching designated
20134   subtypes.
20136 @noindent
20137   RM References:  4.03.01 (16)
20140 @item
20141 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
20142 @cindex AI-0220 (Ada 2012 feature)
20144 @noindent
20145   This AI addresses a wording problem in the RM that appears to permit some
20146   complex cases of aggregates with non-static discriminants. GNAT has always
20147   implemented the intended semantics.
20149 @noindent
20150   RM References:  4.03.01 (17)
20152 @item
20153 @emph{AI-0147 Conditional expressions (2009-03-29)}
20154 @cindex AI-0147 (Ada 2012 feature)
20156 @noindent
20157   Conditional expressions are permitted. The form of such an expression is:
20159 @smallexample
20160     (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
20161 @end smallexample
20163   The parentheses can be omitted in contexts where parentheses are present
20164   anyway, such as subprogram arguments and pragma arguments. If the @b{else}
20165   clause is omitted, @b{else True} is assumed;
20166   thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
20167   @emph{(A implies B)} in standard logic.
20169 @noindent
20170   RM References:  4.03.03 (15)   4.04 (1)   4.04 (7)   4.05.07 (0)   4.07 (2)
20171   4.07 (3)   4.09 (12)   4.09 (33)   5.03 (3)   5.03 (4)   7.05 (2.1/2)
20174 @item
20175 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
20176 @cindex AI-0037 (Ada 2012 feature)
20178 @noindent
20179   This AI confirms that an association of the form @code{Indx => <>} in an
20180   array aggregate must raise @code{Constraint_Error} if @code{Indx}
20181   is out of range. The RM specified a range check on other associations, but
20182   not when the value of the association was defaulted. GNAT has always inserted
20183   a constraint check on the index value.
20185 @noindent
20186   RM References:  4.03.03 (29)
20189 @item
20190 @emph{AI-0123 Composability of equality (2010-04-13)}
20191 @cindex AI-0123 (Ada 2012 feature)
20193 @noindent
20194   Equality of untagged record composes, so that the predefined equality for a
20195   composite type that includes a component of some untagged record type
20196   @code{R} uses the equality operation of @code{R} (which may be user-defined
20197   or predefined). This makes the behavior of untagged records identical to that
20198   of tagged types in this respect.
20200   This change is an incompatibility with previous versions of Ada, but it
20201   corrects a non-uniformity that was often a source of confusion. Analysis of
20202   a large number of industrial programs indicates that in those rare cases
20203   where a composite type had an untagged record component with a user-defined
20204   equality, either there was no use of the composite equality, or else the code
20205   expected the same composability as for tagged types, and thus had a bug that
20206   would be fixed by this change.
20208 @noindent
20209   RM References:  4.05.02 (9.7/2)   4.05.02 (14)   4.05.02 (15)   4.05.02 (24)
20210   8.05.04 (8)
20213 @item
20214 @emph{AI-0088 The value of exponentiation (0000-00-00)}
20215 @cindex AI-0088 (Ada 2012 feature)
20217 @noindent
20218   This AI clarifies the equivalence rule given for the dynamic semantics of
20219   exponentiation: the value of the operation can be obtained by repeated
20220   multiplication, but the operation can be implemented otherwise (for example
20221   using the familiar divide-by-two-and-square algorithm, even if this is less
20222   accurate), and does not imply repeated reads of a volatile base.
20224 @noindent
20225   RM References:  4.05.06 (11)
20227 @item
20228 @emph{AI-0188 Case expressions (2010-01-09)}
20229 @cindex AI-0188 (Ada 2012 feature)
20231 @noindent
20232   Case expressions are permitted. This allows use of constructs such as:
20233 @smallexample
20234   X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
20235 @end smallexample
20237 @noindent
20238   RM References:  4.05.07 (0)   4.05.08 (0)   4.09 (12)   4.09 (33)
20240 @item
20241 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
20242 @cindex AI-0104 (Ada 2012 feature)
20244 @noindent
20245   The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
20246   @code{Constraint_Error} because the default value of the allocated object is
20247   @b{null}. This useless construct is illegal in Ada 2012.
20249 @noindent
20250   RM References:  4.08 (2)
20252 @item
20253 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
20254 @cindex AI-0157 (Ada 2012 feature)
20256 @noindent
20257   Allocation and Deallocation from an empty storage pool (i.e. allocation or
20258   deallocation of a pointer for which a static storage size clause of zero
20259   has been given) is now illegal and is detected as such. GNAT
20260   previously gave a warning but not an error.
20262 @noindent
20263   RM References:  4.08 (5.3/2)   13.11.02 (4)   13.11.02 (17)
20265 @item
20266 @emph{AI-0179 Statement not required after label (2010-04-10)}
20267 @cindex AI-0179 (Ada 2012 feature)
20269 @noindent
20270   It is not necessary to have a statement following a label, so a label
20271   can appear at the end of a statement sequence without the need for putting a
20272   null statement afterwards, but it is not allowable to have only labels and
20273   no real statements in a statement sequence.
20275 @noindent
20276   RM References:  5.01 (2)
20279 @item
20280 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
20281 @cindex AI-139-2 (Ada 2012 feature)
20283 @noindent
20284   The new syntax for iterating over arrays and containers is now implemented.
20285   Iteration over containers is for now limited to read-only iterators. Only
20286   default iterators are supported, with the syntax:  @code{@b{for} Elem @b{of} C}.
20288 @noindent
20289   RM References:  5.05
20291 @item
20292 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
20293 @cindex AI-0134 (Ada 2012 feature)
20295 @noindent
20296   For full conformance, the profiles of anonymous-access-to-subprogram
20297   parameters must match. GNAT has always enforced this rule.
20299 @noindent
20300   RM References:  6.03.01 (18)
20302 @item
20303 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
20304 @cindex AI-0207 (Ada 2012 feature)
20306 @noindent
20307   This AI confirms that access_to_constant indication must match for mode
20308   conformance. This was implemented in GNAT when the qualifier was originally
20309   introduced in Ada 2005.
20311 @noindent
20312   RM References:  6.03.01 (16/2)
20315 @item
20316 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
20317 @cindex AI-0046 (Ada 2012 feature)
20319 @noindent
20320   For full conformance, in the case of access parameters, the null exclusion
20321   must match (either both or neither must have @code{@b{not null}}).
20323 @noindent
20324   RM References:  6.03.02 (18)
20327 @item
20328 @emph{AI-0118 The association of parameter associations (0000-00-00)}
20329 @cindex AI-0118 (Ada 2012 feature)
20331 @noindent
20332   This AI clarifies the rules for named associations in subprogram calls and
20333   generic instantiations. The rules have been in place since Ada 83.
20335 @noindent
20336   RM References:  6.04.01 (2)   12.03 (9)
20339 @item
20340 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
20341 @cindex AI-0196 (Ada 2012 feature)
20343 @noindent
20344   Null exclusion checks are not made for @code{@b{out}} parameters when
20345   evaluating the actual parameters. GNAT has never generated these checks.
20347 @noindent
20348   RM References:  6.04.01 (13)
20350 @item
20351 @emph{AI-0015 Constant return objects (0000-00-00)}
20352 @cindex AI-0015 (Ada 2012 feature)
20354 @noindent
20355   The return object declared in an @i{extended_return_statement} may be
20356   declared constant. This was always intended, and GNAT has always allowed it.
20358 @noindent
20359   RM References:  6.05 (2.1/2)   3.03 (10/2)   3.03 (21)   6.05 (5/2)
20360   6.05 (5.7/2)
20363 @item
20364 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
20365 @cindex AI-0032 (Ada 2012 feature)
20367 @noindent
20368   If a function returns a class-wide type, the object of an extended return
20369   statement can be declared with a specific type that is covered by the class-
20370   wide type. This has been implemented in GNAT since the introduction of
20371   extended returns. Note AI-0103 complements this AI by imposing matching
20372   rules for constrained return types.
20374 @noindent
20375   RM References:  6.05 (5.2/2)   6.05 (5.3/2)   6.05 (5.6/2)   6.05 (5.8/2)
20376   6.05 (8/2)
20378 @item
20379 @emph{AI-0103 Static matching for extended return (2010-07-23)}
20380 @cindex AI-0103 (Ada 2012 feature)
20382 @noindent
20383   If the return subtype of a function is an elementary type or a constrained
20384   type, the subtype indication in an extended return statement must match
20385   statically this return subtype.
20387 @noindent
20388   RM References:  6.05 (5.2/2)
20391 @item
20392 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
20393 @cindex AI-0058 (Ada 2012 feature)
20395 @noindent
20396   The RM had some incorrect wording implying wrong treatment of abnormal
20397   completion in an extended return. GNAT has always implemented the intended
20398   correct semantics as described by this AI.
20400 @noindent
20401   RM References:  6.05 (22/2)
20404 @item
20405 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
20406 @cindex AI-0050 (Ada 2012 feature)
20408 @noindent
20409   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
20410   not take advantage of these incorrect permissions in any case.
20412 @noindent
20413   RM References:  6.05 (24/2)
20416 @item
20417 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
20418 @cindex AI-0125 (Ada 2012 feature)
20420 @noindent
20421   In Ada 2012, the declaration of a primitive operation of a type extension
20422   or private extension can also override an inherited primitive that is not
20423   visible at the point of this declaration.
20425 @noindent
20426   RM References:  7.03.01 (6)   8.03 (23)   8.03.01 (5/2)   8.03.01 (6/2)
20428 @item
20429 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
20430 @cindex AI-0062 (Ada 2012 feature)
20432 @noindent
20433   A full constant may have a null exclusion even if its associated deferred
20434   constant does not. GNAT has always allowed this.
20436 @noindent
20437   RM References:  7.04 (6/2)   7.04 (7.1/2)
20440 @item
20441 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
20442 @cindex AI-0178 (Ada 2012 feature)
20444 @noindent
20445   This AI clarifies the role of incomplete views and plugs an omission in the
20446   RM. GNAT always correctly restricted the use of incomplete views and types.
20448 @noindent
20449   RM References:  7.05 (3/2)   7.05 (6/2)
20451 @item
20452 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
20453 @cindex AI-0087 (Ada 2012 feature)
20455 @noindent
20456   The actual for a formal nonlimited derived type cannot be limited. In
20457   particular, a formal derived type that extends a limited interface but which
20458   is not explicitly limited cannot be instantiated with a limited type.
20460 @noindent
20461   RM References:  7.05 (5/2)   12.05.01 (5.1/2)
20463 @item
20464 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
20465 @cindex AI-0099 (Ada 2012 feature)
20467 @noindent
20468   This AI clarifies that ``needs finalization'' is part of dynamic semantics,
20469   and therefore depends on the run-time characteristics of an object (i.e. its
20470   tag) and not on its nominal type. As the AI indicates: ``we do not expect
20471   this to affect any implementation''.
20473 @noindent
20474   RM References:  7.06.01 (6)   7.06.01 (7)   7.06.01 (8)   7.06.01 (9/2)
20478 @item
20479 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
20480 @cindex AI-0064 (Ada 2012 feature)
20482 @noindent
20483   This is an editorial change only. The intended behavior is already checked
20484   by an existing ACATS test, which GNAT has always executed correctly.
20486 @noindent
20487   RM References:  7.06.01 (17.1/1)
20489 @item
20490 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
20491 @cindex AI-0026 (Ada 2012 feature)
20493 @noindent
20494   Record representation clauses concerning Unchecked_Union types cannot mention
20495   the discriminant of the type. The type of a component declared in the variant
20496   part of an Unchecked_Union cannot be controlled, have controlled components,
20497   nor have protected or task parts. If an Unchecked_Union type is declared
20498   within the body of a generic unit or its descendants, then the type of a
20499   component declared in the variant part cannot be a formal private type or a
20500   formal private extension declared within the same generic unit.
20502 @noindent
20503   RM References:  7.06 (9.4/2)   B.03.03 (9/2)   B.03.03 (10/2)
20506 @item
20507 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
20508 @cindex AI-0205 (Ada 2012 feature)
20510 @noindent
20511   This AI corrects a simple omission in the RM. Return objects have always
20512   been visible within an extended return statement.
20514 @noindent
20515   RM References:  8.03 (17)
20518 @item
20519 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
20520 @cindex AI-0042 (Ada 2012 feature)
20522 @noindent
20523   This AI fixes a wording gap in the RM. An operation of a synchronized
20524   interface can be implemented by a protected or task entry, but the abstract
20525   operation is not being overridden in the usual sense, and it must be stated
20526   separately that this implementation is legal. This has always been the case
20527   in GNAT.
20529 @noindent
20530   RM References:  9.01 (9.2/2)   9.04 (11.1/2)
20532 @item
20533 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
20534 @cindex AI-0030 (Ada 2012 feature)
20536 @noindent
20537   Requeue is permitted to a protected, synchronized or task interface primitive
20538   providing it is known that the overriding operation is an entry. Otherwise
20539   the requeue statement has the same effect as a procedure call. Use of pragma
20540   @code{Implemented} provides a way to impose a static requirement on the
20541   overriding operation by adhering to one of the implementation kinds: entry,
20542   protected procedure or any of the above.
20544 @noindent
20545   RM References:  9.05 (9)   9.05.04 (2)   9.05.04 (3)   9.05.04 (5)
20546   9.05.04 (6)   9.05.04 (7)   9.05.04 (12)
20549 @item
20550 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
20551 @cindex AI-0201 (Ada 2012 feature)
20553 @noindent
20554   If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
20555   attribute, then individual components may not be addressable by independent
20556   tasks. However, if the representation clause has no effect (is confirming),
20557   then independence is not compromised. Furthermore, in GNAT, specification of
20558   other appropriately addressable component sizes (e.g. 16 for 8-bit
20559   characters) also preserves independence. GNAT now gives very clear warnings
20560   both for the declaration of such a type, and for any assignment to its components.
20562 @noindent
20563   RM References:  9.10 (1/3)   C.06 (22/2)   C.06 (23/2)
20565 @item
20566 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
20567 @cindex AI-0009 (Ada 2012 feature)
20569 @noindent
20570   This AI introduces the new pragmas @code{Independent} and
20571   @code{Independent_Components},
20572   which control guaranteeing independence of access to objects and components.
20573   The AI also requires independence not unaffected by confirming rep clauses.
20575 @noindent
20576   RM References:  9.10 (1)   13.01 (15/1)   13.02 (9)   13.03 (13)   C.06 (2)
20577   C.06 (4)   C.06 (6)   C.06 (9)   C.06 (13)   C.06 (14)
20580 @item
20581 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
20582 @cindex AI-0072 (Ada 2012 feature)
20584 @noindent
20585   This AI clarifies that task signalling for reading @code{'Terminated} only
20586   occurs if the result is True. GNAT semantics has always been consistent with
20587   this notion of task signalling.
20589 @noindent
20590   RM References:  9.10 (6.1/1)
20592 @item
20593 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
20594 @cindex AI-0108 (Ada 2012 feature)
20596 @noindent
20597   This AI confirms that an incomplete type from a limited view does not have
20598   discriminants. This has always been the case in GNAT.
20600 @noindent
20601   RM References:  10.01.01 (12.3/2)
20603 @item
20604 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
20605 @cindex AI-0129 (Ada 2012 feature)
20607 @noindent
20608   This AI clarifies the description of limited views: a limited view of a
20609   package includes only one view of a type that has an incomplete declaration
20610   and a full declaration (there is no possible ambiguity in a client package).
20611   This AI also fixes an omission: a nested package in the private part has no
20612   limited view. GNAT always implemented this correctly.
20614 @noindent
20615   RM References:  10.01.01 (12.2/2)   10.01.01 (12.3/2)
20619 @item
20620 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
20621 @cindex AI-0077 (Ada 2012 feature)
20623 @noindent
20624   This AI clarifies that a declaration does not include a context clause,
20625   and confirms that it is illegal to have a context in which both a limited
20626   and a nonlimited view of a package are accessible. Such double visibility
20627   was always rejected by GNAT.
20629 @noindent
20630   RM References:  10.01.02 (12/2)   10.01.02 (21/2)   10.01.02 (22/2)
20632 @item
20633 @emph{AI-0122 Private with and children of generics (0000-00-00)}
20634 @cindex AI-0122 (Ada 2012 feature)
20636 @noindent
20637   This AI clarifies the visibility of private children of generic units within
20638   instantiations of a parent. GNAT has always handled this correctly.
20640 @noindent
20641   RM References:  10.01.02 (12/2)
20645 @item
20646 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
20647 @cindex AI-0040 (Ada 2012 feature)
20649 @noindent
20650   This AI confirms that a limited with clause in a child unit cannot name
20651   an ancestor of the unit. This has always been checked in GNAT.
20653 @noindent
20654   RM References:  10.01.02 (20/2)
20656 @item
20657 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
20658 @cindex AI-0132 (Ada 2012 feature)
20660 @noindent
20661   This AI fills a gap in the description of library unit pragmas. The pragma
20662   clearly must apply to a library unit, even if it does not carry the name
20663   of the enclosing unit. GNAT has always enforced the required check.
20665 @noindent
20666   RM References:  10.01.05 (7)
20669 @item
20670 @emph{AI-0034 Categorization of limited views (0000-00-00)}
20671 @cindex AI-0034 (Ada 2012 feature)
20673 @noindent
20674   The RM makes certain limited with clauses illegal because of categorization
20675   considerations, when the corresponding normal with would be legal. This is
20676   not intended, and GNAT has always implemented the recommended behavior.
20678 @noindent
20679   RM References:  10.02.01 (11/1)   10.02.01 (17/2)
20682 @item
20683 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
20684 @cindex AI-0035 (Ada 2012 feature)
20686 @noindent
20687   This AI remedies some inconsistencies in the legality rules for Pure units.
20688   Derived access types are legal in a pure unit (on the assumption that the
20689   rule for a zero storage pool size has been enforced on the ancestor type).
20690   The rules are enforced in generic instances and in subunits. GNAT has always
20691   implemented the recommended behavior.
20693 @noindent
20694   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)
20697 @item
20698 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
20699 @cindex AI-0219 (Ada 2012 feature)
20701 @noindent
20702   This AI refines the rules for the cases with limited parameters which do not
20703   allow the implementations to omit ``redundant''. GNAT now properly conforms
20704   to the requirements of this binding interpretation.
20706 @noindent
20707   RM References:  10.02.01 (18/2)
20709 @item
20710 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
20711 @cindex AI-0043 (Ada 2012 feature)
20713 @noindent
20714   This AI covers various omissions in the RM regarding the raising of
20715   exceptions. GNAT has always implemented the intended semantics.
20717 @noindent
20718   RM References:  11.04.01 (10.1/2)   11 (2)
20721 @item
20722 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
20723 @cindex AI-0200 (Ada 2012 feature)
20725 @noindent
20726   This AI plugs a gap in the RM which appeared to allow some obviously intended
20727   illegal instantiations. GNAT has never allowed these instantiations.
20729 @noindent
20730   RM References:  12.07 (16)
20733 @item
20734 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
20735 @cindex AI-0112 (Ada 2012 feature)
20737 @noindent
20738   This AI concerns giving names to various representation aspects, but the
20739   practical effect is simply to make the use of duplicate
20740   @code{Atomic}[@code{_Components}],
20741   @code{Volatile}[@code{_Components}] and
20742   @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
20743   now performs this required check.
20745 @noindent
20746   RM References:  13.01 (8)
20748 @item
20749 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
20750 @cindex AI-0106 (Ada 2012 feature)
20752 @noindent
20753   The RM appeared to allow representation pragmas on generic formal parameters,
20754   but this was not intended, and GNAT has never permitted this usage.
20756 @noindent
20757   RM References:  13.01 (9.1/1)
20760 @item
20761 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
20762 @cindex AI-0012 (Ada 2012 feature)
20764 @noindent
20765   It is now illegal to give an inappropriate component size or a pragma
20766   @code{Pack} that attempts to change the component size in the case of atomic
20767   or aliased components. Previously GNAT ignored such an attempt with a
20768   warning.
20770 @noindent
20771   RM References:  13.02 (6.1/2)   13.02 (7)   C.06 (10)   C.06 (11)   C.06 (21)
20774 @item
20775 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
20776 @cindex AI-0039 (Ada 2012 feature)
20778 @noindent
20779   The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
20780   for stream attributes, but these were never useful and are now illegal. GNAT
20781   has always regarded such expressions as illegal.
20783 @noindent
20784   RM References:  13.03 (4)   13.03 (6)   13.13.02 (38/2)
20787 @item
20788 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
20789 @cindex AI-0095 (Ada 2012 feature)
20791 @noindent
20792   The prefix of @code{'Address} cannot statically denote a subprogram with
20793   convention @code{Intrinsic}. The use of the @code{Address} attribute raises
20794   @code{Program_Error} if the prefix denotes a subprogram with convention
20795   @code{Intrinsic}.
20797 @noindent
20798   RM References:  13.03 (11/1)
20801 @item
20802 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
20803 @cindex AI-0116 (Ada 2012 feature)
20805 @noindent
20806   This AI requires that the alignment of a class-wide object be no greater
20807   than the alignment of any type in the class. GNAT has always followed this
20808   recommendation.
20810 @noindent
20811   RM References:  13.03 (29)   13.11 (16)
20814 @item
20815 @emph{AI-0146 Type invariants (2009-09-21)}
20816 @cindex AI-0146 (Ada 2012 feature)
20818 @noindent
20819   Type invariants may be specified for private types using the aspect notation.
20820   Aspect @code{Type_Invariant} may be specified for any private type,
20821   @code{Type_Invariant'Class} can
20822   only be specified for tagged types, and is inherited by any descendent of the
20823   tagged types. The invariant is a boolean expression that is tested for being
20824   true in the following situations: conversions to the private type, object
20825   declarations for the private type that are default initialized, and
20826   [@b{in}] @b{out}
20827   parameters and returned result on return from any primitive operation for
20828   the type that is visible to a client.
20829   GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
20830   @code{Invariant'Class} for @code{Type_Invariant'Class}.
20832 @noindent
20833   RM References:  13.03.03 (00)
20835 @item
20836 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
20837 @cindex AI-0078 (Ada 2012 feature)
20839 @noindent
20840   In Ada 2012, compilers are required to support unchecked conversion where the
20841   target alignment is a multiple of the source alignment. GNAT always supported
20842   this case (and indeed all cases of differing alignments, doing copies where
20843   required if the alignment was reduced).
20845 @noindent
20846   RM References:  13.09 (7)
20849 @item
20850 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
20851 @cindex AI-0195 (Ada 2012 feature)
20853 @noindent
20854   The handling of invalid values is now designated to be implementation
20855   defined. This is a documentation change only, requiring Annex M in the GNAT
20856   Reference Manual to document this handling.
20857   In GNAT, checks for invalid values are made
20858   only when necessary to avoid erroneous behavior. Operations like assignments
20859   which cannot cause erroneous behavior ignore the possibility of invalid
20860   values and do not do a check. The date given above applies only to the
20861   documentation change, this behavior has always been implemented by GNAT.
20863 @noindent
20864   RM References:  13.09.01 (10)
20866 @item
20867 @emph{AI-0193 Alignment of allocators (2010-09-16)}
20868 @cindex AI-0193 (Ada 2012 feature)
20870 @noindent
20871   This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
20872   analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
20873   of size.
20875 @noindent
20876   RM References:  13.11 (16)   13.11 (21)   13.11.01 (0)   13.11.01 (1)
20877   13.11.01 (2)   13.11.01 (3)
20880 @item
20881 @emph{AI-0177 Parameterized expressions (2010-07-10)}
20882 @cindex AI-0177 (Ada 2012 feature)
20884 @noindent
20885   The new Ada 2012 notion of parameterized expressions is implemented. The form
20886   is:
20887 @smallexample
20888   @i{function specification} @b{is} (@i{expression})
20889 @end smallexample
20891 @noindent
20892   This is exactly equivalent to the
20893   corresponding function body that returns the expression, but it can appear
20894   in a package spec. Note that the expression must be parenthesized.
20896 @noindent
20897   RM References:  13.11.01 (3/2)
20899 @item
20900 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
20901 @cindex AI-0033 (Ada 2012 feature)
20903 @noindent
20904   Neither of these two pragmas may appear within a generic template, because
20905   the generic might be instantiated at other than the library level.
20907 @noindent
20908   RM References:  13.11.02 (16)   C.03.01 (7/2)   C.03.01 (8/2)
20911 @item
20912 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
20913 @cindex AI-0161 (Ada 2012 feature)
20915 @noindent
20916   A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
20917   of the default stream attributes for elementary types. If this restriction is
20918   in force, then it is necessary to provide explicit subprograms for any
20919   stream attributes used.
20921 @noindent
20922   RM References:  13.12.01 (4/2)   13.13.02 (40/2)   13.13.02 (52/2)
20924 @item
20925 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
20926 @cindex AI-0194 (Ada 2012 feature)
20928 @noindent
20929   The @code{Stream_Size} attribute returns the default number of bits in the
20930   stream representation of the given type.
20931   This value is not affected by the presence
20932   of stream subprogram attributes for the type. GNAT has always implemented
20933   this interpretation.
20935 @noindent
20936   RM References:  13.13.02 (1.2/2)
20938 @item
20939 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
20940 @cindex AI-0109 (Ada 2012 feature)
20942 @noindent
20943   This AI is an editorial change only. It removes the need for a tag check
20944   that can never fail.
20946 @noindent
20947   RM References:  13.13.02 (34/2)
20949 @item
20950 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
20951 @cindex AI-0007 (Ada 2012 feature)
20953 @noindent
20954   The RM as written appeared to limit the possibilities of declaring read
20955   attribute procedures for private scalar types. This limitation was not
20956   intended, and has never been enforced by GNAT.
20958 @noindent
20959   RM References:  13.13.02 (50/2)   13.13.02 (51/2)
20962 @item
20963 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
20964 @cindex AI-0065 (Ada 2012 feature)
20966 @noindent
20967   This AI clarifies the fact that all remote access types support external
20968   streaming. This fixes an obvious oversight in the definition of the
20969   language, and GNAT always implemented the intended correct rules.
20971 @noindent
20972   RM References:  13.13.02 (52/2)
20974 @item
20975 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
20976 @cindex AI-0019 (Ada 2012 feature)
20978 @noindent
20979   The RM suggests that primitive subprograms of a specific tagged type are
20980   frozen when the tagged type is frozen. This would be an incompatible change
20981   and is not intended. GNAT has never attempted this kind of freezing and its
20982   behavior is consistent with the recommendation of this AI.
20984 @noindent
20985   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)
20987 @item
20988 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
20989 @cindex AI-0017 (Ada 2012 feature)
20991 @noindent
20992   So-called ``Taft-amendment types'' (i.e., types that are completed in package
20993   bodies) are not frozen by the occurrence of bodies in the
20994   enclosing declarative part. GNAT always implemented this properly.
20996 @noindent
20997   RM References:  13.14 (3/1)
21000 @item
21001 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
21002 @cindex AI-0060 (Ada 2012 feature)
21004 @noindent
21005   This AI extends the definition of remote access types to include access
21006   to limited, synchronized, protected or task class-wide interface types.
21007   GNAT already implemented this extension.
21009 @noindent
21010   RM References:  A (4)   E.02.02 (9/1)   E.02.02 (9.2/1)   E.02.02 (14/2)   E.02.02 (18)
21012 @item
21013 @emph{AI-0114 Classification of letters (0000-00-00)}
21014 @cindex AI-0114 (Ada 2012 feature)
21016 @noindent
21017   The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
21018   181 (@code{MICRO SIGN}), and
21019   186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
21020   lower case letters by Unicode.
21021   However, they are not allowed in identifiers, and they
21022   return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
21023   This behavior is consistent with that defined in Ada 95.
21025 @noindent
21026   RM References:  A.03.02 (59)   A.04.06 (7)
21029 @item
21030 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
21031 @cindex AI-0185 (Ada 2012 feature)
21033 @noindent
21034   Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
21035   classification functions for @code{Wide_Character} and
21036   @code{Wide_Wide_Character}, as well as providing
21037   case folding routines for @code{Wide_[Wide_]Character} and
21038   @code{Wide_[Wide_]String}.
21040 @noindent
21041   RM References:  A.03.05 (0)   A.03.06 (0)
21044 @item
21045 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
21046 @cindex AI-0031 (Ada 2012 feature)
21048 @noindent
21049   A new version of @code{Find_Token} is added to all relevant string packages,
21050   with an extra parameter @code{From}. Instead of starting at the first
21051   character of the string, the search for a matching Token starts at the
21052   character indexed by the value of @code{From}.
21053   These procedures are available in all versions of Ada
21054   but if used in versions earlier than Ada 2012 they will generate a warning
21055   that an Ada 2012 subprogram is being used.
21057 @noindent
21058   RM References:  A.04.03 (16)   A.04.03 (67)   A.04.03 (68/1)   A.04.04 (51)
21059   A.04.05 (46)
21062 @item
21063 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
21064 @cindex AI-0056 (Ada 2012 feature)
21066 @noindent
21067   The wording in the Ada 2005 RM implied an incompatible handling of the
21068   @code{Index} functions, resulting in raising an exception instead of
21069   returning zero in some situations.
21070   This was not intended and has been corrected.
21071   GNAT always returned zero, and is thus consistent with this AI.
21073 @noindent
21074   RM References:  A.04.03 (56.2/2)   A.04.03 (58.5/2)
21077 @item
21078 @emph{AI-0137 String encoding package (2010-03-25)}
21079 @cindex AI-0137 (Ada 2012 feature)
21081 @noindent
21082   The packages @code{Ada.Strings.UTF_Encoding}, together with its child
21083   packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
21084   and @code{Wide_Wide_Strings} have been
21085   implemented. These packages (whose documentation can be found in the spec
21086   files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
21087   @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
21088   @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
21089   values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
21090   UTF-16), as well as conversions between the different UTF encodings. With
21091   the exception of @code{Wide_Wide_Strings}, these packages are available in
21092   Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
21093   The @code{Wide_Wide_Strings package}
21094   is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
21095   mode since it uses @code{Wide_Wide_Character}).
21097 @noindent
21098   RM References:  A.04.11
21100 @item
21101 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
21102 @cindex AI-0038 (Ada 2012 feature)
21104 @noindent
21105   These are minor errors in the description on three points. The intent on
21106   all these points has always been clear, and GNAT has always implemented the
21107   correct intended semantics.
21109 @noindent
21110   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)
21112 @item
21113 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
21114 @cindex AI-0044 (Ada 2012 feature)
21116 @noindent
21117   This AI places restrictions on allowed instantiations of generic containers.
21118   These restrictions are not checked by the compiler, so there is nothing to
21119   change in the implementation. This affects only the RM documentation.
21121 @noindent
21122   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)
21124 @item
21125 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
21126 @cindex AI-0127 (Ada 2012 feature)
21128 @noindent
21129   This package provides an interface for identifying the current locale.
21131 @noindent
21132   RM References:  A.19    A.19.01    A.19.02    A.19.03    A.19.05    A.19.06
21133   A.19.07    A.19.08    A.19.09    A.19.10    A.19.11    A.19.12    A.19.13
21137 @item
21138 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
21139 @cindex AI-0002 (Ada 2012 feature)
21141 @noindent
21142   The compiler is not required to support exporting an Ada subprogram with
21143   convention C if there are parameters or a return type of an unconstrained
21144   array type (such as @code{String}). GNAT allows such declarations but
21145   generates warnings. It is possible, but complicated, to write the
21146   corresponding C code and certainly such code would be specific to GNAT and
21147   non-portable.
21149 @noindent
21150   RM References:  B.01 (17)   B.03 (62)   B.03 (71.1/2)
21153 @item
21154 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
21155 @cindex AI05-0216 (Ada 2012 feature)
21157 @noindent
21158   It is clearly the intention that @code{No_Task_Hierarchy} is intended to
21159   forbid tasks declared locally within subprograms, or functions returning task
21160   objects, and that is the implementation that GNAT has always provided.
21161   However the language in the RM was not sufficiently clear on this point.
21162   Thus this is a documentation change in the RM only.
21164 @noindent
21165   RM References:  D.07 (3/3)
21167 @item
21168 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
21169 @cindex AI-0211 (Ada 2012 feature)
21171 @noindent
21172   The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
21173   @code{Ada.Real_Time.Timing_Events.Set_Handler}.
21175 @noindent
21176   RM References:  D.07 (5)   D.07 (10/2)   D.07 (10.4/2)   D.07 (10.7/2)
21178 @item
21179 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
21180 @cindex AI-0190 (Ada 2012 feature)
21182 @noindent
21183   This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
21184   used to control storage pools globally.
21185   In particular, you can force every access
21186   type that is used for allocation (@b{new}) to have an explicit storage pool,
21187   or you can declare a pool globally to be used for all access types that lack
21188   an explicit one.
21190 @noindent
21191   RM References:  D.07 (8)
21193 @item
21194 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
21195 @cindex AI-0189 (Ada 2012 feature)
21197 @noindent
21198   This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
21199   which says that no dynamic allocation will occur once elaboration is
21200   completed.
21201   In general this requires a run-time check, which is not required, and which
21202   GNAT does not attempt. But the static cases of allocators in a task body or
21203   in the body of the main program are detected and flagged at compile or bind
21204   time.
21206 @noindent
21207   RM References:  D.07 (19.1/2)   H.04 (23.3/2)
21209 @item
21210 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
21211 @cindex AI-0171 (Ada 2012 feature)
21213 @noindent
21214   A new package @code{System.Multiprocessors} is added, together with the
21215   definition of pragma @code{CPU} for controlling task affinity. A new no
21216   dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
21217   is added to the Ravenscar profile.
21219 @noindent
21220   RM References:  D.13.01 (4/2)   D.16
21223 @item
21224 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
21225 @cindex AI-0210 (Ada 2012 feature)
21227 @noindent
21228   This is a documentation only issue regarding wording of metric requirements,
21229   that does not affect the implementation of the compiler.
21231 @noindent
21232   RM References:  D.15 (24/2)
21235 @item
21236 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
21237 @cindex AI-0206 (Ada 2012 feature)
21239 @noindent
21240   Remote types packages are now allowed to depend on preelaborated packages.
21241   This was formerly considered illegal.
21243 @noindent
21244   RM References:  E.02.02 (6)
21248 @item
21249 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
21250 @cindex AI-0152 (Ada 2012 feature)
21252 @noindent
21253   Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
21254   where the type of the returned value is an anonymous access type.
21256 @noindent
21257   RM References:  H.04 (8/1)
21258 @end itemize
21261 @node Obsolescent Features
21262 @chapter Obsolescent Features
21264 @noindent
21265 This chapter describes features that are provided by GNAT, but are
21266 considered obsolescent since there are preferred ways of achieving
21267 the same effect. These features are provided solely for historical
21268 compatibility purposes.
21270 @menu
21271 * pragma No_Run_Time::
21272 * pragma Ravenscar::
21273 * pragma Restricted_Run_Time::
21274 @end menu
21276 @node pragma No_Run_Time
21277 @section pragma No_Run_Time
21279 The pragma @code{No_Run_Time} is used to achieve an affect similar
21280 to the use of the "Zero Foot Print" configurable run time, but without
21281 requiring a specially configured run time. The result of using this
21282 pragma, which must be used for all units in a partition, is to restrict
21283 the use of any language features requiring run-time support code. The
21284 preferred usage is to use an appropriately configured run-time that
21285 includes just those features that are to be made accessible.
21287 @node pragma Ravenscar
21288 @section pragma Ravenscar
21290 The pragma @code{Ravenscar} has exactly the same effect as pragma
21291 @code{Profile (Ravenscar)}. The latter usage is preferred since it
21292 is part of the new Ada 2005 standard.
21294 @node pragma Restricted_Run_Time
21295 @section pragma Restricted_Run_Time
21297 The pragma @code{Restricted_Run_Time} has exactly the same effect as
21298 pragma @code{Profile (Restricted)}. The latter usage is
21299 preferred since the Ada 2005 pragma @code{Profile} is intended for
21300 this kind of implementation dependent addition.
21302 @include fdl.texi
21303 @c GNU Free Documentation License
21305 @node Index,,GNU Free Documentation License, Top
21306 @unnumbered Index
21308 @printindex cp
21310 @contents
21312 @bye
21313 tablishes the following set of restrictions:
21314 Pragma Shared