2014-11-18 Christophe Lyon <christophe.lyon@linaro.org>
[official-gcc.git] / gcc / ada / gnat_rm.texi
blobe0f6b3fcf3b7205d2449144976733cee8f282ba5
1 \input texinfo   @c -*-texinfo-*-
3 @c %**start of header
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6 @c                                                                            o
7 @c                           GNAT DOCUMENTATION                               o
8 @c                                                                            o
9 @c                              G N A T _ RM                                  o
10 @c                                                                            o
11 @c  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
12 @c                                                                            o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
15 @setfilename gnat_rm.info
17 @copying
18 Copyright @copyright{} 1995-2012, Free Software Foundation, Inc.
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.3 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts.  A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
26 @end copying
28 @set EDITION GNAT
30 @settitle GNAT Reference Manual
32 @setchapternewpage odd
33 @syncodeindex fn cp
35 @include gcc-common.texi
37 @dircategory GNU Ada tools
38 @direntry
39 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
40 @end direntry
42 @titlepage
43 @title GNAT Reference Manual
44 @subtitle GNAT, The GNU Ada Development Environment
45 @versionsubtitle
46 @author AdaCore
47 @page
48 @vskip 0pt plus 1filll
50 @insertcopying
52 @end titlepage
54 @ifnottex
55 @node Top, About This Guide, (dir), (dir)
56 @top GNAT Reference Manual
58 @noindent
59 GNAT Reference Manual
61 @noindent
62 GNAT, The GNU Ada Development Environment@*
63 GCC version @value{version-GCC}@*
65 @noindent
66 AdaCore
68 @menu
69 * About This Guide::
70 * Implementation Defined Pragmas::
71 * Implementation Defined Aspects::
72 * Implementation Defined Attributes::
73 * Standard and Implementation Defined Restrictions::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
80 * The GNAT Library::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Implementation of Ada 2012 Features::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
87 * Index:Concept Index.
89 @detailmenu
90  --- The Detailed Node Listing ---
92 About This Guide
94 * What This Reference Manual Contains::
95 * Related Information::
97 Implementation Defined Pragmas
99 * Pragma Abort_Defer::
100 * Pragma Abstract_State::
101 * Pragma Ada_83::
102 * Pragma Ada_95::
103 * Pragma Ada_05::
104 * Pragma Ada_2005::
105 * Pragma Ada_12::
106 * Pragma Ada_2012::
107 * Pragma Allow_Integer_Address::
108 * Pragma Annotate::
109 * Pragma Assert::
110 * Pragma Assert_And_Cut::
111 * Pragma Assertion_Policy::
112 * Pragma Assume::
113 * Pragma Assume_No_Invalid_Values::
114 * Pragma AST_Entry::
115 * Pragma Async_Readers::
116 * Pragma Async_Writers::
117 * Pragma Attribute_Definition::
118 * Pragma C_Pass_By_Copy::
119 * Pragma Check::
120 * Pragma Check_Float_Overflow::
121 * Pragma Check_Name::
122 * Pragma Check_Policy::
123 * Pragma CIL_Constructor::
124 * Pragma Comment::
125 * Pragma Common_Object::
126 * Pragma Compile_Time_Error::
127 * Pragma Compile_Time_Warning::
128 * Pragma Compiler_Unit::
129 * Pragma Compiler_Unit_Warning::
130 * Pragma Complete_Representation::
131 * Pragma Complex_Representation::
132 * Pragma Component_Alignment::
133 * Pragma Contract_Cases::
134 * Pragma Convention_Identifier::
135 * Pragma CPP_Class::
136 * Pragma CPP_Constructor::
137 * Pragma CPP_Virtual::
138 * Pragma CPP_Vtable::
139 * Pragma CPU::
140 * Pragma Debug::
141 * Pragma Debug_Policy::
142 * Pragma Default_Scalar_Storage_Order::
143 * Pragma Default_Storage_Pool::
144 * Pragma Depends::
145 * Pragma Detect_Blocking::
146 * Pragma Disable_Atomic_Synchronization::
147 * Pragma Dispatching_Domain::
148 * Pragma Effective_Reads::
149 * Pragma Effective_Writes::
150 * Pragma Elaboration_Checks::
151 * Pragma Eliminate::
152 * Pragma Enable_Atomic_Synchronization::
153 * Pragma Export_Exception::
154 * Pragma Export_Function::
155 * Pragma Export_Object::
156 * Pragma Export_Procedure::
157 * Pragma Export_Value::
158 * Pragma Export_Valued_Procedure::
159 * Pragma Extend_System::
160 * Pragma Extensions_Allowed::
161 * Pragma External::
162 * Pragma External_Name_Casing::
163 * Pragma Fast_Math::
164 * Pragma Favor_Top_Level::
165 * Pragma Finalize_Storage_Only::
166 * Pragma Float_Representation::
167 * Pragma Global::
168 * Pragma Ident::
169 * Pragma Implementation_Defined::
170 * Pragma Implemented::
171 * Pragma Implicit_Packing::
172 * Pragma Import_Exception::
173 * Pragma Import_Function::
174 * Pragma Import_Object::
175 * Pragma Import_Procedure::
176 * Pragma Import_Valued_Procedure::
177 * Pragma Independent::
178 * Pragma Independent_Components::
179 * Pragma Initial_Condition::
180 * Pragma Initialize_Scalars::
181 * Pragma Initializes::
182 * Pragma Inline_Always::
183 * Pragma Inline_Generic::
184 * Pragma Interface::
185 * Pragma Interface_Name::
186 * Pragma Interrupt_Handler::
187 * Pragma Interrupt_State::
188 * Pragma Invariant::
189 * Pragma Java_Constructor::
190 * Pragma Java_Interface::
191 * Pragma Keep_Names::
192 * Pragma License::
193 * Pragma Link_With::
194 * Pragma Linker_Alias::
195 * Pragma Linker_Constructor::
196 * Pragma Linker_Destructor::
197 * Pragma Linker_Section::
198 * Pragma Lock_Free::
199 * Pragma Long_Float::
200 * Pragma Loop_Invariant::
201 * Pragma Loop_Optimize::
202 * Pragma Loop_Variant::
203 * Pragma Machine_Attribute::
204 * Pragma Main::
205 * Pragma Main_Storage::
206 * Pragma No_Body::
207 * Pragma No_Elaboration_Code_All::
208 * Pragma No_Inline::
209 * Pragma No_Return::
210 * Pragma No_Run_Time::
211 * Pragma No_Strict_Aliasing ::
212 * Pragma No_Tagged_Streams::
213 * Pragma Normalize_Scalars::
214 * Pragma Obsolescent::
215 * Pragma Optimize_Alignment::
216 * Pragma Ordered::
217 * Pragma Overflow_Mode::
218 * Pragma Overriding_Renamings::
219 * Pragma Partition_Elaboration_Policy::
220 * Pragma Part_Of::
221 * Pragma Passive::
222 * Pragma Persistent_BSS::
223 * Pragma Polling::
224 * Pragma Post::
225 * Pragma Postcondition::
226 * Pragma Post_Class::
227 * Pragma Pre::
228 * Pragma Precondition::
229 * Pragma Predicate::
230 * Pragma Preelaborable_Initialization::
231 * Pragma Prefix_Exception_Messages::
232 * Pragma Pre_Class::
233 * Pragma Priority_Specific_Dispatching::
234 * Pragma Profile::
235 * Pragma Profile_Warnings::
236 * Pragma Propagate_Exceptions::
237 * Pragma Provide_Shift_Operators::
238 * Pragma Psect_Object::
239 * Pragma Pure_Function::
240 * Pragma Rational::
241 * Pragma Ravenscar::
242 * Pragma Refined_Depends::
243 * Pragma Refined_Global::
244 * Pragma Refined_Post::
245 * Pragma Refined_State::
246 * Pragma Relative_Deadline::
247 * Pragma Remote_Access_Type::
248 * Pragma Restricted_Run_Time::
249 * Pragma Restriction_Warnings::
250 * Pragma Reviewable::
251 * Pragma Share_Generic::
252 * Pragma Shared::
253 * Pragma Short_Circuit_And_Or::
254 * Pragma Short_Descriptors::
255 * Pragma Simple_Storage_Pool_Type::
256 * Pragma Source_File_Name::
257 * Pragma Source_File_Name_Project::
258 * Pragma Source_Reference::
259 * Pragma SPARK_Mode::
260 * Pragma Static_Elaboration_Desired::
261 * Pragma Stream_Convert::
262 * Pragma Style_Checks::
263 * Pragma Subtitle::
264 * Pragma Suppress::
265 * Pragma Suppress_All::
266 * Pragma Suppress_Debug_Info::
267 * Pragma Suppress_Exception_Locations::
268 * Pragma Suppress_Initialization::
269 * Pragma Task_Name::
270 * Pragma Task_Storage::
271 * Pragma Test_Case::
272 * Pragma Thread_Local_Storage::
273 * Pragma Time_Slice::
274 * Pragma Title::
275 * Pragma Type_Invariant::
276 * Pragma Type_Invariant_Class::
277 * Pragma Unchecked_Union::
278 * Pragma Unevaluated_Use_Of_Old::
279 * Pragma Unimplemented_Unit::
280 * Pragma Universal_Aliasing ::
281 * Pragma Universal_Data::
282 * Pragma Unmodified::
283 * Pragma Unreferenced::
284 * Pragma Unreferenced_Objects::
285 * Pragma Unreserve_All_Interrupts::
286 * Pragma Unsuppress::
287 * Pragma Use_VADS_Size::
288 * Pragma Validity_Checks::
289 * Pragma Volatile::
290 * Pragma Warning_As_Error::
291 * Pragma Warnings::
292 * Pragma Weak_External::
293 * Pragma Wide_Character_Encoding::
295 Implementation Defined Aspects
297 * Aspect Abstract_State::
298 * Aspect Annotate::
299 * Aspect Async_Readers::
300 * Aspect Async_Writers::
301 * Aspect Contract_Cases::
302 * Aspect Depends::
303 * Aspect Dimension::
304 * Aspect Dimension_System::
305 * Aspect Effective_Reads::
306 * Aspect Effective_Writes::
307 * Aspect Favor_Top_Level::
308 * Aspect Global::
309 * Aspect Initial_Condition::
310 * Aspect Initializes::
311 * Aspect Inline_Always::
312 * Aspect Invariant::
313 * Aspect Invariant'Class::
314 * Aspect Iterable::
315 * Aspect Linker_Section::
316 * Aspect No_Elaboration_Code_All::
317 * Aspect No_Tagged_Streams::
318 * Aspect Object_Size::
319 * Aspect Obsolescent::
320 * Aspect Part_Of::
321 * Aspect Persistent_BSS::
322 * Aspect Predicate::
323 * Aspect Pure_Function::
324 * Aspect Refined_Depends::
325 * Aspect Refined_Global::
326 * Aspect Refined_Post::
327 * Aspect Refined_State::
328 * Aspect Remote_Access_Type::
329 * Aspect Scalar_Storage_Order::
330 * Aspect Shared::
331 * Aspect Simple_Storage_Pool::
332 * Aspect Simple_Storage_Pool_Type::
333 * Aspect SPARK_Mode::
334 * Aspect Suppress_Debug_Info::
335 * Aspect Suppress_Initialization::
336 * Aspect Test_Case::
337 * Aspect Thread_Local_Storage::
338 * Aspect Universal_Aliasing::
339 * Aspect Universal_Data::
340 * Aspect Unmodified::
341 * Aspect Unreferenced::
342 * Aspect Unreferenced_Objects::
343 * Aspect Value_Size::
344 * Aspect Warnings::
346 Implementation Defined Attributes
348 * Attribute Abort_Signal::
349 * Attribute Address_Size::
350 * Attribute Asm_Input::
351 * Attribute Asm_Output::
352 * Attribute AST_Entry::
353 * Attribute Atomic_Always_Lock_Free::
354 * Attribute Bit::
355 * Attribute Bit_Position::
356 * Attribute Code_Address::
357 * Attribute Compiler_Version::
358 * Attribute Constrained::
359 * Attribute Default_Bit_Order::
360 * Attribute Default_Scalar_Storage_Order::
361 * Attribute Descriptor_Size::
362 * Attribute Elaborated::
363 * Attribute Elab_Body::
364 * Attribute Elab_Spec::
365 * Attribute Elab_Subp_Body::
366 * Attribute Emax::
367 * Attribute Enabled::
368 * Attribute Enum_Rep::
369 * Attribute Enum_Val::
370 * Attribute Epsilon::
371 * Attribute Fast_Math::
372 * Attribute Fixed_Value::
373 * Attribute From_Any::
374 * Attribute Has_Access_Values::
375 * Attribute Has_Discriminants::
376 * Attribute Img::
377 * Attribute Integer_Value::
378 * Attribute Invalid_Value::
379 * Attribute Iterable::
380 * Attribute Large::
381 * Attribute Library_Level::
382 * Attribute Lock_Free::
383 * Attribute Loop_Entry::
384 * Attribute Machine_Size::
385 * Attribute Mantissa::
386 * Attribute Maximum_Alignment::
387 * Attribute Mechanism_Code::
388 * Attribute Null_Parameter::
389 * Attribute Object_Size::
390 * Attribute Old::
391 * Attribute Passed_By_Reference::
392 * Attribute Pool_Address::
393 * Attribute Range_Length::
394 * Attribute Ref::
395 * Attribute Restriction_Set::
396 * Attribute Result::
397 * Attribute Safe_Emax::
398 * Attribute Safe_Large::
399 * Attribute Safe_Small::
400 * Attribute Scalar_Storage_Order::
401 * Attribute Simple_Storage_Pool::
402 * Attribute Small::
403 * Attribute Storage_Unit::
404 * Attribute Stub_Type::
405 * Attribute System_Allocator_Alignment::
406 * Attribute Target_Name::
407 * Attribute To_Address::
408 * Attribute To_Any::
409 * Attribute Type_Class::
410 * Attribute Type_Key::
411 * Attribute TypeCode::
412 * Attribute UET_Address::
413 * Attribute Unconstrained_Array::
414 * Attribute Universal_Literal_String::
415 * Attribute Unrestricted_Access::
416 * Attribute Update::
417 * Attribute VADS_Size::
418 * Attribute Valid_Scalars::
419 * Attribute Value_Size::
420 * Attribute Wchar_T_Size::
421 * Attribute Word_Size::
423 Standard and Implementation Defined Restrictions
425 * Partition-Wide Restrictions::
426 * Program Unit Level Restrictions::
428 Partition-Wide Restrictions
430 * Immediate_Reclamation::
431 * Max_Asynchronous_Select_Nesting::
432 * Max_Entry_Queue_Length::
433 * Max_Protected_Entries::
434 * Max_Select_Alternatives::
435 * Max_Storage_At_Blocking::
436 * Max_Task_Entries::
437 * Max_Tasks::
438 * No_Abort_Statements::
439 * No_Access_Parameter_Allocators::
440 * No_Access_Subprograms::
441 * No_Allocators::
442 * No_Anonymous_Allocators::
443 * No_Calendar::
444 * No_Coextensions::
445 * No_Default_Initialization::
446 * No_Delay::
447 * No_Dependence::
448 * No_Direct_Boolean_Operators::
449 * No_Dispatch::
450 * No_Dispatching_Calls::
451 * No_Dynamic_Attachment::
452 * No_Dynamic_Priorities::
453 * No_Entry_Calls_In_Elaboration_Code::
454 * No_Enumeration_Maps::
455 * No_Exception_Handlers::
456 * No_Exception_Propagation::
457 * No_Exception_Registration::
458 * No_Exceptions::
459 * No_Finalization::
460 * No_Fixed_Point::
461 * No_Floating_Point::
462 * No_Implicit_Conditionals::
463 * No_Implicit_Dynamic_Code::
464 * No_Implicit_Heap_Allocations::
465 * No_Implicit_Loops::
466 * No_Initialize_Scalars::
467 * No_IO::
468 * No_Local_Allocators::
469 * No_Local_Protected_Objects::
470 * No_Local_Timing_Events::
471 * No_Long_Long_Integers::
472 * No_Multiple_Elaboration::
473 * No_Nested_Finalization::
474 * No_Protected_Type_Allocators::
475 * No_Protected_Types::
476 * No_Recursion::
477 * No_Reentrancy::
478 * No_Relative_Delay::
479 * No_Requeue_Statements::
480 * No_Secondary_Stack::
481 * No_Select_Statements::
482 * No_Specific_Termination_Handlers::
483 * No_Specification_of_Aspect::
484 * No_Standard_Allocators_After_Elaboration::
485 * No_Standard_Storage_Pools::
486 * No_Stream_Optimizations::
487 * No_Streams::
488 * No_Task_Allocators::
489 * No_Task_Attributes_Package::
490 * No_Task_Hierarchy::
491 * No_Task_Termination::
492 * No_Tasking::
493 * No_Terminate_Alternatives::
494 * No_Unchecked_Access::
495 * Simple_Barriers::
496 * Static_Priorities::
497 * Static_Storage_Size::
499 Program Unit Level Restrictions
501 * No_Elaboration_Code::
502 * No_Entry_Queue::
503 * No_Implementation_Aspect_Specifications::
504 * No_Implementation_Attributes::
505 * No_Implementation_Identifiers::
506 * No_Implementation_Pragmas::
507 * No_Implementation_Restrictions::
508 * No_Implementation_Units::
509 * No_Implicit_Aliasing::
510 * No_Obsolescent_Features::
511 * No_Wide_Characters::
512 * SPARK_05::
514 The Implementation of Standard I/O
516 * Standard I/O Packages::
517 * FORM Strings::
518 * Direct_IO::
519 * Sequential_IO::
520 * Text_IO::
521 * Wide_Text_IO::
522 * Wide_Wide_Text_IO::
523 * Stream_IO::
524 * Text Translation::
525 * Shared Files::
526 * Filenames encoding::
527 * File content encoding::
528 * Open Modes::
529 * Operations on C Streams::
530 * Interfacing to C Streams::
532 The GNAT Library
534 * Ada.Characters.Latin_9 (a-chlat9.ads)::
535 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
536 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
537 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
538 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
539 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
540 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
541 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
542 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
543 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
544 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
545 * Ada.Containers.Formal_Indefinite_Vectors (a-cfinve.ads)::
546 * Ada.Containers.Bounded_Holders (a-coboho.ads)::
547 * Ada.Command_Line.Environment (a-colien.ads)::
548 * Ada.Command_Line.Remove (a-colire.ads)::
549 * Ada.Command_Line.Response_File (a-clrefi.ads)::
550 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
551 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
552 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
553 * Ada.Exceptions.Traceback (a-exctra.ads)::
554 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
555 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
556 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
557 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
558 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
559 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
560 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
561 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
562 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
563 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
564 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
565 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
566 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
567 * GNAT.Altivec (g-altive.ads)::
568 * GNAT.Altivec.Conversions (g-altcon.ads)::
569 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
570 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
571 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
572 * GNAT.Array_Split (g-arrspl.ads)::
573 * GNAT.AWK (g-awk.ads)::
574 * GNAT.Bounded_Buffers (g-boubuf.ads)::
575 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
576 * GNAT.Bubble_Sort (g-bubsor.ads)::
577 * GNAT.Bubble_Sort_A (g-busora.ads)::
578 * GNAT.Bubble_Sort_G (g-busorg.ads)::
579 * GNAT.Byte_Order_Mark (g-byorma.ads)::
580 * GNAT.Byte_Swapping (g-bytswa.ads)::
581 * GNAT.Calendar (g-calend.ads)::
582 * GNAT.Calendar.Time_IO (g-catiio.ads)::
583 * GNAT.Case_Util (g-casuti.ads)::
584 * GNAT.CGI (g-cgi.ads)::
585 * GNAT.CGI.Cookie (g-cgicoo.ads)::
586 * GNAT.CGI.Debug (g-cgideb.ads)::
587 * GNAT.Command_Line (g-comlin.ads)::
588 * GNAT.Compiler_Version (g-comver.ads)::
589 * GNAT.Ctrl_C (g-ctrl_c.ads)::
590 * GNAT.CRC32 (g-crc32.ads)::
591 * GNAT.Current_Exception (g-curexc.ads)::
592 * GNAT.Debug_Pools (g-debpoo.ads)::
593 * GNAT.Debug_Utilities (g-debuti.ads)::
594 * GNAT.Decode_String (g-decstr.ads)::
595 * GNAT.Decode_UTF8_String (g-deutst.ads)::
596 * GNAT.Directory_Operations (g-dirope.ads)::
597 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
598 * GNAT.Dynamic_HTables (g-dynhta.ads)::
599 * GNAT.Dynamic_Tables (g-dyntab.ads)::
600 * GNAT.Encode_String (g-encstr.ads)::
601 * GNAT.Encode_UTF8_String (g-enutst.ads)::
602 * GNAT.Exception_Actions (g-excact.ads)::
603 * GNAT.Exception_Traces (g-exctra.ads)::
604 * GNAT.Exceptions (g-except.ads)::
605 * GNAT.Expect (g-expect.ads)::
606 * GNAT.Expect.TTY (g-exptty.ads)::
607 * GNAT.Float_Control (g-flocon.ads)::
608 * GNAT.Formatted_String (g-forstr.ads)::
609 * GNAT.Heap_Sort (g-heasor.ads)::
610 * GNAT.Heap_Sort_A (g-hesora.ads)::
611 * GNAT.Heap_Sort_G (g-hesorg.ads)::
612 * GNAT.HTable (g-htable.ads)::
613 * GNAT.IO (g-io.ads)::
614 * GNAT.IO_Aux (g-io_aux.ads)::
615 * GNAT.Lock_Files (g-locfil.ads)::
616 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
617 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
618 * GNAT.MD5 (g-md5.ads)::
619 * GNAT.Memory_Dump (g-memdum.ads)::
620 * GNAT.Most_Recent_Exception (g-moreex.ads)::
621 * GNAT.OS_Lib (g-os_lib.ads)::
622 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
623 * GNAT.Random_Numbers (g-rannum.ads)::
624 * GNAT.Regexp (g-regexp.ads)::
625 * GNAT.Registry (g-regist.ads)::
626 * GNAT.Regpat (g-regpat.ads)::
627 * GNAT.Rewrite_Data (g-rewdat.ads)::
628 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
629 * GNAT.Semaphores (g-semaph.ads)::
630 * GNAT.Serial_Communications (g-sercom.ads)::
631 * GNAT.SHA1 (g-sha1.ads)::
632 * GNAT.SHA224 (g-sha224.ads)::
633 * GNAT.SHA256 (g-sha256.ads)::
634 * GNAT.SHA384 (g-sha384.ads)::
635 * GNAT.SHA512 (g-sha512.ads)::
636 * GNAT.Signals (g-signal.ads)::
637 * GNAT.Sockets (g-socket.ads)::
638 * GNAT.Source_Info (g-souinf.ads)::
639 * GNAT.Spelling_Checker (g-speche.ads)::
640 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
641 * GNAT.Spitbol.Patterns (g-spipat.ads)::
642 * GNAT.Spitbol (g-spitbo.ads)::
643 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
644 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
645 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
646 * GNAT.SSE (g-sse.ads)::
647 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
648 * GNAT.Strings (g-string.ads)::
649 * GNAT.String_Split (g-strspl.ads)::
650 * GNAT.Table (g-table.ads)::
651 * GNAT.Task_Lock (g-tasloc.ads)::
652 * GNAT.Threads (g-thread.ads)::
653 * GNAT.Time_Stamp (g-timsta.ads)::
654 * GNAT.Traceback (g-traceb.ads)::
655 * GNAT.Traceback.Symbolic (g-trasym.ads)::
656 * GNAT.UTF_32 (g-utf_32.ads)::
657 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
658 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
659 * GNAT.Wide_String_Split (g-wistsp.ads)::
660 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
661 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
662 * Interfaces.C.Extensions (i-cexten.ads)::
663 * Interfaces.C.Streams (i-cstrea.ads)::
664 * Interfaces.Packed_Decimal (i-pacdec.ads)::
665 * Interfaces.VxWorks (i-vxwork.ads)::
666 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
667 * System.Address_Image (s-addima.ads)::
668 * System.Assertions (s-assert.ads)::
669 * System.Atomic_Counters (s-atocou.ads)::
670 * System.Memory (s-memory.ads)::
671 * System.Multiprocessors (s-multip.ads)::
672 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
673 * System.Partition_Interface (s-parint.ads)::
674 * System.Pool_Global (s-pooglo.ads)::
675 * System.Pool_Local (s-pooloc.ads)::
676 * System.Restrictions (s-restri.ads)::
677 * System.Rident (s-rident.ads)::
678 * System.Strings.Stream_Ops (s-ststop.ads)::
679 * System.Unsigned_Types (s-unstyp.ads)::
680 * System.Wch_Cnv (s-wchcnv.ads)::
681 * System.Wch_Con (s-wchcon.ads)::
683 Text_IO
685 * Text_IO Stream Pointer Positioning::
686 * Text_IO Reading and Writing Non-Regular Files::
687 * Get_Immediate::
688 * Treating Text_IO Files as Streams::
689 * Text_IO Extensions::
690 * Text_IO Facilities for Unbounded Strings::
692 Wide_Text_IO
694 * Wide_Text_IO Stream Pointer Positioning::
695 * Wide_Text_IO Reading and Writing Non-Regular Files::
697 Wide_Wide_Text_IO
699 * Wide_Wide_Text_IO Stream Pointer Positioning::
700 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
702 Interfacing to Other Languages
704 * Interfacing to C::
705 * Interfacing to C++::
706 * Interfacing to COBOL::
707 * Interfacing to Fortran::
708 * Interfacing to non-GNAT Ada code::
710 Specialized Needs Annexes
712 Implementation of Specific Ada Features
713 * Machine Code Insertions::
714 * GNAT Implementation of Tasking::
715 * GNAT Implementation of Shared Passive Packages::
716 * Code Generation for Array Aggregates::
717 * The Size of Discriminated Records with Default Discriminants::
718 * Strict Conformance to the Ada Reference Manual::
720 Implementation of Ada 2012 Features
722 Obsolescent Features
724 GNU Free Documentation License
726 Index
727 @end detailmenu
728 @end menu
730 @end ifnottex
732 @node About This Guide
733 @unnumbered About This Guide
735 @noindent
736 This manual contains useful information in writing programs using the
737 @value{EDITION} compiler.  It includes information on implementation dependent
738 characteristics of @value{EDITION}, including all the information required by
739 Annex M of the Ada language standard.
741 @value{EDITION} implements Ada 95, Ada 2005 and Ada 2012, and it may also be
742 invoked in Ada 83 compatibility mode.
743 By default, @value{EDITION} assumes Ada 2012,
744 but you can override with a compiler switch
745 to explicitly specify the language version.
746 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
747 @value{EDITION} User's Guide}, for details on these switches.)
748 Throughout this manual, references to ``Ada'' without a year suffix
749 apply to all the Ada versions of the language.
751 Ada is designed to be highly portable.
752 In general, a program will have the same effect even when compiled by
753 different compilers on different platforms.
754 However, since Ada is designed to be used in a
755 wide variety of applications, it also contains a number of system
756 dependent features to be used in interfacing to the external world.
757 @cindex Implementation-dependent features
758 @cindex Portability
760 Note: Any program that makes use of implementation-dependent features
761 may be non-portable.  You should follow good programming practice and
762 isolate and clearly document any sections of your program that make use
763 of these features in a non-portable manner.
765 @ifset PROEDITION
766 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
767 ``GNAT'' in the remainder of this document.
768 @end ifset
770 @menu
771 * What This Reference Manual Contains::
772 * Conventions::
773 * Related Information::
774 @end menu
776 @node What This Reference Manual Contains
777 @unnumberedsec What This Reference Manual Contains
779 @noindent
780 This reference manual contains the following chapters:
782 @itemize @bullet
783 @item
784 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
785 pragmas, which can be used to extend and enhance the functionality of the
786 compiler.
788 @item
789 @ref{Implementation Defined Attributes}, lists GNAT
790 implementation-dependent attributes, which can be used to extend and
791 enhance the functionality of the compiler.
793 @item
794 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
795 implementation-dependent restrictions, which can be used to extend and
796 enhance the functionality of the compiler.
798 @item
799 @ref{Implementation Advice}, provides information on generally
800 desirable behavior which are not requirements that all compilers must
801 follow since it cannot be provided on all systems, or which may be
802 undesirable on some systems.
804 @item
805 @ref{Implementation Defined Characteristics}, provides a guide to
806 minimizing implementation dependent features.
808 @item
809 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
810 implemented by GNAT, and how they can be imported into user
811 application programs.
813 @item
814 @ref{Representation Clauses and Pragmas}, describes in detail the
815 way that GNAT represents data, and in particular the exact set
816 of representation clauses and pragmas that is accepted.
818 @item
819 @ref{Standard Library Routines}, provides a listing of packages and a
820 brief description of the functionality that is provided by Ada's
821 extensive set of standard library routines as implemented by GNAT@.
823 @item
824 @ref{The Implementation of Standard I/O}, details how the GNAT
825 implementation of the input-output facilities.
827 @item
828 @ref{The GNAT Library}, is a catalog of packages that complement
829 the Ada predefined library.
831 @item
832 @ref{Interfacing to Other Languages}, describes how programs
833 written in Ada using GNAT can be interfaced to other programming
834 languages.
836 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
837 of the specialized needs annexes.
839 @item
840 @ref{Implementation of Specific Ada Features}, discusses issues related
841 to GNAT's implementation of machine code insertions, tasking, and several
842 other features.
844 @item
845 @ref{Implementation of Ada 2012 Features}, describes the status of the
846 GNAT implementation of the Ada 2012 language standard.
848 @item
849 @ref{Obsolescent Features} documents implementation dependent features,
850 including pragmas and attributes, which are considered obsolescent, since
851 there are other preferred ways of achieving the same results. These
852 obsolescent forms are retained for backwards compatibility.
854 @end itemize
856 @cindex Ada 95 Language Reference Manual
857 @cindex Ada 2005 Language Reference Manual
858 @noindent
859 This reference manual assumes a basic familiarity with the Ada 95 language, as
860 described in the International Standard ANSI/ISO/IEC-8652:1995,
861 January 1995.
862 It does not require knowledge of the new features introduced by Ada 2005,
863 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
864 and Amendment 1).
865 Both reference manuals are included in the GNAT documentation
866 package.
868 @node Conventions
869 @unnumberedsec Conventions
870 @cindex Conventions, typographical
871 @cindex Typographical conventions
873 @noindent
874 Following are examples of the typographical and graphic conventions used
875 in this guide:
877 @itemize @bullet
878 @item
879 @code{Functions}, @code{utility program names}, @code{standard names},
880 and @code{classes}.
882 @item
883 @code{Option flags}
885 @item
886 @file{File names}, @samp{button names}, and @samp{field names}.
888 @item
889 @code{Variables}, @env{environment variables}, and @var{metasyntactic
890 variables}.
892 @item
893 @emph{Emphasis}.
895 @item
896 [optional information or parameters]
898 @item
899 Examples are described by text
900 @smallexample
901 and then shown this way.
902 @end smallexample
903 @end itemize
905 @noindent
906 Commands that are entered by the user are preceded in this manual by the
907 characters @samp{$ } (dollar sign followed by space).  If your system uses this
908 sequence as a prompt, then the commands will appear exactly as you see them
909 in the manual.  If your system uses some other prompt, then the command will
910 appear with the @samp{$} replaced by whatever prompt character you are using.
912 @node Related Information
913 @unnumberedsec Related Information
914 @noindent
915 See the following documents for further information on GNAT:
917 @itemize @bullet
918 @item
919 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
920 @value{EDITION} User's Guide}, which provides information on how to use the
921 GNAT compiler system.
923 @item
924 @cite{Ada 95 Reference Manual}, which contains all reference
925 material for the Ada 95 programming language.
927 @item
928 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
929 of the Ada 95 standard.  The annotations describe
930 detailed aspects of the design decision, and in particular contain useful
931 sections on Ada 83 compatibility.
933 @item
934 @cite{Ada 2005 Reference Manual}, which contains all reference
935 material for the Ada 2005 programming language.
937 @item
938 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
939 of the Ada 2005 standard.  The annotations describe
940 detailed aspects of the design decision, and in particular contain useful
941 sections on Ada 83 and Ada 95 compatibility.
943 @item
944 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
945 which contains specific information on compatibility between GNAT and
946 DEC Ada 83 systems.
948 @item
949 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
950 describes in detail the pragmas and attributes provided by the DEC Ada 83
951 compiler system.
953 @end itemize
955 @node Implementation Defined Pragmas
956 @chapter Implementation Defined Pragmas
958 @noindent
959 Ada defines a set of pragmas that can be used to supply additional
960 information to the compiler.  These language defined pragmas are
961 implemented in GNAT and work as described in the Ada Reference Manual.
963 In addition, Ada allows implementations to define additional pragmas
964 whose meaning is defined by the implementation.  GNAT provides a number
965 of these implementation-defined pragmas, which can be used to extend
966 and enhance the functionality of the compiler.  This section of the GNAT
967 Reference Manual describes these additional pragmas.
969 Note that any program using these pragmas might not be portable to other
970 compilers (although GNAT implements this set of pragmas on all
971 platforms).  Therefore if portability to other compilers is an important
972 consideration, the use of these pragmas should be minimized.
974 @menu
975 * Pragma Abort_Defer::
976 * Pragma Abstract_State::
977 * Pragma Ada_83::
978 * Pragma Ada_95::
979 * Pragma Ada_05::
980 * Pragma Ada_2005::
981 * Pragma Ada_12::
982 * Pragma Ada_2012::
983 * Pragma Allow_Integer_Address::
984 * Pragma Annotate::
985 * Pragma Assert::
986 * Pragma Assert_And_Cut::
987 * Pragma Assertion_Policy::
988 * Pragma Assume::
989 * Pragma Assume_No_Invalid_Values::
990 * Pragma AST_Entry::
991 * Pragma Async_Readers::
992 * Pragma Async_Writers::
993 * Pragma Attribute_Definition::
994 * Pragma C_Pass_By_Copy::
995 * Pragma Check::
996 * Pragma Check_Float_Overflow::
997 * Pragma Check_Name::
998 * Pragma Check_Policy::
999 * Pragma CIL_Constructor::
1000 * Pragma Comment::
1001 * Pragma Common_Object::
1002 * Pragma Compile_Time_Error::
1003 * Pragma Compile_Time_Warning::
1004 * Pragma Compiler_Unit::
1005 * Pragma Compiler_Unit_Warning::
1006 * Pragma Complete_Representation::
1007 * Pragma Complex_Representation::
1008 * Pragma Component_Alignment::
1009 * Pragma Contract_Cases::
1010 * Pragma Convention_Identifier::
1011 * Pragma CPP_Class::
1012 * Pragma CPP_Constructor::
1013 * Pragma CPP_Virtual::
1014 * Pragma CPP_Vtable::
1015 * Pragma CPU::
1016 * Pragma Debug::
1017 * Pragma Debug_Policy::
1018 * Pragma Default_Scalar_Storage_Order::
1019 * Pragma Default_Storage_Pool::
1020 * Pragma Depends::
1021 * Pragma Detect_Blocking::
1022 * Pragma Disable_Atomic_Synchronization::
1023 * Pragma Dispatching_Domain::
1024 * Pragma Effective_Reads::
1025 * Pragma Effective_Writes::
1026 * Pragma Elaboration_Checks::
1027 * Pragma Eliminate::
1028 * Pragma Enable_Atomic_Synchronization::
1029 * Pragma Export_Exception::
1030 * Pragma Export_Function::
1031 * Pragma Export_Object::
1032 * Pragma Export_Procedure::
1033 * Pragma Export_Value::
1034 * Pragma Export_Valued_Procedure::
1035 * Pragma Extend_System::
1036 * Pragma Extensions_Allowed::
1037 * Pragma External::
1038 * Pragma External_Name_Casing::
1039 * Pragma Fast_Math::
1040 * Pragma Favor_Top_Level::
1041 * Pragma Finalize_Storage_Only::
1042 * Pragma Float_Representation::
1043 * Pragma Global::
1044 * Pragma Ident::
1045 * Pragma Implementation_Defined::
1046 * Pragma Implemented::
1047 * Pragma Implicit_Packing::
1048 * Pragma Import_Exception::
1049 * Pragma Import_Function::
1050 * Pragma Import_Object::
1051 * Pragma Import_Procedure::
1052 * Pragma Import_Valued_Procedure::
1053 * Pragma Independent::
1054 * Pragma Independent_Components::
1055 * Pragma Initial_Condition::
1056 * Pragma Initialize_Scalars::
1057 * Pragma Initializes::
1058 * Pragma Inline_Always::
1059 * Pragma Inline_Generic::
1060 * Pragma Interface::
1061 * Pragma Interface_Name::
1062 * Pragma Interrupt_Handler::
1063 * Pragma Interrupt_State::
1064 * Pragma Invariant::
1065 * Pragma Java_Constructor::
1066 * Pragma Java_Interface::
1067 * Pragma Keep_Names::
1068 * Pragma License::
1069 * Pragma Link_With::
1070 * Pragma Linker_Alias::
1071 * Pragma Linker_Constructor::
1072 * Pragma Linker_Destructor::
1073 * Pragma Linker_Section::
1074 * Pragma Lock_Free::
1075 * Pragma Long_Float::
1076 * Pragma Loop_Invariant::
1077 * Pragma Loop_Optimize::
1078 * Pragma Loop_Variant::
1079 * Pragma Machine_Attribute::
1080 * Pragma Main::
1081 * Pragma Main_Storage::
1082 * Pragma No_Body::
1083 * Pragma No_Elaboration_Code_All::
1084 * Pragma No_Inline::
1085 * Pragma No_Return::
1086 * Pragma No_Run_Time::
1087 * Pragma No_Strict_Aliasing::
1088 * Pragma No_Tagged_Streams::
1089 * Pragma Normalize_Scalars::
1090 * Pragma Obsolescent::
1091 * Pragma Optimize_Alignment::
1092 * Pragma Ordered::
1093 * Pragma Overflow_Mode::
1094 * Pragma Overriding_Renamings::
1095 * Pragma Partition_Elaboration_Policy::
1096 * Pragma Part_Of::
1097 * Pragma Passive::
1098 * Pragma Persistent_BSS::
1099 * Pragma Polling::
1100 * Pragma Post::
1101 * Pragma Postcondition::
1102 * Pragma Post_Class::
1103 * Pragma Pre::
1104 * Pragma Precondition::
1105 * Pragma Predicate::
1106 * Pragma Preelaborable_Initialization::
1107 * Pragma Prefix_Exception_Messages::
1108 * Pragma Pre_Class::
1109 * Pragma Priority_Specific_Dispatching::
1110 * Pragma Profile::
1111 * Pragma Profile_Warnings::
1112 * Pragma Propagate_Exceptions::
1113 * Pragma Provide_Shift_Operators::
1114 * Pragma Psect_Object::
1115 * Pragma Pure_Function::
1116 * Pragma Rational::
1117 * Pragma Ravenscar::
1118 * Pragma Refined_Depends::
1119 * Pragma Refined_Global::
1120 * Pragma Refined_Post::
1121 * Pragma Refined_State::
1122 * Pragma Relative_Deadline::
1123 * Pragma Remote_Access_Type::
1124 * Pragma Restricted_Run_Time::
1125 * Pragma Restriction_Warnings::
1126 * Pragma Reviewable::
1127 * Pragma Share_Generic::
1128 * Pragma Shared::
1129 * Pragma Short_Circuit_And_Or::
1130 * Pragma Short_Descriptors::
1131 * Pragma Simple_Storage_Pool_Type::
1132 * Pragma Source_File_Name::
1133 * Pragma Source_File_Name_Project::
1134 * Pragma Source_Reference::
1135 * Pragma SPARK_Mode::
1136 * Pragma Static_Elaboration_Desired::
1137 * Pragma Stream_Convert::
1138 * Pragma Style_Checks::
1139 * Pragma Subtitle::
1140 * Pragma Suppress::
1141 * Pragma Suppress_All::
1142 * Pragma Suppress_Debug_Info::
1143 * Pragma Suppress_Exception_Locations::
1144 * Pragma Suppress_Initialization::
1145 * Pragma Task_Name::
1146 * Pragma Task_Storage::
1147 * Pragma Test_Case::
1148 * Pragma Thread_Local_Storage::
1149 * Pragma Time_Slice::
1150 * Pragma Title::
1151 * Pragma Type_Invariant::
1152 * Pragma Type_Invariant_Class::
1153 * Pragma Unchecked_Union::
1154 * Pragma Unevaluated_Use_Of_Old::
1155 * Pragma Unimplemented_Unit::
1156 * Pragma Universal_Aliasing ::
1157 * Pragma Universal_Data::
1158 * Pragma Unmodified::
1159 * Pragma Unreferenced::
1160 * Pragma Unreferenced_Objects::
1161 * Pragma Unreserve_All_Interrupts::
1162 * Pragma Unsuppress::
1163 * Pragma Use_VADS_Size::
1164 * Pragma Validity_Checks::
1165 * Pragma Volatile::
1166 * Pragma Warning_As_Error::
1167 * Pragma Warnings::
1168 * Pragma Weak_External::
1169 * Pragma Wide_Character_Encoding::
1170 @end menu
1172 @node Pragma Abort_Defer
1173 @unnumberedsec Pragma Abort_Defer
1174 @findex Abort_Defer
1175 @cindex Deferring aborts
1176 @noindent
1177 Syntax:
1178 @smallexample
1179 pragma Abort_Defer;
1180 @end smallexample
1182 @noindent
1183 This pragma must appear at the start of the statement sequence of a
1184 handled sequence of statements (right after the @code{begin}).  It has
1185 the effect of deferring aborts for the sequence of statements (but not
1186 for the declarations or handlers, if any, associated with this statement
1187 sequence).
1189 @node Pragma Abstract_State
1190 @unnumberedsec Pragma Abstract_State
1191 @findex Abstract_State
1192 @noindent
1193 For the description of this pragma, see SPARK 2014 Reference Manual,
1194 section 7.1.4.
1196 @node Pragma Ada_83
1197 @unnumberedsec Pragma Ada_83
1198 @findex Ada_83
1199 @noindent
1200 Syntax:
1201 @smallexample @c ada
1202 pragma Ada_83;
1203 @end smallexample
1205 @noindent
1206 A configuration pragma that establishes Ada 83 mode for the unit to
1207 which it applies, regardless of the mode set by the command line
1208 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
1209 the syntax and semantics of Ada 83, as defined in the original Ada
1210 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
1211 and Ada 2005 are not recognized, optional package bodies are allowed,
1212 and generics may name types with unknown discriminants without using
1213 the @code{(<>)} notation.  In addition, some but not all of the additional
1214 restrictions of Ada 83 are enforced.
1216 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
1217 Ada 83 code to be compiled and adapted to GNAT with less effort.
1218 Secondly, it aids in keeping code backwards compatible with Ada 83.
1219 However, there is no guarantee that code that is processed correctly
1220 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1221 83 compiler, since GNAT does not enforce all the additional checks
1222 required by Ada 83.
1224 @node Pragma Ada_95
1225 @unnumberedsec Pragma Ada_95
1226 @findex Ada_95
1227 @noindent
1228 Syntax:
1229 @smallexample @c ada
1230 pragma Ada_95;
1231 @end smallexample
1233 @noindent
1234 A configuration pragma that establishes Ada 95 mode for the unit to which
1235 it applies, regardless of the mode set by the command line switches.
1236 This mode is set automatically for the @code{Ada} and @code{System}
1237 packages and their children, so you need not specify it in these
1238 contexts.  This pragma is useful when writing a reusable component that
1239 itself uses Ada 95 features, but which is intended to be usable from
1240 either Ada 83 or Ada 95 programs.
1242 @node Pragma Ada_05
1243 @unnumberedsec Pragma Ada_05
1244 @findex Ada_05
1245 @noindent
1246 Syntax:
1247 @smallexample @c ada
1248 pragma Ada_05;
1249 pragma Ada_05 (local_NAME);
1250 @end smallexample
1252 @noindent
1253 A configuration pragma that establishes Ada 2005 mode for the unit to which
1254 it applies, regardless of the mode set by the command line switches.
1255 This pragma is useful when writing a reusable component that
1256 itself uses Ada 2005 features, but which is intended to be usable from
1257 either Ada 83 or Ada 95 programs.
1259 The one argument form (which is not a configuration pragma)
1260 is used for managing the transition from
1261 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
1262 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
1263 mode will generate a warning. In addition, in Ada_83 or Ada_95
1264 mode, a preference rule is established which does not choose
1265 such an entity unless it is unambiguously specified. This avoids
1266 extra subprograms marked this way from generating ambiguities in
1267 otherwise legal pre-Ada_2005 programs. The one argument form is
1268 intended for exclusive use in the GNAT run-time library.
1270 @node Pragma Ada_2005
1271 @unnumberedsec Pragma Ada_2005
1272 @findex Ada_2005
1273 @noindent
1274 Syntax:
1275 @smallexample @c ada
1276 pragma Ada_2005;
1277 @end smallexample
1279 @noindent
1280 This configuration pragma is a synonym for pragma Ada_05 and has the
1281 same syntax and effect.
1283 @node Pragma Ada_12
1284 @unnumberedsec Pragma Ada_12
1285 @findex Ada_12
1286 @noindent
1287 Syntax:
1288 @smallexample @c ada
1289 pragma Ada_12;
1290 pragma Ada_12 (local_NAME);
1291 @end smallexample
1293 @noindent
1294 A configuration pragma that establishes Ada 2012 mode for the unit to which
1295 it applies, regardless of the mode set by the command line switches.
1296 This mode is set automatically for the @code{Ada} and @code{System}
1297 packages and their children, so you need not specify it in these
1298 contexts.  This pragma is useful when writing a reusable component that
1299 itself uses Ada 2012 features, but which is intended to be usable from
1300 Ada 83, Ada 95, or Ada 2005 programs.
1302 The one argument form, which is not a configuration pragma,
1303 is used for managing the transition from Ada
1304 2005 to Ada 2012 in the run-time library. If an entity is marked
1305 as Ada_201 only, then referencing the entity in any pre-Ada_2012
1306 mode will generate a warning. In addition, in any pre-Ada_2012
1307 mode, a preference rule is established which does not choose
1308 such an entity unless it is unambiguously specified. This avoids
1309 extra subprograms marked this way from generating ambiguities in
1310 otherwise legal pre-Ada_2012 programs. The one argument form is
1311 intended for exclusive use in the GNAT run-time library.
1313 @node Pragma Ada_2012
1314 @unnumberedsec Pragma Ada_2012
1315 @findex Ada_2005
1316 @noindent
1317 Syntax:
1318 @smallexample @c ada
1319 pragma Ada_2012;
1320 @end smallexample
1322 @noindent
1323 This configuration pragma is a synonym for pragma Ada_12 and has the
1324 same syntax and effect.
1326 @node Pragma Allow_Integer_Address
1327 @unnumberedsec Pragma Allow_Integer_Address
1328 @findex Allow_Integer_Address
1329 @noindent
1330 Syntax:
1331 @smallexample @c ada
1332 pragma Allow_Integer_Address;
1333 @end smallexample
1335 @noindent
1336 In almost all versions of GNAT, @code{System.Address} is a private
1337 type in accordance with the implementation advice in the RM. This
1338 means that integer values,
1339 in particular integer literals, are not allowed as address values.
1340 If the configuration pragma
1341 @code{Allow_Integer_Address} is given, then integer expressions may
1342 be used anywhere a value of type @code{System.Address} is required.
1343 The effect is to introduce an implicit unchecked conversion from the
1344 integer value to type @code{System.Address}. The reverse case of using
1345 an address where an integer type is required is handled analogously.
1346 The following example compiles without errors:
1348 @smallexample @c ada
1349 pragma Allow_Integer_Address;
1350 with System; use System;
1351 package AddrAsInt is
1352    X : Integer;
1353    Y : Integer;
1354    for X'Address use 16#1240#;
1355    for Y use at 16#3230#;
1356    m : Address := 16#4000#;
1357    n : constant Address := 4000;
1358    p : constant Address := Address (X + Y);
1359    v : Integer := y'Address;
1360    w : constant Integer := Integer (Y'Address);
1361    type R is new integer;
1362    RR : R := 1000;
1363    Z : Integer;
1364    for Z'Address use RR;
1365 end AddrAsInt;
1366 @end smallexample
1368 @noindent
1369 Note that pragma @code{Allow_Integer_Address} is ignored if
1370 @code{System.Address}
1371 is not a private type. In implementations of @code{GNAT} where
1372 System.Address is a visible integer type (notably the implementations
1373 for @code{OpenVMS}), this pragma serves no purpose but is ignored
1374 rather than rejected to allow common sets of sources to be used
1375 in the two situations.
1377 @node Pragma Annotate
1378 @unnumberedsec Pragma Annotate
1379 @findex Annotate
1380 @noindent
1381 Syntax:
1382 @smallexample @c ada
1383 pragma Annotate (IDENTIFIER [, IDENTIFIER @{, ARG@}] [, entity => local_NAME]);
1385 ARG ::= NAME | EXPRESSION
1386 @end smallexample
1388 @noindent
1389 This pragma is used to annotate programs.  @var{identifier} identifies
1390 the type of annotation.  GNAT verifies that it is an identifier, but does
1391 not otherwise analyze it. The second optional identifier is also left
1392 unanalyzed, and by convention is used to control the action of the tool to
1393 which the annotation is addressed.  The remaining @var{arg} arguments
1394 can be either string literals or more generally expressions.
1395 String literals are assumed to be either of type
1396 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1397 depending on the character literals they contain.
1398 All other kinds of arguments are analyzed as expressions, and must be
1399 unambiguous. The last argument if present must have the identifier
1400 @code{Entity} and GNAT verifies that a local name is given.
1402 The analyzed pragma is retained in the tree, but not otherwise processed
1403 by any part of the GNAT compiler, except to generate corresponding note
1404 lines in the generated ALI file. For the format of these note lines, see
1405 the compiler source file lib-writ.ads. This pragma is intended for use by
1406 external tools, including ASIS@. The use of pragma Annotate does not
1407 affect the compilation process in any way. This pragma may be used as
1408 a configuration pragma.
1410 @node Pragma Assert
1411 @unnumberedsec Pragma Assert
1412 @findex Assert
1413 @noindent
1414 Syntax:
1415 @smallexample @c ada
1416 pragma Assert (
1417   boolean_EXPRESSION
1418   [, string_EXPRESSION]);
1419 @end smallexample
1421 @noindent
1422 The effect of this pragma depends on whether the corresponding command
1423 line switch is set to activate assertions.  The pragma expands into code
1424 equivalent to the following:
1426 @smallexample @c ada
1427 if assertions-enabled then
1428    if not boolean_EXPRESSION then
1429       System.Assertions.Raise_Assert_Failure
1430         (string_EXPRESSION);
1431    end if;
1432 end if;
1433 @end smallexample
1435 @noindent
1436 The string argument, if given, is the message that will be associated
1437 with the exception occurrence if the exception is raised.  If no second
1438 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1439 where @var{file} is the name of the source file containing the assert,
1440 and @var{nnn} is the line number of the assert.  A pragma is not a
1441 statement, so if a statement sequence contains nothing but a pragma
1442 assert, then a null statement is required in addition, as in:
1444 @smallexample @c ada
1445 @dots{}
1446 if J > 3 then
1447    pragma Assert (K > 3, "Bad value for K");
1448    null;
1449 end if;
1450 @end smallexample
1452 @noindent
1453 Note that, as with the @code{if} statement to which it is equivalent, the
1454 type of the expression is either @code{Standard.Boolean}, or any type derived
1455 from this standard type.
1457 Assert checks can be either checked or ignored. By default they are ignored.
1458 They will be checked if either the command line switch @option{-gnata} is
1459 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1460 to enable @code{Assert_Checks}.
1462 If assertions are ignored, then there
1463 is no run-time effect (and in particular, any side effects from the
1464 expression will not occur at run time).  (The expression is still
1465 analyzed at compile time, and may cause types to be frozen if they are
1466 mentioned here for the first time).
1468 If assertions are checked, then the given expression is tested, and if
1469 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1470 which results in the raising of @code{Assert_Failure} with the given message.
1472 You should generally avoid side effects in the expression arguments of
1473 this pragma, because these side effects will turn on and off with the
1474 setting of the assertions mode, resulting in assertions that have an
1475 effect on the program.  However, the expressions are analyzed for
1476 semantic correctness whether or not assertions are enabled, so turning
1477 assertions on and off cannot affect the legality of a program.
1479 Note that the implementation defined policy @code{DISABLE}, given in a
1480 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1482 Note: this is a standard language-defined pragma in versions
1483 of Ada from 2005 on. In GNAT, it is implemented in all versions
1484 of Ada, and the DISABLE policy is an implementation-defined
1485 addition.
1487 @node Pragma Assert_And_Cut
1488 @unnumberedsec Pragma Assert_And_Cut
1489 @findex Assert_And_Cut
1490 @noindent
1491 Syntax:
1492 @smallexample @c ada
1493 pragma Assert_And_Cut (
1494   boolean_EXPRESSION
1495   [, string_EXPRESSION]);
1496 @end smallexample
1498 @noindent
1499 The effect of this pragma is identical to that of pragma @code{Assert},
1500 except that in an @code{Assertion_Policy} pragma, the identifier
1501 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1502 (or disabled).
1504 The intention is that this be used within a subprogram when the
1505 given test expresion sums up all the work done so far in the
1506 subprogram, so that the rest of the subprogram can be verified
1507 (informally or formally) using only the entry preconditions,
1508 and the expression in this pragma. This allows dividing up
1509 a subprogram into sections for the purposes of testing or
1510 formal verification. The pragma also serves as useful
1511 documentation.
1513 @node Pragma Assertion_Policy
1514 @unnumberedsec Pragma Assertion_Policy
1515 @findex Assertion_Policy
1516 @noindent
1517 Syntax:
1518 @smallexample @c ada
1519 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1521 pragma Assertion_Policy (
1522     ASSERTION_KIND => POLICY_IDENTIFIER
1523  @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1525 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1527 RM_ASSERTION_KIND ::= Assert               |
1528                       Static_Predicate     |
1529                       Dynamic_Predicate    |
1530                       Pre                  |
1531                       Pre'Class            |
1532                       Post                 |
1533                       Post'Class           |
1534                       Type_Invariant       |
1535                       Type_Invariant'Class
1537 ID_ASSERTION_KIND ::= Assertions           |
1538                       Assert_And_Cut       |
1539                       Assume               |
1540                       Contract_Cases       |
1541                       Debug                |
1542                       Invariant            |
1543                       Invariant'Class      |
1544                       Loop_Invariant       |
1545                       Loop_Variant         |
1546                       Postcondition        |
1547                       Precondition         |
1548                       Predicate            |
1549                       Refined_Post         |
1550                       Statement_Assertions
1552 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1553 @end smallexample
1555 @noindent
1556 This is a standard Ada 2012 pragma that is available as an
1557 implementation-defined pragma in earlier versions of Ada.
1558 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1559 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1560 are implementation defined additions recognized by the GNAT compiler.
1562 The pragma applies in both cases to pragmas and aspects with matching
1563 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1564 applies to both the @code{Precondition} pragma
1565 and the aspect @code{Precondition}. Note that the identifiers for
1566 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
1567 Pre_Class and Post_Class), since these pragmas are intended to be
1568 identical to the corresponding aspects).
1570 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1571 the corresponding pragma or aspect is activated.
1572 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1573 the corresponding pragma or aspect is deactivated.
1574 This pragma overrides the effect of the @option{-gnata} switch on the
1575 command line.
1577 The implementation defined policy @code{DISABLE} is like
1578 @code{IGNORE} except that it completely disables semantic
1579 checking of the corresponding pragma or aspect. This is
1580 useful when the pragma or aspect argument references subprograms
1581 in a with'ed package which is replaced by a dummy package
1582 for the final build.
1584 The implementation defined assertion kind @code{Assertions} applies to all
1585 assertion kinds. The form with no assertion kind given implies this
1586 choice, so it applies to all assertion kinds (RM defined, and
1587 implementation defined).
1589 The implementation defined assertion kind @code{Statement_Assertions}
1590 applies to @code{Assert}, @code{Assert_And_Cut},
1591 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
1593 @node Pragma Assume
1594 @unnumberedsec Pragma Assume
1595 @findex Assume
1596 @noindent
1597 Syntax:
1598 @smallexample @c ada
1599 pragma Assume (
1600   boolean_EXPRESSION
1601   [, string_EXPRESSION]);
1602 @end smallexample
1604 @noindent
1605 The effect of this pragma is identical to that of pragma @code{Assert},
1606 except that in an @code{Assertion_Policy} pragma, the identifier
1607 @code{Assume} is used to control whether it is ignored or checked
1608 (or disabled).
1610 The intention is that this be used for assumptions about the
1611 external environment. So you cannot expect to verify formally
1612 or informally that the condition is met, this must be
1613 established by examining things outside the program itself.
1614 For example, we may have code that depends on the size of
1615 @code{Long_Long_Integer} being at least 64. So we could write:
1617 @smallexample @c ada
1618 pragma Assume (Long_Long_Integer'Size >= 64);
1619 @end smallexample
1621 @noindent
1622 This assumption cannot be proved from the program itself,
1623 but it acts as a useful run-time check that the assumption
1624 is met, and documents the need to ensure that it is met by
1625 reference to information outside the program.
1627 @node Pragma Assume_No_Invalid_Values
1628 @unnumberedsec Pragma Assume_No_Invalid_Values
1629 @findex Assume_No_Invalid_Values
1630 @cindex Invalid representations
1631 @cindex Invalid values
1632 @noindent
1633 Syntax:
1634 @smallexample @c ada
1635 pragma Assume_No_Invalid_Values (On | Off);
1636 @end smallexample
1638 @noindent
1639 This is a configuration pragma that controls the assumptions made by the
1640 compiler about the occurrence of invalid representations (invalid values)
1641 in the code.
1643 The default behavior (corresponding to an Off argument for this pragma), is
1644 to assume that values may in general be invalid unless the compiler can
1645 prove they are valid. Consider the following example:
1647 @smallexample @c ada
1648 V1 : Integer range 1 .. 10;
1649 V2 : Integer range 11 .. 20;
1651 for J in V2 .. V1 loop
1652    ...
1653 end loop;
1654 @end smallexample
1656 @noindent
1657 if V1 and V2 have valid values, then the loop is known at compile
1658 time not to execute since the lower bound must be greater than the
1659 upper bound. However in default mode, no such assumption is made,
1660 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1661 is given, the compiler will assume that any occurrence of a variable
1662 other than in an explicit @code{'Valid} test always has a valid
1663 value, and the loop above will be optimized away.
1665 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1666 you know your code is free of uninitialized variables and other
1667 possible sources of invalid representations, and may result in
1668 more efficient code. A program that accesses an invalid representation
1669 with this pragma in effect is erroneous, so no guarantees can be made
1670 about its behavior.
1672 It is peculiar though permissible to use this pragma in conjunction
1673 with validity checking (-gnatVa). In such cases, accessing invalid
1674 values will generally give an exception, though formally the program
1675 is erroneous so there are no guarantees that this will always be the
1676 case, and it is recommended that these two options not be used together.
1678 @node Pragma Async_Readers
1679 @unnumberedsec Pragma Async_Readers
1680 @findex Async_Readers
1681 @noindent
1682 For the description of this pragma, see SPARK 2014 Reference Manual,
1683 section 7.1.2.
1685 @node Pragma Async_Writers
1686 @unnumberedsec Pragma Async_Writers
1687 @findex Async_Writers
1688 @noindent
1689 For the description of this pragma, see SPARK 2014 Reference Manual,
1690 section 7.1.2.
1692 @node Pragma AST_Entry
1693 @unnumberedsec Pragma AST_Entry
1694 @cindex OpenVMS
1695 @findex AST_Entry
1696 @noindent
1697 Syntax:
1698 @smallexample @c ada
1699 pragma AST_Entry (entry_IDENTIFIER);
1700 @end smallexample
1702 @noindent
1703 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1704 argument is the simple name of a single entry; at most one @code{AST_Entry}
1705 pragma is allowed for any given entry.  This pragma must be used in
1706 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1707 the entry declaration and in the same task type specification or single task
1708 as the entry to which it applies.  This pragma specifies that the given entry
1709 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1710 resulting from an OpenVMS system service call.  The pragma does not affect
1711 normal use of the entry.  For further details on this pragma, see the
1712 DEC Ada Language Reference Manual, section 9.12a.
1714 @node Pragma Attribute_Definition
1715 @unnumberedsec Pragma Attribute_Definition
1716 @findex Attribute_Definition
1717 @noindent
1718 Syntax:
1719 @smallexample @c ada
1720 pragma Attribute_Definition
1721   ([Attribute  =>] ATTRIBUTE_DESIGNATOR,
1722    [Entity     =>] LOCAL_NAME,
1723    [Expression =>] EXPRESSION | NAME);
1724 @end smallexample
1726 @noindent
1727 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1728 the attribute definition clause:
1730 @smallexample @c ada
1731   for Entity'Attribute use Expression;
1732 @end smallexample
1734 If @code{Attribute} is not a recognized attribute name, the pragma is
1735 ignored, and a warning is emitted. This allows source
1736 code to be written that takes advantage of some new attribute, while remaining
1737 compilable with earlier compilers.
1739 @node Pragma C_Pass_By_Copy
1740 @unnumberedsec Pragma C_Pass_By_Copy
1741 @cindex Passing by copy
1742 @findex C_Pass_By_Copy
1743 @noindent
1744 Syntax:
1745 @smallexample @c ada
1746 pragma C_Pass_By_Copy
1747   ([Max_Size =>] static_integer_EXPRESSION);
1748 @end smallexample
1750 @noindent
1751 Normally the default mechanism for passing C convention records to C
1752 convention subprograms is to pass them by reference, as suggested by RM
1753 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1754 this default, by requiring that record formal parameters be passed by
1755 copy if all of the following conditions are met:
1757 @itemize @bullet
1758 @item
1759 The size of the record type does not exceed the value specified for
1760 @code{Max_Size}.
1761 @item
1762 The record type has @code{Convention C}.
1763 @item
1764 The formal parameter has this record type, and the subprogram has a
1765 foreign (non-Ada) convention.
1766 @end itemize
1768 @noindent
1769 If these conditions are met the argument is passed by copy, i.e.@: in a
1770 manner consistent with what C expects if the corresponding formal in the
1771 C prototype is a struct (rather than a pointer to a struct).
1773 You can also pass records by copy by specifying the convention
1774 @code{C_Pass_By_Copy} for the record type, or by using the extended
1775 @code{Import} and @code{Export} pragmas, which allow specification of
1776 passing mechanisms on a parameter by parameter basis.
1778 @node Pragma Check
1779 @unnumberedsec Pragma Check
1780 @cindex Assertions
1781 @cindex Named assertions
1782 @findex Check
1783 @noindent
1784 Syntax:
1785 @smallexample @c ada
1786 pragma Check (
1787      [Name    =>] CHECK_KIND,
1788      [Check   =>] Boolean_EXPRESSION
1789   [, [Message =>] string_EXPRESSION] );
1791 CHECK_KIND ::= IDENTIFIER           |
1792                Pre'Class            |
1793                Post'Class           |
1794                Type_Invariant'Class |
1795                Invariant'Class
1796 @end smallexample
1798 @noindent
1799 This pragma is similar to the predefined pragma @code{Assert} except that an
1800 extra identifier argument is present. In conjunction with pragma
1801 @code{Check_Policy}, this can be used to define groups of assertions that can
1802 be independently controlled. The identifier @code{Assertion} is special, it
1803 refers to the normal set of pragma @code{Assert} statements.
1805 Checks introduced by this pragma are normally deactivated by default. They can
1806 be activated either by the command line option @option{-gnata}, which turns on
1807 all checks, or individually controlled using pragma @code{Check_Policy}.
1809 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1810 permitted as check kinds, since this would cause confusion with the use
1811 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1812 pragmas, where they are used to refer to sets of assertions.
1814 @node Pragma Check_Float_Overflow
1815 @unnumberedsec Pragma Check_Float_Overflow
1816 @cindex Floating-point overflow
1817 @findex Check_Float_Overflow
1818 @noindent
1819 Syntax:
1820 @smallexample @c ada
1821 pragma Check_Float_Overflow;
1822 @end smallexample
1824 @noindent
1825 In Ada, the predefined floating-point types (@code{Short_Float},
1826 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1827 defined to be @emph{unconstrained}. This means that even though each
1828 has a well-defined base range, an operation that delivers a result
1829 outside this base range is not required to raise an exception.
1830 This implementation permission accommodates the notion
1831 of infinities in IEEE floating-point, and corresponds to the
1832 efficient execution mode on most machines. GNAT will not raise
1833 overflow exceptions on these machines; instead it will generate
1834 infinities and NaN's as defined in the IEEE standard.
1836 Generating infinities, although efficient, is not always desirable.
1837 Often the preferable approach is to check for overflow, even at the
1838 (perhaps considerable) expense of run-time performance.
1839 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1840 range constraints -- and indeed such a subtype
1841 can have the same base range as its base type. For example:
1843 @smallexample @c ada
1844 subtype My_Float is Float range Float'Range;
1845 @end smallexample
1847 @noindent
1848 Here @code{My_Float} has the same range as
1849 @code{Float} but is constrained, so operations on
1850 @code{My_Float} values will be checked for overflow
1851 against this range.
1853 This style will achieve the desired goal, but
1854 it is often more convenient to be able to simply use
1855 the standard predefined floating-point types as long
1856 as overflow checking could be guaranteed.
1857 The @code{Check_Float_Overflow}
1858 configuration pragma achieves this effect. If a unit is compiled
1859 subject to this configuration pragma, then all operations
1860 on predefined floating-point types including operations on
1861 base types of these floating-point types will be treated as
1862 though those types were constrained, and overflow checks
1863 will be generated. The @code{Constraint_Error}
1864 exception is raised if the result is out of range.
1866 This mode can also be set by use of the compiler
1867 switch @option{-gnateF}.
1869 @node Pragma Check_Name
1870 @unnumberedsec Pragma Check_Name
1871 @cindex Defining check names
1872 @cindex Check names, defining
1873 @findex Check_Name
1874 @noindent
1875 Syntax:
1876 @smallexample @c ada
1877 pragma Check_Name (check_name_IDENTIFIER);
1878 @end smallexample
1880 @noindent
1881 This is a configuration pragma that defines a new implementation
1882 defined check name (unless IDENTIFIER matches one of the predefined
1883 check names, in which case the pragma has no effect). Check names
1884 are global to a partition, so if two or more configuration pragmas
1885 are present in a partition mentioning the same name, only one new
1886 check name is introduced.
1888 An implementation defined check name introduced with this pragma may
1889 be used in only three contexts: @code{pragma Suppress},
1890 @code{pragma Unsuppress},
1891 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1892 any of these three cases, the check name must be visible. A check
1893 name is visible if it is in the configuration pragmas applying to
1894 the current unit, or if it appears at the start of any unit that
1895 is part of the dependency set of the current unit (e.g., units that
1896 are mentioned in @code{with} clauses).
1898 Check names introduced by this pragma are subject to control by compiler
1899 switches (in particular -gnatp) in the usual manner.
1901 @node Pragma Check_Policy
1902 @unnumberedsec Pragma Check_Policy
1903 @cindex Controlling assertions
1904 @cindex Assertions, control
1905 @cindex Check pragma control
1906 @cindex Named assertions
1907 @findex Check
1908 @noindent
1909 Syntax:
1910 @smallexample @c ada
1911 pragma Check_Policy
1912  ([Name   =>] CHECK_KIND,
1913   [Policy =>] POLICY_IDENTIFIER);
1915 pragma Check_Policy (
1916     CHECK_KIND => POLICY_IDENTIFIER
1917  @{, CHECK_KIND => POLICY_IDENTIFIER@});
1919 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1921 CHECK_KIND ::= IDENTIFIER           |
1922                Pre'Class            |
1923                Post'Class           |
1924                Type_Invariant'Class |
1925                Invariant'Class
1927 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1928 avoids confusion between the two possible syntax forms for this pragma.
1930 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1931 @end smallexample
1933 @noindent
1934 This pragma is used to set the checking policy for assertions (specified
1935 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1936 to be checked using the @code{Check} pragma. It may appear either as
1937 a configuration pragma, or within a declarative part of package. In the
1938 latter case, it applies from the point where it appears to the end of
1939 the declarative region (like pragma @code{Suppress}).
1941 The @code{Check_Policy} pragma is similar to the
1942 predefined @code{Assertion_Policy} pragma,
1943 and if the check kind corresponds to one of the assertion kinds that
1944 are allowed by @code{Assertion_Policy}, then the effect is identical.
1946 If the first argument is Debug, then the policy applies to Debug pragmas,
1947 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1948 @code{IGNORE}, and allowing them to execute with normal semantics if
1949 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1950 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1951 be totally ignored and not analyzed semantically.
1953 Finally the first argument may be some other identifier than the above
1954 possibilities, in which case it controls a set of named assertions
1955 that can be checked using pragma @code{Check}. For example, if the pragma:
1957 @smallexample @c ada
1958 pragma Check_Policy (Critical_Error, OFF);
1959 @end smallexample
1961 @noindent
1962 is given, then subsequent @code{Check} pragmas whose first argument is also
1963 @code{Critical_Error} will be disabled.
1965 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1966 to turn on corresponding checks. The default for a set of checks for which no
1967 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1968 @option{-gnata} is given, which turns on all checks by default.
1970 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1971 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1972 compatibility with the standard @code{Assertion_Policy} pragma. The check
1973 policy setting @code{DISABLE} causes the second argument of a corresponding
1974 @code{Check} pragma to be completely ignored and not analyzed.
1976 @node Pragma CIL_Constructor
1977 @unnumberedsec Pragma CIL_Constructor
1978 @findex CIL_Constructor
1979 @noindent
1980 Syntax:
1982 @smallexample @c ada
1983 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1984 @end smallexample
1986 @noindent
1987 This pragma is used to assert that the specified Ada function should be
1988 mapped to the .NET constructor for some Ada tagged record type.
1990 See section 4.1 of the
1991 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1992 for related information.
1994 @node Pragma Comment
1995 @unnumberedsec Pragma Comment
1996 @findex Comment
1997 @noindent
1998 Syntax:
2000 @smallexample @c ada
2001 pragma Comment (static_string_EXPRESSION);
2002 @end smallexample
2004 @noindent
2005 This is almost identical in effect to pragma @code{Ident}.  It allows the
2006 placement of a comment into the object file and hence into the
2007 executable file if the operating system permits such usage.  The
2008 difference is that @code{Comment}, unlike @code{Ident}, has
2009 no limitations on placement of the pragma (it can be placed
2010 anywhere in the main source unit), and if more than one pragma
2011 is used, all comments are retained.
2013 @node Pragma Common_Object
2014 @unnumberedsec Pragma Common_Object
2015 @findex Common_Object
2016 @noindent
2017 Syntax:
2019 @smallexample @c ada
2020 pragma Common_Object (
2021      [Internal =>] LOCAL_NAME
2022   [, [External =>] EXTERNAL_SYMBOL]
2023   [, [Size     =>] EXTERNAL_SYMBOL] );
2025 EXTERNAL_SYMBOL ::=
2026   IDENTIFIER
2027 | static_string_EXPRESSION
2028 @end smallexample
2030 @noindent
2031 This pragma enables the shared use of variables stored in overlaid
2032 linker areas corresponding to the use of @code{COMMON}
2033 in Fortran.  The single
2034 object @var{LOCAL_NAME} is assigned to the area designated by
2035 the @var{External} argument.
2036 You may define a record to correspond to a series
2037 of fields.  The @var{Size} argument
2038 is syntax checked in GNAT, but otherwise ignored.
2040 @code{Common_Object} is not supported on all platforms.  If no
2041 support is available, then the code generator will issue a message
2042 indicating that the necessary attribute for implementation of this
2043 pragma is not available.
2045 @node Pragma Compile_Time_Error
2046 @unnumberedsec Pragma Compile_Time_Error
2047 @findex Compile_Time_Error
2048 @noindent
2049 Syntax:
2051 @smallexample @c ada
2052 pragma Compile_Time_Error
2053          (boolean_EXPRESSION, static_string_EXPRESSION);
2054 @end smallexample
2056 @noindent
2057 This pragma can be used to generate additional compile time
2058 error messages. It
2059 is particularly useful in generics, where errors can be issued for
2060 specific problematic instantiations. The first parameter is a boolean
2061 expression. The pragma is effective only if the value of this expression
2062 is known at compile time, and has the value True. The set of expressions
2063 whose values are known at compile time includes all static boolean
2064 expressions, and also other values which the compiler can determine
2065 at compile time (e.g., the size of a record type set by an explicit
2066 size representation clause, or the value of a variable which was
2067 initialized to a constant and is known not to have been modified).
2068 If these conditions are met, an error message is generated using
2069 the value given as the second argument. This string value may contain
2070 embedded ASCII.LF characters to break the message into multiple lines.
2072 @node Pragma Compile_Time_Warning
2073 @unnumberedsec Pragma Compile_Time_Warning
2074 @findex Compile_Time_Warning
2075 @noindent
2076 Syntax:
2078 @smallexample @c ada
2079 pragma Compile_Time_Warning
2080          (boolean_EXPRESSION, static_string_EXPRESSION);
2081 @end smallexample
2083 @noindent
2084 Same as pragma Compile_Time_Error, except a warning is issued instead
2085 of an error message. Note that if this pragma is used in a package that
2086 is with'ed by a client, the client will get the warning even though it
2087 is issued by a with'ed package (normally warnings in with'ed units are
2088 suppressed, but this is a special exception to that rule).
2090 One typical use is within a generic where compile time known characteristics
2091 of formal parameters are tested, and warnings given appropriately. Another use
2092 with a first parameter of True is to warn a client about use of a package,
2093 for example that it is not fully implemented.
2095 @node Pragma Compiler_Unit
2096 @unnumberedsec Pragma Compiler_Unit
2097 @findex Compiler_Unit
2098 @noindent
2099 Syntax:
2101 @smallexample @c ada
2102 pragma Compiler_Unit;
2103 @end smallexample
2105 @noindent
2106 This pragma is obsolete. It is equivalent to Compiler_Unit_Warning. It is
2107 retained so that old versions of the GNAT run-time that use this pragma can
2108 be compiled with newer versions of the compiler.
2110 @node Pragma Compiler_Unit_Warning
2111 @unnumberedsec Pragma Compiler_Unit_Warning
2112 @findex Compiler_Unit_Warning
2113 @noindent
2114 Syntax:
2116 @smallexample @c ada
2117 pragma Compiler_Unit_Warning;
2118 @end smallexample
2120 @noindent
2121 This pragma is intended only for internal use in the GNAT run-time library.
2122 It indicates that the unit is used as part of the compiler build. The effect
2123 is to generate warnings for the use of constructs (for example, conditional
2124 expressions) that would cause trouble when bootstrapping using an older
2125 version of GNAT. For the exact list of restrictions, see the compiler sources
2126 and references to Check_Compiler_Unit.
2128 @node Pragma Complete_Representation
2129 @unnumberedsec Pragma Complete_Representation
2130 @findex Complete_Representation
2131 @noindent
2132 Syntax:
2134 @smallexample @c ada
2135 pragma Complete_Representation;
2136 @end smallexample
2138 @noindent
2139 This pragma must appear immediately within a record representation
2140 clause. Typical placements are before the first component clause
2141 or after the last component clause. The effect is to give an error
2142 message if any component is missing a component clause. This pragma
2143 may be used to ensure that a record representation clause is
2144 complete, and that this invariant is maintained if fields are
2145 added to the record in the future.
2147 @node Pragma Complex_Representation
2148 @unnumberedsec Pragma Complex_Representation
2149 @findex Complex_Representation
2150 @noindent
2151 Syntax:
2153 @smallexample @c ada
2154 pragma Complex_Representation
2155         ([Entity =>] LOCAL_NAME);
2156 @end smallexample
2158 @noindent
2159 The @var{Entity} argument must be the name of a record type which has
2160 two fields of the same floating-point type.  The effect of this pragma is
2161 to force gcc to use the special internal complex representation form for
2162 this record, which may be more efficient.  Note that this may result in
2163 the code for this type not conforming to standard ABI (application
2164 binary interface) requirements for the handling of record types.  For
2165 example, in some environments, there is a requirement for passing
2166 records by pointer, and the use of this pragma may result in passing
2167 this type in floating-point registers.
2169 @node Pragma Component_Alignment
2170 @unnumberedsec Pragma Component_Alignment
2171 @cindex Alignments of components
2172 @findex Component_Alignment
2173 @noindent
2174 Syntax:
2176 @smallexample @c ada
2177 pragma Component_Alignment (
2178      [Form =>] ALIGNMENT_CHOICE
2179   [, [Name =>] type_LOCAL_NAME]);
2181 ALIGNMENT_CHOICE ::=
2182   Component_Size
2183 | Component_Size_4
2184 | Storage_Unit
2185 | Default
2186 @end smallexample
2188 @noindent
2189 Specifies the alignment of components in array or record types.
2190 The meaning of the @var{Form} argument is as follows:
2192 @table @code
2193 @findex Component_Size
2194 @item Component_Size
2195 Aligns scalar components and subcomponents of the array or record type
2196 on boundaries appropriate to their inherent size (naturally
2197 aligned).  For example, 1-byte components are aligned on byte boundaries,
2198 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2199 integer components are aligned on 4-byte boundaries and so on.  These
2200 alignment rules correspond to the normal rules for C compilers on all
2201 machines except the VAX@.
2203 @findex Component_Size_4
2204 @item Component_Size_4
2205 Naturally aligns components with a size of four or fewer
2206 bytes.  Components that are larger than 4 bytes are placed on the next
2207 4-byte boundary.
2209 @findex Storage_Unit
2210 @item Storage_Unit
2211 Specifies that array or record components are byte aligned, i.e.@:
2212 aligned on boundaries determined by the value of the constant
2213 @code{System.Storage_Unit}.
2215 @cindex OpenVMS
2216 @item Default
2217 Specifies that array or record components are aligned on default
2218 boundaries, appropriate to the underlying hardware or operating system or
2219 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
2220 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
2221 the @code{Default} choice is the same as @code{Component_Size} (natural
2222 alignment).
2223 @end table
2225 @noindent
2226 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2227 refer to a local record or array type, and the specified alignment
2228 choice applies to the specified type.  The use of
2229 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2230 @code{Component_Alignment} pragma to be ignored.  The use of
2231 @code{Component_Alignment} together with a record representation clause
2232 is only effective for fields not specified by the representation clause.
2234 If the @code{Name} parameter is absent, the pragma can be used as either
2235 a configuration pragma, in which case it applies to one or more units in
2236 accordance with the normal rules for configuration pragmas, or it can be
2237 used within a declarative part, in which case it applies to types that
2238 are declared within this declarative part, or within any nested scope
2239 within this declarative part.  In either case it specifies the alignment
2240 to be applied to any record or array type which has otherwise standard
2241 representation.
2243 If the alignment for a record or array type is not specified (using
2244 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2245 clause), the GNAT uses the default alignment as described previously.
2247 @node Pragma Contract_Cases
2248 @unnumberedsec Pragma Contract_Cases
2249 @cindex Contract cases
2250 @findex Contract_Cases
2251 @noindent
2252 Syntax:
2254 @smallexample @c ada
2255 pragma Contract_Cases (
2256    Condition => Consequence
2257  @{,Condition => Consequence@});
2258 @end smallexample
2260 @noindent
2261 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2262 that can complement or replace the contract given by a precondition and a
2263 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2264 by testing and formal verification tools. The compiler checks its validity and,
2265 depending on the assertion policy at the point of declaration of the pragma,
2266 it may insert a check in the executable. For code generation, the contract
2267 cases
2269 @smallexample @c ada
2270 pragma Contract_Cases (
2271   Cond1 => Pred1,
2272   Cond2 => Pred2);
2273 @end smallexample
2275 @noindent
2276 are equivalent to
2278 @smallexample @c ada
2279 C1 : constant Boolean := Cond1;  --  evaluated at subprogram entry
2280 C2 : constant Boolean := Cond2;  --  evaluated at subprogram entry
2281 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2282 pragma Postcondition (if C1 then Pred1);
2283 pragma Postcondition (if C2 then Pred2);
2284 @end smallexample
2286 @noindent
2287 The precondition ensures that one and only one of the conditions is
2288 satisfied on entry to the subprogram.
2289 The postcondition ensures that for the condition that was True on entry,
2290 the corrresponding consequence is True on exit. Other consequence expressions
2291 are not evaluated.
2293 A precondition @code{P} and postcondition @code{Q} can also be
2294 expressed as contract cases:
2296 @smallexample @c ada
2297 pragma Contract_Cases (P => Q);
2298 @end smallexample
2300 The placement and visibility rules for @code{Contract_Cases} pragmas are
2301 identical to those described for preconditions and postconditions.
2303 The compiler checks that boolean expressions given in conditions and
2304 consequences are valid, where the rules for conditions are the same as
2305 the rule for an expression in @code{Precondition} and the rules for
2306 consequences are the same as the rule for an expression in
2307 @code{Postcondition}. In particular, attributes @code{'Old} and
2308 @code{'Result} can only be used within consequence expressions.
2309 The condition for the last contract case may be @code{others}, to denote
2310 any case not captured by the previous cases. The
2311 following is an example of use within a package spec:
2313 @smallexample @c ada
2314 package Math_Functions is
2315    ...
2316    function Sqrt (Arg : Float) return Float;
2317    pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2318                           Arg >= 100       => Sqrt'Result >= 10,
2319                           others           => Sqrt'Result = 0);
2320    ...
2321 end Math_Functions;
2322 @end smallexample
2324 @noindent
2325 The meaning of contract cases is that only one case should apply at each
2326 call, as determined by the corresponding condition evaluating to True,
2327 and that the consequence for this case should hold when the subprogram
2328 returns.
2330 @node Pragma Convention_Identifier
2331 @unnumberedsec Pragma Convention_Identifier
2332 @findex Convention_Identifier
2333 @cindex Conventions, synonyms
2334 @noindent
2335 Syntax:
2337 @smallexample @c ada
2338 pragma Convention_Identifier (
2339          [Name =>]       IDENTIFIER,
2340          [Convention =>] convention_IDENTIFIER);
2341 @end smallexample
2343 @noindent
2344 This pragma provides a mechanism for supplying synonyms for existing
2345 convention identifiers. The @code{Name} identifier can subsequently
2346 be used as a synonym for the given convention in other pragmas (including
2347 for example pragma @code{Import} or another @code{Convention_Identifier}
2348 pragma). As an example of the use of this, suppose you had legacy code
2349 which used Fortran77 as the identifier for Fortran. Then the pragma:
2351 @smallexample @c ada
2352 pragma Convention_Identifier (Fortran77, Fortran);
2353 @end smallexample
2355 @noindent
2356 would allow the use of the convention identifier @code{Fortran77} in
2357 subsequent code, avoiding the need to modify the sources. As another
2358 example, you could use this to parameterize convention requirements
2359 according to systems. Suppose you needed to use @code{Stdcall} on
2360 windows systems, and @code{C} on some other system, then you could
2361 define a convention identifier @code{Library} and use a single
2362 @code{Convention_Identifier} pragma to specify which convention
2363 would be used system-wide.
2365 @node Pragma CPP_Class
2366 @unnumberedsec Pragma CPP_Class
2367 @findex CPP_Class
2368 @cindex Interfacing with C++
2369 @noindent
2370 Syntax:
2372 @smallexample @c ada
2373 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2374 @end smallexample
2376 @noindent
2377 The argument denotes an entity in the current declarative region that is
2378 declared as a record type. It indicates that the type corresponds to an
2379 externally declared C++ class type, and is to be laid out the same way
2380 that C++ would lay out the type. If the C++ class has virtual primitives
2381 then the record must be declared as a tagged record type.
2383 Types for which @code{CPP_Class} is specified do not have assignment or
2384 equality operators defined (such operations can be imported or declared
2385 as subprograms as required). Initialization is allowed only by constructor
2386 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2387 limited if not explicitly declared as limited or derived from a limited
2388 type, and an error is issued in that case.
2390 See @ref{Interfacing to C++} for related information.
2392 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2393 for backward compatibility but its functionality is available
2394 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2396 @node Pragma CPP_Constructor
2397 @unnumberedsec Pragma CPP_Constructor
2398 @cindex Interfacing with C++
2399 @findex CPP_Constructor
2400 @noindent
2401 Syntax:
2403 @smallexample @c ada
2404 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2405   [, [External_Name =>] static_string_EXPRESSION ]
2406   [, [Link_Name     =>] static_string_EXPRESSION ]);
2407 @end smallexample
2409 @noindent
2410 This pragma identifies an imported function (imported in the usual way
2411 with pragma @code{Import}) as corresponding to a C++ constructor. If
2412 @code{External_Name} and @code{Link_Name} are not specified then the
2413 @code{Entity} argument is a name that must have been previously mentioned
2414 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2415 must be of one of the following forms:
2417 @itemize @bullet
2418 @item
2419 @code{function @var{Fname} return @var{T}}
2421 @itemize @bullet
2422 @item
2423 @code{function @var{Fname} return @var{T}'Class}
2425 @item
2426 @code{function @var{Fname} (@dots{}) return @var{T}}
2427 @end itemize
2429 @item
2430 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2431 @end itemize
2433 @noindent
2434 where @var{T} is a limited record type imported from C++ with pragma
2435 @code{Import} and @code{Convention} = @code{CPP}.
2437 The first two forms import the default constructor, used when an object
2438 of type @var{T} is created on the Ada side with no explicit constructor.
2439 The latter two forms cover all the non-default constructors of the type.
2440 See the @value{EDITION} User's Guide for details.
2442 If no constructors are imported, it is impossible to create any objects
2443 on the Ada side and the type is implicitly declared abstract.
2445 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2446 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2447 GCC switch).
2448 See @ref{Interfacing to C++} for more related information.
2450 Note: The use of functions returning class-wide types for constructors is
2451 currently obsolete. They are supported for backward compatibility. The
2452 use of functions returning the type T leave the Ada sources more clear
2453 because the imported C++ constructors always return an object of type T;
2454 that is, they never return an object whose type is a descendant of type T.
2456 @node Pragma CPP_Virtual
2457 @unnumberedsec Pragma CPP_Virtual
2458 @cindex Interfacing to C++
2459 @findex CPP_Virtual
2460 @noindent
2461 This pragma is now obsolete and, other than generating a warning if warnings
2462 on obsolescent features are enabled, is completely ignored.
2463 It is retained for compatibility
2464 purposes. It used to be required to ensure compoatibility with C++, but
2465 is no longer required for that purpose because GNAT generates
2466 the same object layout as the G++ compiler by default.
2468 See @ref{Interfacing to C++} for related information.
2470 @node Pragma CPP_Vtable
2471 @unnumberedsec Pragma CPP_Vtable
2472 @cindex Interfacing with C++
2473 @findex CPP_Vtable
2474 @noindent
2475 This pragma is now obsolete and, other than generating a warning if warnings
2476 on obsolescent features are enabled, is completely ignored.
2477 It used to be required to ensure compatibility with C++, but
2478 is no longer required for that purpose because GNAT generates
2479 the same object layout as the G++ compiler by default.
2481 See @ref{Interfacing to C++} for related information.
2483 @node Pragma CPU
2484 @unnumberedsec Pragma CPU
2485 @findex CPU
2486 @noindent
2487 Syntax:
2489 @smallexample @c ada
2490 pragma CPU (EXPRESSION);
2491 @end smallexample
2493 @noindent
2494 This pragma is standard in Ada 2012, but is available in all earlier
2495 versions of Ada as an implementation-defined pragma.
2496 See Ada 2012 Reference Manual for details.
2498 @node Pragma Debug
2499 @unnumberedsec Pragma Debug
2500 @findex Debug
2501 @noindent
2502 Syntax:
2504 @smallexample @c ada
2505 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2507 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2508   PROCEDURE_NAME
2509 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2510 @end smallexample
2512 @noindent
2513 The procedure call argument has the syntactic form of an expression, meeting
2514 the syntactic requirements for pragmas.
2516 If debug pragmas are not enabled or if the condition is present and evaluates
2517 to False, this pragma has no effect. If debug pragmas are enabled, the
2518 semantics of the pragma is exactly equivalent to the procedure call statement
2519 corresponding to the argument with a terminating semicolon. Pragmas are
2520 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2521 intersperse calls to debug procedures in the middle of declarations. Debug
2522 pragmas can be enabled either by use of the command line switch @option{-gnata}
2523 or by use of the pragma @code{Check_Policy} with a first argument of
2524 @code{Debug}.
2526 @node Pragma Debug_Policy
2527 @unnumberedsec Pragma Debug_Policy
2528 @findex Debug_Policy
2529 @noindent
2530 Syntax:
2532 @smallexample @c ada
2533 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2534 @end smallexample
2536 @noindent
2537 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2538 with a first argument of @code{Debug}. It is retained for historical
2539 compatibility reasons.
2541 @node Pragma Default_Scalar_Storage_Order
2542 @unnumberedsec Pragma Default_Scalar_Storage_Order
2543 @cindex Default_Scalar_Storage_Order
2544 @cindex Scalar_Storage_Order
2545 @findex Default_Scalar_Storage_Order
2546 @noindent
2547 Syntax:
2549 @smallexample @c ada
2550 pragma Default_Scalar_Storage_Order (High_Order_First | Low_Order_First);
2551 @end smallexample
2553 @noindent
2554 Normally if no explicit @code{Scalar_Storage_Order} is given for a record
2555 type or array type, then the scalar storage order defaults to the ordinary
2556 default for the target. But this default may be overridden using this pragma.
2557 The pragma may appear as a configuration pragma, or locally within a package
2558 spec or declarative part. In the latter case, it applies to all subsequent
2559 types declared within that package spec or declarative part.
2561 If this pragma is used as a configuration pragma which appears within a
2562 configuration pragma file (as opposed to appearing explicitly at the start
2563 of a single unit), then the binder will require that all units in a partition
2564 be compiled in a similar manner, other than run-time units, which are not
2565 affected by this pragma.
2567 The following example shows the use of this pragma:
2569 @smallexample @c ada
2570 pragma Default_Scalar_Storage_Order (High_Order_First);
2571 with System; use System;
2572 package DSSO1 is
2573    type H1 is record
2574       a : Integer;
2575    end record;
2577    type L2 is record
2578       a : Integer;
2579    end record;
2580    for L2'Scalar_Storage_Order use Low_Order_First;
2582    type L2a is new L2;
2584    package Inner is
2585       type H3 is record
2586          a : Integer;
2587       end record;
2589       pragma Default_Scalar_Storage_Order (Low_Order_First);
2591       type L4 is record
2592          a : Integer;
2593       end record;
2594    end Inner;
2596    type H4a is new Inner.L4;
2598    type H5 is record
2599       a : Integer;
2600    end record;
2601 end DSSO1;
2602 @end smallexample
2604 @noindent
2605 In this example record types L.. have @code{Low_Order_First} scalar
2606 storage order, and record types H.. have @code{High_Order_First}.
2607 Note that in the case of @code{H4a}, the order is not inherited
2608 from the parent type. Only an explicitly set @code{Scalar_Storage_Order}
2609 gets inherited on type derivation.
2611 @node Pragma Default_Storage_Pool
2612 @unnumberedsec Pragma Default_Storage_Pool
2613 @cindex Default_Storage_Pool
2614 @findex Default_Storage_Pool
2615 @noindent
2616 Syntax:
2618 @smallexample @c ada
2619 pragma Default_Storage_Pool (storage_pool_NAME | null);
2620 @end smallexample
2622 @noindent
2623 This pragma is standard in Ada 2012, but is available in all earlier
2624 versions of Ada as an implementation-defined pragma.
2625 See Ada 2012 Reference Manual for details.
2627 @node Pragma Depends
2628 @unnumberedsec Pragma Depends
2629 @findex Depends
2630 @noindent
2631 For the description of this pragma, see SPARK 2014 Reference Manual,
2632 section 6.1.5.
2634 @node Pragma Detect_Blocking
2635 @unnumberedsec Pragma Detect_Blocking
2636 @findex Detect_Blocking
2637 @noindent
2638 Syntax:
2640 @smallexample @c ada
2641 pragma Detect_Blocking;
2642 @end smallexample
2644 @noindent
2645 This is a standard pragma in Ada 2005, that is available in all earlier
2646 versions of Ada as an implementation-defined pragma.
2648 This is a configuration pragma that forces the detection of potentially
2649 blocking operations within a protected operation, and to raise Program_Error
2650 if that happens.
2652 @node Pragma Disable_Atomic_Synchronization
2653 @unnumberedsec Pragma Disable_Atomic_Synchronization
2654 @cindex Atomic Synchronization
2655 @findex Disable_Atomic_Synchronization
2656 @noindent
2657 Syntax:
2659 @smallexample @c ada
2660 pragma Disable_Atomic_Synchronization [(Entity)];
2661 @end smallexample
2663 @noindent
2664 Ada requires that accesses (reads or writes) of an atomic variable be
2665 regarded as synchronization points in the case of multiple tasks.
2666 Particularly in the case of multi-processors this may require special
2667 handling, e.g. the generation of memory barriers. This capability may
2668 be turned off using this pragma in cases where it is known not to be
2669 required.
2671 The placement and scope rules for this pragma are the same as those
2672 for @code{pragma Suppress}. In particular it can be used as a
2673 configuration  pragma, or in a declaration sequence where it applies
2674 till the end of the scope. If an @code{Entity} argument is present,
2675 the action applies only to that entity.
2677 @node Pragma Dispatching_Domain
2678 @unnumberedsec Pragma Dispatching_Domain
2679 @findex Dispatching_Domain
2680 @noindent
2681 Syntax:
2683 @smallexample @c ada
2684 pragma Dispatching_Domain (EXPRESSION);
2685 @end smallexample
2687 @noindent
2688 This pragma is standard in Ada 2012, but is available in all earlier
2689 versions of Ada as an implementation-defined pragma.
2690 See Ada 2012 Reference Manual for details.
2692 @node Pragma Effective_Reads
2693 @unnumberedsec Pragma Effective_Reads
2694 @findex Effective_Reads
2695 @noindent
2696 For the description of this pragma, see SPARK 2014 Reference Manual,
2697 section 7.1.2.
2699 @node Pragma Effective_Writes
2700 @unnumberedsec Pragma Effective_Writes
2701 @findex Effective_Writes
2702 @noindent
2703 For the description of this pragma, see SPARK 2014 Reference Manual,
2704 section 7.1.2.
2706 @node Pragma Elaboration_Checks
2707 @unnumberedsec Pragma Elaboration_Checks
2708 @cindex Elaboration control
2709 @findex Elaboration_Checks
2710 @noindent
2711 Syntax:
2713 @smallexample @c ada
2714 pragma Elaboration_Checks (Dynamic | Static);
2715 @end smallexample
2717 @noindent
2718 This is a configuration pragma that provides control over the
2719 elaboration model used by the compilation affected by the
2720 pragma.  If the parameter is @code{Dynamic},
2721 then the dynamic elaboration
2722 model described in the Ada Reference Manual is used, as though
2723 the @option{-gnatE} switch had been specified on the command
2724 line.  If the parameter is @code{Static}, then the default GNAT static
2725 model is used.  This configuration pragma overrides the setting
2726 of the command line.  For full details on the elaboration models
2727 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2728 gnat_ugn, @value{EDITION} User's Guide}.
2730 @node Pragma Eliminate
2731 @unnumberedsec Pragma Eliminate
2732 @cindex Elimination of unused subprograms
2733 @findex Eliminate
2734 @noindent
2735 Syntax:
2737 @smallexample @c ada
2738 pragma Eliminate ([Entity          =>] DEFINING_DESIGNATOR,
2739                   [Source_Location =>] STRING_LITERAL);
2740 @end smallexample
2742 @noindent
2743 The string literal given for the source location is a string which
2744 specifies the line number of the occurrence of the entity, using
2745 the syntax for SOURCE_TRACE given below:
2747 @smallexample @c ada
2748  SOURCE_TRACE     ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2750  LBRACKET         ::= [
2751  RBRACKET         ::= ]
2753  SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2755  LINE_NUMBER      ::= DIGIT @{DIGIT@}
2756 @end smallexample
2758 @noindent
2759 Spaces around the colon in a @code{Source_Reference} are optional.
2761 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2762 explicit subprogram declaration, where the @code{entity} name in this
2763 designator appears on the source line specified by the source location.
2765 The source trace that is given as the @code{Source_Location} shall obey the
2766 following rules. The @code{FILE_NAME} is the short name (with no directory
2767 information) of an Ada source file, given using exactly the required syntax
2768 for the underlying file system (e.g. case is important if the underlying
2769 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2770 number of the occurrence of the @code{entity}
2771 as a decimal literal without an exponent or point. If an @code{entity} is not
2772 declared in a generic instantiation (this includes generic subprogram
2773 instances), the source trace includes only one source reference. If an entity
2774 is declared inside a generic instantiation, its source trace (when parsing
2775 from left to right) starts with the source location of the declaration of the
2776 entity in the generic unit and ends with the source location of the
2777 instantiation (it is given in square brackets). This approach is recursively
2778 used in case of nested instantiations: the rightmost (nested most deeply in
2779 square brackets) element of the source trace is the location of the outermost
2780 instantiation, the next to left element is the location of the next (first
2781 nested) instantiation in the code of the corresponding generic unit, and so
2782 on, and the leftmost element (that is out of any square brackets) is the
2783 location of the declaration of the entity to eliminate in a generic unit.
2785 Note that the @code{Source_Location} argument specifies which of a set of
2786 similarly named entities is being eliminated, dealing both with overloading,
2787 and also appearance of the same entity name in different scopes.
2789 This pragma indicates that the given entity is not used in the program to be
2790 compiled and built. The effect of the pragma is to allow the compiler to
2791 eliminate the code or data associated with the named entity. Any reference to
2792 an eliminated entity causes a compile-time or link-time error.
2794 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2795 in a system-independent manner, with unused entities eliminated, without
2796 needing to modify the source text. Normally the required set of
2797 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2799 Any source file change that removes, splits, or
2800 adds lines may make the set of Eliminate pragmas invalid because their
2801 @code{Source_Location} argument values may get out of date.
2803 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2804 operation. In this case all the subprograms to which the given operation can
2805 dispatch are considered to be unused (are never called as a result of a direct
2806 or a dispatching call).
2808 @node Pragma Enable_Atomic_Synchronization
2809 @unnumberedsec Pragma Enable_Atomic_Synchronization
2810 @cindex Atomic Synchronization
2811 @findex Enable_Atomic_Synchronization
2812 @noindent
2813 Syntax:
2815 @smallexample @c ada
2816 pragma Enable_Atomic_Synchronization [(Entity)];
2817 @end smallexample
2819 @noindent
2820 Ada requires that accesses (reads or writes) of an atomic variable be
2821 regarded as synchronization points in the case of multiple tasks.
2822 Particularly in the case of multi-processors this may require special
2823 handling, e.g. the generation of memory barriers. This synchronization
2824 is performed by default, but can be turned off using
2825 @code{pragma Disable_Atomic_Synchronization}. The
2826 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2827 it back on.
2829 The placement and scope rules for this pragma are the same as those
2830 for @code{pragma Unsuppress}. In particular it can be used as a
2831 configuration  pragma, or in a declaration sequence where it applies
2832 till the end of the scope. If an @code{Entity} argument is present,
2833 the action applies only to that entity.
2835 @node Pragma Export_Exception
2836 @unnumberedsec Pragma Export_Exception
2837 @cindex OpenVMS
2838 @findex Export_Exception
2839 @noindent
2840 Syntax:
2842 @smallexample @c ada
2843 pragma Export_Exception (
2844      [Internal =>] LOCAL_NAME
2845   [, [External =>] EXTERNAL_SYMBOL]
2846   [, [Form     =>] Ada | VMS]
2847   [, [Code     =>] static_integer_EXPRESSION]);
2849 EXTERNAL_SYMBOL ::=
2850   IDENTIFIER
2851 | static_string_EXPRESSION
2852 @end smallexample
2854 @noindent
2855 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
2856 causes the specified exception to be propagated outside of the Ada program,
2857 so that it can be handled by programs written in other OpenVMS languages.
2858 This pragma establishes an external name for an Ada exception and makes the
2859 name available to the OpenVMS Linker as a global symbol.  For further details
2860 on this pragma, see the
2861 DEC Ada Language Reference Manual, section 13.9a3.2.
2863 @node Pragma Export_Function
2864 @unnumberedsec Pragma Export_Function
2865 @cindex Argument passing mechanisms
2866 @findex Export_Function
2868 @noindent
2869 Syntax:
2871 @smallexample @c ada
2872 pragma Export_Function (
2873      [Internal         =>] LOCAL_NAME
2874   [, [External         =>] EXTERNAL_SYMBOL]
2875   [, [Parameter_Types  =>] PARAMETER_TYPES]
2876   [, [Result_Type      =>] result_SUBTYPE_MARK]
2877   [, [Mechanism        =>] MECHANISM]
2878   [, [Result_Mechanism =>] MECHANISM_NAME]);
2880 EXTERNAL_SYMBOL ::=
2881   IDENTIFIER
2882 | static_string_EXPRESSION
2883 | ""
2885 PARAMETER_TYPES ::=
2886   null
2887 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2889 TYPE_DESIGNATOR ::=
2890   subtype_NAME
2891 | subtype_Name ' Access
2893 MECHANISM ::=
2894   MECHANISM_NAME
2895 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2897 MECHANISM_ASSOCIATION ::=
2898   [formal_parameter_NAME =>] MECHANISM_NAME
2900 MECHANISM_NAME ::= Value | Reference
2901 @end smallexample
2903 @noindent
2904 Use this pragma to make a function externally callable and optionally
2905 provide information on mechanisms to be used for passing parameter and
2906 result values.  We recommend, for the purposes of improving portability,
2907 this pragma always be used in conjunction with a separate pragma
2908 @code{Export}, which must precede the pragma @code{Export_Function}.
2909 GNAT does not require a separate pragma @code{Export}, but if none is
2910 present, @code{Convention Ada} is assumed, which is usually
2911 not what is wanted, so it is usually appropriate to use this
2912 pragma in conjunction with a @code{Export} or @code{Convention}
2913 pragma that specifies the desired foreign convention.
2914 Pragma @code{Export_Function}
2915 (and @code{Export}, if present) must appear in the same declarative
2916 region as the function to which they apply.
2918 @var{internal_name} must uniquely designate the function to which the
2919 pragma applies.  If more than one function name exists of this name in
2920 the declarative part you must use the @code{Parameter_Types} and
2921 @code{Result_Type} parameters is mandatory to achieve the required
2922 unique designation.  @var{subtype_mark}s in these parameters must
2923 exactly match the subtypes in the corresponding function specification,
2924 using positional notation to match parameters with subtype marks.
2925 The form with an @code{'Access} attribute can be used to match an
2926 anonymous access parameter.
2928 @cindex Suppressing external name
2929 Special treatment is given if the EXTERNAL is an explicit null
2930 string or a static string expressions that evaluates to the null
2931 string. In this case, no external name is generated. This form
2932 still allows the specification of parameter mechanisms.
2934 @node Pragma Export_Object
2935 @unnumberedsec Pragma Export_Object
2936 @findex Export_Object
2937 @noindent
2938 Syntax:
2940 @smallexample @c ada
2941 pragma Export_Object
2942       [Internal =>] LOCAL_NAME
2943    [, [External =>] EXTERNAL_SYMBOL]
2944    [, [Size     =>] EXTERNAL_SYMBOL]
2946 EXTERNAL_SYMBOL ::=
2947   IDENTIFIER
2948 | static_string_EXPRESSION
2949 @end smallexample
2951 @noindent
2952 This pragma designates an object as exported, and apart from the
2953 extended rules for external symbols, is identical in effect to the use of
2954 the normal @code{Export} pragma applied to an object.  You may use a
2955 separate Export pragma (and you probably should from the point of view
2956 of portability), but it is not required.  @var{Size} is syntax checked,
2957 but otherwise ignored by GNAT@.
2959 @node Pragma Export_Procedure
2960 @unnumberedsec Pragma Export_Procedure
2961 @findex Export_Procedure
2962 @noindent
2963 Syntax:
2965 @smallexample @c ada
2966 pragma Export_Procedure (
2967      [Internal        =>] LOCAL_NAME
2968   [, [External        =>] EXTERNAL_SYMBOL]
2969   [, [Parameter_Types =>] PARAMETER_TYPES]
2970   [, [Mechanism       =>] MECHANISM]);
2972 EXTERNAL_SYMBOL ::=
2973   IDENTIFIER
2974 | static_string_EXPRESSION
2975 | ""
2977 PARAMETER_TYPES ::=
2978   null
2979 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2981 TYPE_DESIGNATOR ::=
2982   subtype_NAME
2983 | subtype_Name ' Access
2985 MECHANISM ::=
2986   MECHANISM_NAME
2987 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2989 MECHANISM_ASSOCIATION ::=
2990   [formal_parameter_NAME =>] MECHANISM_NAME
2992 MECHANISM_NAME ::= Value | Reference
2993 @end smallexample
2995 @noindent
2996 This pragma is identical to @code{Export_Function} except that it
2997 applies to a procedure rather than a function and the parameters
2998 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2999 GNAT does not require a separate pragma @code{Export}, but if none is
3000 present, @code{Convention Ada} is assumed, which is usually
3001 not what is wanted, so it is usually appropriate to use this
3002 pragma in conjunction with a @code{Export} or @code{Convention}
3003 pragma that specifies the desired foreign convention.
3005 @cindex Suppressing external name
3006 Special treatment is given if the EXTERNAL is an explicit null
3007 string or a static string expressions that evaluates to the null
3008 string. In this case, no external name is generated. This form
3009 still allows the specification of parameter mechanisms.
3011 @node Pragma Export_Value
3012 @unnumberedsec Pragma Export_Value
3013 @findex Export_Value
3014 @noindent
3015 Syntax:
3017 @smallexample @c ada
3018 pragma Export_Value (
3019   [Value     =>] static_integer_EXPRESSION,
3020   [Link_Name =>] static_string_EXPRESSION);
3021 @end smallexample
3023 @noindent
3024 This pragma serves to export a static integer value for external use.
3025 The first argument specifies the value to be exported. The Link_Name
3026 argument specifies the symbolic name to be associated with the integer
3027 value. This pragma is useful for defining a named static value in Ada
3028 that can be referenced in assembly language units to be linked with
3029 the application. This pragma is currently supported only for the
3030 AAMP target and is ignored for other targets.
3032 @node Pragma Export_Valued_Procedure
3033 @unnumberedsec Pragma Export_Valued_Procedure
3034 @findex Export_Valued_Procedure
3035 @noindent
3036 Syntax:
3038 @smallexample @c ada
3039 pragma Export_Valued_Procedure (
3040      [Internal        =>] LOCAL_NAME
3041   [, [External        =>] EXTERNAL_SYMBOL]
3042   [, [Parameter_Types =>] PARAMETER_TYPES]
3043   [, [Mechanism       =>] MECHANISM]);
3045 EXTERNAL_SYMBOL ::=
3046   IDENTIFIER
3047 | static_string_EXPRESSION
3048 | ""
3050 PARAMETER_TYPES ::=
3051   null
3052 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3054 TYPE_DESIGNATOR ::=
3055   subtype_NAME
3056 | subtype_Name ' Access
3058 MECHANISM ::=
3059   MECHANISM_NAME
3060 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3062 MECHANISM_ASSOCIATION ::=
3063   [formal_parameter_NAME =>] MECHANISM_NAME
3065 MECHANISM_NAME ::= Value | Reference
3066 @end smallexample
3068 @noindent
3069 This pragma is identical to @code{Export_Procedure} except that the
3070 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3071 mode @code{OUT}, and externally the subprogram is treated as a function
3072 with this parameter as the result of the function.  GNAT provides for
3073 this capability to allow the use of @code{OUT} and @code{IN OUT}
3074 parameters in interfacing to external functions (which are not permitted
3075 in Ada functions).
3076 GNAT does not require a separate pragma @code{Export}, but if none is
3077 present, @code{Convention Ada} is assumed, which is almost certainly
3078 not what is wanted since the whole point of this pragma is to interface
3079 with foreign language functions, so it is usually appropriate to use this
3080 pragma in conjunction with a @code{Export} or @code{Convention}
3081 pragma that specifies the desired foreign convention.
3083 @cindex Suppressing external name
3084 Special treatment is given if the EXTERNAL is an explicit null
3085 string or a static string expressions that evaluates to the null
3086 string. In this case, no external name is generated. This form
3087 still allows the specification of parameter mechanisms.
3089 @node Pragma Extend_System
3090 @unnumberedsec Pragma Extend_System
3091 @cindex @code{system}, extending
3092 @cindex Dec Ada 83
3093 @findex Extend_System
3094 @noindent
3095 Syntax:
3097 @smallexample @c ada
3098 pragma Extend_System ([Name =>] IDENTIFIER);
3099 @end smallexample
3101 @noindent
3102 This pragma is used to provide backwards compatibility with other
3103 implementations that extend the facilities of package @code{System}.  In
3104 GNAT, @code{System} contains only the definitions that are present in
3105 the Ada RM@.  However, other implementations, notably the DEC Ada 83
3106 implementation, provide many extensions to package @code{System}.
3108 For each such implementation accommodated by this pragma, GNAT provides a
3109 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
3110 implementation, which provides the required additional definitions.  You
3111 can use this package in two ways.  You can @code{with} it in the normal
3112 way and access entities either by selection or using a @code{use}
3113 clause.  In this case no special processing is required.
3115 However, if existing code contains references such as
3116 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
3117 definitions provided in package @code{System}, you may use this pragma
3118 to extend visibility in @code{System} in a non-standard way that
3119 provides greater compatibility with the existing code.  Pragma
3120 @code{Extend_System} is a configuration pragma whose single argument is
3121 the name of the package containing the extended definition
3122 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
3123 control of this pragma will be processed using special visibility
3124 processing that looks in package @code{System.Aux_@var{xxx}} where
3125 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
3126 package @code{System}, but not found in package @code{System}.
3128 You can use this pragma either to access a predefined @code{System}
3129 extension supplied with the compiler, for example @code{Aux_DEC} or
3130 you can construct your own extension unit following the above
3131 definition.  Note that such a package is a child of @code{System}
3132 and thus is considered part of the implementation.
3133 To compile it you will have to use the @option{-gnatg} switch,
3134 or the @option{/GNAT_INTERNAL} qualifier on OpenVMS,
3135 for compiling System units, as explained in the
3136 @value{EDITION} User's Guide.
3138 @node Pragma Extensions_Allowed
3139 @unnumberedsec Pragma Extensions_Allowed
3140 @cindex Ada Extensions
3141 @cindex GNAT Extensions
3142 @findex Extensions_Allowed
3143 @noindent
3144 Syntax:
3146 @smallexample @c ada
3147 pragma Extensions_Allowed (On | Off);
3148 @end smallexample
3150 @noindent
3151 This configuration pragma enables or disables the implementation
3152 extension mode (the use of Off as a parameter cancels the effect
3153 of the @option{-gnatX} command switch).
3155 In extension mode, the latest version of the Ada language is
3156 implemented (currently Ada 2012), and in addition a small number
3157 of GNAT specific extensions are recognized as follows:
3159 @table @asis
3160 @item Constrained attribute for generic objects
3161 The @code{Constrained} attribute is permitted for objects of
3162 generic types. The result indicates if the corresponding actual
3163 is constrained.
3165 @end table
3167 @node Pragma External
3168 @unnumberedsec Pragma External
3169 @findex External
3170 @noindent
3171 Syntax:
3173 @smallexample @c ada
3174 pragma External (
3175   [   Convention    =>] convention_IDENTIFIER,
3176   [   Entity        =>] LOCAL_NAME
3177   [, [External_Name =>] static_string_EXPRESSION ]
3178   [, [Link_Name     =>] static_string_EXPRESSION ]);
3179 @end smallexample
3181 @noindent
3182 This pragma is identical in syntax and semantics to pragma
3183 @code{Export} as defined in the Ada Reference Manual.  It is
3184 provided for compatibility with some Ada 83 compilers that
3185 used this pragma for exactly the same purposes as pragma
3186 @code{Export} before the latter was standardized.
3188 @node Pragma External_Name_Casing
3189 @unnumberedsec Pragma External_Name_Casing
3190 @cindex Dec Ada 83 casing compatibility
3191 @cindex External Names, casing
3192 @cindex Casing of External names
3193 @findex External_Name_Casing
3194 @noindent
3195 Syntax:
3197 @smallexample @c ada
3198 pragma External_Name_Casing (
3199   Uppercase | Lowercase
3200   [, Uppercase | Lowercase | As_Is]);
3201 @end smallexample
3203 @noindent
3204 This pragma provides control over the casing of external names associated
3205 with Import and Export pragmas.  There are two cases to consider:
3207 @table @asis
3208 @item Implicit external names
3209 Implicit external names are derived from identifiers.  The most common case
3210 arises when a standard Ada Import or Export pragma is used with only two
3211 arguments, as in:
3213 @smallexample @c ada
3214    pragma Import (C, C_Routine);
3215 @end smallexample
3217 @noindent
3218 Since Ada is a case-insensitive language, the spelling of the identifier in
3219 the Ada source program does not provide any information on the desired
3220 casing of the external name, and so a convention is needed.  In GNAT the
3221 default treatment is that such names are converted to all lower case
3222 letters.  This corresponds to the normal C style in many environments.
3223 The first argument of pragma @code{External_Name_Casing} can be used to
3224 control this treatment.  If @code{Uppercase} is specified, then the name
3225 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3226 then the normal default of all lower case letters will be used.
3228 This same implicit treatment is also used in the case of extended DEC Ada 83
3229 compatible Import and Export pragmas where an external name is explicitly
3230 specified using an identifier rather than a string.
3232 @item Explicit external names
3233 Explicit external names are given as string literals.  The most common case
3234 arises when a standard Ada Import or Export pragma is used with three
3235 arguments, as in:
3237 @smallexample @c ada
3238 pragma Import (C, C_Routine, "C_routine");
3239 @end smallexample
3241 @noindent
3242 In this case, the string literal normally provides the exact casing required
3243 for the external name.  The second argument of pragma
3244 @code{External_Name_Casing} may be used to modify this behavior.
3245 If @code{Uppercase} is specified, then the name
3246 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3247 then the name will be forced to all lowercase letters.  A specification of
3248 @code{As_Is} provides the normal default behavior in which the casing is
3249 taken from the string provided.
3250 @end table
3252 @noindent
3253 This pragma may appear anywhere that a pragma is valid.  In particular, it
3254 can be used as a configuration pragma in the @file{gnat.adc} file, in which
3255 case it applies to all subsequent compilations, or it can be used as a program
3256 unit pragma, in which case it only applies to the current unit, or it can
3257 be used more locally to control individual Import/Export pragmas.
3259 It is primarily intended for use with OpenVMS systems, where many
3260 compilers convert all symbols to upper case by default.  For interfacing to
3261 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3262 the pragma:
3264 @smallexample @c ada
3265 pragma External_Name_Casing (Uppercase, Uppercase);
3266 @end smallexample
3268 @noindent
3269 to enforce the upper casing of all external symbols.
3271 @node Pragma Fast_Math
3272 @unnumberedsec Pragma Fast_Math
3273 @findex Fast_Math
3274 @noindent
3275 Syntax:
3277 @smallexample @c ada
3278 pragma Fast_Math;
3279 @end smallexample
3281 @noindent
3282 This is a configuration pragma which activates a mode in which speed is
3283 considered more important for floating-point operations than absolutely
3284 accurate adherence to the requirements of the standard. Currently the
3285 following operations are affected:
3287 @table @asis
3288 @item Complex Multiplication
3289 The normal simple formula for complex multiplication can result in intermediate
3290 overflows for numbers near the end of the range. The Ada standard requires that
3291 this situation be detected and corrected by scaling, but in Fast_Math mode such
3292 cases will simply result in overflow. Note that to take advantage of this you
3293 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3294 under control of the pragma, rather than use the preinstantiated versions.
3295 @end table
3297 @node Pragma Favor_Top_Level
3298 @unnumberedsec Pragma Favor_Top_Level
3299 @findex Favor_Top_Level
3300 @noindent
3301 Syntax:
3303 @smallexample @c ada
3304 pragma Favor_Top_Level (type_NAME);
3305 @end smallexample
3307 @noindent
3308 The named type must be an access-to-subprogram type. This pragma is an
3309 efficiency hint to the compiler, regarding the use of 'Access or
3310 'Unrestricted_Access on nested (non-library-level) subprograms. The
3311 pragma means that nested subprograms are not used with this type, or
3312 are rare, so that the generated code should be efficient in the
3313 top-level case. When this pragma is used, dynamically generated
3314 trampolines may be used on some targets for nested subprograms.
3315 See also the No_Implicit_Dynamic_Code restriction.
3317 @node Pragma Finalize_Storage_Only
3318 @unnumberedsec Pragma Finalize_Storage_Only
3319 @findex Finalize_Storage_Only
3320 @noindent
3321 Syntax:
3323 @smallexample @c ada
3324 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3325 @end smallexample
3327 @noindent
3328 This pragma allows the compiler not to emit a Finalize call for objects
3329 defined at the library level.  This is mostly useful for types where
3330 finalization is only used to deal with storage reclamation since in most
3331 environments it is not necessary to reclaim memory just before terminating
3332 execution, hence the name.
3334 @node Pragma Float_Representation
3335 @unnumberedsec Pragma Float_Representation
3336 @cindex OpenVMS
3337 @findex Float_Representation
3338 @noindent
3339 Syntax:
3341 @smallexample @c ada
3342 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3344 FLOAT_REP ::= VAX_Float | IEEE_Float
3345 @end smallexample
3347 @noindent
3348 In the one argument form, this pragma is a configuration pragma which
3349 allows control over the internal representation chosen for the predefined
3350 floating point types declared in the packages @code{Standard} and
3351 @code{System}. On all systems other than OpenVMS, the argument must
3352 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3353 argument may be @code{VAX_Float} to specify the use of the VAX float
3354 format for the floating-point types in Standard. This requires that
3355 the standard runtime libraries be recompiled.
3357 The two argument form specifies the representation to be used for
3358 the specified floating-point type. On all systems other than OpenVMS,
3359 the argument must
3360 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3362 @itemize @bullet
3363 @item
3364 For a digits value of 6, 32-bit IEEE short format will be used.
3365 @item
3366 For a digits value of 15, 64-bit IEEE long format will be used.
3367 @item
3368 No other value of digits is permitted.
3369 @end itemize
3371 On OpenVMS, the
3372 argument may be @code{VAX_Float} to specify the use of the VAX float
3373 format, as follows:
3375 @itemize @bullet
3376 @item
3377 For digits values up to 6, F float format will be used.
3378 @item
3379 For digits values from 7 to 9, D float format will be used.
3380 @item
3381 For digits values from 10 to 15, G float format will be used.
3382 @item
3383 Digits values above 15 are not allowed.
3384 @end itemize
3386 @node Pragma Global
3387 @unnumberedsec Pragma Global
3388 @findex Global
3389 @noindent
3390 For the description of this pragma, see SPARK 2014 Reference Manual,
3391 section 6.1.4.
3393 @node Pragma Ident
3394 @unnumberedsec Pragma Ident
3395 @findex Ident
3396 @noindent
3397 Syntax:
3399 @smallexample @c ada
3400 pragma Ident (static_string_EXPRESSION);
3401 @end smallexample
3403 @noindent
3404 This pragma is identical in effect to pragma @code{Comment}. It is provided
3405 for compatibility with other Ada compilers providing this pragma.
3407 @node Pragma Implementation_Defined
3408 @unnumberedsec Pragma Implementation_Defined
3409 @findex Implementation_Defined
3410 @noindent
3411 Syntax:
3413 @smallexample @c ada
3414 pragma Implementation_Defined (local_NAME);
3415 @end smallexample
3417 @noindent
3418 This pragma marks a previously declared entioty as implementation-defined.
3419 For an overloaded entity, applies to the most recent homonym.
3421 @smallexample @c ada
3422 pragma Implementation_Defined;
3423 @end smallexample
3425 @noindent
3426 The form with no arguments appears anywhere within a scope, most
3427 typically a package spec, and indicates that all entities that are
3428 defined within the package spec are Implementation_Defined.
3430 This pragma is used within the GNAT runtime library to identify
3431 implementation-defined entities introduced in language-defined units,
3432 for the purpose of implementing the No_Implementation_Identifiers
3433 restriction.
3435 @node Pragma Implemented
3436 @unnumberedsec Pragma Implemented
3437 @findex Implemented
3438 @noindent
3439 Syntax:
3441 @smallexample @c ada
3442 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3444 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3445 @end smallexample
3447 @noindent
3448 This is an Ada 2012 representation pragma which applies to protected, task
3449 and synchronized interface primitives. The use of pragma Implemented provides
3450 a way to impose a static requirement on the overriding operation by adhering
3451 to one of the three implementation kinds: entry, protected procedure or any of
3452 the above. This pragma is available in all earlier versions of Ada as an
3453 implementation-defined pragma.
3455 @smallexample @c ada
3456 type Synch_Iface is synchronized interface;
3457 procedure Prim_Op (Obj : in out Iface) is abstract;
3458 pragma Implemented (Prim_Op, By_Protected_Procedure);
3460 protected type Prot_1 is new Synch_Iface with
3461    procedure Prim_Op;  --  Legal
3462 end Prot_1;
3464 protected type Prot_2 is new Synch_Iface with
3465    entry Prim_Op;      --  Illegal
3466 end Prot_2;
3468 task type Task_Typ is new Synch_Iface with
3469    entry Prim_Op;      --  Illegal
3470 end Task_Typ;
3471 @end smallexample
3473 @noindent
3474 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3475 Implemented determines the runtime behavior of the requeue. Implementation kind
3476 By_Entry guarantees that the action of requeueing will proceed from an entry to
3477 another entry. Implementation kind By_Protected_Procedure transforms the
3478 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3479 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3480 the target's overriding subprogram kind.
3482 @node Pragma Implicit_Packing
3483 @unnumberedsec Pragma Implicit_Packing
3484 @findex Implicit_Packing
3485 @cindex Rational Profile
3486 @noindent
3487 Syntax:
3489 @smallexample @c ada
3490 pragma Implicit_Packing;
3491 @end smallexample
3493 @noindent
3494 This is a configuration pragma that requests implicit packing for packed
3495 arrays for which a size clause is given but no explicit pragma Pack or
3496 specification of Component_Size is present. It also applies to records
3497 where no record representation clause is present. Consider this example:
3499 @smallexample @c ada
3500 type R is array (0 .. 7) of Boolean;
3501 for R'Size use 8;
3502 @end smallexample
3504 @noindent
3505 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3506 does not change the layout of a composite object. So the Size clause in the
3507 above example is normally rejected, since the default layout of the array uses
3508 8-bit components, and thus the array requires a minimum of 64 bits.
3510 If this declaration is compiled in a region of code covered by an occurrence
3511 of the configuration pragma Implicit_Packing, then the Size clause in this
3512 and similar examples will cause implicit packing and thus be accepted. For
3513 this implicit packing to occur, the type in question must be an array of small
3514 components whose size is known at compile time, and the Size clause must
3515 specify the exact size that corresponds to the number of elements in the array
3516 multiplied by the size in bits of the component type (both single and
3517 multi-dimensioned arrays can be controlled with this pragma).
3519 @cindex Array packing
3521 Similarly, the following example shows the use in the record case
3523 @smallexample @c ada
3524 type r is record
3525    a, b, c, d, e, f, g, h : boolean;
3526    chr                    : character;
3527 end record;
3528 for r'size use 16;
3529 @end smallexample
3531 @noindent
3532 Without a pragma Pack, each Boolean field requires 8 bits, so the
3533 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3534 sufficient. The use of pragma Implicit_Packing allows this record
3535 declaration to compile without an explicit pragma Pack.
3536 @node Pragma Import_Exception
3537 @unnumberedsec Pragma Import_Exception
3538 @cindex OpenVMS
3539 @findex Import_Exception
3540 @noindent
3541 Syntax:
3543 @smallexample @c ada
3544 pragma Import_Exception (
3545      [Internal =>] LOCAL_NAME
3546   [, [External =>] EXTERNAL_SYMBOL]
3547   [, [Form     =>] Ada | VMS]
3548   [, [Code     =>] static_integer_EXPRESSION]);
3550 EXTERNAL_SYMBOL ::=
3551   IDENTIFIER
3552 | static_string_EXPRESSION
3553 @end smallexample
3555 @noindent
3556 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3557 It allows OpenVMS conditions (for example, from OpenVMS system services or
3558 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3559 The pragma specifies that the exception associated with an exception
3560 declaration in an Ada program be defined externally (in non-Ada code).
3561 For further details on this pragma, see the
3562 DEC Ada Language Reference Manual, section 13.9a.3.1.
3564 @node Pragma Import_Function
3565 @unnumberedsec Pragma Import_Function
3566 @findex Import_Function
3567 @noindent
3568 Syntax:
3570 @smallexample @c ada
3571 pragma Import_Function (
3572      [Internal                 =>] LOCAL_NAME,
3573   [, [External                 =>] EXTERNAL_SYMBOL]
3574   [, [Parameter_Types          =>] PARAMETER_TYPES]
3575   [, [Result_Type              =>] SUBTYPE_MARK]
3576   [, [Mechanism                =>] MECHANISM]
3577   [, [Result_Mechanism         =>] MECHANISM_NAME]);
3579 EXTERNAL_SYMBOL ::=
3580   IDENTIFIER
3581 | static_string_EXPRESSION
3583 PARAMETER_TYPES ::=
3584   null
3585 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3587 TYPE_DESIGNATOR ::=
3588   subtype_NAME
3589 | subtype_Name ' Access
3591 MECHANISM ::=
3592   MECHANISM_NAME
3593 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3595 MECHANISM_ASSOCIATION ::=
3596   [formal_parameter_NAME =>] MECHANISM_NAME
3598 MECHANISM_NAME ::=
3599   Value
3600 | Reference
3601 @end smallexample
3603 @noindent
3604 This pragma is used in conjunction with a pragma @code{Import} to
3605 specify additional information for an imported function.  The pragma
3606 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3607 @code{Import_Function} pragma and both must appear in the same
3608 declarative part as the function specification.
3610 The @var{Internal} argument must uniquely designate
3611 the function to which the
3612 pragma applies.  If more than one function name exists of this name in
3613 the declarative part you must use the @code{Parameter_Types} and
3614 @var{Result_Type} parameters to achieve the required unique
3615 designation.  Subtype marks in these parameters must exactly match the
3616 subtypes in the corresponding function specification, using positional
3617 notation to match parameters with subtype marks.
3618 The form with an @code{'Access} attribute can be used to match an
3619 anonymous access parameter.
3621 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3622 parameters to specify passing mechanisms for the
3623 parameters and result.  If you specify a single mechanism name, it
3624 applies to all parameters.  Otherwise you may specify a mechanism on a
3625 parameter by parameter basis using either positional or named
3626 notation.  If the mechanism is not specified, the default mechanism
3627 is used.
3629 @node Pragma Import_Object
3630 @unnumberedsec Pragma Import_Object
3631 @findex Import_Object
3632 @noindent
3633 Syntax:
3635 @smallexample @c ada
3636 pragma Import_Object
3637      [Internal =>] LOCAL_NAME
3638   [, [External =>] EXTERNAL_SYMBOL]
3639   [, [Size     =>] EXTERNAL_SYMBOL]);
3641 EXTERNAL_SYMBOL ::=
3642   IDENTIFIER
3643 | static_string_EXPRESSION
3644 @end smallexample
3646 @noindent
3647 This pragma designates an object as imported, and apart from the
3648 extended rules for external symbols, is identical in effect to the use of
3649 the normal @code{Import} pragma applied to an object.  Unlike the
3650 subprogram case, you need not use a separate @code{Import} pragma,
3651 although you may do so (and probably should do so from a portability
3652 point of view).  @var{size} is syntax checked, but otherwise ignored by
3653 GNAT@.
3655 @node Pragma Import_Procedure
3656 @unnumberedsec Pragma Import_Procedure
3657 @findex Import_Procedure
3658 @noindent
3659 Syntax:
3661 @smallexample @c ada
3662 pragma Import_Procedure (
3663      [Internal                 =>] LOCAL_NAME
3664   [, [External                 =>] EXTERNAL_SYMBOL]
3665   [, [Parameter_Types          =>] PARAMETER_TYPES]
3666   [, [Mechanism                =>] MECHANISM]);
3668 EXTERNAL_SYMBOL ::=
3669   IDENTIFIER
3670 | static_string_EXPRESSION
3672 PARAMETER_TYPES ::=
3673   null
3674 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3676 TYPE_DESIGNATOR ::=
3677   subtype_NAME
3678 | subtype_Name ' Access
3680 MECHANISM ::=
3681   MECHANISM_NAME
3682 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3684 MECHANISM_ASSOCIATION ::=
3685   [formal_parameter_NAME =>] MECHANISM_NAME
3687 MECHANISM_NAME ::= Value | Reference
3688 @end smallexample
3690 @noindent
3691 This pragma is identical to @code{Import_Function} except that it
3692 applies to a procedure rather than a function and the parameters
3693 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3695 @node Pragma Import_Valued_Procedure
3696 @unnumberedsec Pragma Import_Valued_Procedure
3697 @findex Import_Valued_Procedure
3698 @noindent
3699 Syntax:
3701 @smallexample @c ada
3702 pragma Import_Valued_Procedure (
3703      [Internal                 =>] LOCAL_NAME
3704   [, [External                 =>] EXTERNAL_SYMBOL]
3705   [, [Parameter_Types          =>] PARAMETER_TYPES]
3706   [, [Mechanism                =>] MECHANISM]);
3708 EXTERNAL_SYMBOL ::=
3709   IDENTIFIER
3710 | static_string_EXPRESSION
3712 PARAMETER_TYPES ::=
3713   null
3714 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3716 TYPE_DESIGNATOR ::=
3717   subtype_NAME
3718 | subtype_Name ' Access
3720 MECHANISM ::=
3721   MECHANISM_NAME
3722 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3724 MECHANISM_ASSOCIATION ::=
3725   [formal_parameter_NAME =>] MECHANISM_NAME
3727 MECHANISM_NAME ::= Value | Reference
3728 @end smallexample
3730 @noindent
3731 This pragma is identical to @code{Import_Procedure} except that the
3732 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3733 mode @code{OUT}, and externally the subprogram is treated as a function
3734 with this parameter as the result of the function.  The purpose of this
3735 capability is to allow the use of @code{OUT} and @code{IN OUT}
3736 parameters in interfacing to external functions (which are not permitted
3737 in Ada functions).  You may optionally use the @code{Mechanism}
3738 parameters to specify passing mechanisms for the parameters.
3739 If you specify a single mechanism name, it applies to all parameters.
3740 Otherwise you may specify a mechanism on a parameter by parameter
3741 basis using either positional or named notation.  If the mechanism is not
3742 specified, the default mechanism is used.
3744 Note that it is important to use this pragma in conjunction with a separate
3745 pragma Import that specifies the desired convention, since otherwise the
3746 default convention is Ada, which is almost certainly not what is required.
3748 @node Pragma Independent
3749 @unnumberedsec Pragma Independent
3750 @findex Independent
3751 @noindent
3752 Syntax:
3754 @smallexample @c ada
3755 pragma Independent (Local_NAME);
3756 @end smallexample
3758 @noindent
3759 This pragma is standard in Ada 2012 mode (which also provides an aspect
3760 of the same name). It is also available as an implementation-defined
3761 pragma in all earlier versions. It specifies that the
3762 designated object or all objects of the designated type must be
3763 independently addressable. This means that separate tasks can safely
3764 manipulate such objects. For example, if two components of a record are
3765 independent, then two separate tasks may access these two components.
3766 This may place
3767 constraints on the representation of the object (for instance prohibiting
3768 tight packing).
3770 @node Pragma Independent_Components
3771 @unnumberedsec Pragma Independent_Components
3772 @findex Independent_Components
3773 @noindent
3774 Syntax:
3776 @smallexample @c ada
3777 pragma Independent_Components (Local_NAME);
3778 @end smallexample
3780 @noindent
3781 This pragma is standard in Ada 2012 mode (which also provides an aspect
3782 of the same name). It is also available as an implementation-defined
3783 pragma in all earlier versions. It specifies that the components of the
3784 designated object, or the components of each object of the designated
3785 type, must be
3786 independently addressable. This means that separate tasks can safely
3787 manipulate separate components in the composite object. This may place
3788 constraints on the representation of the object (for instance prohibiting
3789 tight packing).
3791 @node Pragma Initial_Condition
3792 @unnumberedsec Pragma Initial_Condition
3793 @findex Initial_Condition
3794 @noindent
3795 For the description of this pragma, see SPARK 2014 Reference Manual,
3796 section 7.1.6.
3798 @node Pragma Initialize_Scalars
3799 @unnumberedsec Pragma Initialize_Scalars
3800 @findex Initialize_Scalars
3801 @cindex debugging with Initialize_Scalars
3802 @noindent
3803 Syntax:
3805 @smallexample @c ada
3806 pragma Initialize_Scalars;
3807 @end smallexample
3809 @noindent
3810 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3811 two important differences.  First, there is no requirement for the pragma
3812 to be used uniformly in all units of a partition, in particular, it is fine
3813 to use this just for some or all of the application units of a partition,
3814 without needing to recompile the run-time library.
3816 In the case where some units are compiled with the pragma, and some without,
3817 then a declaration of a variable where the type is defined in package
3818 Standard or is locally declared will always be subject to initialization,
3819 as will any declaration of a scalar variable.  For composite variables,
3820 whether the variable is initialized may also depend on whether the package
3821 in which the type of the variable is declared is compiled with the pragma.
3823 The other important difference is that you can control the value used
3824 for initializing scalar objects.  At bind time, you can select several
3825 options for initialization. You can
3826 initialize with invalid values (similar to Normalize_Scalars, though for
3827 Initialize_Scalars it is not always possible to determine the invalid
3828 values in complex cases like signed component fields with non-standard
3829 sizes). You can also initialize with high or
3830 low values, or with a specified bit pattern.  See the @value{EDITION}
3831 User's Guide for binder options for specifying these cases.
3833 This means that you can compile a program, and then without having to
3834 recompile the program, you can run it with different values being used
3835 for initializing otherwise uninitialized values, to test if your program
3836 behavior depends on the choice.  Of course the behavior should not change,
3837 and if it does, then most likely you have an incorrect reference to an
3838 uninitialized value.
3840 It is even possible to change the value at execution time eliminating even
3841 the need to rebind with a different switch using an environment variable.
3842 See the @value{EDITION} User's Guide for details.
3844 Note that pragma @code{Initialize_Scalars} is particularly useful in
3845 conjunction with the enhanced validity checking that is now provided
3846 in GNAT, which checks for invalid values under more conditions.
3847 Using this feature (see description of the @option{-gnatV} flag in the
3848 @value{EDITION} User's Guide) in conjunction with
3849 pragma @code{Initialize_Scalars}
3850 provides a powerful new tool to assist in the detection of problems
3851 caused by uninitialized variables.
3853 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3854 effect on the generated code. This may cause your code to be
3855 substantially larger. It may also cause an increase in the amount
3856 of stack required, so it is probably a good idea to turn on stack
3857 checking (see description of stack checking in the @value{EDITION}
3858 User's Guide) when using this pragma.
3860 @node Pragma Initializes
3861 @unnumberedsec Pragma Initializes
3862 @findex Initializes
3863 @noindent
3864 For the description of this pragma, see SPARK 2014 Reference Manual,
3865 section 7.1.5.
3867 @node Pragma Inline_Always
3868 @unnumberedsec Pragma Inline_Always
3869 @findex Inline_Always
3870 @noindent
3871 Syntax:
3873 @smallexample @c ada
3874 pragma Inline_Always (NAME [, NAME]);
3875 @end smallexample
3877 @noindent
3878 Similar to pragma @code{Inline} except that inlining is not subject to
3879 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3880 happens regardless of whether these options are used.
3882 @node Pragma Inline_Generic
3883 @unnumberedsec Pragma Inline_Generic
3884 @findex Inline_Generic
3885 @noindent
3886 Syntax:
3888 @smallexample @c ada
3889 pragma Inline_Generic (GNAME @{, GNAME@});
3891 GNAME ::= generic_unit_NAME | generic_instance_NAME
3892 @end smallexample
3894 @noindent
3895 This pragma is provided for compatibility with Dec Ada 83. It has
3896 no effect in @code{GNAT} (which always inlines generics), other
3897 than to check that the given names are all names of generic units or
3898 generic instances.
3900 @node Pragma Interface
3901 @unnumberedsec Pragma Interface
3902 @findex Interface
3903 @noindent
3904 Syntax:
3906 @smallexample @c ada
3907 pragma Interface (
3908      [Convention    =>] convention_identifier,
3909      [Entity        =>] local_NAME
3910   [, [External_Name =>] static_string_expression]
3911   [, [Link_Name     =>] static_string_expression]);
3912 @end smallexample
3914 @noindent
3915 This pragma is identical in syntax and semantics to
3916 the standard Ada pragma @code{Import}.  It is provided for compatibility
3917 with Ada 83.  The definition is upwards compatible both with pragma
3918 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3919 with some extended implementations of this pragma in certain Ada 83
3920 implementations.  The only difference between pragma @code{Interface}
3921 and pragma @code{Import} is that there is special circuitry to allow
3922 both pragmas to appear for the same subprogram entity (normally it
3923 is illegal to have multiple @code{Import} pragmas. This is useful in
3924 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3925 Ada 83 compilers.
3927 @node Pragma Interface_Name
3928 @unnumberedsec Pragma Interface_Name
3929 @findex Interface_Name
3930 @noindent
3931 Syntax:
3933 @smallexample @c ada
3934 pragma Interface_Name (
3935      [Entity        =>] LOCAL_NAME
3936   [, [External_Name =>] static_string_EXPRESSION]
3937   [, [Link_Name     =>] static_string_EXPRESSION]);
3938 @end smallexample
3940 @noindent
3941 This pragma provides an alternative way of specifying the interface name
3942 for an interfaced subprogram, and is provided for compatibility with Ada
3943 83 compilers that use the pragma for this purpose.  You must provide at
3944 least one of @var{External_Name} or @var{Link_Name}.
3946 @node Pragma Interrupt_Handler
3947 @unnumberedsec Pragma Interrupt_Handler
3948 @findex Interrupt_Handler
3949 @noindent
3950 Syntax:
3952 @smallexample @c ada
3953 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3954 @end smallexample
3956 @noindent
3957 This program unit pragma is supported for parameterless protected procedures
3958 as described in Annex C of the Ada Reference Manual. On the AAMP target
3959 the pragma can also be specified for nonprotected parameterless procedures
3960 that are declared at the library level (which includes procedures
3961 declared at the top level of a library package). In the case of AAMP,
3962 when this pragma is applied to a nonprotected procedure, the instruction
3963 @code{IERET} is generated for returns from the procedure, enabling
3964 maskable interrupts, in place of the normal return instruction.
3966 @node Pragma Interrupt_State
3967 @unnumberedsec Pragma Interrupt_State
3968 @findex Interrupt_State
3969 @noindent
3970 Syntax:
3972 @smallexample @c ada
3973 pragma Interrupt_State
3974  ([Name  =>] value,
3975   [State =>] SYSTEM | RUNTIME | USER);
3976 @end smallexample
3978 @noindent
3979 Normally certain interrupts are reserved to the implementation.  Any attempt
3980 to attach an interrupt causes Program_Error to be raised, as described in
3981 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3982 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3983 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3984 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
3985 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3986 Ada exceptions, or used to implement run-time functions such as the
3987 @code{abort} statement and stack overflow checking.
3989 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3990 such uses of interrupts.  It subsumes the functionality of pragma
3991 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
3992 available on Windows or VMS.  On all other platforms than VxWorks,
3993 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3994 and may be used to mark interrupts required by the board support package
3995 as reserved.
3997 Interrupts can be in one of three states:
3998 @itemize @bullet
3999 @item System
4001 The interrupt is reserved (no Ada handler can be installed), and the
4002 Ada run-time may not install a handler. As a result you are guaranteed
4003 standard system default action if this interrupt is raised.
4005 @item Runtime
4007 The interrupt is reserved (no Ada handler can be installed). The run time
4008 is allowed to install a handler for internal control purposes, but is
4009 not required to do so.
4011 @item User
4013 The interrupt is unreserved.  The user may install a handler to provide
4014 some other action.
4015 @end itemize
4017 @noindent
4018 These states are the allowed values of the @code{State} parameter of the
4019 pragma.  The @code{Name} parameter is a value of the type
4020 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
4021 @code{Ada.Interrupts.Names}.
4023 This is a configuration pragma, and the binder will check that there
4024 are no inconsistencies between different units in a partition in how a
4025 given interrupt is specified. It may appear anywhere a pragma is legal.
4027 The effect is to move the interrupt to the specified state.
4029 By declaring interrupts to be SYSTEM, you guarantee the standard system
4030 action, such as a core dump.
4032 By declaring interrupts to be USER, you guarantee that you can install
4033 a handler.
4035 Note that certain signals on many operating systems cannot be caught and
4036 handled by applications.  In such cases, the pragma is ignored.  See the
4037 operating system documentation, or the value of the array @code{Reserved}
4038 declared in the spec of package @code{System.OS_Interface}.
4040 Overriding the default state of signals used by the Ada runtime may interfere
4041 with an application's runtime behavior in the cases of the synchronous signals,
4042 and in the case of the signal used to implement the @code{abort} statement.
4044 @node Pragma Invariant
4045 @unnumberedsec Pragma Invariant
4046 @findex Invariant
4047 @noindent
4048 Syntax:
4050 @smallexample @c ada
4051 pragma Invariant
4052   ([Entity =>]    private_type_LOCAL_NAME,
4053    [Check  =>]    EXPRESSION
4054    [,[Message =>] String_Expression]);
4055 @end smallexample
4057 @noindent
4058 This pragma provides exactly the same capabilities as the Type_Invariant aspect
4059 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
4060 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
4061 requires the use of the aspect syntax, which is not available except in 2012
4062 mode, it is not possible to use the Type_Invariant aspect in earlier versions
4063 of Ada. However the Invariant pragma may be used in any version of Ada. Also
4064 note that the aspect Invariant is a synonym in GNAT for the aspect
4065 Type_Invariant, but there is no pragma Type_Invariant.
4067 The pragma must appear within the visible part of the package specification,
4068 after the type to which its Entity argument appears. As with the Invariant
4069 aspect, the Check expression is not analyzed until the end of the visible
4070 part of the package, so it may contain forward references. The Message
4071 argument, if present, provides the exception message used if the invariant
4072 is violated. If no Message parameter is provided, a default message that
4073 identifies the line on which the pragma appears is used.
4075 It is permissible to have multiple Invariants for the same type entity, in
4076 which case they are and'ed together. It is permissible to use this pragma
4077 in Ada 2012 mode, but you cannot have both an invariant aspect and an
4078 invariant pragma for the same entity.
4080 For further details on the use of this pragma, see the Ada 2012 documentation
4081 of the Type_Invariant aspect.
4083 @node Pragma Java_Constructor
4084 @unnumberedsec Pragma Java_Constructor
4085 @findex Java_Constructor
4086 @noindent
4087 Syntax:
4089 @smallexample @c ada
4090 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
4091 @end smallexample
4093 @noindent
4094 This pragma is used to assert that the specified Ada function should be
4095 mapped to the Java constructor for some Ada tagged record type.
4097 See section 7.3.2 of the
4098 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4099 for related information.
4101 @node Pragma Java_Interface
4102 @unnumberedsec Pragma Java_Interface
4103 @findex Java_Interface
4104 @noindent
4105 Syntax:
4107 @smallexample @c ada
4108 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
4109 @end smallexample
4111 @noindent
4112 This pragma is used to assert that the specified Ada abstract tagged type
4113 is to be mapped to a Java interface name.
4115 See sections 7.1 and 7.2 of the
4116 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4117 for related information.
4119 @node Pragma Keep_Names
4120 @unnumberedsec Pragma Keep_Names
4121 @findex Keep_Names
4122 @noindent
4123 Syntax:
4125 @smallexample @c ada
4126 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4127 @end smallexample
4129 @noindent
4130 The @var{LOCAL_NAME} argument
4131 must refer to an enumeration first subtype
4132 in the current declarative part. The effect is to retain the enumeration
4133 literal names for use by @code{Image} and @code{Value} even if a global
4134 @code{Discard_Names} pragma applies. This is useful when you want to
4135 generally suppress enumeration literal names and for example you therefore
4136 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
4137 want to retain the names for specific enumeration types.
4139 @node Pragma License
4140 @unnumberedsec Pragma License
4141 @findex License
4142 @cindex License checking
4143 @noindent
4144 Syntax:
4146 @smallexample @c ada
4147 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4148 @end smallexample
4150 @noindent
4151 This pragma is provided to allow automated checking for appropriate license
4152 conditions with respect to the standard and modified GPL@.  A pragma
4153 @code{License}, which is a configuration pragma that typically appears at
4154 the start of a source file or in a separate @file{gnat.adc} file, specifies
4155 the licensing conditions of a unit as follows:
4157 @itemize @bullet
4158 @item Unrestricted
4159 This is used for a unit that can be freely used with no license restrictions.
4160 Examples of such units are public domain units, and units from the Ada
4161 Reference Manual.
4163 @item GPL
4164 This is used for a unit that is licensed under the unmodified GPL, and which
4165 therefore cannot be @code{with}'ed by a restricted unit.
4167 @item Modified_GPL
4168 This is used for a unit licensed under the GNAT modified GPL that includes
4169 a special exception paragraph that specifically permits the inclusion of
4170 the unit in programs without requiring the entire program to be released
4171 under the GPL@.
4173 @item Restricted
4174 This is used for a unit that is restricted in that it is not permitted to
4175 depend on units that are licensed under the GPL@.  Typical examples are
4176 proprietary code that is to be released under more restrictive license
4177 conditions.  Note that restricted units are permitted to @code{with} units
4178 which are licensed under the modified GPL (this is the whole point of the
4179 modified GPL).
4181 @end itemize
4183 @noindent
4184 Normally a unit with no @code{License} pragma is considered to have an
4185 unknown license, and no checking is done.  However, standard GNAT headers
4186 are recognized, and license information is derived from them as follows.
4188 A GNAT license header starts with a line containing 78 hyphens.  The following
4189 comment text is searched for the appearance of any of the following strings.
4191 If the string ``GNU General Public License'' is found, then the unit is assumed
4192 to have GPL license, unless the string ``As a special exception'' follows, in
4193 which case the license is assumed to be modified GPL@.
4195 If one of the strings
4196 ``This specification is adapted from the Ada Semantic Interface'' or
4197 ``This specification is derived from the Ada Reference Manual'' is found
4198 then the unit is assumed to be unrestricted.
4200 @noindent
4201 These default actions means that a program with a restricted license pragma
4202 will automatically get warnings if a GPL unit is inappropriately
4203 @code{with}'ed.  For example, the program:
4205 @smallexample @c ada
4206 with Sem_Ch3;
4207 with GNAT.Sockets;
4208 procedure Secret_Stuff is
4209   @dots{}
4210 end Secret_Stuff
4211 @end smallexample
4213 @noindent
4214 if compiled with pragma @code{License} (@code{Restricted}) in a
4215 @file{gnat.adc} file will generate the warning:
4217 @smallexample
4218 1.  with Sem_Ch3;
4219         |
4220    >>> license of withed unit "Sem_Ch3" is incompatible
4222 2.  with GNAT.Sockets;
4223 3.  procedure Secret_Stuff is
4224 @end smallexample
4226 @noindent
4227 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4228 compiler and is licensed under the
4229 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4230 run time, and is therefore licensed under the modified GPL@.
4232 @node Pragma Link_With
4233 @unnumberedsec Pragma Link_With
4234 @findex Link_With
4235 @noindent
4236 Syntax:
4238 @smallexample @c ada
4239 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4240 @end smallexample
4242 @noindent
4243 This pragma is provided for compatibility with certain Ada 83 compilers.
4244 It has exactly the same effect as pragma @code{Linker_Options} except
4245 that spaces occurring within one of the string expressions are treated
4246 as separators. For example, in the following case:
4248 @smallexample @c ada
4249 pragma Link_With ("-labc -ldef");
4250 @end smallexample
4252 @noindent
4253 results in passing the strings @code{-labc} and @code{-ldef} as two
4254 separate arguments to the linker. In addition pragma Link_With allows
4255 multiple arguments, with the same effect as successive pragmas.
4257 @node Pragma Linker_Alias
4258 @unnumberedsec Pragma Linker_Alias
4259 @findex Linker_Alias
4260 @noindent
4261 Syntax:
4263 @smallexample @c ada
4264 pragma Linker_Alias (
4265   [Entity =>] LOCAL_NAME,
4266   [Target =>] static_string_EXPRESSION);
4267 @end smallexample
4269 @noindent
4270 @var{LOCAL_NAME} must refer to an object that is declared at the library
4271 level. This pragma establishes the given entity as a linker alias for the
4272 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4273 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4274 @var{static_string_EXPRESSION} in the object file, that is to say no space
4275 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4276 to the same address as @var{static_string_EXPRESSION} by the linker.
4278 The actual linker name for the target must be used (e.g.@: the fully
4279 encoded name with qualification in Ada, or the mangled name in C++),
4280 or it must be declared using the C convention with @code{pragma Import}
4281 or @code{pragma Export}.
4283 Not all target machines support this pragma. On some of them it is accepted
4284 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4286 @smallexample @c ada
4287 --  Example of the use of pragma Linker_Alias
4289 package p is
4290   i : Integer := 1;
4291   pragma Export (C, i);
4293   new_name_for_i : Integer;
4294   pragma Linker_Alias (new_name_for_i, "i");
4295 end p;
4296 @end smallexample
4298 @node Pragma Linker_Constructor
4299 @unnumberedsec Pragma Linker_Constructor
4300 @findex Linker_Constructor
4301 @noindent
4302 Syntax:
4304 @smallexample @c ada
4305 pragma Linker_Constructor (procedure_LOCAL_NAME);
4306 @end smallexample
4308 @noindent
4309 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4310 is declared at the library level. A procedure to which this pragma is
4311 applied will be treated as an initialization routine by the linker.
4312 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4313 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4314 of the executable is called (or immediately after the shared library is
4315 loaded if the procedure is linked in a shared library), in particular
4316 before the Ada run-time environment is set up.
4318 Because of these specific contexts, the set of operations such a procedure
4319 can perform is very limited and the type of objects it can manipulate is
4320 essentially restricted to the elementary types. In particular, it must only
4321 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4323 This pragma is used by GNAT to implement auto-initialization of shared Stand
4324 Alone Libraries, which provides a related capability without the restrictions
4325 listed above. Where possible, the use of Stand Alone Libraries is preferable
4326 to the use of this pragma.
4328 @node Pragma Linker_Destructor
4329 @unnumberedsec Pragma Linker_Destructor
4330 @findex Linker_Destructor
4331 @noindent
4332 Syntax:
4334 @smallexample @c ada
4335 pragma Linker_Destructor (procedure_LOCAL_NAME);
4336 @end smallexample
4338 @noindent
4339 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4340 is declared at the library level. A procedure to which this pragma is
4341 applied will be treated as a finalization routine by the linker.
4342 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4343 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4344 of the executable has exited (or immediately before the shared library
4345 is unloaded if the procedure is linked in a shared library), in particular
4346 after the Ada run-time environment is shut down.
4348 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4349 because of these specific contexts.
4351 @node Pragma Linker_Section
4352 @unnumberedsec Pragma Linker_Section
4353 @findex Linker_Section
4354 @noindent
4355 Syntax:
4357 @smallexample @c ada
4358 pragma Linker_Section (
4359   [Entity  =>] LOCAL_NAME,
4360   [Section =>] static_string_EXPRESSION);
4361 @end smallexample
4363 @noindent
4364 @var{LOCAL_NAME} must refer to an object, type, or subprogram that is
4365 declared at the library level. This pragma specifies the name of the
4366 linker section for the given entity. It is equivalent to
4367 @code{__attribute__((section))} in GNU C and causes @var{LOCAL_NAME} to
4368 be placed in the @var{static_string_EXPRESSION} section of the
4369 executable (assuming the linker doesn't rename the section).
4370 GNAT also provides an implementation defined aspect of the same name.
4372 In the case of specifying this aspect for a type, the effect is to
4373 specify the corresponding for all library level objects of the type which
4374 do not have an explicit linker section set. Note that this only applies to
4375 whole objects, not to components of composite objects.
4377 In the case of a subprogram, the linker section applies to all previously
4378 declared matching overloaded subprograms in the current declarative part
4379 which do not already have a linker section assigned. The linker section
4380 aspect is useful in this case for specifying different linker sections
4381 for different elements of such an overloaded set.
4383 Note that an empty string specifies that no linker section is specified.
4384 This is not quite the same as omitting the pragma or aspect, since it
4385 can be used to specify that one element of an overloaded set of subprograms
4386 has the default linker section, or that one object of a type for which a
4387 linker section is specified should has the default linker section.
4389 The compiler normally places library-level entities in standard sections
4390 depending on the class: procedures and functions generally go in the
4391 @code{.text} section, initialized variables in the @code{.data} section
4392 and uninitialized variables in the @code{.bss} section.
4394 Other, special sections may exist on given target machines to map special
4395 hardware, for example I/O ports or flash memory. This pragma is a means to
4396 defer the final layout of the executable to the linker, thus fully working
4397 at the symbolic level with the compiler.
4399 Some file formats do not support arbitrary sections so not all target
4400 machines support this pragma. The use of this pragma may cause a program
4401 execution to be erroneous if it is used to place an entity into an
4402 inappropriate section (e.g.@: a modified variable into the @code{.text}
4403 section). See also @code{pragma Persistent_BSS}.
4405 @smallexample @c ada
4406 --  Example of the use of pragma Linker_Section
4408 package IO_Card is
4409   Port_A : Integer;
4410   pragma Volatile (Port_A);
4411   pragma Linker_Section (Port_A, ".bss.port_a");
4413   Port_B : Integer;
4414   pragma Volatile (Port_B);
4415   pragma Linker_Section (Port_B, ".bss.port_b");
4417   type Port_Type is new Integer with Linker_Section => ".bss";
4418   PA : Port_Type with Linker_Section => ".bss.PA";
4419   PB : Port_Type; --  ends up in linker section ".bss"
4421   procedure Q with Linker_Section => "Qsection";
4422 end IO_Card;
4423 @end smallexample
4425 @node Pragma Lock_Free
4426 @unnumberedsec Pragma Lock_Free
4427 @findex Lock_Free
4428 @noindent
4429 Syntax:
4430 This pragma may be specified for protected types or objects. It specifies that
4431 the implementation of protected operations must be implemented without locks.
4432 Compilation fails if the compiler cannot generate lock-free code for the
4433 operations.
4435 @node Pragma Long_Float
4436 @unnumberedsec Pragma Long_Float
4437 @cindex OpenVMS
4438 @findex Long_Float
4439 @noindent
4440 Syntax:
4442 @smallexample @c ada
4443 pragma Long_Float (FLOAT_FORMAT);
4445 FLOAT_FORMAT ::= D_Float | G_Float
4446 @end smallexample
4448 @noindent
4449 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4450 It allows control over the internal representation chosen for the predefined
4451 type @code{Long_Float} and for floating point type representations with
4452 @code{digits} specified in the range 7 through 15.
4453 For further details on this pragma, see the
4454 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
4455 this pragma, the standard runtime libraries must be recompiled.
4457 @node Pragma Loop_Invariant
4458 @unnumberedsec Pragma Loop_Invariant
4459 @findex Loop_Invariant
4460 @noindent
4461 Syntax:
4463 @smallexample @c ada
4464 pragma Loop_Invariant ( boolean_EXPRESSION );
4465 @end smallexample
4467 @noindent
4468 The effect of this pragma is similar to that of pragma @code{Assert},
4469 except that in an @code{Assertion_Policy} pragma, the identifier
4470 @code{Loop_Invariant} is used to control whether it is ignored or checked
4471 (or disabled).
4473 @code{Loop_Invariant} can only appear as one of the items in the sequence
4474 of statements of a loop body, or nested inside block statements that
4475 appear in the sequence of statements of a loop body.
4476 The intention is that it be used to
4477 represent a "loop invariant" assertion, i.e. something that is true each
4478 time through the loop, and which can be used to show that the loop is
4479 achieving its purpose.
4481 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4482 apply to the same loop should be grouped in the same sequence of
4483 statements.
4485 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4486 may be used to refer to the value of an expression on entry to the loop. This
4487 attribute can only be used within the expression of a @code{Loop_Invariant}
4488 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4490 @node Pragma Loop_Optimize
4491 @unnumberedsec Pragma Loop_Optimize
4492 @findex Loop_Optimize
4493 @noindent
4494 Syntax:
4496 @smallexample @c ada
4497 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4499 OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
4500 @end smallexample
4502 @noindent
4503 This pragma must appear immediately within a loop statement.  It allows the
4504 programmer to specify optimization hints for the enclosing loop.  The hints
4505 are not mutually exclusive and can be freely mixed, but not all combinations
4506 will yield a sensible outcome.
4508 There are five supported optimization hints for a loop:
4510 @itemize @bullet
4511 @item Ivdep
4513 The programmer asserts that there are no loop-carried dependencies
4514 which would prevent consecutive iterations of the loop from being
4515 executed simultaneously.
4517 @item No_Unroll
4519 The loop must not be unrolled.  This is a strong hint: the compiler will not
4520 unroll a loop marked with this hint.
4522 @item Unroll
4524 The loop should be unrolled.  This is a weak hint: the compiler will try to
4525 apply unrolling to this loop preferably to other optimizations, notably
4526 vectorization, but there is no guarantee that the loop will be unrolled.
4528 @item No_Vector
4530 The loop must not be vectorized.  This is a strong hint: the compiler will not
4531 vectorize a loop marked with this hint.
4533 @item Vector
4535 The loop should be vectorized.  This is a weak hint: the compiler will try to
4536 apply vectorization to this loop preferably to other optimizations, notably
4537 unrolling, but there is no guarantee that the loop will be vectorized.
4539 @end itemize
4541 These hints do not remove the need to pass the appropriate switches to the
4542 compiler in order to enable the relevant optimizations, that is to say
4543 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4544 vectorization.
4546 @node Pragma Loop_Variant
4547 @unnumberedsec Pragma Loop_Variant
4548 @findex Loop_Variant
4549 @noindent
4550 Syntax:
4552 @smallexample @c ada
4553 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4554 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4555 CHANGE_DIRECTION ::= Increases | Decreases
4556 @end smallexample
4558 @noindent
4559 @code{Loop_Variant} can only appear as one of the items in the sequence
4560 of statements of a loop body, or nested inside block statements that
4561 appear in the sequence of statements of a loop body.
4562 It allows the specification of quantities which must always
4563 decrease or increase in successive iterations of the loop. In its simplest
4564 form, just one expression is specified, whose value must increase or decrease
4565 on each iteration of the loop.
4567 In a more complex form, multiple arguments can be given which are intepreted
4568 in a nesting lexicographic manner. For example:
4570 @smallexample @c ada
4571 pragma Loop_Variant (Increases => X, Decreases => Y);
4572 @end smallexample
4574 @noindent
4575 specifies that each time through the loop either X increases, or X stays
4576 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4577 loop is making progress. It can be useful in helping to show informally
4578 or prove formally that the loop always terminates.
4580 @code{Loop_Variant} is an assertion whose effect can be controlled using
4581 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4582 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4583 to ignore the check (in which case the pragma has no effect on the program),
4584 or @code{Disable} in which case the pragma is not even checked for correct
4585 syntax.
4587 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4588 apply to the same loop should be grouped in the same sequence of
4589 statements.
4591 The @code{Loop_Entry} attribute may be used within the expressions of the
4592 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4594 @node Pragma Machine_Attribute
4595 @unnumberedsec Pragma Machine_Attribute
4596 @findex Machine_Attribute
4597 @noindent
4598 Syntax:
4600 @smallexample @c ada
4601 pragma Machine_Attribute (
4602      [Entity         =>] LOCAL_NAME,
4603      [Attribute_Name =>] static_string_EXPRESSION
4604   [, [Info           =>] static_EXPRESSION] );
4605 @end smallexample
4607 @noindent
4608 Machine-dependent attributes can be specified for types and/or
4609 declarations.  This pragma is semantically equivalent to
4610 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4611 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4612 in GNU C, where @code{@var{attribute_name}} is recognized by the
4613 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4614 specific macro.  A string literal for the optional parameter @var{info}
4615 is transformed into an identifier, which may make this pragma unusable
4616 for some attributes.  @xref{Target Attributes,, Defining target-specific
4617 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4618 Internals}, further information.
4620 @node Pragma Main
4621 @unnumberedsec Pragma Main
4622 @cindex OpenVMS
4623 @findex Main
4624 @noindent
4625 Syntax:
4627 @smallexample @c ada
4628 pragma Main
4629  (MAIN_OPTION [, MAIN_OPTION]);
4631 MAIN_OPTION ::=
4632   [Stack_Size              =>] static_integer_EXPRESSION
4633 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4634 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
4635 @end smallexample
4637 @noindent
4638 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4639 no effect in GNAT, other than being syntax checked.
4641 @node Pragma Main_Storage
4642 @unnumberedsec Pragma Main_Storage
4643 @cindex OpenVMS
4644 @findex Main_Storage
4645 @noindent
4646 Syntax:
4648 @smallexample @c ada
4649 pragma Main_Storage
4650   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4652 MAIN_STORAGE_OPTION ::=
4653   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4654 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
4655 @end smallexample
4657 @noindent
4658 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4659 no effect in GNAT, other than being syntax checked.  Note that the pragma
4660 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4662 @node Pragma No_Body
4663 @unnumberedsec Pragma No_Body
4664 @findex No_Body
4665 @noindent
4666 Syntax:
4668 @smallexample @c ada
4669 pragma No_Body;
4670 @end smallexample
4672 @noindent
4673 There are a number of cases in which a package spec does not require a body,
4674 and in fact a body is not permitted. GNAT will not permit the spec to be
4675 compiled if there is a body around. The pragma No_Body allows you to provide
4676 a body file, even in a case where no body is allowed. The body file must
4677 contain only comments and a single No_Body pragma. This is recognized by
4678 the compiler as indicating that no body is logically present.
4680 This is particularly useful during maintenance when a package is modified in
4681 such a way that a body needed before is no longer needed. The provision of a
4682 dummy body with a No_Body pragma ensures that there is no interference from
4683 earlier versions of the package body.
4685 @node Pragma No_Elaboration_Code_All
4686 @unnumberedsec Pragma No_Elaboration_Code_All
4687 @findex No_Elaboration_Code_All
4688 @noindent
4689 Syntax:
4691 @smallexample @c ada
4692 pragma No_Elaboration_Code_All [(program_unit_NAME)];
4693 @end smallexample
4695 @noindent
4696 This is a program unit pragma (there is also an equivalent aspect of the
4697 same name) that establishes the restriction @code{No_Elaboration_Code} for
4698 the current unit and any extended main source units (body and subunits.
4699 It also has has the effect of enforcing a transitive application of this
4700 aspect, so that if any unit is implicitly or explicitly WITH'ed by the
4701 current unit, it must also have the No_Elaboration_Code_All aspect set.
4703 @node Pragma No_Inline
4704 @unnumberedsec Pragma No_Inline
4705 @findex No_Inline
4706 @noindent
4707 Syntax:
4709 @smallexample @c ada
4710 pragma No_Inline (NAME @{, NAME@});
4711 @end smallexample
4713 @noindent
4714 This pragma suppresses inlining for the callable entity or the instances of
4715 the generic subprogram designated by @var{NAME}, including inlining that
4716 results from the use of pragma @code{Inline}.  This pragma is always active,
4717 in particular it is not subject to the use of option @option{-gnatn} or
4718 @option{-gnatN}.  It is illegal to specify both pragma @code{No_Inline} and
4719 pragma @code{Inline_Always} for the same @var{NAME}.
4721 @node Pragma No_Return
4722 @unnumberedsec Pragma No_Return
4723 @findex No_Return
4724 @noindent
4725 Syntax:
4727 @smallexample @c ada
4728 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4729 @end smallexample
4731 @noindent
4732 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4733 declarations in the current declarative part.  A procedure to which this
4734 pragma is applied may not contain any explicit @code{return} statements.
4735 In addition, if the procedure contains any implicit returns from falling
4736 off the end of a statement sequence, then execution of that implicit
4737 return will cause Program_Error to be raised.
4739 One use of this pragma is to identify procedures whose only purpose is to raise
4740 an exception. Another use of this pragma is to suppress incorrect warnings
4741 about missing returns in functions, where the last statement of a function
4742 statement sequence is a call to such a procedure.
4744 Note that in Ada 2005 mode, this pragma is part of the language. It is
4745 available in all earlier versions of Ada as an implementation-defined
4746 pragma.
4748 @node Pragma No_Run_Time
4749 @unnumberedsec Pragma No_Run_Time
4750 @findex No_Run_Time
4751 @noindent
4752 Syntax:
4754 @smallexample @c ada
4755 pragma No_Run_Time;
4756 @end smallexample
4758 @noindent
4759 This is an obsolete configuration pragma that historically was used to
4760 set up a runtime library with no object code. It is now used only for
4761 internal testing. The pragma has been superseded by the reconfigurable
4762 runtime capability of @code{GNAT}.
4764 @node Pragma No_Strict_Aliasing
4765 @unnumberedsec Pragma No_Strict_Aliasing
4766 @findex No_Strict_Aliasing
4767 @noindent
4768 Syntax:
4770 @smallexample @c ada
4771 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4772 @end smallexample
4774 @noindent
4775 @var{type_LOCAL_NAME} must refer to an access type
4776 declaration in the current declarative part.  The effect is to inhibit
4777 strict aliasing optimization for the given type.  The form with no
4778 arguments is a configuration pragma which applies to all access types
4779 declared in units to which the pragma applies. For a detailed
4780 description of the strict aliasing optimization, and the situations
4781 in which it must be suppressed, see @ref{Optimization and Strict
4782 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4784 This pragma currently has no effects on access to unconstrained array types.
4786 @node Pragma No_Tagged_Streams
4787 @unnumberedsec Pragma No_Tagged_Streams
4788 @findex No_Tagged_Streams
4789 @noindent
4790 Syntax:
4792 @smallexample @c ada
4793 pragma No_Tagged_Streams;
4794 pragma No_Tagged_Streams [([Entity =>] tagged_type_LOCAL_NAME)];
4795 @end smallexample
4797 @noindent
4798 Normally when a tagged type is introduced using a full type declaration,
4799 part of the processing includes generating stream access routines to be
4800 used by stream attributes referencing the type (or one of its subtypes
4801 or derived types). This can involve the generation of significant amounts
4802 of code which is wasted space if stream routines are not needed for the
4803 type in question.
4805 The @code{No_Tagged_Streams} pragma causes the generation of these stream
4806 routines to be skipped, and any attempt to use stream operations on
4807 types subject to this pragma will be statically rejected as illegal.
4809 There are two forms of the pragma. The form with no arguments must appear
4810 in a declarative sequence or in the declarations of a package spec. This
4811 pragma affects all subsequent root tagged types declared in the declaration
4812 sequence, and specifies that no stream routines be generated. The form with
4813 an argument (for which there is also a corresponding aspect) specifies a
4814 single root tagged type for which stream routines are not to be generated.
4816 Once the pragma has been given for a particular root tagged type, all subtypes
4817 and derived types of this type inherit the pragma automatically, so the effect
4818 applies to a complete hierarchy (this is necessary to deal with the class-wide
4819 dispatching versions of the stream routines).
4821 @node Pragma Normalize_Scalars
4822 @unnumberedsec Pragma Normalize_Scalars
4823 @findex Normalize_Scalars
4824 @noindent
4825 Syntax:
4827 @smallexample @c ada
4828 pragma Normalize_Scalars;
4829 @end smallexample
4831 @noindent
4832 This is a language defined pragma which is fully implemented in GNAT@.  The
4833 effect is to cause all scalar objects that are not otherwise initialized
4834 to be initialized.  The initial values are implementation dependent and
4835 are as follows:
4837 @table @code
4838 @item Standard.Character
4839 @noindent
4840 Objects whose root type is Standard.Character are initialized to
4841 Character'Last unless the subtype range excludes NUL (in which case
4842 NUL is used). This choice will always generate an invalid value if
4843 one exists.
4845 @item Standard.Wide_Character
4846 @noindent
4847 Objects whose root type is Standard.Wide_Character are initialized to
4848 Wide_Character'Last unless the subtype range excludes NUL (in which case
4849 NUL is used). This choice will always generate an invalid value if
4850 one exists.
4852 @item Standard.Wide_Wide_Character
4853 @noindent
4854 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4855 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4856 which case NUL is used). This choice will always generate an invalid value if
4857 one exists.
4859 @item Integer types
4860 @noindent
4861 Objects of an integer type are treated differently depending on whether
4862 negative values are present in the subtype. If no negative values are
4863 present, then all one bits is used as the initial value except in the
4864 special case where zero is excluded from the subtype, in which case
4865 all zero bits are used. This choice will always generate an invalid
4866 value if one exists.
4868 For subtypes with negative values present, the largest negative number
4869 is used, except in the unusual case where this largest negative number
4870 is in the subtype, and the largest positive number is not, in which case
4871 the largest positive value is used. This choice will always generate
4872 an invalid value if one exists.
4874 @item Floating-Point Types
4875 Objects of all floating-point types are initialized to all 1-bits. For
4876 standard IEEE format, this corresponds to a NaN (not a number) which is
4877 indeed an invalid value.
4879 @item Fixed-Point Types
4880 Objects of all fixed-point types are treated as described above for integers,
4881 with the rules applying to the underlying integer value used to represent
4882 the fixed-point value.
4884 @item Modular types
4885 Objects of a modular type are initialized to all one bits, except in
4886 the special case where zero is excluded from the subtype, in which
4887 case all zero bits are used. This choice will always generate an
4888 invalid value if one exists.
4890 @item Enumeration types
4891 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4892 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4893 whose Pos value is zero, in which case a code of zero is used. This choice
4894 will always generate an invalid value if one exists.
4896 @end table
4898 @node Pragma Obsolescent
4899 @unnumberedsec Pragma Obsolescent
4900 @findex Obsolescent
4901 @noindent
4902 Syntax:
4904 @smallexample @c ada
4905 pragma Obsolescent;
4907 pragma Obsolescent (
4908   [Message =>] static_string_EXPRESSION
4909 [,[Version =>] Ada_05]]);
4911 pragma Obsolescent (
4912   [Entity  =>] NAME
4913 [,[Message =>] static_string_EXPRESSION
4914 [,[Version =>] Ada_05]] );
4915 @end smallexample
4917 @noindent
4918 This pragma can occur immediately following a declaration of an entity,
4919 including the case of a record component. If no Entity argument is present,
4920 then this declaration is the one to which the pragma applies. If an Entity
4921 parameter is present, it must either match the name of the entity in this
4922 declaration, or alternatively, the pragma can immediately follow an enumeration
4923 type declaration, where the Entity argument names one of the enumeration
4924 literals.
4926 This pragma is used to indicate that the named entity
4927 is considered obsolescent and should not be used. Typically this is
4928 used when an API must be modified by eventually removing or modifying
4929 existing subprograms or other entities. The pragma can be used at an
4930 intermediate stage when the entity is still present, but will be
4931 removed later.
4933 The effect of this pragma is to output a warning message on a reference to
4934 an entity thus marked that the subprogram is obsolescent if the appropriate
4935 warning option in the compiler is activated. If the Message parameter is
4936 present, then a second warning message is given containing this text. In
4937 addition, a reference to the entity is considered to be a violation of pragma
4938 Restrictions (No_Obsolescent_Features).
4940 This pragma can also be used as a program unit pragma for a package,
4941 in which case the entity name is the name of the package, and the
4942 pragma indicates that the entire package is considered
4943 obsolescent. In this case a client @code{with}'ing such a package
4944 violates the restriction, and the @code{with} statement is
4945 flagged with warnings if the warning option is set.
4947 If the Version parameter is present (which must be exactly
4948 the identifier Ada_05, no other argument is allowed), then the
4949 indication of obsolescence applies only when compiling in Ada 2005
4950 mode. This is primarily intended for dealing with the situations
4951 in the predefined library where subprograms or packages
4952 have become defined as obsolescent in Ada 2005
4953 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4955 The following examples show typical uses of this pragma:
4957 @smallexample @c ada
4958 package p is
4959    pragma Obsolescent (p, Message => "use pp instead of p");
4960 end p;
4962 package q is
4963    procedure q2;
4964    pragma Obsolescent ("use q2new instead");
4966    type R is new integer;
4967    pragma Obsolescent
4968      (Entity  => R,
4969       Message => "use RR in Ada 2005",
4970       Version => Ada_05);
4972    type M is record
4973       F1 : Integer;
4974       F2 : Integer;
4975       pragma Obsolescent;
4976       F3 : Integer;
4977    end record;
4979    type E is (a, bc, 'd', quack);
4980    pragma Obsolescent (Entity => bc)
4981    pragma Obsolescent (Entity => 'd')
4983    function "+"
4984      (a, b : character) return character;
4985    pragma Obsolescent (Entity => "+");
4986 end;
4987 @end smallexample
4989 @noindent
4990 Note that, as for all pragmas, if you use a pragma argument identifier,
4991 then all subsequent parameters must also use a pragma argument identifier.
4992 So if you specify "Entity =>" for the Entity argument, and a Message
4993 argument is present, it must be preceded by "Message =>".
4995 @node Pragma Optimize_Alignment
4996 @unnumberedsec Pragma Optimize_Alignment
4997 @findex Optimize_Alignment
4998 @cindex Alignment, default settings
4999 @noindent
5000 Syntax:
5002 @smallexample @c ada
5003 pragma Optimize_Alignment (TIME | SPACE | OFF);
5004 @end smallexample
5006 @noindent
5007 This is a configuration pragma which affects the choice of default alignments
5008 for types and objects where no alignment is explicitly specified. There is a
5009 time/space trade-off in the selection of these values. Large alignments result
5010 in more efficient code, at the expense of larger data space, since sizes have
5011 to be increased to match these alignments. Smaller alignments save space, but
5012 the access code is slower. The normal choice of default alignments for types
5013 and individual alignment promotions for objects (which is what you get if you
5014 do not use this pragma, or if you use an argument of OFF), tries to balance
5015 these two requirements.
5017 Specifying SPACE causes smaller default alignments to be chosen in two cases.
5018 First any packed record is given an alignment of 1. Second, if a size is given
5019 for the type, then the alignment is chosen to avoid increasing this size. For
5020 example, consider:
5022 @smallexample @c ada
5023    type R is record
5024       X : Integer;
5025       Y : Character;
5026    end record;
5028    for R'Size use 5*8;
5029 @end smallexample
5031 @noindent
5032 In the default mode, this type gets an alignment of 4, so that access to the
5033 Integer field X are efficient. But this means that objects of the type end up
5034 with a size of 8 bytes. This is a valid choice, since sizes of objects are
5035 allowed to be bigger than the size of the type, but it can waste space if for
5036 example fields of type R appear in an enclosing record. If the above type is
5037 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
5039 However, there is one case in which SPACE is ignored. If a variable length
5040 record (that is a discriminated record with a component which is an array
5041 whose length depends on a discriminant), has a pragma Pack, then it is not
5042 in general possible to set the alignment of such a record to one, so the
5043 pragma is ignored in this case (with a warning).
5045 Specifying SPACE also disables alignment promotions for standalone objects,
5046 which occur when the compiler increases the alignment of a specific object
5047 without changing the alignment of its type.
5049 Specifying TIME causes larger default alignments to be chosen in the case of
5050 small types with sizes that are not a power of 2. For example, consider:
5052 @smallexample @c ada
5053    type R is record
5054       A : Character;
5055       B : Character;
5056       C : Boolean;
5057    end record;
5059    pragma Pack (R);
5060    for R'Size use 17;
5061 @end smallexample
5063 @noindent
5064 The default alignment for this record is normally 1, but if this type is
5065 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
5066 to 4, which wastes space for objects of the type, since they are now 4 bytes
5067 long, but results in more efficient access when the whole record is referenced.
5069 As noted above, this is a configuration pragma, and there is a requirement
5070 that all units in a partition be compiled with a consistent setting of the
5071 optimization setting. This would normally be achieved by use of a configuration
5072 pragma file containing the appropriate setting. The exception to this rule is
5073 that units with an explicit configuration pragma in the same file as the source
5074 unit are excluded from the consistency check, as are all predefined units. The
5075 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
5076 pragma appears at the start of the file.
5078 @node Pragma Ordered
5079 @unnumberedsec Pragma Ordered
5080 @findex Ordered
5081 @findex pragma @code{Ordered}
5082 @noindent
5083 Syntax:
5085 @smallexample @c ada
5086 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
5087 @end smallexample
5089 @noindent
5090 Most enumeration types are from a conceptual point of view unordered.
5091 For example, consider:
5093 @smallexample @c ada
5094 type Color is (Red, Blue, Green, Yellow);
5095 @end smallexample
5097 @noindent
5098 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
5099 but really these relations make no sense; the enumeration type merely
5100 specifies a set of possible colors, and the order is unimportant.
5102 For unordered enumeration types, it is generally a good idea if
5103 clients avoid comparisons (other than equality or inequality) and
5104 explicit ranges. (A @emph{client} is a unit where the type is referenced,
5105 other than the unit where the type is declared, its body, and its subunits.)
5106 For example, if code buried in some client says:
5108 @smallexample @c ada
5109 if Current_Color < Yellow then ...
5110 if Current_Color in Blue .. Green then ...
5111 @end smallexample
5113 @noindent
5114 then the client code is relying on the order, which is undesirable.
5115 It makes the code hard to read and creates maintenance difficulties if
5116 entries have to be added to the enumeration type. Instead,
5117 the code in the client should list the possibilities, or an
5118 appropriate subtype should be declared in the unit that declares
5119 the original enumeration type. E.g., the following subtype could
5120 be declared along with the type @code{Color}:
5122 @smallexample @c ada
5123 subtype RBG is Color range Red .. Green;
5124 @end smallexample
5126 @noindent
5127 and then the client could write:
5129 @smallexample @c ada
5130 if Current_Color in RBG then ...
5131 if Current_Color = Blue or Current_Color = Green then ...
5132 @end smallexample
5134 @noindent
5135 However, some enumeration types are legitimately ordered from a conceptual
5136 point of view. For example, if you declare:
5138 @smallexample @c ada
5139 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
5140 @end smallexample
5142 @noindent
5143 then the ordering imposed by the language is reasonable, and
5144 clients can depend on it, writing for example:
5146 @smallexample @c ada
5147 if D in Mon .. Fri then ...
5148 if D < Wed then ...
5149 @end smallexample
5151 @noindent
5152 The pragma @option{Ordered} is provided to mark enumeration types that
5153 are conceptually ordered, alerting the reader that clients may depend
5154 on the ordering. GNAT provides a pragma to mark enumerations as ordered
5155 rather than one to mark them as unordered, since in our experience,
5156 the great majority of enumeration types are conceptually unordered.
5158 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
5159 and @code{Wide_Wide_Character}
5160 are considered to be ordered types, so each is declared with a
5161 pragma @code{Ordered} in package @code{Standard}.
5163 Normally pragma @code{Ordered} serves only as documentation and a guide for
5164 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
5165 requests warnings for inappropriate uses (comparisons and explicit
5166 subranges) for unordered types. If this switch is used, then any
5167 enumeration type not marked with pragma @code{Ordered} will be considered
5168 as unordered, and will generate warnings for inappropriate uses.
5170 Note that generic types are not considered ordered or unordered (since the
5171 template can be instantiated for both cases), so we never generate warnings
5172 for the case of generic enumerated types.
5174 For additional information please refer to the description of the
5175 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
5177 @node Pragma Overflow_Mode
5178 @unnumberedsec Pragma Overflow_Mode
5179 @findex Overflow checks
5180 @findex Overflow mode
5181 @findex pragma @code{Overflow_Mode}
5182 @noindent
5183 Syntax:
5185 @smallexample @c ada
5186 pragma Overflow_Mode
5187  (  [General    =>] MODE
5188   [,[Assertions =>] MODE]);
5190 MODE ::= STRICT | MINIMIZED | ELIMINATED
5191 @end smallexample
5193 @noindent
5194 This pragma sets the current overflow mode to the given setting. For details
5195 of the meaning of these modes, please refer to the
5196 ``Overflow Check Handling in GNAT'' appendix in the
5197 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
5198 the given mode applies to all expressions. If both parameters are present,
5199 the @code{General} mode applies to expressions outside assertions, and
5200 the @code{Eliminated} mode applies to expressions within assertions.
5202 The case of the @code{MODE} parameter is ignored,
5203 so @code{MINIMIZED}, @code{Minimized} and
5204 @code{minimized} all have the same effect.
5206 The @code{Overflow_Mode} pragma has the same scoping and placement
5207 rules as pragma @code{Suppress}, so it can occur either as a
5208 configuration pragma, specifying a default for the whole
5209 program, or in a declarative scope, where it applies to the
5210 remaining declarations and statements in that scope.
5212 The pragma @code{Suppress (Overflow_Check)} suppresses
5213 overflow checking, but does not affect the overflow mode.
5215 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
5216 overflow checking, but does not affect the overflow mode.
5218 @node Pragma Overriding_Renamings
5219 @unnumberedsec Pragma Overriding_Renamings
5220 @findex Overriding_Renamings
5221 @cindex Rational profile
5222 @cindex Rational compatibility
5223 @noindent
5224 Syntax:
5226 @smallexample @c ada
5227 pragma Overriding_Renamings;
5228 @end smallexample
5230 @noindent
5231 This is a GNAT configuration pragma to simplify porting
5232 legacy code accepted by the Rational
5233 Ada compiler. In the presence of this pragma, a renaming declaration that
5234 renames an inherited operation declared in the same scope is legal if selected
5235 notation is used as in:
5237 @smallexample @c ada
5238 pragma Overriding_Renamings;
5240 package R is
5241   function F (..);
5242   ...
5243   function F (..) renames R.F;
5244 end R;
5245 @end smallexample
5247 even though
5248 RM 8.3 (15) stipulates that an overridden operation is not visible within the
5249 declaration of the overriding operation.
5251 @node Pragma Partition_Elaboration_Policy
5252 @unnumberedsec Pragma Partition_Elaboration_Policy
5253 @findex Partition_Elaboration_Policy
5254 @noindent
5255 Syntax:
5257 @smallexample @c ada
5258 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
5260 POLICY_IDENTIFIER ::= Concurrent | Sequential
5261 @end smallexample
5263 @noindent
5264 This pragma is standard in Ada 2005, but is available in all earlier
5265 versions of Ada as an implementation-defined pragma.
5266 See Ada 2012 Reference Manual for details.
5268 @node Pragma Part_Of
5269 @unnumberedsec Pragma Part_Of
5270 @findex Part_Of
5271 @noindent
5272 For the description of this pragma, see SPARK 2014 Reference Manual,
5273 section 7.2.6.
5275 @node Pragma Passive
5276 @unnumberedsec Pragma Passive
5277 @findex Passive
5278 @noindent
5279 Syntax:
5281 @smallexample @c ada
5282 pragma Passive [(Semaphore | No)];
5283 @end smallexample
5285 @noindent
5286 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
5287 compatibility with DEC Ada 83 implementations, where it is used within a
5288 task definition to request that a task be made passive.  If the argument
5289 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
5290 treats the pragma as an assertion that the containing task is passive
5291 and that optimization of context switch with this task is permitted and
5292 desired.  If the argument @code{No} is present, the task must not be
5293 optimized.  GNAT does not attempt to optimize any tasks in this manner
5294 (since protected objects are available in place of passive tasks).
5296 For more information on the subject of passive tasks, see the section
5297 ``Passive Task Optimization'' in the GNAT Users Guide.
5299 @node Pragma Persistent_BSS
5300 @unnumberedsec Pragma Persistent_BSS
5301 @findex Persistent_BSS
5302 @noindent
5303 Syntax:
5305 @smallexample @c ada
5306 pragma Persistent_BSS [(LOCAL_NAME)]
5307 @end smallexample
5309 @noindent
5310 This pragma allows selected objects to be placed in the @code{.persistent_bss}
5311 section. On some targets the linker and loader provide for special
5312 treatment of this section, allowing a program to be reloaded without
5313 affecting the contents of this data (hence the name persistent).
5315 There are two forms of usage. If an argument is given, it must be the
5316 local name of a library level object, with no explicit initialization
5317 and whose type is potentially persistent. If no argument is given, then
5318 the pragma is a configuration pragma, and applies to all library level
5319 objects with no explicit initialization of potentially persistent types.
5321 A potentially persistent type is a scalar type, or an untagged,
5322 non-discriminated record, all of whose components have no explicit
5323 initialization and are themselves of a potentially persistent type,
5324 or an array, all of whose constraints are static, and whose component
5325 type is potentially persistent.
5327 If this pragma is used on a target where this feature is not supported,
5328 then the pragma will be ignored. See also @code{pragma Linker_Section}.
5330 @node Pragma Polling
5331 @unnumberedsec Pragma Polling
5332 @findex Polling
5333 @noindent
5334 Syntax:
5336 @smallexample @c ada
5337 pragma Polling (ON | OFF);
5338 @end smallexample
5340 @noindent
5341 This pragma controls the generation of polling code.  This is normally off.
5342 If @code{pragma Polling (ON)} is used then periodic calls are generated to
5343 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
5344 runtime library, and can be found in file @file{a-excpol.adb}.
5346 Pragma @code{Polling} can appear as a configuration pragma (for example it
5347 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
5348 can be used in the statement or declaration sequence to control polling
5349 more locally.
5351 A call to the polling routine is generated at the start of every loop and
5352 at the start of every subprogram call.  This guarantees that the @code{Poll}
5353 routine is called frequently, and places an upper bound (determined by
5354 the complexity of the code) on the period between two @code{Poll} calls.
5356 The primary purpose of the polling interface is to enable asynchronous
5357 aborts on targets that cannot otherwise support it (for example Windows
5358 NT), but it may be used for any other purpose requiring periodic polling.
5359 The standard version is null, and can be replaced by a user program.  This
5360 will require re-compilation of the @code{Ada.Exceptions} package that can
5361 be found in files @file{a-except.ads} and @file{a-except.adb}.
5363 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
5364 distribution) is used to enable the asynchronous abort capability on
5365 targets that do not normally support the capability.  The version of
5366 @code{Poll} in this file makes a call to the appropriate runtime routine
5367 to test for an abort condition.
5369 Note that polling can also be enabled by use of the @option{-gnatP} switch.
5370 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
5371 details.
5373 @node Pragma Post
5374 @unnumberedsec Pragma Post
5375 @cindex Post
5376 @cindex Checks, postconditions
5377 @findex Postconditions
5378 @noindent
5379 Syntax:
5381 @smallexample @c ada
5382 pragma Post (Boolean_Expression);
5383 @end smallexample
5385 @noindent
5386 The @code{Post} pragma is intended to be an exact replacement for
5387 the language-defined
5388 @code{Post} aspect, and shares its restrictions and semantics.
5389 It must appear either immediately following the corresponding
5390 subprogram declaration (only other pragmas may intervene), or
5391 if there is no separate subprogram declaration, then it can
5392 appear at the start of the declarations in a subprogram body
5393 (preceded only by other pragmas).
5395 @node Pragma Postcondition
5396 @unnumberedsec Pragma Postcondition
5397 @cindex Postcondition
5398 @cindex Checks, postconditions
5399 @findex Postconditions
5400 @noindent
5401 Syntax:
5403 @smallexample @c ada
5404 pragma Postcondition (
5405    [Check   =>] Boolean_Expression
5406  [,[Message =>] String_Expression]);
5407 @end smallexample
5409 @noindent
5410 The @code{Postcondition} pragma allows specification of automatic
5411 postcondition checks for subprograms. These checks are similar to
5412 assertions, but are automatically inserted just prior to the return
5413 statements of the subprogram with which they are associated (including
5414 implicit returns at the end of procedure bodies and associated
5415 exception handlers).
5417 In addition, the boolean expression which is the condition which
5418 must be true may contain references to function'Result in the case
5419 of a function to refer to the returned value.
5421 @code{Postcondition} pragmas may appear either immediately following the
5422 (separate) declaration of a subprogram, or at the start of the
5423 declarations of a subprogram body. Only other pragmas may intervene
5424 (that is appear between the subprogram declaration and its
5425 postconditions, or appear before the postcondition in the
5426 declaration sequence in a subprogram body). In the case of a
5427 postcondition appearing after a subprogram declaration, the
5428 formal arguments of the subprogram are visible, and can be
5429 referenced in the postcondition expressions.
5431 The postconditions are collected and automatically tested just
5432 before any return (implicit or explicit) in the subprogram body.
5433 A postcondition is only recognized if postconditions are active
5434 at the time the pragma is encountered. The compiler switch @option{gnata}
5435 turns on all postconditions by default, and pragma @code{Check_Policy}
5436 with an identifier of @code{Postcondition} can also be used to
5437 control whether postconditions are active.
5439 The general approach is that postconditions are placed in the spec
5440 if they represent functional aspects which make sense to the client.
5441 For example we might have:
5443 @smallexample @c ada
5444    function Direction return Integer;
5445    pragma Postcondition
5446     (Direction'Result = +1
5447        or else
5448      Direction'Result = -1);
5449 @end smallexample
5451 @noindent
5452 which serves to document that the result must be +1 or -1, and
5453 will test that this is the case at run time if postcondition
5454 checking is active.
5456 Postconditions within the subprogram body can be used to
5457 check that some internal aspect of the implementation,
5458 not visible to the client, is operating as expected.
5459 For instance if a square root routine keeps an internal
5460 counter of the number of times it is called, then we
5461 might have the following postcondition:
5463 @smallexample @c ada
5464    Sqrt_Calls : Natural := 0;
5466    function Sqrt (Arg : Float) return Float is
5467      pragma Postcondition
5468        (Sqrt_Calls = Sqrt_Calls'Old + 1);
5469      ...
5470    end Sqrt
5471 @end smallexample
5473 @noindent
5474 As this example, shows, the use of the @code{Old} attribute
5475 is often useful in postconditions to refer to the state on
5476 entry to the subprogram.
5478 Note that postconditions are only checked on normal returns
5479 from the subprogram. If an abnormal return results from
5480 raising an exception, then the postconditions are not checked.
5482 If a postcondition fails, then the exception
5483 @code{System.Assertions.Assert_Failure} is raised. If
5484 a message argument was supplied, then the given string
5485 will be used as the exception message. If no message
5486 argument was supplied, then the default message has
5487 the form "Postcondition failed at file:line". The
5488 exception is raised in the context of the subprogram
5489 body, so it is possible to catch postcondition failures
5490 within the subprogram body itself.
5492 Within a package spec, normal visibility rules
5493 in Ada would prevent forward references within a
5494 postcondition pragma to functions defined later in
5495 the same package. This would introduce undesirable
5496 ordering constraints. To avoid this problem, all
5497 postcondition pragmas are analyzed at the end of
5498 the package spec, allowing forward references.
5500 The following example shows that this even allows
5501 mutually recursive postconditions as in:
5503 @smallexample @c ada
5504 package Parity_Functions is
5505    function Odd  (X : Natural) return Boolean;
5506    pragma Postcondition
5507      (Odd'Result =
5508         (x = 1
5509           or else
5510         (x /= 0 and then Even (X - 1))));
5512    function Even (X : Natural) return Boolean;
5513    pragma Postcondition
5514      (Even'Result =
5515         (x = 0
5516           or else
5517         (x /= 1 and then Odd (X - 1))));
5519 end Parity_Functions;
5520 @end smallexample
5522 @noindent
5523 There are no restrictions on the complexity or form of
5524 conditions used within @code{Postcondition} pragmas.
5525 The following example shows that it is even possible
5526 to verify performance behavior.
5528 @smallexample @c ada
5529 package Sort is
5531    Performance : constant Float;
5532    --  Performance constant set by implementation
5533    --  to match target architecture behavior.
5535    procedure Treesort (Arg : String);
5536    --  Sorts characters of argument using N*logN sort
5537    pragma Postcondition
5538      (Float (Clock - Clock'Old) <=
5539         Float (Arg'Length) *
5540         log (Float (Arg'Length)) *
5541         Performance);
5542 end Sort;
5543 @end smallexample
5545 @noindent
5546 Note: postcondition pragmas associated with subprograms that are
5547 marked as Inline_Always, or those marked as Inline with front-end
5548 inlining (-gnatN option set) are accepted and legality-checked
5549 by the compiler, but are ignored at run-time even if postcondition
5550 checking is enabled.
5552 Note that pragma @code{Postcondition} differs from the language-defined
5553 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
5554 multiple occurrences, allowing occurences in the body even if there
5555 is a separate spec, and allowing a second string parameter, and the
5556 use of the pragma identifier @code{Check}. Historically, pragma
5557 @code{Postcondition} was implemented prior to the development of
5558 Ada 2012, and has been retained in its original form for
5559 compatibility purposes.
5561 @node Pragma Post_Class
5562 @unnumberedsec Pragma Post_Class
5563 @cindex Post
5564 @cindex Checks, postconditions
5565 @findex Postconditions
5566 @noindent
5567 Syntax:
5569 @smallexample @c ada
5570 pragma Post_Class (Boolean_Expression);
5571 @end smallexample
5573 @noindent
5574 The @code{Post_Class} pragma is intended to be an exact replacement for
5575 the language-defined
5576 @code{Post'Class} aspect, and shares its restrictions and semantics.
5577 It must appear either immediately following the corresponding
5578 subprogram declaration (only other pragmas may intervene), or
5579 if there is no separate subprogram declaration, then it can
5580 appear at the start of the declarations in a subprogram body
5581 (preceded only by other pragmas).
5583 Note: This pragma is called @code{Post_Class} rather than
5584 @code{Post'Class} because the latter would not be strictly
5585 conforming to the allowed syntax for pragmas. The motivation
5586 for provinding pragmas equivalent to the aspects is to allow a program
5587 to be written using the pragmas, and then compiled if necessary
5588 using an Ada compiler that does not recognize the pragmas or
5589 aspects, but is prepared to ignore the pragmas. The assertion
5590 policy that controls this pragma is @code{Post'Class}, not
5591 @code{Post_Class}.
5593 @node Pragma Pre
5594 @unnumberedsec Pragma Pre
5595 @cindex Pre
5596 @cindex Checks, preconditions
5597 @findex Preconditions
5598 @noindent
5599 Syntax:
5601 @smallexample @c ada
5602 pragma Pre (Boolean_Expression);
5603 @end smallexample
5605 @noindent
5606 The @code{Pre} pragma is intended to be an exact replacement for
5607 the language-defined
5608 @code{Pre} aspect, and shares its restrictions and semantics.
5609 It must appear either immediately following the corresponding
5610 subprogram declaration (only other pragmas may intervene), or
5611 if there is no separate subprogram declaration, then it can
5612 appear at the start of the declarations in a subprogram body
5613 (preceded only by other pragmas).
5615 @node Pragma Precondition
5616 @unnumberedsec Pragma Precondition
5617 @cindex Preconditions
5618 @cindex Checks, preconditions
5619 @findex Preconditions
5620 @noindent
5621 Syntax:
5623 @smallexample @c ada
5624 pragma Precondition (
5625    [Check   =>] Boolean_Expression
5626  [,[Message =>] String_Expression]);
5627 @end smallexample
5629 @noindent
5630 The @code{Precondition} pragma is similar to @code{Postcondition}
5631 except that the corresponding checks take place immediately upon
5632 entry to the subprogram, and if a precondition fails, the exception
5633 is raised in the context of the caller, and the attribute 'Result
5634 cannot be used within the precondition expression.
5636 Otherwise, the placement and visibility rules are identical to those
5637 described for postconditions. The following is an example of use
5638 within a package spec:
5640 @smallexample @c ada
5641 package Math_Functions is
5642    ...
5643    function Sqrt (Arg : Float) return Float;
5644    pragma Precondition (Arg >= 0.0)
5645    ...
5646 end Math_Functions;
5647 @end smallexample
5649 @noindent
5650 @code{Precondition} pragmas may appear either immediately following the
5651 (separate) declaration of a subprogram, or at the start of the
5652 declarations of a subprogram body. Only other pragmas may intervene
5653 (that is appear between the subprogram declaration and its
5654 postconditions, or appear before the postcondition in the
5655 declaration sequence in a subprogram body).
5657 Note: precondition pragmas associated with subprograms that are
5658 marked as Inline_Always, or those marked as Inline with front-end
5659 inlining (-gnatN option set) are accepted and legality-checked
5660 by the compiler, but are ignored at run-time even if precondition
5661 checking is enabled.
5663 Note that pragma @code{Precondition} differs from the language-defined
5664 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
5665 multiple occurrences, allowing occurences in the body even if there
5666 is a separate spec, and allowing a second string parameter, and the
5667 use of the pragma identifier @code{Check}. Historically, pragma
5668 @code{Precondition} was implemented prior to the development of
5669 Ada 2012, and has been retained in its original form for
5670 compatibility purposes.
5672 @node Pragma Predicate
5673 @unnumberedsec Pragma Predicate
5674 @findex Predicate
5675 @findex Predicate pragma
5676 @noindent
5677 Syntax:
5679 @smallexample @c ada
5680 pragma Predicate
5681   ([Entity =>] type_LOCAL_NAME,
5682    [Check  =>] EXPRESSION);
5683 @end smallexample
5685 @noindent
5686 This pragma (available in all versions of Ada in GNAT) encompasses both
5687 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
5688 Ada 2012. A predicate is regarded as static if it has an allowed form
5689 for @code{Static_Predicate} and is otherwise treated as a
5690 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
5691 pragma behave exactly as described in the Ada 2012 reference manual.
5692 For example, if we have
5694 @smallexample @c ada
5695 type R is range 1 .. 10;
5696 subtype S is R;
5697 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5698 subtype Q is R
5699 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5700 @end smallexample
5702 @noindent
5703 the effect is identical to the following Ada 2012 code:
5705 @smallexample @c ada
5706 type R is range 1 .. 10;
5707 subtype S is R with
5708   Static_Predicate => S not in 4 .. 6;
5709 subtype Q is R with
5710   Dynamic_Predicate => F(Q) or G(Q);
5711 @end smallexample
5713 Note that there is are no pragmas @code{Dynamic_Predicate}
5714 or @code{Static_Predicate}. That is
5715 because these pragmas would affect legality and semantics of
5716 the program and thus do not have a neutral effect if ignored.
5717 The motivation behind providing pragmas equivalent to
5718 corresponding aspects is to allow a program to be written
5719 using the pragmas, and then compiled with a compiler that
5720 will ignore the pragmas. That doesn't work in the case of
5721 static and dynamic predicates, since if the corresponding
5722 pragmas are ignored, then the behavior of the program is
5723 fundamentally changed (for example a membership test
5724 @code{A in B} would not take into account a predicate
5725 defined for subtype B). When following this approach, the
5726 use of predicates should be avoided.
5728 @node Pragma Preelaborable_Initialization
5729 @unnumberedsec Pragma Preelaborable_Initialization
5730 @findex Preelaborable_Initialization
5731 @noindent
5732 Syntax:
5734 @smallexample @c ada
5735 pragma Preelaborable_Initialization (DIRECT_NAME);
5736 @end smallexample
5738 @noindent
5739 This pragma is standard in Ada 2005, but is available in all earlier
5740 versions of Ada as an implementation-defined pragma.
5741 See Ada 2012 Reference Manual for details.
5743 @node Pragma Prefix_Exception_Messages
5744 @unnumberedsec Pragma Prefix_Exception_Messages
5745 @cindex Prefix_Exception_Messages
5746 @cindex exception
5747 @cindex Exception_Message
5748 @findex Exceptions
5749 @noindent
5750 Syntax:
5752 @smallexample @c ada
5753 pragma Prefix_Exception_Messages;
5754 @end smallexample
5756 @noindent
5757 This is an implementation-defined configuration pragma that affects the
5758 behavior of raise statements with a message given as a static string
5759 constant (typically a string literal). In such cases, the string will
5760 be automatically prefixed by the name of the enclosing entity (giving
5761 the package and subprogram containing the raise statement). This helps
5762 to identify where messages are coming from, and this mode is automatic
5763 for the run-time library.
5765 The pragma has no effect if the message is computed with an expression other
5766 than a static string constant, since the assumption in this case is that
5767 the program computes exactly the string it wants. If you still want the
5768 prefixing in this case, you can always call
5769 @code{GNAT.Source_Info.Enclosing_Entity} and prepend the string manually.
5771 @node Pragma Pre_Class
5772 @unnumberedsec Pragma Pre_Class
5773 @cindex Pre_Class
5774 @cindex Checks, preconditions
5775 @findex Preconditions
5776 @noindent
5777 Syntax:
5779 @smallexample @c ada
5780 pragma Pre_Class (Boolean_Expression);
5781 @end smallexample
5783 @noindent
5784 The @code{Pre_Class} pragma is intended to be an exact replacement for
5785 the language-defined
5786 @code{Pre'Class} aspect, and shares its restrictions and semantics.
5787 It must appear either immediately following the corresponding
5788 subprogram declaration (only other pragmas may intervene), or
5789 if there is no separate subprogram declaration, then it can
5790 appear at the start of the declarations in a subprogram body
5791 (preceded only by other pragmas).
5793 Note: This pragma is called @code{Pre_Class} rather than
5794 @code{Pre'Class} because the latter would not be strictly
5795 conforming to the allowed syntax for pragmas. The motivation
5796 for providing pragmas equivalent to the aspects is to allow a program
5797 to be written using the pragmas, and then compiled if necessary
5798 using an Ada compiler that does not recognize the pragmas or
5799 aspects, but is prepared to ignore the pragmas. The assertion
5800 policy that controls this pragma is @code{Pre'Class}, not
5801 @code{Pre_Class}.
5803 @node Pragma Priority_Specific_Dispatching
5804 @unnumberedsec Pragma Priority_Specific_Dispatching
5805 @findex Priority_Specific_Dispatching
5806 @noindent
5807 Syntax:
5809 @smallexample @c ada
5810 pragma Priority_Specific_Dispatching (
5811    POLICY_IDENTIFIER,
5812    first_priority_EXPRESSION,
5813    last_priority_EXPRESSION)
5815 POLICY_IDENTIFIER ::=
5816    EDF_Across_Priorities            |
5817    FIFO_Within_Priorities           |
5818    Non_Preemptive_Within_Priorities |
5819    Round_Robin_Within_Priorities
5820 @end smallexample
5822 @noindent
5823 This pragma is standard in Ada 2005, but is available in all earlier
5824 versions of Ada as an implementation-defined pragma.
5825 See Ada 2012 Reference Manual for details.
5827 @node Pragma Profile
5828 @unnumberedsec Pragma Profile
5829 @findex Profile
5830 @noindent
5831 Syntax:
5833 @smallexample @c ada
5834 pragma Profile (Ravenscar | Restricted | Rational);
5835 @end smallexample
5837 @noindent
5838 This pragma is standard in Ada 2005, but is available in all earlier
5839 versions of Ada as an implementation-defined pragma. This is a
5840 configuration pragma that establishes a set of configiuration pragmas
5841 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5842 The other two possibilities (@code{Restricted} or @code{Rational})
5843 are implementation-defined. The set of configuration pragmas
5844 is defined in the following sections.
5846 @itemize
5848 @item Pragma Profile (Ravenscar)
5849 @findex Ravenscar
5850 @noindent
5852 The @code{Ravenscar} profile is standard in Ada 2005,
5853 but is available in all earlier
5854 versions of Ada as an implementation-defined pragma. This profile
5855 establishes the following set of configuration pragmas:
5857 @table @code
5858 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5859 [RM D.2.2] Tasks are dispatched following a preemptive
5860 priority-ordered scheduling policy.
5862 @item Locking_Policy (Ceiling_Locking)
5863 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5864 the ceiling priority of the corresponding protected object.
5866 @item Detect_Blocking
5867 This pragma forces the detection of potentially blocking operations within a
5868 protected operation, and to raise Program_Error if that happens.
5869 @end table
5870 @noindent
5872 plus the following set of restrictions:
5874 @table @code
5875 @item Max_Entry_Queue_Length => 1
5876 No task can be queued on a protected entry.
5877 @item Max_Protected_Entries => 1
5878 @item Max_Task_Entries => 0
5879 No rendezvous statements are allowed.
5880 @item No_Abort_Statements
5881 @item No_Dynamic_Attachment
5882 @item No_Dynamic_Priorities
5883 @item No_Implicit_Heap_Allocations
5884 @item No_Local_Protected_Objects
5885 @item No_Local_Timing_Events
5886 @item No_Protected_Type_Allocators
5887 @item No_Relative_Delay
5888 @item No_Requeue_Statements
5889 @item No_Select_Statements
5890 @item No_Specific_Termination_Handlers
5891 @item No_Task_Allocators
5892 @item No_Task_Hierarchy
5893 @item No_Task_Termination
5894 @item Simple_Barriers
5895 @end table
5896 @noindent
5898 The Ravenscar profile also includes the following restrictions that specify
5899 that there are no semantic dependences on the corresponding predefined
5900 packages:
5902 @table @code
5903 @item No_Dependence => Ada.Asynchronous_Task_Control
5904 @item No_Dependence => Ada.Calendar
5905 @item No_Dependence => Ada.Execution_Time.Group_Budget
5906 @item No_Dependence => Ada.Execution_Time.Timers
5907 @item No_Dependence => Ada.Task_Attributes
5908 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5909 @end table
5911 @noindent
5913 This set of configuration pragmas and restrictions correspond to the
5914 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5915 published by the @cite{International Real-Time Ada Workshop}, 1997,
5916 and whose most recent description is available at
5917 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5919 The original definition of the profile was revised at subsequent IRTAW
5920 meetings. It has been included in the ISO
5921 @cite{Guide for the Use of the Ada Programming Language in High
5922 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5923 the next revision of the standard. The formal definition given by
5924 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5925 AI-305) available at
5926 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5927 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5929 The above set is a superset of the restrictions provided by pragma
5930 @code{Profile (Restricted)}, it includes six additional restrictions
5931 (@code{Simple_Barriers}, @code{No_Select_Statements},
5932 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5933 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
5934 that pragma @code{Profile (Ravenscar)}, like the pragma
5935 @code{Profile (Restricted)},
5936 automatically causes the use of a simplified,
5937 more efficient version of the tasking run-time system.
5939 @item Pragma Profile (Restricted)
5940 @findex Restricted Run Time
5941 @noindent
5942 This profile corresponds to the GNAT restricted run time. It
5943 establishes the following set of restrictions:
5945 @itemize @bullet
5946 @item No_Abort_Statements
5947 @item No_Entry_Queue
5948 @item No_Task_Hierarchy
5949 @item No_Task_Allocators
5950 @item No_Dynamic_Priorities
5951 @item No_Terminate_Alternatives
5952 @item No_Dynamic_Attachment
5953 @item No_Protected_Type_Allocators
5954 @item No_Local_Protected_Objects
5955 @item No_Requeue_Statements
5956 @item No_Task_Attributes_Package
5957 @item Max_Asynchronous_Select_Nesting =  0
5958 @item Max_Task_Entries =  0
5959 @item Max_Protected_Entries = 1
5960 @item Max_Select_Alternatives = 0
5961 @end itemize
5963 @noindent
5964 This set of restrictions causes the automatic selection of a simplified
5965 version of the run time that provides improved performance for the
5966 limited set of tasking functionality permitted by this set of restrictions.
5968 @item Pragma Profile (Rational)
5969 @findex Rational compatibility mode
5970 @noindent
5971 The Rational profile is intended to facilitate porting legacy code that
5972 compiles with the Rational APEX compiler, even when the code includes non-
5973 conforming Ada constructs.  The profile enables the following three pragmas:
5975 @itemize @bullet
5976 @item pragma Implicit_Packing
5977 @item pragma Overriding_Renamings
5978 @item pragma Use_VADS_Size
5979 @end itemize
5981 @end itemize
5983 @node Pragma Profile_Warnings
5984 @unnumberedsec Pragma Profile_Warnings
5985 @findex Profile_Warnings
5986 @noindent
5987 Syntax:
5989 @smallexample @c ada
5990 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5991 @end smallexample
5993 @noindent
5994 This is an implementation-defined pragma that is similar in
5995 effect to @code{pragma Profile} except that instead of
5996 generating @code{Restrictions} pragmas, it generates
5997 @code{Restriction_Warnings} pragmas. The result is that
5998 violations of the profile generate warning messages instead
5999 of error messages.
6001 @node Pragma Propagate_Exceptions
6002 @unnumberedsec Pragma Propagate_Exceptions
6003 @cindex Interfacing to C++
6004 @findex Propagate_Exceptions
6005 @noindent
6006 Syntax:
6008 @smallexample @c ada
6009 pragma Propagate_Exceptions;
6010 @end smallexample
6012 @noindent
6013 This pragma is now obsolete and, other than generating a warning if warnings
6014 on obsolescent features are enabled, is ignored.
6015 It is retained for compatibility
6016 purposes. It used to be used in connection with optimization of
6017 a now-obsolete mechanism for implementation of exceptions.
6019 @node Pragma Provide_Shift_Operators
6020 @unnumberedsec Pragma Provide_Shift_Operators
6021 @cindex Shift operators
6022 @findex Provide_Shift_Operators
6023 @noindent
6024 Syntax:
6026 @smallexample @c ada
6027 pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
6028 @end smallexample
6030 @noindent
6031 This pragma can be applied to a first subtype local name that specifies
6032 either an unsigned or signed type. It has the effect of providing the
6033 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
6034 Rotate_Left and Rotate_Right) for the given type. It is similar to
6035 including the function declarations for these five operators, together
6036 with the pragma Import (Intrinsic, ...) statements.
6038 @node Pragma Psect_Object
6039 @unnumberedsec Pragma Psect_Object
6040 @findex Psect_Object
6041 @noindent
6042 Syntax:
6044 @smallexample @c ada
6045 pragma Psect_Object (
6046      [Internal =>] LOCAL_NAME,
6047   [, [External =>] EXTERNAL_SYMBOL]
6048   [, [Size     =>] EXTERNAL_SYMBOL]);
6050 EXTERNAL_SYMBOL ::=
6051   IDENTIFIER
6052 | static_string_EXPRESSION
6053 @end smallexample
6055 @noindent
6056 This pragma is identical in effect to pragma @code{Common_Object}.
6058 @node Pragma Pure_Function
6059 @unnumberedsec Pragma Pure_Function
6060 @findex Pure_Function
6061 @noindent
6062 Syntax:
6064 @smallexample @c ada
6065 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
6066 @end smallexample
6068 @noindent
6069 This pragma appears in the same declarative part as a function
6070 declaration (or a set of function declarations if more than one
6071 overloaded declaration exists, in which case the pragma applies
6072 to all entities).  It specifies that the function @code{Entity} is
6073 to be considered pure for the purposes of code generation.  This means
6074 that the compiler can assume that there are no side effects, and
6075 in particular that two calls with identical arguments produce the
6076 same result.  It also means that the function can be used in an
6077 address clause.
6079 Note that, quite deliberately, there are no static checks to try
6080 to ensure that this promise is met, so @code{Pure_Function} can be used
6081 with functions that are conceptually pure, even if they do modify
6082 global variables.  For example, a square root function that is
6083 instrumented to count the number of times it is called is still
6084 conceptually pure, and can still be optimized, even though it
6085 modifies a global variable (the count).  Memo functions are another
6086 example (where a table of previous calls is kept and consulted to
6087 avoid re-computation).
6089 Note also that the normal rules excluding optimization of subprograms
6090 in pure units (when parameter types are descended from System.Address,
6091 or when the full view of a parameter type is limited), do not apply
6092 for the Pure_Function case. If you explicitly specify Pure_Function,
6093 the compiler may optimize away calls with identical arguments, and
6094 if that results in unexpected behavior, the proper action is not to
6095 use the pragma for subprograms that are not (conceptually) pure.
6097 @findex Pure
6098 Note: Most functions in a @code{Pure} package are automatically pure, and
6099 there is no need to use pragma @code{Pure_Function} for such functions.  One
6100 exception is any function that has at least one formal of type
6101 @code{System.Address} or a type derived from it.  Such functions are not
6102 considered pure by default, since the compiler assumes that the
6103 @code{Address} parameter may be functioning as a pointer and that the
6104 referenced data may change even if the address value does not.
6105 Similarly, imported functions are not considered to be pure by default,
6106 since there is no way of checking that they are in fact pure.  The use
6107 of pragma @code{Pure_Function} for such a function will override these default
6108 assumption, and cause the compiler to treat a designated subprogram as pure
6109 in these cases.
6111 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
6112 applies to the underlying renamed function.  This can be used to
6113 disambiguate cases of overloading where some but not all functions
6114 in a set of overloaded functions are to be designated as pure.
6116 If pragma @code{Pure_Function} is applied to a library level function, the
6117 function is also considered pure from an optimization point of view, but the
6118 unit is not a Pure unit in the categorization sense. So for example, a function
6119 thus marked is free to @code{with} non-pure units.
6121 @node Pragma Rational
6122 @unnumberedsec Pragma Rational
6123 @findex Rational
6124 @noindent
6125 Syntax:
6127 @smallexample @c ada
6128 pragma Rational;
6129 @end smallexample
6131 @noindent
6132 This pragma is considered obsolescent, but is retained for
6133 compatibility purposes. It is equivalent to:
6135 @smallexample @c ada
6136 pragma Profile (Rational);
6137 @end smallexample
6139 @node Pragma Ravenscar
6140 @unnumberedsec Pragma Ravenscar
6141 @findex Pragma Ravenscar
6142 @noindent
6143 Syntax:
6145 @smallexample @c ada
6146 pragma Ravenscar;
6147 @end smallexample
6149 @noindent
6150 This pragma is considered obsolescent, but is retained for
6151 compatibility purposes. It is equivalent to:
6153 @smallexample @c ada
6154 pragma Profile (Ravenscar);
6155 @end smallexample
6157 @noindent
6158 which is the preferred method of setting the @code{Ravenscar} profile.
6160 @node Pragma Refined_Depends
6161 @unnumberedsec Pragma Refined_Depends
6162 @findex Refined_Depends
6163 @noindent
6164 For the description of this pragma, see SPARK 2014 Reference Manual,
6165 section 6.1.5.
6167 @node Pragma Refined_Global
6168 @unnumberedsec Pragma Refined_Global
6169 @findex Refined_Global
6170 @noindent
6171 For the description of this pragma, see SPARK 2014 Reference Manual,
6172 section 6.1.4.
6174 @node Pragma Refined_Post
6175 @unnumberedsec Pragma Refined_Post
6176 @findex Refined_Post
6177 @noindent
6178 For the description of this pragma, see SPARK 2014 Reference Manual,
6179 section 7.2.7.
6181 @node Pragma Refined_State
6182 @unnumberedsec Pragma Refined_State
6183 @findex Refined_State
6184 @noindent
6185 For the description of this pragma, see SPARK 2014 Reference Manual,
6186 section 7.2.2.
6188 @node Pragma Relative_Deadline
6189 @unnumberedsec Pragma Relative_Deadline
6190 @findex Relative_Deadline
6191 @noindent
6192 Syntax:
6194 @smallexample @c ada
6195 pragma Relative_Deadline (time_span_EXPRESSION);
6196 @end smallexample
6198 @noindent
6199 This pragma is standard in Ada 2005, but is available in all earlier
6200 versions of Ada as an implementation-defined pragma.
6201 See Ada 2012 Reference Manual for details.
6203 @node Pragma Remote_Access_Type
6204 @unnumberedsec Pragma Remote_Access_Type
6205 @findex Remote_Access_Type
6206 @noindent
6207 Syntax:
6209 @smallexample @c ada
6210 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
6211 @end smallexample
6213 @noindent
6214 This pragma appears in the formal part of a generic declaration.
6215 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
6216 the use of a remote access to class-wide type as actual for a formal
6217 access type.
6219 When this pragma applies to a formal access type @code{Entity}, that
6220 type is treated as a remote access to class-wide type in the generic.
6221 It must be a formal general access type, and its designated type must
6222 be the class-wide type of a formal tagged limited private type from the
6223 same generic declaration.
6225 In the generic unit, the formal type is subject to all restrictions
6226 pertaining to remote access to class-wide types. At instantiation, the
6227 actual type must be a remote access to class-wide type.
6229 @node Pragma Restricted_Run_Time
6230 @unnumberedsec Pragma Restricted_Run_Time
6231 @findex Pragma Restricted_Run_Time
6232 @noindent
6233 Syntax:
6235 @smallexample @c ada
6236 pragma Restricted_Run_Time;
6237 @end smallexample
6239 @noindent
6240 This pragma is considered obsolescent, but is retained for
6241 compatibility purposes. It is equivalent to:
6243 @smallexample @c ada
6244 pragma Profile (Restricted);
6245 @end smallexample
6247 @noindent
6248 which is the preferred method of setting the restricted run time
6249 profile.
6251 @node Pragma Restriction_Warnings
6252 @unnumberedsec Pragma Restriction_Warnings
6253 @findex Restriction_Warnings
6254 @noindent
6255 Syntax:
6257 @smallexample @c ada
6258 pragma Restriction_Warnings
6259   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
6260 @end smallexample
6262 @noindent
6263 This pragma allows a series of restriction identifiers to be
6264 specified (the list of allowed identifiers is the same as for
6265 pragma @code{Restrictions}). For each of these identifiers
6266 the compiler checks for violations of the restriction, but
6267 generates a warning message rather than an error message
6268 if the restriction is violated.
6270 One use of this is in situations where you want to know
6271 about violations of a restriction, but you want to ignore some of
6272 these violations. Consider this example, where you want to set
6273 Ada_95 mode and enable style checks, but you want to know about
6274 any other use of implementation pragmas:
6276 @smallexample @c ada
6277 pragma Restriction_Warnings (No_Implementation_Pragmas);
6278 7 (Off, "violation of*No_Implementation_Pragmas*");
6279 pragma Ada_95;
6280 pragma Style_Checks ("2bfhkM160");
6281 pragma Warnings (On, "violation of*No_Implementation_Pragmas*");
6282 @end smallexample
6284 @noindent
6285 By including the above lines in a configuration pragmas file,
6286 the Ada_95 and Style_Checks pragmas are accepted without
6287 generating a warning, but any other use of implementation
6288 defined pragmas will cause a warning to be generated.
6290 @node Pragma Reviewable
6291 @unnumberedsec Pragma Reviewable
6292 @findex Reviewable
6293 @noindent
6294 Syntax:
6296 @smallexample @c ada
6297 pragma Reviewable;
6298 @end smallexample
6300 @noindent
6301 This pragma is an RM-defined standard pragma, but has no effect on the
6302 program being compiled, or on the code generated for the program.
6304 To obtain the required output specified in RM H.3.1, the compiler must be
6305 run with various special switches as follows:
6307 @table @i
6309 @item Where compiler-generated run-time checks remain
6311 The switch @option{-gnatGL}
6312 @findex @option{-gnatGL}
6313 may be used to list the expanded code in pseudo-Ada form.
6314 Runtime checks show up in the listing either as explicit
6315 checks or operators marked with @{@} to indicate a check is present.
6317 @item An identification of known exceptions at compile time
6319 If the program is compiled with @option{-gnatwa},
6320 @findex @option{-gnatwa}
6321 the compiler warning messages will indicate all cases where the compiler
6322 detects that an exception is certain to occur at run time.
6324 @item Possible reads of uninitialized variables
6326 The compiler warns of many such cases, but its output is incomplete.
6327 @ifclear FSFEDITION
6328 The CodePeer analysis tool
6329 @findex CodePeer static analysis tool
6330 @end ifclear
6331 @ifset FSFEDITION
6332 A supplemental static analysis tool
6333 @end ifset
6334 may be used to obtain a comprehensive list of all
6335 possible points at which uninitialized data may be read.
6337 @item Where run-time support routines are implicitly invoked
6339 In the output from @option{-gnatGL},
6340 @findex @option{-gnatGL}
6341 run-time calls are explicitly listed as calls to the relevant
6342 run-time routine.
6344 @item Object code listing
6346 This may be obtained either by using the @option{-S} switch,
6347 @findex @option{-S}
6348 or the objdump utility.
6349 @findex objdump
6351 @item Constructs known to be erroneous at compile time
6353 These are identified by warnings issued by the compiler (use @option{-gnatwa}).
6354 @findex @option{-gnatwa}
6356 @item Stack usage information
6358 Static stack usage data (maximum per-subprogram) can be obtained via the
6359 @option{-fstack-usage} switch to the compiler.
6360 @findex @option{-fstack-usage}
6361 Dynamic stack usage data (per task) can be obtained via the @option{-u} switch
6362 to gnatbind
6363 @findex @option{-u}
6364 @ifclear FSFEDITION
6365 The gnatstack utility
6366 @findex gnatstack
6367 can be used to provide additional information on stack usage.
6368 @end ifclear
6370 @item Object code listing of entire partition
6372 This can be obtained by compiling the partition with @option{-S},
6373 @findex @option{-S}
6374 or by applying objdump
6375 @findex objdump
6376 to all the object files that are part of the partition.
6378 @item A description of the run-time model
6380 The full sources of the run-time are available, and the documentation of
6381 these routines describes how these run-time routines interface to the
6382 underlying operating system facilities.
6384 @item Control and data-flow information
6386 @ifclear FSFEDITION
6387 The CodePeer tool
6388 @findex CodePeer static analysis tool
6389 @end ifclear
6390 @ifset FSFEDITION
6391 A supplemental static analysis tool
6392 @end ifset
6393 may be used to obtain complete control and data-flow information, as well as
6394 comprehensive messages identifying possible problems based on this
6395 information.
6396 @end table
6398 @node Pragma Share_Generic
6399 @unnumberedsec Pragma Share_Generic
6400 @findex Share_Generic
6401 @noindent
6402 Syntax:
6404 @smallexample @c ada
6405 pragma Share_Generic (GNAME @{, GNAME@});
6407 GNAME ::= generic_unit_NAME | generic_instance_NAME
6408 @end smallexample
6410 @noindent
6411 This pragma is provided for compatibility with Dec Ada 83. It has
6412 no effect in @code{GNAT} (which does not implement shared generics), other
6413 than to check that the given names are all names of generic units or
6414 generic instances.
6416 @node Pragma Shared
6417 @unnumberedsec Pragma Shared
6418 @findex Shared
6420 @noindent
6421 This pragma is provided for compatibility with Ada 83. The syntax and
6422 semantics are identical to pragma Atomic.
6424 @node Pragma Short_Circuit_And_Or
6425 @unnumberedsec Pragma Short_Circuit_And_Or
6426 @findex Short_Circuit_And_Or
6427 @noindent
6428 Syntax:
6430 @smallexample @c ada
6431 pragma Short_Circuit_And_Or;
6432 @end smallexample
6434 @noindent
6435 This configuration pragma causes any occurrence of the AND operator applied to
6436 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
6437 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
6438 may be useful in the context of certification protocols requiring the use of
6439 short-circuited logical operators. If this configuration pragma occurs locally
6440 within the file being compiled, it applies only to the file being compiled.
6441 There is no requirement that all units in a partition use this option.
6443 @node Pragma Short_Descriptors
6444 @unnumberedsec Pragma Short_Descriptors
6445 @findex Short_Descriptors
6446 @noindent
6447 Syntax:
6449 @smallexample @c ada
6450 pragma Short_Descriptors
6451 @end smallexample
6453 @noindent
6454 This pragma is provided for compatibility with other Ada implementations. It
6455 is recognized but ignored by all current versions of GNAT.
6457 @node Pragma Simple_Storage_Pool_Type
6458 @unnumberedsec Pragma Simple_Storage_Pool_Type
6459 @findex Simple_Storage_Pool_Type
6460 @cindex Storage pool, simple
6461 @cindex Simple storage pool
6462 @noindent
6463 Syntax:
6465 @smallexample @c ada
6466 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
6467 @end smallexample
6469 @noindent
6470 A type can be established as a ``simple storage pool type'' by applying
6471 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
6472 A type named in the pragma must be a library-level immutably limited record
6473 type or limited tagged type declared immediately within a package declaration.
6474 The type can also be a limited private type whose full type is allowed as
6475 a simple storage pool type.
6477 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
6478 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
6479 are subtype conformant with the following subprogram declarations:
6481 @smallexample @c ada
6482 procedure Allocate
6483   (Pool                     : in out SSP;
6484    Storage_Address          : out System.Address;
6485    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6486    Alignment                : System.Storage_Elements.Storage_Count);
6488 procedure Deallocate
6489   (Pool : in out SSP;
6490    Storage_Address          : System.Address;
6491    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6492    Alignment                : System.Storage_Elements.Storage_Count);
6494 function Storage_Size (Pool : SSP)
6495   return System.Storage_Elements.Storage_Count;
6496 @end smallexample
6498 @noindent
6499 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
6500 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
6501 applying an unchecked deallocation has no effect other than to set its actual
6502 parameter to null. If @code{Storage_Size} is not declared, then the
6503 @code{Storage_Size} attribute applied to an access type associated with
6504 a pool object of type SSP returns zero. Additional operations can be declared
6505 for a simple storage pool type (such as for supporting a mark/release
6506 storage-management discipline).
6508 An object of a simple storage pool type can be associated with an access
6509 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
6511 @smallexample @c ada
6513 My_Pool : My_Simple_Storage_Pool_Type;
6515 type Acc is access My_Data_Type;
6517 for Acc'Simple_Storage_Pool use My_Pool;
6519 @end smallexample
6521 @noindent
6522 See attribute @code{Simple_Storage_Pool} for further details.
6524 @node Pragma Source_File_Name
6525 @unnumberedsec Pragma Source_File_Name
6526 @findex Source_File_Name
6527 @noindent
6528 Syntax:
6530 @smallexample @c ada
6531 pragma Source_File_Name (
6532   [Unit_Name   =>] unit_NAME,
6533   Spec_File_Name =>  STRING_LITERAL,
6534   [Index => INTEGER_LITERAL]);
6536 pragma Source_File_Name (
6537   [Unit_Name   =>] unit_NAME,
6538   Body_File_Name =>  STRING_LITERAL,
6539   [Index => INTEGER_LITERAL]);
6540 @end smallexample
6542 @noindent
6543 Use this to override the normal naming convention.  It is a configuration
6544 pragma, and so has the usual applicability of configuration pragmas
6545 (i.e.@: it applies to either an entire partition, or to all units in a
6546 compilation, or to a single unit, depending on how it is used.
6547 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
6548 the second argument is required, and indicates whether this is the file
6549 name for the spec or for the body.
6551 The optional Index argument should be used when a file contains multiple
6552 units, and when you do not want to use @code{gnatchop} to separate then
6553 into multiple files (which is the recommended procedure to limit the
6554 number of recompilations that are needed when some sources change).
6555 For instance, if the source file @file{source.ada} contains
6557 @smallexample @c ada
6558 package B is
6560 end B;
6562 with B;
6563 procedure A is
6564 begin
6565    ..
6566 end A;
6567 @end smallexample
6569 you could use the following configuration pragmas:
6571 @smallexample @c ada
6572 pragma Source_File_Name
6573   (B, Spec_File_Name => "source.ada", Index => 1);
6574 pragma Source_File_Name
6575   (A, Body_File_Name => "source.ada", Index => 2);
6576 @end smallexample
6578 Note that the @code{gnatname} utility can also be used to generate those
6579 configuration pragmas.
6581 Another form of the @code{Source_File_Name} pragma allows
6582 the specification of patterns defining alternative file naming schemes
6583 to apply to all files.
6585 @smallexample @c ada
6586 pragma Source_File_Name
6587   (  [Spec_File_Name  =>] STRING_LITERAL
6588    [,[Casing          =>] CASING_SPEC]
6589    [,[Dot_Replacement =>] STRING_LITERAL]);
6591 pragma Source_File_Name
6592   (  [Body_File_Name  =>] STRING_LITERAL
6593    [,[Casing          =>] CASING_SPEC]
6594    [,[Dot_Replacement =>] STRING_LITERAL]);
6596 pragma Source_File_Name
6597   (  [Subunit_File_Name =>] STRING_LITERAL
6598    [,[Casing            =>] CASING_SPEC]
6599    [,[Dot_Replacement   =>] STRING_LITERAL]);
6601 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
6602 @end smallexample
6604 @noindent
6605 The first argument is a pattern that contains a single asterisk indicating
6606 the point at which the unit name is to be inserted in the pattern string
6607 to form the file name.  The second argument is optional.  If present it
6608 specifies the casing of the unit name in the resulting file name string.
6609 The default is lower case.  Finally the third argument allows for systematic
6610 replacement of any dots in the unit name by the specified string literal.
6612 Note that Source_File_Name pragmas should not be used if you are using
6613 project files. The reason for this rule is that the project manager is not
6614 aware of these pragmas, and so other tools that use the projet file would not
6615 be aware of the intended naming conventions. If you are using project files,
6616 file naming is controlled by Source_File_Name_Project pragmas, which are
6617 usually supplied automatically by the project manager. A pragma
6618 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
6620 For more details on the use of the @code{Source_File_Name} pragma,
6621 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
6622 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
6623 User's Guide}.
6625 @node Pragma Source_File_Name_Project
6626 @unnumberedsec Pragma Source_File_Name_Project
6627 @findex Source_File_Name_Project
6628 @noindent
6630 This pragma has the same syntax and semantics as pragma Source_File_Name.
6631 It is only allowed as a stand alone configuration pragma.
6632 It cannot appear after a @ref{Pragma Source_File_Name}, and
6633 most importantly, once pragma Source_File_Name_Project appears,
6634 no further Source_File_Name pragmas are allowed.
6636 The intention is that Source_File_Name_Project pragmas are always
6637 generated by the Project Manager in a manner consistent with the naming
6638 specified in a project file, and when naming is controlled in this manner,
6639 it is not permissible to attempt to modify this naming scheme using
6640 Source_File_Name or Source_File_Name_Project pragmas (which would not be
6641 known to the project manager).
6643 @node Pragma Source_Reference
6644 @unnumberedsec Pragma Source_Reference
6645 @findex Source_Reference
6646 @noindent
6647 Syntax:
6649 @smallexample @c ada
6650 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
6651 @end smallexample
6653 @noindent
6654 This pragma must appear as the first line of a source file.
6655 @var{integer_literal} is the logical line number of the line following
6656 the pragma line (for use in error messages and debugging
6657 information).  @var{string_literal} is a static string constant that
6658 specifies the file name to be used in error messages and debugging
6659 information.  This is most notably used for the output of @code{gnatchop}
6660 with the @option{-r} switch, to make sure that the original unchopped
6661 source file is the one referred to.
6663 The second argument must be a string literal, it cannot be a static
6664 string expression other than a string literal.  This is because its value
6665 is needed for error messages issued by all phases of the compiler.
6667 @node Pragma SPARK_Mode
6668 @unnumberedsec Pragma SPARK_Mode
6669 @findex SPARK_Mode
6670 @noindent
6671 Syntax:
6673 @smallexample @c ada
6674 pragma SPARK_Mode [(On | Off)] ;
6675 @end smallexample
6677 @noindent
6678 In general a program can have some parts that are in SPARK 2014 (and
6679 follow all the rules in the SPARK Reference Manual), and some parts
6680 that are full Ada 2012.
6682 The SPARK_Mode pragma is used to identify which parts are in SPARK
6683 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
6684 be used in the following places:
6686 @itemize @bullet
6688 @item
6689 As a configuration pragma, in which case it sets the default mode for
6690 all units compiled with this pragma.
6692 @item
6693 Immediately following a library-level subprogram spec
6695 @item
6696 Immediately within a library-level package body
6698 @item
6699 Immediately following the @code{private} keyword of a library-level
6700 package spec
6702 @item
6703 Immediately following the @code{begin} keyword of a library-level
6704 package body
6706 @item
6707 Immediately within a library-level subprogram body
6709 @end itemize
6711 @noindent
6712 Normally a subprogram or package spec/body inherits the current mode
6713 that is active at the point it is declared. But this can be overridden
6714 by pragma within the spec or body as above.
6716 The basic consistency rule is that you can't turn SPARK_Mode back
6717 @code{On}, once you have explicitly (with a pragma) turned if
6718 @code{Off}. So the following rules apply:
6720 @noindent
6721 If a subprogram spec has SPARK_Mode @code{Off}, then the body must
6722 also have SPARK_Mode @code{Off}.
6724 @noindent
6725 For a package, we have four parts:
6727 @itemize
6728 @item
6729 the package public declarations
6730 @item
6731 the package private part
6732 @item
6733 the body of the package
6734 @item
6735 the elaboration code after @code{begin}
6736 @end itemize
6738 @noindent
6739 For a package, the rule is that if you explicitly turn SPARK_Mode
6740 @code{Off} for any part, then all the following parts must have
6741 SPARK_Mode @code{Off}. Note that this may require repeating a pragma
6742 SPARK_Mode (@code{Off}) in the body. For example, if we have a
6743 configuration pragma SPARK_Mode (@code{On}) that turns the mode on by
6744 default everywhere, and one particular package spec has pragma
6745 SPARK_Mode (@code{Off}), then that pragma will need to be repeated in
6746 the package body.
6748 @node Pragma Static_Elaboration_Desired
6749 @unnumberedsec Pragma Static_Elaboration_Desired
6750 @findex Static_Elaboration_Desired
6751 @noindent
6752 Syntax:
6754 @smallexample @c ada
6755 pragma Static_Elaboration_Desired;
6756 @end smallexample
6758 @noindent
6759 This pragma is used to indicate that the compiler should attempt to initialize
6760 statically the objects declared in the library unit to which the pragma applies,
6761 when these objects are initialized (explicitly or implicitly) by an aggregate.
6762 In the absence of this pragma, aggregates in object declarations are expanded
6763 into assignments and loops, even when the aggregate components are static
6764 constants. When the aggregate is present the compiler builds a static expression
6765 that requires no run-time code, so that the initialized object can be placed in
6766 read-only data space. If the components are not static, or the aggregate has
6767 more that 100 components, the compiler emits a warning that the pragma cannot
6768 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6769 construction of larger aggregates with static components that include an others
6770 choice.)
6772 @node Pragma Stream_Convert
6773 @unnumberedsec Pragma Stream_Convert
6774 @findex Stream_Convert
6775 @noindent
6776 Syntax:
6778 @smallexample @c ada
6779 pragma Stream_Convert (
6780   [Entity =>] type_LOCAL_NAME,
6781   [Read   =>] function_NAME,
6782   [Write  =>] function_NAME);
6783 @end smallexample
6785 @noindent
6786 This pragma provides an efficient way of providing user-defined stream
6787 attributes.  Not only is it simpler to use than specifying the attributes
6788 directly, but more importantly, it allows the specification to be made in such
6789 a way that the predefined unit Ada.Streams is not loaded unless it is actually
6790 needed (i.e. unless the stream attributes are actually used); the use of
6791 the Stream_Convert pragma adds no overhead at all, unless the stream
6792 attributes are actually used on the designated type.
6794 The first argument specifies the type for which stream functions are
6795 provided.  The second parameter provides a function used to read values
6796 of this type.  It must name a function whose argument type may be any
6797 subtype, and whose returned type must be the type given as the first
6798 argument to the pragma.
6800 The meaning of the @var{Read} parameter is that if a stream attribute directly
6801 or indirectly specifies reading of the type given as the first parameter,
6802 then a value of the type given as the argument to the Read function is
6803 read from the stream, and then the Read function is used to convert this
6804 to the required target type.
6806 Similarly the @var{Write} parameter specifies how to treat write attributes
6807 that directly or indirectly apply to the type given as the first parameter.
6808 It must have an input parameter of the type specified by the first parameter,
6809 and the return type must be the same as the input type of the Read function.
6810 The effect is to first call the Write function to convert to the given stream
6811 type, and then write the result type to the stream.
6813 The Read and Write functions must not be overloaded subprograms.  If necessary
6814 renamings can be supplied to meet this requirement.
6815 The usage of this attribute is best illustrated by a simple example, taken
6816 from the GNAT implementation of package Ada.Strings.Unbounded:
6818 @smallexample @c ada
6819 function To_Unbounded (S : String)
6820            return Unbounded_String
6821   renames To_Unbounded_String;
6823 pragma Stream_Convert
6824   (Unbounded_String, To_Unbounded, To_String);
6825 @end smallexample
6827 @noindent
6828 The specifications of the referenced functions, as given in the Ada
6829 Reference Manual are:
6831 @smallexample @c ada
6832 function To_Unbounded_String (Source : String)
6833   return Unbounded_String;
6835 function To_String (Source : Unbounded_String)
6836   return String;
6837 @end smallexample
6839 @noindent
6840 The effect is that if the value of an unbounded string is written to a stream,
6841 then the representation of the item in the stream is in the same format that
6842 would be used for @code{Standard.String'Output}, and this same representation
6843 is expected when a value of this type is read from the stream. Note that the
6844 value written always includes the bounds, even for Unbounded_String'Write,
6845 since Unbounded_String is not an array type.
6847 Note that the @code{Stream_Convert} pragma is not effective in the case of
6848 a derived type of a non-limited tagged type. If such a type is specified then
6849 the pragma is silently ignored, and the default implementation of the stream
6850 attributes is used instead.
6852 @node Pragma Style_Checks
6853 @unnumberedsec Pragma Style_Checks
6854 @findex Style_Checks
6855 @noindent
6856 Syntax:
6858 @smallexample @c ada
6859 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6860                      On | Off [, LOCAL_NAME]);
6861 @end smallexample
6863 @noindent
6864 This pragma is used in conjunction with compiler switches to control the
6865 built in style checking provided by GNAT@.  The compiler switches, if set,
6866 provide an initial setting for the switches, and this pragma may be used
6867 to modify these settings, or the settings may be provided entirely by
6868 the use of the pragma.  This pragma can be used anywhere that a pragma
6869 is legal, including use as a configuration pragma (including use in
6870 the @file{gnat.adc} file).
6872 The form with a string literal specifies which style options are to be
6873 activated.  These are additive, so they apply in addition to any previously
6874 set style check options.  The codes for the options are the same as those
6875 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6876 For example the following two methods can be used to enable
6877 layout checking:
6879 @itemize @bullet
6880 @item
6881 @smallexample @c ada
6882 pragma Style_Checks ("l");
6883 @end smallexample
6885 @item
6886 @smallexample
6887 gcc -c -gnatyl @dots{}
6888 @end smallexample
6889 @end itemize
6891 @noindent
6892 The form ALL_CHECKS activates all standard checks (its use is equivalent
6893 to the use of the @code{gnaty} switch with no options.  @xref{Top,
6894 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6895 @value{EDITION} User's Guide}, for details.)
6897 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6898 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6899 options (i.e. equivalent to -gnatyg).
6901 The forms with @code{Off} and @code{On}
6902 can be used to temporarily disable style checks
6903 as shown in the following example:
6905 @smallexample @c ada
6906 @iftex
6907 @leftskip=0cm
6908 @end iftex
6909 pragma Style_Checks ("k"); -- requires keywords in lower case
6910 pragma Style_Checks (Off); -- turn off style checks
6911 NULL;                      -- this will not generate an error message
6912 pragma Style_Checks (On);  -- turn style checks back on
6913 NULL;                      -- this will generate an error message
6914 @end smallexample
6916 @noindent
6917 Finally the two argument form is allowed only if the first argument is
6918 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
6919 for the specified entity, as shown in the following example:
6921 @smallexample @c ada
6922 @iftex
6923 @leftskip=0cm
6924 @end iftex
6925 pragma Style_Checks ("r"); -- require consistency of identifier casing
6926 Arg : Integer;
6927 Rf1 : Integer := ARG;      -- incorrect, wrong case
6928 pragma Style_Checks (Off, Arg);
6929 Rf2 : Integer := ARG;      -- OK, no error
6930 @end smallexample
6932 @node Pragma Subtitle
6933 @unnumberedsec Pragma Subtitle
6934 @findex Subtitle
6935 @noindent
6936 Syntax:
6938 @smallexample @c ada
6939 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6940 @end smallexample
6942 @noindent
6943 This pragma is recognized for compatibility with other Ada compilers
6944 but is ignored by GNAT@.
6946 @node Pragma Suppress
6947 @unnumberedsec Pragma Suppress
6948 @findex Suppress
6949 @noindent
6950 Syntax:
6952 @smallexample @c ada
6953 pragma Suppress (Identifier [, [On =>] Name]);
6954 @end smallexample
6956 @noindent
6957 This is a standard pragma, and supports all the check names required in
6958 the RM. It is included here because GNAT recognizes some additional check
6959 names that are implementation defined (as permitted by the RM):
6961 @itemize @bullet
6963 @item
6964 @code{Alignment_Check} can be used to suppress alignment checks
6965 on addresses used in address clauses. Such checks can also be suppressed
6966 by suppressing range checks, but the specific use of @code{Alignment_Check}
6967 allows suppression of alignment checks without suppressing other range checks.
6969 @item
6970 @code{Atomic_Synchronization} can be used to suppress the special memory
6971 synchronization instructions that are normally generated for access to
6972 @code{Atomic} variables to ensure correct synchronization between tasks
6973 that use such variables for synchronization purposes.
6975 @item
6976 @code{Duplicated_Tag_Check} Can be used to suppress the check that is generated
6977 for a duplicated tag value when a tagged type is declared.
6979 @item
6980 @code{Predicate_Check} can be used to control whether predicate checks are
6981 active. It is applicable only to predicates for which the policy is
6982 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6983 predicate is ignored or checked for the whole program, the use of
6984 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6985 predicate to be turned on and off at specific points in the program.
6987 @item
6988 @code{Validity_Check} can be used specifically to control validity checks.
6989 If @code{Suppress} is used to suppress validity checks, then no validity
6990 checks are performed, including those specified by the appropriate compiler
6991 switch or the @code{Validity_Checks} pragma.
6993 @item
6994 Additional check names previously introduced by use of the @code{Check_Name}
6995 pragma are also allowed.
6997 @end itemize
6999 @noindent
7000 Note that pragma Suppress gives the compiler permission to omit
7001 checks, but does not require the compiler to omit checks. The compiler
7002 will generate checks if they are essentially free, even when they are
7003 suppressed. In particular, if the compiler can prove that a certain
7004 check will necessarily fail, it will generate code to do an
7005 unconditional ``raise'', even if checks are suppressed. The compiler
7006 warns in this case.
7008 Of course, run-time checks are omitted whenever the compiler can prove
7009 that they will not fail, whether or not checks are suppressed.
7011 @node Pragma Suppress_All
7012 @unnumberedsec Pragma Suppress_All
7013 @findex Suppress_All
7014 @noindent
7015 Syntax:
7017 @smallexample @c ada
7018 pragma Suppress_All;
7019 @end smallexample
7021 @noindent
7022 This pragma can appear anywhere within a unit.
7023 The effect is to apply @code{Suppress (All_Checks)} to the unit
7024 in which it appears.  This pragma is implemented for compatibility with DEC
7025 Ada 83 usage where it appears at the end of a unit, and for compatibility
7026 with Rational Ada, where it appears as a program unit pragma.
7027 The use of the standard Ada pragma @code{Suppress (All_Checks)}
7028 as a normal configuration pragma is the preferred usage in GNAT@.
7030 @node Pragma Suppress_Debug_Info
7031 @unnumberedsec Pragma Suppress_Debug_Info
7032 @findex Suppress_Debug_Info
7033 @noindent
7034 Syntax:
7036 @smallexample @c ada
7037 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
7038 @end smallexample
7040 @noindent
7041 This pragma can be used to suppress generation of debug information
7042 for the specified entity. It is intended primarily for use in debugging
7043 the debugger, and navigating around debugger problems.
7045 @node Pragma Suppress_Exception_Locations
7046 @unnumberedsec Pragma Suppress_Exception_Locations
7047 @findex Suppress_Exception_Locations
7048 @noindent
7049 Syntax:
7051 @smallexample @c ada
7052 pragma Suppress_Exception_Locations;
7053 @end smallexample
7055 @noindent
7056 In normal mode, a raise statement for an exception by default generates
7057 an exception message giving the file name and line number for the location
7058 of the raise. This is useful for debugging and logging purposes, but this
7059 entails extra space for the strings for the messages. The configuration
7060 pragma @code{Suppress_Exception_Locations} can be used to suppress the
7061 generation of these strings, with the result that space is saved, but the
7062 exception message for such raises is null. This configuration pragma may
7063 appear in a global configuration pragma file, or in a specific unit as
7064 usual. It is not required that this pragma be used consistently within
7065 a partition, so it is fine to have some units within a partition compiled
7066 with this pragma and others compiled in normal mode without it.
7068 @node Pragma Suppress_Initialization
7069 @unnumberedsec Pragma Suppress_Initialization
7070 @findex Suppress_Initialization
7071 @cindex Suppressing initialization
7072 @cindex Initialization, suppression of
7073 @noindent
7074 Syntax:
7076 @smallexample @c ada
7077 pragma Suppress_Initialization ([Entity =>] variable_or_subtype_Name);
7078 @end smallexample
7080 @noindent
7081 Here variable_or_subtype_Name is the name introduced by a type declaration
7082 or subtype declaration or the name of a variable introduced by an
7083 object declaration.
7085 In the case of a type or subtype
7086 this pragma suppresses any implicit or explicit initialization
7087 for all variables of the given type or subtype,
7088 including initialization resulting from the use of pragmas
7089 Normalize_Scalars or Initialize_Scalars.
7091 This is considered a representation item, so it cannot be given after
7092 the type is frozen. It applies to all subsequent object declarations,
7093 and also any allocator that creates objects of the type.
7095 If the pragma is given for the first subtype, then it is considered
7096 to apply to the base type and all its subtypes. If the pragma is given
7097 for other than a first subtype, then it applies only to the given subtype.
7098 The pragma may not be given after the type is frozen.
7100 Note that this includes eliminating initialization of discriminants
7101 for discriminated types, and tags for tagged types. In these cases,
7102 you will have to use some non-portable mechanism (e.g. address
7103 overlays or unchecked conversion) to achieve required initialization
7104 of these fields before accessing any object of the corresponding type.
7106 For the variable case, implicit initialization for the named variable
7107 is suppressed, just as though its subtype had been given in a pragma
7108 Suppress_Initialization, as described above.
7110 @node Pragma Task_Name
7111 @unnumberedsec Pragma Task_Name
7112 @findex Task_Name
7113 @noindent
7114 Syntax
7116 @smallexample @c ada
7117 pragma Task_Name (string_EXPRESSION);
7118 @end smallexample
7120 @noindent
7121 This pragma appears within a task definition (like pragma
7122 @code{Priority}) and applies to the task in which it appears.  The
7123 argument must be of type String, and provides a name to be used for
7124 the task instance when the task is created.  Note that this expression
7125 is not required to be static, and in particular, it can contain
7126 references to task discriminants.  This facility can be used to
7127 provide different names for different tasks as they are created,
7128 as illustrated in the example below.
7130 The task name is recorded internally in the run-time structures
7131 and is accessible to tools like the debugger.  In addition the
7132 routine @code{Ada.Task_Identification.Image} will return this
7133 string, with a unique task address appended.
7135 @smallexample @c ada
7136 --  Example of the use of pragma Task_Name
7138 with Ada.Task_Identification;
7139 use Ada.Task_Identification;
7140 with Text_IO; use Text_IO;
7141 procedure t3 is
7143    type Astring is access String;
7145    task type Task_Typ (Name : access String) is
7146       pragma Task_Name (Name.all);
7147    end Task_Typ;
7149    task body Task_Typ is
7150       Nam : constant String := Image (Current_Task);
7151    begin
7152       Put_Line ("-->" & Nam (1 .. 14) & "<--");
7153    end Task_Typ;
7155    type Ptr_Task is access Task_Typ;
7156    Task_Var : Ptr_Task;
7158 begin
7159    Task_Var :=
7160      new Task_Typ (new String'("This is task 1"));
7161    Task_Var :=
7162      new Task_Typ (new String'("This is task 2"));
7163 end;
7164 @end smallexample
7166 @node Pragma Task_Storage
7167 @unnumberedsec Pragma Task_Storage
7168 @findex Task_Storage
7169 Syntax:
7171 @smallexample @c ada
7172 pragma Task_Storage (
7173   [Task_Type =>] LOCAL_NAME,
7174   [Top_Guard =>] static_integer_EXPRESSION);
7175 @end smallexample
7177 @noindent
7178 This pragma specifies the length of the guard area for tasks.  The guard
7179 area is an additional storage area allocated to a task.  A value of zero
7180 means that either no guard area is created or a minimal guard area is
7181 created, depending on the target.  This pragma can appear anywhere a
7182 @code{Storage_Size} attribute definition clause is allowed for a task
7183 type.
7185 @node Pragma Test_Case
7186 @unnumberedsec Pragma Test_Case
7187 @cindex Test cases
7188 @findex Test_Case
7189 @noindent
7190 Syntax:
7192 @smallexample @c ada
7193 pragma Test_Case (
7194    [Name     =>] static_string_Expression
7195   ,[Mode     =>] (Nominal | Robustness)
7196  [, Requires =>  Boolean_Expression]
7197  [, Ensures  =>  Boolean_Expression]);
7198 @end smallexample
7200 @noindent
7201 The @code{Test_Case} pragma allows defining fine-grain specifications
7202 for use by testing tools.
7203 The compiler checks the validity of the @code{Test_Case} pragma, but its
7204 presence does not lead to any modification of the code generated by the
7205 compiler.
7207 @code{Test_Case} pragmas may only appear immediately following the
7208 (separate) declaration of a subprogram in a package declaration, inside
7209 a package spec unit. Only other pragmas may intervene (that is appear
7210 between the subprogram declaration and a test case).
7212 The compiler checks that boolean expressions given in @code{Requires} and
7213 @code{Ensures} are valid, where the rules for @code{Requires} are the
7214 same as the rule for an expression in @code{Precondition} and the rules
7215 for @code{Ensures} are the same as the rule for an expression in
7216 @code{Postcondition}. In particular, attributes @code{'Old} and
7217 @code{'Result} can only be used within the @code{Ensures}
7218 expression. The following is an example of use within a package spec:
7220 @smallexample @c ada
7221 package Math_Functions is
7222    ...
7223    function Sqrt (Arg : Float) return Float;
7224    pragma Test_Case (Name     => "Test 1",
7225                      Mode     => Nominal,
7226                      Requires => Arg < 10000,
7227                      Ensures  => Sqrt'Result < 10);
7228    ...
7229 end Math_Functions;
7230 @end smallexample
7232 @noindent
7233 The meaning of a test case is that there is at least one context where
7234 @code{Requires} holds such that, if the associated subprogram is executed in
7235 that context, then @code{Ensures} holds when the subprogram returns.
7236 Mode @code{Nominal} indicates that the input context should also satisfy the
7237 precondition of the subprogram, and the output context should also satisfy its
7238 postcondition. Mode @code{Robustness} indicates that the precondition and
7239 postcondition of the subprogram should be ignored for this test case.
7241 @node Pragma Thread_Local_Storage
7242 @unnumberedsec Pragma Thread_Local_Storage
7243 @findex Thread_Local_Storage
7244 @cindex Task specific storage
7245 @cindex TLS (Thread Local Storage)
7246 @cindex Task_Attributes
7247 Syntax:
7249 @smallexample @c ada
7250 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
7251 @end smallexample
7253 @noindent
7254 This pragma specifies that the specified entity, which must be
7255 a variable declared in a library level package, is to be marked as
7256 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
7257 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
7258 (and hence each Ada task) to see a distinct copy of the variable.
7260 The variable may not have default initialization, and if there is
7261 an explicit initialization, it must be either @code{null} for an
7262 access variable, or a static expression for a scalar variable.
7263 This provides a low level mechanism similar to that provided by
7264 the @code{Ada.Task_Attributes} package, but much more efficient
7265 and is also useful in writing interface code that will interact
7266 with foreign threads.
7268 If this pragma is used on a system where @code{TLS} is not supported,
7269 then an error message will be generated and the program will be rejected.
7271 @node Pragma Time_Slice
7272 @unnumberedsec Pragma Time_Slice
7273 @findex Time_Slice
7274 @noindent
7275 Syntax:
7277 @smallexample @c ada
7278 pragma Time_Slice (static_duration_EXPRESSION);
7279 @end smallexample
7281 @noindent
7282 For implementations of GNAT on operating systems where it is possible
7283 to supply a time slice value, this pragma may be used for this purpose.
7284 It is ignored if it is used in a system that does not allow this control,
7285 or if it appears in other than the main program unit.
7286 @cindex OpenVMS
7287 Note that the effect of this pragma is identical to the effect of the
7288 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
7290 @node Pragma Title
7291 @unnumberedsec Pragma Title
7292 @findex Title
7293 @noindent
7294 Syntax:
7296 @smallexample @c ada
7297 pragma Title (TITLING_OPTION [, TITLING OPTION]);
7299 TITLING_OPTION ::=
7300   [Title    =>] STRING_LITERAL,
7301 | [Subtitle =>] STRING_LITERAL
7302 @end smallexample
7304 @noindent
7305 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
7306 pragma used in DEC Ada 83 implementations to provide a title and/or
7307 subtitle for the program listing.  The program listing generated by GNAT
7308 does not have titles or subtitles.
7310 Unlike other pragmas, the full flexibility of named notation is allowed
7311 for this pragma, i.e.@: the parameters may be given in any order if named
7312 notation is used, and named and positional notation can be mixed
7313 following the normal rules for procedure calls in Ada.
7315 @node Pragma Type_Invariant
7316 @unnumberedsec Pragma Type_Invariant
7317 @findex Invariant
7318 @findex Type_Invariant pragma
7319 @noindent
7320 Syntax:
7322 @smallexample @c ada
7323 pragma Type_Invariant
7324   ([Entity =>] type_LOCAL_NAME,
7325    [Check  =>] EXPRESSION);
7326 @end smallexample
7328 @noindent
7329 The @code{Type_Invariant} pragma is intended to be an exact
7330 replacement for the language-defined @code{Type_Invariant}
7331 aspect, and shares its restrictions and semantics. It differs
7332 from the language defined @code{Invariant} pragma in that it
7333 does not permit a string parameter, and it is
7334 controlled by the assertion identifier @code{Type_Invariant}
7335 rather than @code{Invariant}.
7337 @node Pragma Type_Invariant_Class
7338 @unnumberedsec Pragma Type_Invariant_Class
7339 @findex Invariant
7340 @findex Type_Invariant_Class pragma
7341 @noindent
7342 Syntax:
7344 @smallexample @c ada
7345 pragma Type_Invariant_Class
7346   ([Entity =>] type_LOCAL_NAME,
7347    [Check  =>] EXPRESSION);
7348 @end smallexample
7350 @noindent
7351 The @code{Type_Invariant_Class} pragma is intended to be an exact
7352 replacement for the language-defined @code{Type_Invariant'Class}
7353 aspect, and shares its restrictions and semantics.
7355 Note: This pragma is called @code{Type_Invariant_Class} rather than
7356 @code{Type_Invariant'Class} because the latter would not be strictly
7357 conforming to the allowed syntax for pragmas. The motivation
7358 for providing pragmas equivalent to the aspects is to allow a program
7359 to be written using the pragmas, and then compiled if necessary
7360 using an Ada compiler that does not recognize the pragmas or
7361 aspects, but is prepared to ignore the pragmas. The assertion
7362 policy that controls this pragma is @code{Type_Invariant'Class},
7363 not @code{Type_Invariant_Class}.
7365 @node Pragma Unchecked_Union
7366 @unnumberedsec Pragma Unchecked_Union
7367 @cindex Unions in C
7368 @findex Unchecked_Union
7369 @noindent
7370 Syntax:
7372 @smallexample @c ada
7373 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
7374 @end smallexample
7376 @noindent
7377 This pragma is used to specify a representation of a record type that is
7378 equivalent to a C union. It was introduced as a GNAT implementation defined
7379 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
7380 pragma, making it language defined, and GNAT fully implements this extended
7381 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
7382 details, consult the Ada 2012 Reference Manual, section B.3.3.
7384 @node Pragma Unevaluated_Use_Of_Old
7385 @unnumberedsec Pragma Unevaluated_Use_Of_Old
7386 @cindex Attribute Old
7387 @cindex Attribute Loop_Entry
7388 @cindex Unevaluated_Use_Of_Old
7389 @findex Unevaluated_Use_Of_Old
7390 @noindent
7391 Syntax:
7393 @smallexample @c ada
7394 pragma Unevaluated_Use_Of_Old (Error | Warn | Allow);
7395 @end smallexample
7397 @noindent
7398 This pragma controls the processing of attributes Old and Loop_Entry.
7399 If either of these attributes is used in a potentially unevaluated
7400 expression  (e.g. the then or else parts of an if expression), then
7401 normally this usage is considered illegal if the prefix of the attribute
7402 is other than an entity name. The language requires this
7403 behavior for Old, and GNAT copies the same rule for Loop_Entry.
7405 The reason for this rule is that otherwise, we can have a situation
7406 where we save the Old value, and this results in an exception, even
7407 though we might not evaluate the attribute. Consider this example:
7409 @smallexample @c ada
7410 package UnevalOld is
7411    K : Character;
7412    procedure U (A : String; C : Boolean)  -- ERROR
7413      with Post => (if C then A(1)'Old = K else True);
7414 end;
7415 @end smallexample
7417 @noindent
7418 If procedure U is called with a string with a lower bound of 2, and
7419 C false, then an exception would be raised trying to evaluate A(1)
7420 on entry even though the value would not be actually used.
7422 Although the rule guarantees against this possibility, it is sometimes
7423 too restrictive. For example if we know that the string has a lower
7424 bound of 1, then we will never raise an exception.
7425 The pragma @code{Unevaluated_Use_Of_Old} can be
7426 used to modify this behavior. If the argument is @code{Error} then an
7427 error is given (this is the default RM behavior). If the argument is
7428 @code{Warn} then the usage is allowed as legal but with a warning
7429 that an exception might be raised. If the argument is @code{Allow}
7430 then the usage is allowed as legal without generating a warning.
7432 This pragma may appear as a configuration pragma, or in a declarative
7433 part or package specification. In the latter case it applies to
7434 uses up to the end of the corresponding statement sequence or
7435 sequence of package declarations.
7437 @node Pragma Unimplemented_Unit
7438 @unnumberedsec Pragma Unimplemented_Unit
7439 @findex Unimplemented_Unit
7440 @noindent
7441 Syntax:
7443 @smallexample @c ada
7444 pragma Unimplemented_Unit;
7445 @end smallexample
7447 @noindent
7448 If this pragma occurs in a unit that is processed by the compiler, GNAT
7449 aborts with the message @samp{@var{xxx} not implemented}, where
7450 @var{xxx} is the name of the current compilation unit.  This pragma is
7451 intended to allow the compiler to handle unimplemented library units in
7452 a clean manner.
7454 The abort only happens if code is being generated.  Thus you can use
7455 specs of unimplemented packages in syntax or semantic checking mode.
7457 @node Pragma Universal_Aliasing
7458 @unnumberedsec Pragma Universal_Aliasing
7459 @findex Universal_Aliasing
7460 @noindent
7461 Syntax:
7463 @smallexample @c ada
7464 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
7465 @end smallexample
7467 @noindent
7468 @var{type_LOCAL_NAME} must refer to a type declaration in the current
7469 declarative part.  The effect is to inhibit strict type-based aliasing
7470 optimization for the given type.  In other words, the effect is as though
7471 access types designating this type were subject to pragma No_Strict_Aliasing.
7472 For a detailed description of the strict aliasing optimization, and the
7473 situations in which it must be suppressed, @xref{Optimization and Strict
7474 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
7476 @node Pragma Universal_Data
7477 @unnumberedsec Pragma Universal_Data
7478 @findex Universal_Data
7479 @noindent
7480 Syntax:
7482 @smallexample @c ada
7483 pragma Universal_Data [(library_unit_Name)];
7484 @end smallexample
7486 @noindent
7487 This pragma is supported only for the AAMP target and is ignored for
7488 other targets. The pragma specifies that all library-level objects
7489 (Counter 0 data) associated with the library unit are to be accessed
7490 and updated using universal addressing (24-bit addresses for AAMP5)
7491 rather than the default of 16-bit Data Environment (DENV) addressing.
7492 Use of this pragma will generally result in less efficient code for
7493 references to global data associated with the library unit, but
7494 allows such data to be located anywhere in memory. This pragma is
7495 a library unit pragma, but can also be used as a configuration pragma
7496 (including use in the @file{gnat.adc} file). The functionality
7497 of this pragma is also available by applying the -univ switch on the
7498 compilations of units where universal addressing of the data is desired.
7500 @node Pragma Unmodified
7501 @unnumberedsec Pragma Unmodified
7502 @findex Unmodified
7503 @cindex Warnings, unmodified
7504 @noindent
7505 Syntax:
7507 @smallexample @c ada
7508 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
7509 @end smallexample
7511 @noindent
7512 This pragma signals that the assignable entities (variables,
7513 @code{out} parameters, @code{in out} parameters) whose names are listed are
7514 deliberately not assigned in the current source unit. This
7515 suppresses warnings about the
7516 entities being referenced but not assigned, and in addition a warning will be
7517 generated if one of these entities is in fact assigned in the
7518 same unit as the pragma (or in the corresponding body, or one
7519 of its subunits).
7521 This is particularly useful for clearly signaling that a particular
7522 parameter is not modified, even though the spec suggests that it might
7525 For the variable case, warnings are never given for unreferenced variables
7526 whose name contains one of the substrings
7527 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7528 are typically to be used in cases where such warnings are expected.
7529 Thus it is never necessary to use @code{pragma Unmodified} for such
7530 variables, though it is harmless to do so.
7532 @node Pragma Unreferenced
7533 @unnumberedsec Pragma Unreferenced
7534 @findex Unreferenced
7535 @cindex Warnings, unreferenced
7536 @noindent
7537 Syntax:
7539 @smallexample @c ada
7540 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
7541 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
7542 @end smallexample
7544 @noindent
7545 This pragma signals that the entities whose names are listed are
7546 deliberately not referenced in the current source unit after the
7547 occurrence of the pragma. This
7548 suppresses warnings about the
7549 entities being unreferenced, and in addition a warning will be
7550 generated if one of these entities is in fact subsequently referenced in the
7551 same unit as the pragma (or in the corresponding body, or one
7552 of its subunits).
7554 This is particularly useful for clearly signaling that a particular
7555 parameter is not referenced in some particular subprogram implementation
7556 and that this is deliberate. It can also be useful in the case of
7557 objects declared only for their initialization or finalization side
7558 effects.
7560 If @code{LOCAL_NAME} identifies more than one matching homonym in the
7561 current scope, then the entity most recently declared is the one to which
7562 the pragma applies. Note that in the case of accept formals, the pragma
7563 Unreferenced may appear immediately after the keyword @code{do} which
7564 allows the indication of whether or not accept formals are referenced
7565 or not to be given individually for each accept statement.
7567 The left hand side of an assignment does not count as a reference for the
7568 purpose of this pragma. Thus it is fine to assign to an entity for which
7569 pragma Unreferenced is given.
7571 Note that if a warning is desired for all calls to a given subprogram,
7572 regardless of whether they occur in the same unit as the subprogram
7573 declaration, then this pragma should not be used (calls from another
7574 unit would not be flagged); pragma Obsolescent can be used instead
7575 for this purpose, see @xref{Pragma Obsolescent}.
7577 The second form of pragma @code{Unreferenced} is used within a context
7578 clause. In this case the arguments must be unit names of units previously
7579 mentioned in @code{with} clauses (similar to the usage of pragma
7580 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
7581 units and unreferenced entities within these units.
7583 For the variable case, warnings are never given for unreferenced variables
7584 whose name contains one of the substrings
7585 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7586 are typically to be used in cases where such warnings are expected.
7587 Thus it is never necessary to use @code{pragma Unreferenced} for such
7588 variables, though it is harmless to do so.
7590 @node Pragma Unreferenced_Objects
7591 @unnumberedsec Pragma Unreferenced_Objects
7592 @findex Unreferenced_Objects
7593 @cindex Warnings, unreferenced
7594 @noindent
7595 Syntax:
7597 @smallexample @c ada
7598 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
7599 @end smallexample
7601 @noindent
7602 This pragma signals that for the types or subtypes whose names are
7603 listed, objects which are declared with one of these types or subtypes may
7604 not be referenced, and if no references appear, no warnings are given.
7606 This is particularly useful for objects which are declared solely for their
7607 initialization and finalization effect. Such variables are sometimes referred
7608 to as RAII variables (Resource Acquisition Is Initialization). Using this
7609 pragma on the relevant type (most typically a limited controlled type), the
7610 compiler will automatically suppress unwanted warnings about these variables
7611 not being referenced.
7613 @node Pragma Unreserve_All_Interrupts
7614 @unnumberedsec Pragma Unreserve_All_Interrupts
7615 @findex Unreserve_All_Interrupts
7616 @noindent
7617 Syntax:
7619 @smallexample @c ada
7620 pragma Unreserve_All_Interrupts;
7621 @end smallexample
7623 @noindent
7624 Normally certain interrupts are reserved to the implementation.  Any attempt
7625 to attach an interrupt causes Program_Error to be raised, as described in
7626 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
7627 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
7628 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
7629 interrupt execution.
7631 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
7632 a program, then all such interrupts are unreserved.  This allows the
7633 program to handle these interrupts, but disables their standard
7634 functions.  For example, if this pragma is used, then pressing
7635 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
7636 a program can then handle the @code{SIGINT} interrupt as it chooses.
7638 For a full list of the interrupts handled in a specific implementation,
7639 see the source code for the spec of @code{Ada.Interrupts.Names} in
7640 file @file{a-intnam.ads}.  This is a target dependent file that contains the
7641 list of interrupts recognized for a given target.  The documentation in
7642 this file also specifies what interrupts are affected by the use of
7643 the @code{Unreserve_All_Interrupts} pragma.
7645 For a more general facility for controlling what interrupts can be
7646 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
7647 of the @code{Unreserve_All_Interrupts} pragma.
7649 @node Pragma Unsuppress
7650 @unnumberedsec Pragma Unsuppress
7651 @findex Unsuppress
7652 @noindent
7653 Syntax:
7655 @smallexample @c ada
7656 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
7657 @end smallexample
7659 @noindent
7660 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
7661 there is no corresponding pragma @code{Suppress} in effect, it has no
7662 effect.  The range of the effect is the same as for pragma
7663 @code{Suppress}.  The meaning of the arguments is identical to that used
7664 in pragma @code{Suppress}.
7666 One important application is to ensure that checks are on in cases where
7667 code depends on the checks for its correct functioning, so that the code
7668 will compile correctly even if the compiler switches are set to suppress
7669 checks. For example, in a program that depends on external names of tagged
7670 types and wants to ensure that the duplicated tag check occurs even if all
7671 run-time checks are suppressed by a compiler switch, the following
7672 configuration pragma will ensure this test is not suppressed:
7674 @smallexample @c ada
7675 pragma Unsuppress (Duplicated_Tag_Check);
7676 @end smallexample
7678 @noindent
7679 This pragma is standard in Ada 2005. It is available in all earlier versions
7680 of Ada as an implementation-defined pragma.
7682 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
7683 a number of implementation-defined check names. See description of pragma
7684 @code{Suppress} for full details.
7686 @node Pragma Use_VADS_Size
7687 @unnumberedsec Pragma Use_VADS_Size
7688 @cindex @code{Size}, VADS compatibility
7689 @cindex Rational profile
7690 @findex Use_VADS_Size
7691 @noindent
7692 Syntax:
7694 @smallexample @c ada
7695 pragma Use_VADS_Size;
7696 @end smallexample
7698 @noindent
7699 This is a configuration pragma.  In a unit to which it applies, any use
7700 of the 'Size attribute is automatically interpreted as a use of the
7701 'VADS_Size attribute.  Note that this may result in incorrect semantic
7702 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
7703 the handling of existing code which depends on the interpretation of Size
7704 as implemented in the VADS compiler.  See description of the VADS_Size
7705 attribute for further details.
7707 @node Pragma Validity_Checks
7708 @unnumberedsec Pragma Validity_Checks
7709 @findex Validity_Checks
7710 @noindent
7711 Syntax:
7713 @smallexample @c ada
7714 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
7715 @end smallexample
7717 @noindent
7718 This pragma is used in conjunction with compiler switches to control the
7719 built-in validity checking provided by GNAT@.  The compiler switches, if set
7720 provide an initial setting for the switches, and this pragma may be used
7721 to modify these settings, or the settings may be provided entirely by
7722 the use of the pragma.  This pragma can be used anywhere that a pragma
7723 is legal, including use as a configuration pragma (including use in
7724 the @file{gnat.adc} file).
7726 The form with a string literal specifies which validity options are to be
7727 activated.  The validity checks are first set to include only the default
7728 reference manual settings, and then a string of letters in the string
7729 specifies the exact set of options required.  The form of this string
7730 is exactly as described for the @option{-gnatVx} compiler switch (see the
7731 @value{EDITION} User's Guide for details).  For example the following two
7732 methods can be used to enable validity checking for mode @code{in} and
7733 @code{in out} subprogram parameters:
7735 @itemize @bullet
7736 @item
7737 @smallexample @c ada
7738 pragma Validity_Checks ("im");
7739 @end smallexample
7741 @item
7742 @smallexample
7743 gcc -c -gnatVim @dots{}
7744 @end smallexample
7745 @end itemize
7747 @noindent
7748 The form ALL_CHECKS activates all standard checks (its use is equivalent
7749 to the use of the @code{gnatva} switch.
7751 The forms with @code{Off} and @code{On}
7752 can be used to temporarily disable validity checks
7753 as shown in the following example:
7755 @smallexample @c ada
7756 @iftex
7757 @leftskip=0cm
7758 @end iftex
7759 pragma Validity_Checks ("c"); -- validity checks for copies
7760 pragma Validity_Checks (Off); -- turn off validity checks
7761 A := B;                       -- B will not be validity checked
7762 pragma Validity_Checks (On);  -- turn validity checks back on
7763 A := C;                       -- C will be validity checked
7764 @end smallexample
7766 @node Pragma Volatile
7767 @unnumberedsec Pragma Volatile
7768 @findex Volatile
7769 @noindent
7770 Syntax:
7772 @smallexample @c ada
7773 pragma Volatile (LOCAL_NAME);
7774 @end smallexample
7776 @noindent
7777 This pragma is defined by the Ada Reference Manual, and the GNAT
7778 implementation is fully conformant with this definition.  The reason it
7779 is mentioned in this section is that a pragma of the same name was supplied
7780 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
7781 implementation of pragma Volatile is upwards compatible with the
7782 implementation in DEC Ada 83.
7784 @node Pragma Warning_As_Error
7785 @unnumberedsec Pragma Warning_As_Error
7786 @findex Warning_As_Error
7787 @noindent
7788 Syntax:
7790 @smallexample @c ada
7791 pragma Warning_As_Error (static_string_EXPRESSION);
7792 @end smallexample
7794 @noindent
7795 This configuration pragma allows the programmer to specify a set
7796 of warnings that will be treated as errors. Any warning which
7797 matches the pattern given by the pragma argument will be treated
7798 as an error. This gives much more precise control that -gnatwe
7799 which treats all warnings as errors.
7801 The pattern may contain asterisks, which match zero or more characters in
7802 the message. For example, you can use
7803 @code{pragma Warning_As_Error ("bits of*unused")} to treat the warning
7804 message @code{warning: 960 bits of "a" unused} as an error. No other regular
7805 expression notations are permitted. All characters other than asterisk in
7806 these three specific cases are treated as literal characters in the match.
7807 The match is case insensitive, for example XYZ matches xyz.
7809 Note that the pattern matches if it occurs anywhere within the warning
7810 message string (it is not necessary to put an asterisk at the start and
7811 the end of the message, since this is implied).
7813 Another possibility for the static_string_EXPRESSION which works whether
7814 or not error tags are enabled (@option{-gnatw.d}) is to use the
7815 @option{-gnatw} tag string, enclosed in brackets,
7816 as shown in the example below, to treat a class of warnings as errors.
7818 The above use of patterns to match the message applies only to warning
7819 messages generated by the front end. This pragma can also be applied to
7820 warnings provided by the back end and mentioned in @ref{Pragma Warnings}.
7821 By using a single full @option{-Wxxx} switch in the pragma, such warnings
7822 can also be treated as errors.
7824 The pragma can appear either in a global configuration pragma file
7825 (e.g. @file{gnat.adc}), or at the start of a file. Given a global
7826 configuration pragma file containing:
7828 @smallexample @c ada
7829 pragma Warning_As_Error ("[-gnatwj]");
7830 @end smallexample
7832 @noindent
7833 which will treat all obsolescent feature warnings as errors, the
7834 following program compiles as shown (compile options here are
7835 @option{-gnatwa.d -gnatl -gnatj55}).
7837 @smallexample @c ada
7838      1. pragma Warning_As_Error ("*never assigned*");
7839      2. function Warnerr return String is
7840      3.    X : Integer;
7841            |
7842         >>> error: variable "X" is never read and
7843             never assigned [-gnatwv] [warning-as-error]
7845      4.    Y : Integer;
7846            |
7847         >>> warning: variable "Y" is assigned but
7848             never read [-gnatwu]
7850      5. begin
7851      6.    Y := 0;
7852      7.    return %ABC%;
7853                   |
7854         >>> error: use of "%" is an obsolescent
7855             feature (RM J.2(4)), use """ instead
7856             [-gnatwj] [warning-as-error]
7858      8. end;
7860  8 lines: No errors, 3 warnings (2 treated as errors)
7861 @end smallexample
7863 @noindent
7864 Note that this pragma does not affect the set of warnings issued in
7865 any way, it merely changes the effect of a matching warning if one
7866 is produced as a result of other warnings options. As shown in this
7867 example, if the pragma results in a warning being treated as an error,
7868 the tag is changed from "warning:" to "error:" and the string
7869 "[warning-as-error]" is appended to the end of the message.
7871 @node Pragma Warnings
7872 @unnumberedsec Pragma Warnings
7873 @findex Warnings
7874 @noindent
7875 Syntax:
7877 @smallexample @c ada
7878 pragma Warnings (On | Off [,REASON]);
7879 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
7880 pragma Warnings (static_string_EXPRESSION [,REASON]);
7881 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
7883 REASON ::= Reason => STRING_LITERAL @{& STRING_LITERAL@}
7885 Note: in Ada 83 mode, a string literal may be used in place of
7886 a static string expression (which does not exist in Ada 83).
7887 @end smallexample
7889 @noindent
7890 Normally warnings are enabled, with the output being controlled by
7891 the command line switch.  Warnings (@code{Off}) turns off generation of
7892 warnings until a Warnings (@code{On}) is encountered or the end of the
7893 current unit.  If generation of warnings is turned off using this
7894 pragma, then some or all of the warning messages are suppressed,
7895 regardless of the setting of the command line switches.
7897 The @code{Reason} parameter may optionally appear as the last argument
7898 in any of the forms of this pragma. It is intended purely for the
7899 purposes of documenting the reason for the @code{Warnings} pragma.
7900 The compiler will check that the argument is a static string but
7901 otherwise ignore this argument. Other tools may provide specialized
7902 processing for this string.
7904 The form with a single argument (or two arguments if Reason present),
7905 where the first argument is @code{ON} or @code{OFF}
7906 may be used as a configuration pragma.
7908 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
7909 the specified entity.  This suppression is effective from the point where
7910 it occurs till the end of the extended scope of the variable (similar to
7911 the scope of @code{Suppress}). This form cannot be used as a configuration
7912 pragma.
7914 In the case where the first argument is other than @code{ON} or
7915 @code{OFF},
7916 the third form with a single static_string_EXPRESSION argument (and possible
7917 reason) provides more precise
7918 control over which warnings are active. The string is a list of letters
7919 specifying which warnings are to be activated and which deactivated. The
7920 code for these letters is the same as the string used in the command
7921 line switch controlling warnings. For a brief summary, use the gnatmake
7922 command with no arguments, which will generate usage information containing
7923 the list of warnings switches supported. For
7924 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
7925 User's Guide}. This form can also be used as a configuration pragma.
7927 @noindent
7928 The warnings controlled by the @option{-gnatw} switch are generated by the
7929 front end of the compiler. The GCC back end can provide additional warnings
7930 and they are controlled by the @option{-W} switch. Such warnings can be
7931 identified by the appearance of a string of the form @code{[-Wxxx]} in the
7932 message which designates the @option{-Wxxx} switch that controls the message.
7933 The form with a single static_string_EXPRESSION argument also works for these
7934 warnings, but the string must be a single full @option{-Wxxx} switch in this
7935 case. The above reference lists a few examples of these additional warnings.
7937 @noindent
7938 The specified warnings will be in effect until the end of the program
7939 or another pragma Warnings is encountered. The effect of the pragma is
7940 cumulative. Initially the set of warnings is the standard default set
7941 as possibly modified by compiler switches. Then each pragma Warning
7942 modifies this set of warnings as specified. This form of the pragma may
7943 also be used as a configuration pragma.
7945 The fourth form, with an @code{On|Off} parameter and a string, is used to
7946 control individual messages, based on their text. The string argument
7947 is a pattern that is used to match against the text of individual
7948 warning messages (not including the initial "warning: " tag).
7950 The pattern may contain asterisks, which match zero or more characters in
7951 the message. For example, you can use
7952 @code{pragma Warnings (Off, "bits of*unused")} to suppress the warning
7953 message @code{warning: 960 bits of "a" unused}. No other regular
7954 expression notations are permitted. All characters other than asterisk in
7955 these three specific cases are treated as literal characters in the match.
7956 The match is case insensitive, for example XYZ matches xyz.
7958 Note that the pattern matches if it occurs anywhere within the warning
7959 message string (it is not necessary to put an asterisk at the start and
7960 the end of the message, since this is implied).
7962 The above use of patterns to match the message applies only to warning
7963 messages generated by the front end. This form of the pragma with a string
7964 argument can also be used to control warnings provided by the back end and
7965 mentioned above. By using a single full @option{-Wxxx} switch in the pragma,
7966 such warnings can be turned on and off.
7968 There are two ways to use the pragma in this form. The OFF form can be used
7969 as a configuration pragma. The effect is to suppress all warnings (if any)
7970 that match the pattern string throughout the compilation (or match the
7971 -W switch in the back end case).
7973 The second usage is to suppress a warning locally, and in this case, two
7974 pragmas must appear in sequence:
7976 @smallexample @c ada
7977 pragma Warnings (Off, Pattern);
7978 @dots{} code where given warning is to be suppressed
7979 pragma Warnings (On, Pattern);
7980 @end smallexample
7982 @noindent
7983 In this usage, the pattern string must match in the Off and On
7984 pragmas, and (if @option{-gnatw.w} is given) at least one matching
7985 warning must be suppressed.
7987 Note: to write a string that will match any warning, use the string
7988 @code{"***"}. It will not work to use a single asterisk or two
7989 asterisks since this looks like an operator name. This form with three
7990 asterisks is similar in effect to specifying @code{pragma Warnings
7991 (Off)} except (if @option{-gnatw.w} is given) that a matching
7992 @code{pragma Warnings (On, "***")} will be required. This can be
7993 helpful in avoiding forgetting to turn warnings back on.
7995 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7996 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7997 be useful in checking whether obsolete pragmas in existing programs are hiding
7998 real problems.
8000 Note: pragma Warnings does not affect the processing of style messages. See
8001 separate entry for pragma Style_Checks for control of style messages.
8003 @node Pragma Weak_External
8004 @unnumberedsec Pragma Weak_External
8005 @findex Weak_External
8006 @noindent
8007 Syntax:
8009 @smallexample @c ada
8010 pragma Weak_External ([Entity =>] LOCAL_NAME);
8011 @end smallexample
8013 @noindent
8014 @var{LOCAL_NAME} must refer to an object that is declared at the library
8015 level. This pragma specifies that the given entity should be marked as a
8016 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
8017 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
8018 of a regular symbol, that is to say a symbol that does not have to be
8019 resolved by the linker if used in conjunction with a pragma Import.
8021 When a weak symbol is not resolved by the linker, its address is set to
8022 zero. This is useful in writing interfaces to external modules that may
8023 or may not be linked in the final executable, for example depending on
8024 configuration settings.
8026 If a program references at run time an entity to which this pragma has been
8027 applied, and the corresponding symbol was not resolved at link time, then
8028 the execution of the program is erroneous. It is not erroneous to take the
8029 Address of such an entity, for example to guard potential references,
8030 as shown in the example below.
8032 Some file formats do not support weak symbols so not all target machines
8033 support this pragma.
8035 @smallexample @c ada
8036 --  Example of the use of pragma Weak_External
8038 package External_Module is
8039   key : Integer;
8040   pragma Import (C, key);
8041   pragma Weak_External (key);
8042   function Present return boolean;
8043 end External_Module;
8045 with System; use System;
8046 package body External_Module is
8047   function Present return boolean is
8048   begin
8049     return key'Address /= System.Null_Address;
8050   end Present;
8051 end External_Module;
8052 @end smallexample
8054 @node Pragma Wide_Character_Encoding
8055 @unnumberedsec Pragma Wide_Character_Encoding
8056 @findex Wide_Character_Encoding
8057 @noindent
8058 Syntax:
8060 @smallexample @c ada
8061 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
8062 @end smallexample
8064 @noindent
8065 This pragma specifies the wide character encoding to be used in program
8066 source text appearing subsequently. It is a configuration pragma, but may
8067 also be used at any point that a pragma is allowed, and it is permissible
8068 to have more than one such pragma in a file, allowing multiple encodings
8069 to appear within the same file.
8071 The argument can be an identifier or a character literal. In the identifier
8072 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
8073 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
8074 case it is correspondingly one of the characters @samp{h}, @samp{u},
8075 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
8077 Note that when the pragma is used within a file, it affects only the
8078 encoding within that file, and does not affect withed units, specs,
8079 or subunits.
8081 @node Implementation Defined Aspects
8082 @chapter Implementation Defined Aspects
8083 Ada defines (throughout the Ada 2012 reference manual, summarized
8084 in Annex K) a set of aspects that can be specified for certain entities.
8085 These language defined aspects are implemented in GNAT in Ada 2012 mode
8086 and work as described in the Ada 2012 Reference Manual.
8088 In addition, Ada 2012 allows implementations to define additional aspects
8089 whose meaning is defined by the implementation.  GNAT provides
8090 a number of these implementation-defined aspects which can be used
8091 to extend and enhance the functionality of the compiler.  This section of
8092 the GNAT reference manual describes these additional aspects.
8094 Note that any program using these aspects may not be portable to
8095 other compilers (although GNAT implements this set of aspects on all
8096 platforms).  Therefore if portability to other compilers is an important
8097 consideration, you should minimize the use of these aspects.
8099 Note that for many of these aspects, the effect is essentially similar
8100 to the use of a pragma or attribute specification with the same name
8101 applied to the entity. For example, if we write:
8103 @smallexample @c ada
8104 type R is range 1 .. 100
8105   with Value_Size => 10;
8106 @end smallexample
8108 @noindent
8109 then the effect is the same as:
8111 @smallexample @c ada
8112 type R is range 1 .. 100;
8113 for R'Value_Size use 10;
8114 @end smallexample
8116 @noindent
8117 and if we write:
8119 @smallexample @c ada
8120 type R is new Integer
8121   with Shared => True;
8122 @end smallexample
8124 @noindent
8125 then the effect is the same as:
8127 @smallexample @c ada
8128 type R is new Integer;
8129 pragma Shared (R);
8130 @end smallexample
8132 @noindent
8133 In the documentation below, such cases are simply marked
8134 as being boolean aspects equivalent to the corresponding pragma
8135 or attribute definition clause.
8137 @menu
8138 * Aspect Abstract_State::
8139 * Aspect Annotate::
8140 * Aspect Async_Readers::
8141 * Aspect Async_Writers::
8142 * Aspect Contract_Cases::
8143 * Aspect Depends::
8144 * Aspect Dimension::
8145 * Aspect Dimension_System::
8146 * Aspect Effective_Reads::
8147 * Aspect Effective_Writes::
8148 * Aspect Favor_Top_Level::
8149 * Aspect Global::
8150 * Aspect Initial_Condition::
8151 * Aspect Initializes::
8152 * Aspect Inline_Always::
8153 * Aspect Invariant::
8154 * Aspect Invariant'Class::
8155 * Aspect Iterable::
8156 * Aspect Linker_Section::
8157 * Aspect Lock_Free::
8158 * Aspect No_Elaboration_Code_All::
8159 * Aspect No_Tagged_Streams::
8160 * Aspect Object_Size::
8161 * Aspect Obsolescent::
8162 * Aspect Part_Of::
8163 * Aspect Persistent_BSS::
8164 * Aspect Predicate::
8165 * Aspect Pure_Function::
8166 * Aspect Refined_Depends::
8167 * Aspect Refined_Global::
8168 * Aspect Refined_Post::
8169 * Aspect Refined_State::
8170 * Aspect Remote_Access_Type::
8171 * Aspect Scalar_Storage_Order::
8172 * Aspect Shared::
8173 * Aspect Simple_Storage_Pool::
8174 * Aspect Simple_Storage_Pool_Type::
8175 * Aspect SPARK_Mode::
8176 * Aspect Suppress_Debug_Info::
8177 * Aspect Suppress_Initialization::
8178 * Aspect Test_Case::
8179 * Aspect Thread_Local_Storage::
8180 * Aspect Universal_Aliasing::
8181 * Aspect Universal_Data::
8182 * Aspect Unmodified::
8183 * Aspect Unreferenced::
8184 * Aspect Unreferenced_Objects::
8185 * Aspect Value_Size::
8186 * Aspect Warnings::
8187 @end menu
8189 @node Aspect Abstract_State
8190 @unnumberedsec Aspect Abstract_State
8191 @findex Abstract_State
8192 @noindent
8193 This aspect is equivalent to pragma @code{Abstract_State}.
8195 @node Aspect Annotate
8196 @unnumberedsec Annotate
8197 @findex Annotate
8198 @noindent
8199 There are three forms of this aspect (where ID is an identifier,
8200 and ARG is a general expression).
8202 @table @code
8203 @item Annotate => ID
8204 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
8206 @item Annotate => (ID)
8207 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
8209 @item Annotate => (ID ,ID @{, ARG@})
8210 Equivalent to @code{pragma Annotate (ID, ID @{, ARG@}, Entity => Name);}
8211 @end table
8213 @node Aspect Async_Readers
8214 @unnumberedsec Aspect Async_Readers
8215 @findex Async_Readers
8216 @noindent
8217 This boolean aspect is equivalent to pragma @code{Async_Readers}.
8219 @node Aspect Async_Writers
8220 @unnumberedsec Aspect Async_Writers
8221 @findex Async_Writers
8222 @noindent
8223 This boolean aspect is equivalent to pragma @code{Async_Writers}.
8225 @node Aspect Contract_Cases
8226 @unnumberedsec Aspect Contract_Cases
8227 @findex Contract_Cases
8228 @noindent
8229 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
8230 of clauses being enclosed in parentheses so that syntactically it is an
8231 aggregate.
8233 @node Aspect Depends
8234 @unnumberedsec Aspect Depends
8235 @findex Depends
8236 @noindent
8237 This aspect is equivalent to pragma @code{Depends}.
8239 @node Aspect Dimension
8240 @unnumberedsec Aspect Dimension
8241 @findex Dimension
8242 @noindent
8243 The @code{Dimension} aspect is used to specify the dimensions of a given
8244 subtype of a dimensioned numeric type. The aspect also specifies a symbol
8245 used when doing formatted output of dimensioned quantities. The syntax is:
8247 @smallexample @c ada
8248 with Dimension =>
8249   ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
8251 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
8253 DIMENSION_VALUE ::=
8254   RATIONAL
8255 | others               => RATIONAL
8256 | DISCRETE_CHOICE_LIST => RATIONAL
8258 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
8259 @end smallexample
8261 @noindent
8262 This aspect can only be applied to a subtype whose parent type has
8263 a @code{Dimension_Systen} aspect. The aspect must specify values for
8264 all dimensions of the system. The rational values are the powers of the
8265 corresponding dimensions that are used by the compiler to verify that
8266 physical (numeric) computations are dimensionally consistent. For example,
8267 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
8268 For further examples of the usage
8269 of this aspect, see package @code{System.Dim.Mks}.
8270 Note that when the dimensioned type is an integer type, then any
8271 dimension value must be an integer literal.
8273 @node Aspect Dimension_System
8274 @unnumberedsec Aspect Dimension_System
8275 @findex Dimension_System
8276 @noindent
8277 The @code{Dimension_System} aspect is used to define a system of
8278 dimensions that will be used in subsequent subtype declarations with
8279 @code{Dimension} aspects that reference this system. The syntax is:
8281 @smallexample @c ada
8282 with Dimension_System => (DIMENSION @{, DIMENSION@});
8284 DIMENSION ::= ([Unit_Name   =>] IDENTIFIER,
8285                [Unit_Symbol =>] SYMBOL,
8286                [Dim_Symbol  =>] SYMBOL)
8288 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
8289 @end smallexample
8291 @noindent
8292 This aspect is applied to a type, which must be a numeric derived type
8293 (typically a floating-point type), that
8294 will represent values within the dimension system. Each @code{DIMENSION}
8295 corresponds to one particular dimension. A maximum of 7 dimensions may
8296 be specified. @code{Unit_Name} is the name of the dimension (for example
8297 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
8298 of this dimension (for example @code{m} for @code{Meter}).
8299 @code{Dim_Symbol} gives
8300 the identification within the dimension system (typically this is a
8301 single letter, e.g. @code{L} standing for length for unit name @code{Meter}).
8302 The @code{Unit_Symbol} is used in formatted output of dimensioned quantities.
8303 The @code{Dim_Symbol} is used in error messages when numeric operations have
8304 inconsistent dimensions.
8306 GNAT provides the standard definition of the International MKS system in
8307 the run-time package @code{System.Dim.Mks}. You can easily define
8308 similar packages for cgs units or British units, and define conversion factors
8309 between values in different systems. The MKS system is characterized by the
8310 following aspect:
8312 @smallexample @c ada
8313    type Mks_Type is new Long_Long_Float with
8314      Dimension_System => (
8315        (Unit_Name => Meter,    Unit_Symbol => 'm',   Dim_Symbol => 'L'),
8316        (Unit_Name => Kilogram, Unit_Symbol => "kg",  Dim_Symbol => 'M'),
8317        (Unit_Name => Second,   Unit_Symbol => 's',   Dim_Symbol => 'T'),
8318        (Unit_Name => Ampere,   Unit_Symbol => 'A',   Dim_Symbol => 'I'),
8319        (Unit_Name => Kelvin,   Unit_Symbol => 'K',   Dim_Symbol => '@'),
8320        (Unit_Name => Mole,     Unit_Symbol => "mol", Dim_Symbol => 'N'),
8321        (Unit_Name => Candela,  Unit_Symbol => "cd",  Dim_Symbol => 'J'));
8322 @end smallexample
8324 @noindent
8325 Note that in the above type definition, we use the symbol @code{@@} to
8326 represent a theta character (avoiding the use of extended Latin-1
8327 characters in this context).
8329 See section ``Performing Dimensionality Analysis in GNAT'' in the GNAT Users
8330 Guide for detailed examples of use of the dimension system.
8332 @node Aspect Effective_Reads
8333 @unnumberedsec Aspect Effective_Reads
8334 @findex Effective_Reads
8335 @noindent
8336 This aspect is equivalent to pragma @code{Effective_Reads}.
8338 @node Aspect Effective_Writes
8339 @unnumberedsec Aspect Effective_Writes
8340 @findex Effective_Writes
8341 @noindent
8342 This aspect is equivalent to pragma @code{Effective_Writes}.
8344 @node Aspect Favor_Top_Level
8345 @unnumberedsec Aspect Favor_Top_Level
8346 @findex Favor_Top_Level
8347 @noindent
8348 This boolean aspect is equivalent to pragma @code{Favor_Top_Level}.
8350 @node Aspect Global
8351 @unnumberedsec Aspect Global
8352 @findex Global
8353 @noindent
8354 This aspect is equivalent to pragma @code{Global}.
8356 @node Aspect Initial_Condition
8357 @unnumberedsec Aspect Initial_Condition
8358 @findex Initial_Condition
8359 @noindent
8360 This aspect is equivalent to pragma @code{Initial_Condition}.
8362 @node Aspect Initializes
8363 @unnumberedsec Aspect Initializes
8364 @findex Initializes
8365 @noindent
8366 This aspect is equivalent to pragma @code{Initializes}.
8368 @node Aspect Inline_Always
8369 @unnumberedsec Aspect Inline_Always
8370 @findex Inline_Always
8371 @noindent
8372 This boolean aspect is equivalent to pragma @code{Inline_Always}.
8374 @node Aspect Invariant
8375 @unnumberedsec Aspect Invariant
8376 @findex Invariant
8377 @noindent
8378 This aspect is equivalent to pragma @code{Invariant}. It is a
8379 synonym for the language defined aspect @code{Type_Invariant} except
8380 that it is separately controllable using pragma @code{Assertion_Policy}.
8382 @node Aspect Invariant'Class
8383 @unnumberedsec Aspect Invariant'Class
8384 @findex Invariant'Class
8385 @noindent
8386 This aspect is equivalent to pragma @code{Type_Invariant_Class}. It is a
8387 synonym for the language defined aspect @code{Type_Invariant'Class} except
8388 that it is separately controllable using pragma @code{Assertion_Policy}.
8390 @node Aspect Iterable
8391 @unnumberedsec Aspect Iterable
8392 @findex Iterable
8393 @noindent
8394 This aspect is used in the GNAT-defined formal container packages, to provide
8395 a light-weight mechanism for loops over such containers, without the overhead
8396 imposed by the tampering checks of standard Ada2012 iterators. The value of the
8397 aspect is a aggregate with four named  components: First, Next, Has_Element,
8398 and Element. The following is a typical example of use:
8400 @smallexample @c ada
8401 type List is private with
8402     Iterable => (First        => First_Element,
8403                  Next         => Advance,
8404                  Has_Element  => Get_Element,
8405                  Element      => List_Element);
8406 @end smallexample
8407 @itemize @bullet
8408 @item The value denoted by @code{First} must denote a primitive operation of
8409 the  container type that returns a Cursor, which must a be a type declared in
8410 the container package.
8411 @item The value of @code{Next} is a primitive operation of the container type
8412 that takes a cursor and yields a cursor.
8413 @item @code{Has_Element} is an operation that applies to a cursor a yields an
8414 element of the container.
8415 @item @code{Element} is the type of the elements of the container type, and
8416 thus the result of the function denoted by Has_Element.
8417 @end itemize
8419 @node Aspect Linker_Section
8420 @unnumberedsec Aspect Linker_Section
8421 @findex Linker_Section
8422 @noindent
8423 This aspect is equivalent to an @code{Linker_Section} pragma.
8425 @node Aspect Lock_Free
8426 @unnumberedsec Aspect Lock_Free
8427 @findex Lock_Free
8428 @noindent
8429 This boolean aspect is equivalent to pragma @code{Lock_Free}.
8431 @node Aspect No_Elaboration_Code_All
8432 @unnumberedsec Aspect No_Elaboration_Code_All
8433 @findex No_Elaboration_Code_All
8434 @noindent
8435 This aspect is equivalent to a @code{pragma No_Elaboration_Code_All}
8436 statement for a program unit.
8438 @node Aspect No_Tagged_Streams
8439 @unnumberedsec Aspect No_Tagged_Streams
8440 @findex No_Tagged_Streams
8441 @noindent
8442 This aspect is equivalent to a @code{pragma No_Tagged_Streams} with an
8443 argument specifying a root tagged type (thus this aspect can only be
8444 applied to such a type).
8446 @node Aspect Object_Size
8447 @unnumberedsec Aspect Object_Size
8448 @findex Object_Size
8449 @noindent
8450 This aspect is equivalent to an @code{Object_Size} attribute definition
8451 clause.
8453 @node Aspect Obsolescent
8454 @unnumberedsec Aspect Obsolescent
8455 @findex Obsolsecent
8456 @noindent
8457 This aspect is equivalent to an @code{Obsolescent} pragma. Note that the
8458 evaluation of this aspect happens at the point of occurrence, it is not
8459 delayed until the freeze point.
8461 @node Aspect Part_Of
8462 @unnumberedsec Aspect Part_Of
8463 @findex Part_Of
8464 @noindent
8465 This aspect is equivalent to pragma @code{Part_Of}.
8467 @node Aspect Persistent_BSS
8468 @unnumberedsec Aspect Persistent_BSS
8469 @findex Persistent_BSS
8470 @noindent
8471 This boolean aspect is equivalent to pragma @code{Persistent_BSS}.
8473 @node Aspect Predicate
8474 @unnumberedsec Aspect Predicate
8475 @findex Predicate
8476 @noindent
8477 This aspect is equivalent to pragma @code{Predicate}. It is thus
8478 similar to the language defined aspects @code{Dynamic_Predicate}
8479 and @code{Static_Predicate} except that whether the resulting
8480 predicate is static or dynamic is controlled by the form of the
8481 expression. It is also separately controllable using pragma
8482 @code{Assertion_Policy}.
8484 @node Aspect Pure_Function
8485 @unnumberedsec Aspect Pure_Function
8486 @findex Pure_Function
8487 @noindent
8488 This boolean aspect is equivalent to pragma @code{Pure_Function}.
8490 @node Aspect Refined_Depends
8491 @unnumberedsec Aspect Refined_Depends
8492 @findex Refined_Depends
8493 @noindent
8494 This aspect is equivalent to pragma @code{Refined_Depends}.
8496 @node Aspect Refined_Global
8497 @unnumberedsec Aspect Refined_Global
8498 @findex Refined_Global
8499 @noindent
8500 This aspect is equivalent to pragma @code{Refined_Global}.
8502 @node Aspect Refined_Post
8503 @unnumberedsec Aspect Refined_Post
8504 @findex Refined_Post
8505 @noindent
8506 This aspect is equivalent to pragma @code{Refined_Post}.
8508 @node Aspect Refined_State
8509 @unnumberedsec Aspect Refined_State
8510 @findex Refined_State
8511 @noindent
8512 This aspect is equivalent to pragma @code{Refined_State}.
8514 @node Aspect Remote_Access_Type
8515 @unnumberedsec Aspect Remote_Access_Type
8516 @findex Remote_Access_Type
8517 @noindent
8518 This aspect is equivalent to pragma @code{Remote_Access_Type}.
8520 @node Aspect Scalar_Storage_Order
8521 @unnumberedsec Aspect Scalar_Storage_Order
8522 @findex Scalar_Storage_Order
8523 @noindent
8524 This aspect is equivalent to a @code{Scalar_Storage_Order}
8525 attribute definition clause.
8527 @node Aspect Shared
8528 @unnumberedsec Aspect Shared
8529 @findex Shared
8530 @noindent
8531 This booleanaspect is equivalent to pragma @code{Shared},
8532 and is thus a synonym for aspect @code{Atomic}.
8534 @node Aspect Simple_Storage_Pool
8535 @unnumberedsec Aspect Simple_Storage_Pool
8536 @findex Simple_Storage_Pool
8537 @noindent
8538 This aspect is equivalent to a @code{Simple_Storage_Pool}
8539 attribute definition clause.
8541 @node Aspect Simple_Storage_Pool_Type
8542 @unnumberedsec Aspect Simple_Storage_Pool_Type
8543 @findex Simple_Storage_Pool_Type
8544 @noindent
8545 This boolean aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
8547 @node Aspect SPARK_Mode
8548 @unnumberedsec Aspect SPARK_Mode
8549 @findex SPARK_Mode
8550 @noindent
8551 This aspect is equivalent to pragma @code{SPARK_Mode} and
8552 may be specified for either or both of the specification and body
8553 of a subprogram or package.
8555 @node Aspect Suppress_Debug_Info
8556 @unnumberedsec Aspect Suppress_Debug_Info
8557 @findex Suppress_Debug_Info
8558 @noindent
8559 This boolean aspect is equivalent to pragma @code{Suppress_Debug_Info}.
8561 @node Aspect Suppress_Initialization
8562 @unnumberedsec Aspect Suppress_Initialization
8563 @findex Suppress_Initialization
8564 @noindent
8565 This boolean aspect is equivalent to pragma @code{Suppress_Initialization}.
8567 @node Aspect Test_Case
8568 @unnumberedsec Aspect Test_Case
8569 @findex Test_Case
8570 @noindent
8571 This aspect is equivalent to pragma @code{Test_Case}.
8573 @node Aspect Thread_Local_Storage
8574 @unnumberedsec Aspect Thread_Local_Storage
8575 @findex Thread_Local_Storage
8576 @noindent
8577 This boolean aspect is equivalent to pragma @code{Thread_Local_Storage}.
8579 @node Aspect Universal_Aliasing
8580 @unnumberedsec Aspect Universal_Aliasing
8581 @findex Universal_Aliasing
8582 @noindent
8583 This boolean aspect is equivalent to pragma @code{Universal_Aliasing}.
8585 @node Aspect Universal_Data
8586 @unnumberedsec Aspect Universal_Data
8587 @findex Universal_Data
8588 @noindent
8589 This aspect is equivalent to pragma @code{Universal_Data}.
8591 @node Aspect Unmodified
8592 @unnumberedsec Aspect Unmodified
8593 @findex Unmodified
8594 @noindent
8595 This boolean aspect is equivalent to pragma @code{Unmodified}.
8597 @node Aspect Unreferenced
8598 @unnumberedsec Aspect Unreferenced
8599 @findex Unreferenced
8600 @noindent
8601 This boolean aspect is equivalent to pragma @code{Unreferenced}. Note that
8602 in the case of formal parameters, it is not permitted to have aspects for
8603 a formal parameter, so in this case the pragma form must be used.
8605 @node Aspect Unreferenced_Objects
8606 @unnumberedsec Aspect Unreferenced_Objects
8607 @findex Unreferenced_Objects
8608 @noindent
8609 This boolean aspect is equivalent to pragma @code{Unreferenced_Objects}.
8611 @node Aspect Value_Size
8612 @unnumberedsec Aspect Value_Size
8613 @findex Value_Size
8614 @noindent
8615 This aspect is equivalent to a @code{Value_Size}
8616 attribute definition clause.
8618 @node Aspect Warnings
8619 @unnumberedsec Aspect Warnings
8620 @findex Warnings
8621 @noindent
8622 This aspect is equivalent to the two argument form of pragma @code{Warnings},
8623 where the first argument is @code{ON} or @code{OFF} and the second argument
8624 is the entity.
8627 @node Implementation Defined Attributes
8628 @chapter Implementation Defined Attributes
8629 Ada defines (throughout the Ada reference manual,
8630 summarized in Annex K),
8631 a set of attributes that provide useful additional functionality in all
8632 areas of the language.  These language defined attributes are implemented
8633 in GNAT and work as described in the Ada Reference Manual.
8635 In addition, Ada allows implementations to define additional
8636 attributes whose meaning is defined by the implementation.  GNAT provides
8637 a number of these implementation-dependent attributes which can be used
8638 to extend and enhance the functionality of the compiler.  This section of
8639 the GNAT reference manual describes these additional attributes.  It also
8640 describes additional implementation-dependent features of standard
8641 language-defined attributes.
8643 Note that any program using these attributes may not be portable to
8644 other compilers (although GNAT implements this set of attributes on all
8645 platforms).  Therefore if portability to other compilers is an important
8646 consideration, you should minimize the use of these attributes.
8648 @menu
8649 * Attribute Abort_Signal::
8650 * Attribute Address_Size::
8651 * Attribute Asm_Input::
8652 * Attribute Asm_Output::
8653 * Attribute AST_Entry::
8654 * Attribute Atomic_Always_Lock_Free::
8655 * Attribute Bit::
8656 * Attribute Bit_Position::
8657 * Attribute Code_Address::
8658 * Attribute Compiler_Version::
8659 * Attribute Constrained::
8660 * Attribute Default_Bit_Order::
8661 * Attribute Default_Scalar_Storage_Order::
8662 * Attribute Descriptor_Size::
8663 * Attribute Elaborated::
8664 * Attribute Elab_Body::
8665 * Attribute Elab_Spec::
8666 * Attribute Elab_Subp_Body::
8667 * Attribute Emax::
8668 * Attribute Enabled::
8669 * Attribute Enum_Rep::
8670 * Attribute Enum_Val::
8671 * Attribute Epsilon::
8672 * Attribute Fast_Math::
8673 * Attribute Fixed_Value::
8674 * Attribute From_Any::
8675 * Attribute Has_Access_Values::
8676 * Attribute Has_Discriminants::
8677 * Attribute Img::
8678 * Attribute Integer_Value::
8679 * Attribute Invalid_Value::
8680 * Attribute Iterable::
8681 * Attribute Large::
8682 * Attribute Library_Level::
8683 * Attribute Lock_Free::
8684 * Attribute Loop_Entry::
8685 * Attribute Machine_Size::
8686 * Attribute Mantissa::
8687 * Attribute Maximum_Alignment::
8688 * Attribute Mechanism_Code::
8689 * Attribute Null_Parameter::
8690 * Attribute Object_Size::
8691 * Attribute Old::
8692 * Attribute Passed_By_Reference::
8693 * Attribute Pool_Address::
8694 * Attribute Range_Length::
8695 * Attribute Ref::
8696 * Attribute Restriction_Set::
8697 * Attribute Result::
8698 * Attribute Safe_Emax::
8699 * Attribute Safe_Large::
8700 * Attribute Safe_Small::
8701 * Attribute Scalar_Storage_Order::
8702 * Attribute Simple_Storage_Pool::
8703 * Attribute Small::
8704 * Attribute Storage_Unit::
8705 * Attribute Stub_Type::
8706 * Attribute System_Allocator_Alignment::
8707 * Attribute Target_Name::
8708 * Attribute To_Address::
8709 * Attribute To_Any::
8710 * Attribute Type_Class::
8711 * Attribute Type_Key::
8712 * Attribute TypeCode::
8713 * Attribute UET_Address::
8714 * Attribute Unconstrained_Array::
8715 * Attribute Universal_Literal_String::
8716 * Attribute Unrestricted_Access::
8717 * Attribute Update::
8718 * Attribute VADS_Size::
8719 * Attribute Valid_Scalars::
8720 * Attribute Value_Size::
8721 * Attribute Wchar_T_Size::
8722 * Attribute Word_Size::
8723 @end menu
8725 @node Attribute Abort_Signal
8726 @unnumberedsec Attribute Abort_Signal
8727 @findex Abort_Signal
8728 @noindent
8729 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
8730 prefix) provides the entity for the special exception used to signal
8731 task abort or asynchronous transfer of control.  Normally this attribute
8732 should only be used in the tasking runtime (it is highly peculiar, and
8733 completely outside the normal semantics of Ada, for a user program to
8734 intercept the abort exception).
8736 @node Attribute Address_Size
8737 @unnumberedsec Attribute Address_Size
8738 @cindex Size of @code{Address}
8739 @findex Address_Size
8740 @noindent
8741 @code{Standard'Address_Size} (@code{Standard} is the only allowed
8742 prefix) is a static constant giving the number of bits in an
8743 @code{Address}. It is the same value as System.Address'Size,
8744 but has the advantage of being static, while a direct
8745 reference to System.Address'Size is non-static because Address
8746 is a private type.
8748 @node Attribute Asm_Input
8749 @unnumberedsec Attribute Asm_Input
8750 @findex Asm_Input
8751 @noindent
8752 The @code{Asm_Input} attribute denotes a function that takes two
8753 parameters.  The first is a string, the second is an expression of the
8754 type designated by the prefix.  The first (string) argument is required
8755 to be a static expression, and is the constraint for the parameter,
8756 (e.g.@: what kind of register is required).  The second argument is the
8757 value to be used as the input argument.  The possible values for the
8758 constant are the same as those used in the RTL, and are dependent on
8759 the configuration file used to built the GCC back end.
8760 @ref{Machine Code Insertions}
8762 @node Attribute Asm_Output
8763 @unnumberedsec Attribute Asm_Output
8764 @findex Asm_Output
8765 @noindent
8766 The @code{Asm_Output} attribute denotes a function that takes two
8767 parameters.  The first is a string, the second is the name of a variable
8768 of the type designated by the attribute prefix.  The first (string)
8769 argument is required to be a static expression and designates the
8770 constraint for the parameter (e.g.@: what kind of register is
8771 required).  The second argument is the variable to be updated with the
8772 result.  The possible values for constraint are the same as those used in
8773 the RTL, and are dependent on the configuration file used to build the
8774 GCC back end.  If there are no output operands, then this argument may
8775 either be omitted, or explicitly given as @code{No_Output_Operands}.
8776 @ref{Machine Code Insertions}
8778 @node Attribute AST_Entry
8779 @unnumberedsec Attribute AST_Entry
8780 @cindex OpenVMS
8781 @findex AST_Entry
8782 @noindent
8783 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
8784 the name of an entry, it yields a value of the predefined type AST_Handler
8785 (declared in the predefined package System, as extended by the use of
8786 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
8787 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
8788 Language Reference Manual}, section 9.12a.
8790 @node Attribute Atomic_Always_Lock_Free
8791 @unnumberedsec Attribute Atomic_Always_Lock_Free
8792 @findex Atomic_Always_Lock_Free
8793 @noindent
8795 The prefix of the @code{Atomic_Always_Lock_Free} attribute is a type.
8796 The result is a Boolean value which is True if the type has discriminants,
8797 and False otherwise.  The result indicate whether atomic operations are
8798 supported by the target for the given type.
8800 @node Attribute Bit
8801 @unnumberedsec Attribute Bit
8802 @findex Bit
8803 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
8804 offset within the storage unit (byte) that contains the first bit of
8805 storage allocated for the object.  The value of this attribute is of the
8806 type @code{Universal_Integer}, and is always a non-negative number not
8807 exceeding the value of @code{System.Storage_Unit}.
8809 For an object that is a variable or a constant allocated in a register,
8810 the value is zero.  (The use of this attribute does not force the
8811 allocation of a variable to memory).
8813 For an object that is a formal parameter, this attribute applies
8814 to either the matching actual parameter or to a copy of the
8815 matching actual parameter.
8817 For an access object the value is zero.  Note that
8818 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
8819 designated object.  Similarly for a record component
8820 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
8821 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
8822 are subject to index checks.
8824 This attribute is designed to be compatible with the DEC Ada 83 definition
8825 and implementation of the @code{Bit} attribute.
8827 @node Attribute Bit_Position
8828 @unnumberedsec Attribute Bit_Position
8829 @findex Bit_Position
8830 @noindent
8831 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
8832 of the fields of the record type, yields the bit
8833 offset within the record contains the first bit of
8834 storage allocated for the object.  The value of this attribute is of the
8835 type @code{Universal_Integer}.  The value depends only on the field
8836 @var{C} and is independent of the alignment of
8837 the containing record @var{R}.
8839 @node Attribute Code_Address
8840 @unnumberedsec Attribute Code_Address
8841 @findex Code_Address
8842 @cindex Subprogram address
8843 @cindex Address of subprogram code
8844 @noindent
8845 The @code{'Address}
8846 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
8847 intended effect seems to be to provide
8848 an address value which can be used to call the subprogram by means of
8849 an address clause as in the following example:
8851 @smallexample @c ada
8852 procedure K is @dots{}
8854 procedure L;
8855 for L'Address use K'Address;
8856 pragma Import (Ada, L);
8857 @end smallexample
8859 @noindent
8860 A call to @code{L} is then expected to result in a call to @code{K}@.
8861 In Ada 83, where there were no access-to-subprogram values, this was
8862 a common work-around for getting the effect of an indirect call.
8863 GNAT implements the above use of @code{Address} and the technique
8864 illustrated by the example code works correctly.
8866 However, for some purposes, it is useful to have the address of the start
8867 of the generated code for the subprogram.  On some architectures, this is
8868 not necessarily the same as the @code{Address} value described above.
8869 For example, the @code{Address} value may reference a subprogram
8870 descriptor rather than the subprogram itself.
8872 The @code{'Code_Address} attribute, which can only be applied to
8873 subprogram entities, always returns the address of the start of the
8874 generated code of the specified subprogram, which may or may not be
8875 the same value as is returned by the corresponding @code{'Address}
8876 attribute.
8878 @node Attribute Compiler_Version
8879 @unnumberedsec Attribute Compiler_Version
8880 @findex Compiler_Version
8881 @noindent
8882 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
8883 prefix) yields a static string identifying the version of the compiler
8884 being used to compile the unit containing the attribute reference. A
8885 typical result would be something like
8886 "@value{EDITION} @value{gnat_version} (20090221)".
8888 @node Attribute Constrained
8889 @unnumberedsec Attribute Constrained
8890 @findex Constrained
8891 @noindent
8892 In addition to the usage of this attribute in the Ada RM, @code{GNAT}
8893 also permits the use of the @code{'Constrained} attribute
8894 in a generic template
8895 for any type, including types without discriminants. The value of this
8896 attribute in the generic instance when applied to a scalar type or a
8897 record type without discriminants is always @code{True}. This usage is
8898 compatible with older Ada compilers, including notably DEC Ada.
8900 @node Attribute Default_Bit_Order
8901 @unnumberedsec Attribute Default_Bit_Order
8902 @cindex Big endian
8903 @cindex Little endian
8904 @findex Default_Bit_Order
8905 @noindent
8906 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
8907 permissible prefix), provides the value @code{System.Default_Bit_Order}
8908 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
8909 @code{Low_Order_First}).  This is used to construct the definition of
8910 @code{Default_Bit_Order} in package @code{System}.
8912 @node Attribute Default_Scalar_Storage_Order
8913 @unnumberedsec Attribute Default_Scalar_Storage_Order
8914 @cindex Big endian
8915 @cindex Little endian
8916 @findex Default_Scalar_Storage_Order
8917 @noindent
8918 @code{Standard'Default_Scalar_Storage_Order} (@code{Standard} is the only
8919 permissible prefix), provides the current value of the default scalar storage
8920 order (as specified using pragma @code{Default_Scalar_Storage_Order}, or
8921 equal to @code{Default_Bit_Order} if unspecified) as a
8922 @code{System.Bit_Order} value. This is a static attribute.
8924 @node Attribute Descriptor_Size
8925 @unnumberedsec Attribute Descriptor_Size
8926 @cindex Descriptor
8927 @cindex Dope vector
8928 @findex Descriptor_Size
8929 @noindent
8930 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
8931 descriptor allocated for a type.  The result is non-zero only for unconstrained
8932 array types and the returned value is of type universal integer.  In GNAT, an
8933 array descriptor contains bounds information and is located immediately before
8934 the first element of the array.
8936 @smallexample @c ada
8937 type Unconstr_Array is array (Positive range <>) of Boolean;
8938 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
8939 @end smallexample
8941 @noindent
8942 The attribute takes into account any additional padding due to type alignment.
8943 In the example above, the descriptor contains two values of type
8944 @code{Positive} representing the low and high bound.  Since @code{Positive} has
8945 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
8946 Positive'Size + 2} or 64 bits.
8948 @node Attribute Elaborated
8949 @unnumberedsec Attribute Elaborated
8950 @findex Elaborated
8951 @noindent
8952 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
8953 value is a Boolean which indicates whether or not the given unit has been
8954 elaborated.  This attribute is primarily intended for internal use by the
8955 generated code for dynamic elaboration checking, but it can also be used
8956 in user programs.  The value will always be True once elaboration of all
8957 units has been completed.  An exception is for units which need no
8958 elaboration, the value is always False for such units.
8960 @node Attribute Elab_Body
8961 @unnumberedsec Attribute Elab_Body
8962 @findex Elab_Body
8963 @noindent
8964 This attribute can only be applied to a program unit name.  It returns
8965 the entity for the corresponding elaboration procedure for elaborating
8966 the body of the referenced unit.  This is used in the main generated
8967 elaboration procedure by the binder and is not normally used in any
8968 other context.  However, there may be specialized situations in which it
8969 is useful to be able to call this elaboration procedure from Ada code,
8970 e.g.@: if it is necessary to do selective re-elaboration to fix some
8971 error.
8973 @node Attribute Elab_Spec
8974 @unnumberedsec Attribute Elab_Spec
8975 @findex Elab_Spec
8976 @noindent
8977 This attribute can only be applied to a program unit name.  It returns
8978 the entity for the corresponding elaboration procedure for elaborating
8979 the spec of the referenced unit.  This is used in the main
8980 generated elaboration procedure by the binder and is not normally used
8981 in any other context.  However, there may be specialized situations in
8982 which it is useful to be able to call this elaboration procedure from
8983 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
8984 some error.
8986 @node Attribute Elab_Subp_Body
8987 @unnumberedsec Attribute Elab_Subp_Body
8988 @findex Elab_Subp_Body
8989 @noindent
8990 This attribute can only be applied to a library level subprogram
8991 name and is only allowed in CodePeer mode. It returns the entity
8992 for the corresponding elaboration procedure for elaborating the body
8993 of the referenced subprogram unit. This is used in the main generated
8994 elaboration procedure by the binder in CodePeer mode only and is unrecognized
8995 otherwise.
8997 @node Attribute Emax
8998 @unnumberedsec Attribute Emax
8999 @cindex Ada 83 attributes
9000 @findex Emax
9001 @noindent
9002 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
9003 the Ada 83 reference manual for an exact description of the semantics of
9004 this attribute.
9006 @node Attribute Enabled
9007 @unnumberedsec Attribute Enabled
9008 @findex Enabled
9009 @noindent
9010 The @code{Enabled} attribute allows an application program to check at compile
9011 time to see if the designated check is currently enabled. The prefix is a
9012 simple identifier, referencing any predefined check name (other than
9013 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
9014 no argument is given for the attribute, the check is for the general state
9015 of the check, if an argument is given, then it is an entity name, and the
9016 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
9017 given naming the entity (if not, then the argument is ignored).
9019 Note that instantiations inherit the check status at the point of the
9020 instantiation, so a useful idiom is to have a library package that
9021 introduces a check name with @code{pragma Check_Name}, and then contains
9022 generic packages or subprograms which use the @code{Enabled} attribute
9023 to see if the check is enabled. A user of this package can then issue
9024 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
9025 the package or subprogram, controlling whether the check will be present.
9027 @node Attribute Enum_Rep
9028 @unnumberedsec Attribute Enum_Rep
9029 @cindex Representation of enums
9030 @findex Enum_Rep
9031 @noindent
9032 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
9033 function with the following spec:
9035 @smallexample @c ada
9036 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
9037   return @i{Universal_Integer};
9038 @end smallexample
9040 @noindent
9041 It is also allowable to apply @code{Enum_Rep} directly to an object of an
9042 enumeration type or to a non-overloaded enumeration
9043 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
9044 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
9045 enumeration literal or object.
9047 The function returns the representation value for the given enumeration
9048 value.  This will be equal to value of the @code{Pos} attribute in the
9049 absence of an enumeration representation clause.  This is a static
9050 attribute (i.e.@: the result is static if the argument is static).
9052 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
9053 in which case it simply returns the integer value.  The reason for this
9054 is to allow it to be used for @code{(<>)} discrete formal arguments in
9055 a generic unit that can be instantiated with either enumeration types
9056 or integer types.  Note that if @code{Enum_Rep} is used on a modular
9057 type whose upper bound exceeds the upper bound of the largest signed
9058 integer type, and the argument is a variable, so that the universal
9059 integer calculation is done at run time, then the call to @code{Enum_Rep}
9060 may raise @code{Constraint_Error}.
9062 @node Attribute Enum_Val
9063 @unnumberedsec Attribute Enum_Val
9064 @cindex Representation of enums
9065 @findex Enum_Val
9066 @noindent
9067 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
9068 function with the following spec:
9070 @smallexample @c ada
9071 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
9072   return @var{S}'Base};
9073 @end smallexample
9075 @noindent
9076 The function returns the enumeration value whose representation matches the
9077 argument, or raises Constraint_Error if no enumeration literal of the type
9078 has the matching value.
9079 This will be equal to value of the @code{Val} attribute in the
9080 absence of an enumeration representation clause.  This is a static
9081 attribute (i.e.@: the result is static if the argument is static).
9083 @node Attribute Epsilon
9084 @unnumberedsec Attribute Epsilon
9085 @cindex Ada 83 attributes
9086 @findex Epsilon
9087 @noindent
9088 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
9089 the Ada 83 reference manual for an exact description of the semantics of
9090 this attribute.
9092 @node Attribute Fast_Math
9093 @unnumberedsec Attribute Fast_Math
9094 @findex Fast_Math
9095 @noindent
9096 @code{Standard'Fast_Math} (@code{Standard} is the only allowed
9097 prefix) yields a static Boolean value that is True if pragma
9098 @code{Fast_Math} is active, and False otherwise.
9100 @node Attribute Fixed_Value
9101 @unnumberedsec Attribute Fixed_Value
9102 @findex Fixed_Value
9103 @noindent
9104 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
9105 function with the following specification:
9107 @smallexample @c ada
9108 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
9109   return @var{S};
9110 @end smallexample
9112 @noindent
9113 The value returned is the fixed-point value @var{V} such that
9115 @smallexample @c ada
9116 @var{V} = Arg * @var{S}'Small
9117 @end smallexample
9119 @noindent
9120 The effect is thus similar to first converting the argument to the
9121 integer type used to represent @var{S}, and then doing an unchecked
9122 conversion to the fixed-point type.  The difference is
9123 that there are full range checks, to ensure that the result is in range.
9124 This attribute is primarily intended for use in implementation of the
9125 input-output functions for fixed-point values.
9127 @node Attribute From_Any
9128 @unnumberedsec Attribute From_Any
9129 @findex From_Any
9130 @noindent
9131 This internal attribute is used for the generation of remote subprogram
9132 stubs in the context of the Distributed Systems Annex.
9134 @node Attribute Has_Access_Values
9135 @unnumberedsec Attribute Has_Access_Values
9136 @cindex Access values, testing for
9137 @findex Has_Access_Values
9138 @noindent
9139 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
9140 is a Boolean value which is True if the is an access type, or is a composite
9141 type with a component (at any nesting depth) that is an access type, and is
9142 False otherwise.
9143 The intended use of this attribute is in conjunction with generic
9144 definitions.  If the attribute is applied to a generic private type, it
9145 indicates whether or not the corresponding actual type has access values.
9147 @node Attribute Has_Discriminants
9148 @unnumberedsec Attribute Has_Discriminants
9149 @cindex Discriminants, testing for
9150 @findex Has_Discriminants
9151 @noindent
9152 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
9153 is a Boolean value which is True if the type has discriminants, and False
9154 otherwise.  The intended use of this attribute is in conjunction with generic
9155 definitions.  If the attribute is applied to a generic private type, it
9156 indicates whether or not the corresponding actual type has discriminants.
9158 @node Attribute Img
9159 @unnumberedsec Attribute Img
9160 @findex Img
9161 @noindent
9162 The @code{Img} attribute differs from @code{Image} in that it is applied
9163 directly to an object, and yields the same result as
9164 @code{Image} for the subtype of the object.  This is convenient for
9165 debugging:
9167 @smallexample @c ada
9168 Put_Line ("X = " & X'Img);
9169 @end smallexample
9171 @noindent
9172 has the same meaning as the more verbose:
9174 @smallexample @c ada
9175 Put_Line ("X = " & @var{T}'Image (X));
9176 @end smallexample
9178 @noindent
9179 where @var{T} is the (sub)type of the object @code{X}.
9181 Note that technically, in analogy to @code{Image},
9182 @code{X'Img} returns a parameterless function
9183 that returns the appropriate string when called. This means that
9184 @code{X'Img} can be renamed as a function-returning-string, or used
9185 in an instantiation as a function parameter.
9187 @node Attribute Integer_Value
9188 @unnumberedsec Attribute Integer_Value
9189 @findex Integer_Value
9190 @noindent
9191 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
9192 function with the following spec:
9194 @smallexample @c ada
9195 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
9196   return @var{S};
9197 @end smallexample
9199 @noindent
9200 The value returned is the integer value @var{V}, such that
9202 @smallexample @c ada
9203 Arg = @var{V} * @var{T}'Small
9204 @end smallexample
9206 @noindent
9207 where @var{T} is the type of @code{Arg}.
9208 The effect is thus similar to first doing an unchecked conversion from
9209 the fixed-point type to its corresponding implementation type, and then
9210 converting the result to the target integer type.  The difference is
9211 that there are full range checks, to ensure that the result is in range.
9212 This attribute is primarily intended for use in implementation of the
9213 standard input-output functions for fixed-point values.
9215 @node Attribute Invalid_Value
9216 @unnumberedsec Attribute Invalid_Value
9217 @findex Invalid_Value
9218 @noindent
9219 For every scalar type S, S'Invalid_Value returns an undefined value of the
9220 type. If possible this value is an invalid representation for the type. The
9221 value returned is identical to the value used to initialize an otherwise
9222 uninitialized value of the type if pragma Initialize_Scalars is used,
9223 including the ability to modify the value with the binder -Sxx flag and
9224 relevant environment variables at run time.
9226 @node Attribute Iterable
9227 @unnumberedsec Attribute Iterable
9228 @findex Iterable
9229 @noindent
9230 Equivalent to Aspect Iterable.
9232 @node Attribute Large
9233 @unnumberedsec Attribute Large
9234 @cindex Ada 83 attributes
9235 @findex Large
9236 @noindent
9237 The @code{Large} attribute is provided for compatibility with Ada 83.  See
9238 the Ada 83 reference manual for an exact description of the semantics of
9239 this attribute.
9241 @node Attribute Library_Level
9242 @unnumberedsec Attribute Library_Level
9243 @findex Library_Level
9244 @noindent
9245 @noindent
9246 @code{P'Library_Level}, where P is an entity name,
9247 returns a Boolean value which is True if the entity is declared
9248 at the library level, and False otherwise. Note that within a
9249 generic instantition, the name of the generic unit denotes the
9250 instance, which means that this attribute can be used to test
9251 if a generic is instantiated at the library level, as shown
9252 in this example:
9254 @smallexample @c ada
9255 generic
9256   ...
9257 package Gen is
9258   pragma Compile_Time_Error
9259     (not Gen'Library_Level,
9260      "Gen can only be instantiated at library level");
9261   ...
9262 end Gen;
9263 @end smallexample
9265 @node Attribute Lock_Free
9266 @unnumberedsec Attribute Lock_Free
9267 @findex Lock_Free
9268 @noindent
9269 @code{P'Lock_Free}, where P is a protected object, returns True if a
9270 pragma @code{Lock_Free} applies to P.
9272 @node Attribute Loop_Entry
9273 @unnumberedsec Attribute Loop_Entry
9274 @findex Loop_Entry
9275 @noindent
9276 Syntax:
9278 @smallexample @c ada
9279 X'Loop_Entry [(loop_name)]
9280 @end smallexample
9282 @noindent
9283 The @code{Loop_Entry} attribute is used to refer to the value that an
9284 expression had upon entry to a given loop in much the same way that the
9285 @code{Old} attribute in a subprogram postcondition can be used to refer
9286 to the value an expression had upon entry to the subprogram. The
9287 relevant loop is either identified by the given loop name, or it is the
9288 innermost enclosing loop when no loop name is given.
9290 @noindent
9291 A @code{Loop_Entry} attribute can only occur within a
9292 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
9293 @code{Loop_Entry} is to compare the current value of objects with their
9294 initial value at loop entry, in a @code{Loop_Invariant} pragma.
9296 @noindent
9297 The effect of using @code{X'Loop_Entry} is the same as declaring
9298 a constant initialized with the initial value of @code{X} at loop
9299 entry. This copy is not performed if the loop is not entered, or if the
9300 corresponding pragmas are ignored or disabled.
9302 @node Attribute Machine_Size
9303 @unnumberedsec Attribute Machine_Size
9304 @findex Machine_Size
9305 @noindent
9306 This attribute is identical to the @code{Object_Size} attribute.  It is
9307 provided for compatibility with the DEC Ada 83 attribute of this name.
9309 @node Attribute Mantissa
9310 @unnumberedsec Attribute Mantissa
9311 @cindex Ada 83 attributes
9312 @findex Mantissa
9313 @noindent
9314 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
9315 the Ada 83 reference manual for an exact description of the semantics of
9316 this attribute.
9318 @node Attribute Maximum_Alignment
9319 @unnumberedsec Attribute Maximum_Alignment
9320 @cindex Alignment, maximum
9321 @findex Maximum_Alignment
9322 @noindent
9323 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
9324 permissible prefix) provides the maximum useful alignment value for the
9325 target.  This is a static value that can be used to specify the alignment
9326 for an object, guaranteeing that it is properly aligned in all
9327 cases.
9329 @node Attribute Mechanism_Code
9330 @unnumberedsec Attribute Mechanism_Code
9331 @cindex Return values, passing mechanism
9332 @cindex Parameters, passing mechanism
9333 @findex Mechanism_Code
9334 @noindent
9335 @code{@var{function}'Mechanism_Code} yields an integer code for the
9336 mechanism used for the result of function, and
9337 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
9338 used for formal parameter number @var{n} (a static integer value with 1
9339 meaning the first parameter) of @var{subprogram}.  The code returned is:
9341 @table @asis
9342 @item 1
9343 by copy (value)
9344 @item 2
9345 by reference
9346 @end table
9348 @node Attribute Null_Parameter
9349 @unnumberedsec Attribute Null_Parameter
9350 @cindex Zero address, passing
9351 @findex Null_Parameter
9352 @noindent
9353 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
9354 type or subtype @var{T} allocated at machine address zero.  The attribute
9355 is allowed only as the default expression of a formal parameter, or as
9356 an actual expression of a subprogram call.  In either case, the
9357 subprogram must be imported.
9359 The identity of the object is represented by the address zero in the
9360 argument list, independent of the passing mechanism (explicit or
9361 default).
9363 This capability is needed to specify that a zero address should be
9364 passed for a record or other composite object passed by reference.
9365 There is no way of indicating this without the @code{Null_Parameter}
9366 attribute.
9368 @node Attribute Object_Size
9369 @unnumberedsec Attribute Object_Size
9370 @cindex Size, used for objects
9371 @findex Object_Size
9372 @noindent
9373 The size of an object is not necessarily the same as the size of the type
9374 of an object.  This is because by default object sizes are increased to be
9375 a multiple of the alignment of the object.  For example,
9376 @code{Natural'Size} is
9377 31, but by default objects of type @code{Natural} will have a size of 32 bits.
9378 Similarly, a record containing an integer and a character:
9380 @smallexample @c ada
9381 type Rec is record
9382    I : Integer;
9383    C : Character;
9384 end record;
9385 @end smallexample
9387 @noindent
9388 will have a size of 40 (that is @code{Rec'Size} will be 40).  The
9389 alignment will be 4, because of the
9390 integer field, and so the default size of record objects for this type
9391 will be 64 (8 bytes).
9393 If the alignment of the above record is specified to be 1, then the
9394 object size will be 40 (5 bytes). This is true by default, and also
9395 an object size of 40 can be explicitly specified in this case.
9397 A consequence of this capability is that different object sizes can be
9398 given to subtypes that would otherwise be considered in Ada to be
9399 statically matching.  But it makes no sense to consider such subtypes
9400 as statically matching.  Consequently, in @code{GNAT} we add a rule
9401 to the static matching rules that requires object sizes to match.
9402 Consider this example:
9404 @smallexample @c ada
9405  1. procedure BadAVConvert is
9406  2.    type R is new Integer;
9407  3.    subtype R1 is R range 1 .. 10;
9408  4.    subtype R2 is R range 1 .. 10;
9409  5.    for R1'Object_Size use 8;
9410  6.    for R2'Object_Size use 16;
9411  7.    type R1P is access all R1;
9412  8.    type R2P is access all R2;
9413  9.    R1PV : R1P := new R1'(4);
9414 10.    R2PV : R2P;
9415 11. begin
9416 12.    R2PV := R2P (R1PV);
9417                |
9418        >>> target designated subtype not compatible with
9419            type "R1" defined at line 3
9421 13. end;
9422 @end smallexample
9424 @noindent
9425 In the absence of lines 5 and 6,
9426 types @code{R1} and @code{R2} statically match and
9427 hence the conversion on line 12 is legal. But since lines 5 and 6
9428 cause the object sizes to differ, @code{GNAT} considers that types
9429 @code{R1} and @code{R2} are not statically matching, and line 12
9430 generates the diagnostic shown above.
9432 @noindent
9433 Similar additional checks are performed in other contexts requiring
9434 statically matching subtypes.
9436 @node Attribute Old
9437 @unnumberedsec Attribute Old
9438 @findex Old
9439 @noindent
9440 In addition to the usage of @code{Old} defined in the Ada 2012 RM (usage
9441 within @code{Post} aspect), GNAT also permits the use of this attribute
9442 in implementation defined pragmas @code{Postcondition},
9443 @code{Contract_Cases} and @code{Test_Case}. Also usages of
9444 @code{Old} which would be illegal according to the Ada 2012 RM
9445 definition are allowed under control of
9446 implementation defined pragma @code{Unevaluated_Use_Of_Old}.
9448 @node Attribute Passed_By_Reference
9449 @unnumberedsec Attribute Passed_By_Reference
9450 @cindex Parameters, when passed by reference
9451 @findex Passed_By_Reference
9452 @noindent
9453 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
9454 a value of type @code{Boolean} value that is @code{True} if the type is
9455 normally passed by reference and @code{False} if the type is normally
9456 passed by copy in calls.  For scalar types, the result is always @code{False}
9457 and is static.  For non-scalar types, the result is non-static.
9459 @node Attribute Pool_Address
9460 @unnumberedsec Attribute Pool_Address
9461 @cindex Parameters, when passed by reference
9462 @findex Pool_Address
9463 @noindent
9464 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
9465 of X within its storage pool. This is the same as
9466 @code{@var{X}'Address}, except that for an unconstrained array whose
9467 bounds are allocated just before the first component,
9468 @code{@var{X}'Pool_Address} returns the address of those bounds,
9469 whereas @code{@var{X}'Address} returns the address of the first
9470 component.
9472 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
9473 the object is allocated'', which could be a user-defined storage pool,
9474 the global heap, on the stack, or in a static memory area. For an
9475 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
9476 what is passed to @code{Allocate} and returned from @code{Deallocate}.
9478 @node Attribute Range_Length
9479 @unnumberedsec Attribute Range_Length
9480 @findex Range_Length
9481 @noindent
9482 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
9483 the number of values represented by the subtype (zero for a null
9484 range).  The result is static for static subtypes.  @code{Range_Length}
9485 applied to the index subtype of a one dimensional array always gives the
9486 same result as @code{Length} applied to the array itself.
9488 @node Attribute Ref
9489 @unnumberedsec Attribute Ref
9490 @findex Ref
9491 @noindent
9494 @node Attribute Restriction_Set
9495 @unnumberedsec Attribute Restriction_Set
9496 @findex Restriction_Set
9497 @cindex Restrictions
9498 @noindent
9499 This attribute allows compile time testing of restrictions that
9500 are currently in effect. It is primarily intended for specializing
9501 code in the run-time based on restrictions that are active (e.g.
9502 don't need to save fpt registers if restriction No_Floating_Point
9503 is known to be in effect), but can be used anywhere.
9505 There are two forms:
9507 @smallexample @c ada
9508 System'Restriction_Set (partition_boolean_restriction_NAME)
9509 System'Restriction_Set (No_Dependence => library_unit_NAME);
9510 @end smallexample
9512 @noindent
9513 In the case of the first form, the only restriction names
9514 allowed are parameterless restrictions that are checked
9515 for consistency at bind time. For a complete list see the
9516 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
9518 The result returned is True if the restriction is known to
9519 be in effect, and False if the restriction is known not to
9520 be in effect. An important guarantee is that the value of
9521 a Restriction_Set attribute is known to be consistent throughout
9522 all the code of a partition.
9524 This is trivially achieved if the entire partition is compiled
9525 with a consistent set of restriction pragmas. However, the
9526 compilation model does not require this. It is possible to
9527 compile one set of units with one set of pragmas, and another
9528 set of units with another set of pragmas. It is even possible
9529 to compile a spec with one set of pragmas, and then WITH the
9530 same spec with a different set of pragmas. Inconsistencies
9531 in the actual use of the restriction are checked at bind time.
9533 In order to achieve the guarantee of consistency for the
9534 Restriction_Set pragma, we consider that a use of the pragma
9535 that yields False is equivalent to a violation of the
9536 restriction.
9538 So for example if you write
9540 @smallexample @c ada
9541 if System'Restriction_Set (No_Floating_Point) then
9542    ...
9543 else
9544    ...
9545 end if;
9546 @end smallexample
9548 @noindent
9549 And the result is False, so that the else branch is executed,
9550 you can assume that this restriction is not set for any unit
9551 in the partition. This is checked by considering this use of
9552 the restriction pragma to be a violation of the restriction
9553 No_Floating_Point. This means that no other unit can attempt
9554 to set this restriction (if some unit does attempt to set it,
9555 the binder will refuse to bind the partition).
9557 Technical note: The restriction name and the unit name are
9558 intepreted entirely syntactically, as in the corresponding
9559 Restrictions pragma, they are not analyzed semantically,
9560 so they do not have a type.
9562 @node Attribute Result
9563 @unnumberedsec Attribute Result
9564 @findex Result
9565 @noindent
9566 @code{@var{function}'Result} can only be used with in a Postcondition pragma
9567 for a function. The prefix must be the name of the corresponding function. This
9568 is used to refer to the result of the function in the postcondition expression.
9569 For a further discussion of the use of this attribute and examples of its use,
9570 see the description of pragma Postcondition.
9572 @node Attribute Safe_Emax
9573 @unnumberedsec Attribute Safe_Emax
9574 @cindex Ada 83 attributes
9575 @findex Safe_Emax
9576 @noindent
9577 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
9578 the Ada 83 reference manual for an exact description of the semantics of
9579 this attribute.
9581 @node Attribute Safe_Large
9582 @unnumberedsec Attribute Safe_Large
9583 @cindex Ada 83 attributes
9584 @findex Safe_Large
9585 @noindent
9586 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
9587 the Ada 83 reference manual for an exact description of the semantics of
9588 this attribute.
9590 @node Attribute Safe_Small
9591 @unnumberedsec Attribute Safe_Small
9592 @cindex Ada 83 attributes
9593 @findex Safe_Small
9594 @noindent
9595 The @code{Safe_Small} attribute is provided for compatibility with Ada 83.  See
9596 the Ada 83 reference manual for an exact description of the semantics of
9597 this attribute.
9599 @node Attribute Scalar_Storage_Order
9600 @unnumberedsec Attribute Scalar_Storage_Order
9601 @cindex Endianness
9602 @cindex Scalar storage order
9603 @findex Scalar_Storage_Order
9604 @noindent
9605 For every array or record type @var{S}, the representation attribute
9606 @code{Scalar_Storage_Order} denotes the order in which storage elements
9607 that make up scalar components are ordered within S. The value given must
9608 be a static expression of type System.Bit_Order. The following is an example
9609 of the use of this feature:
9611 @smallexample @c ada
9612    --  Component type definitions
9614    subtype Yr_Type is Natural range 0 .. 127;
9615    subtype Mo_Type is Natural range 1 .. 12;
9616    subtype Da_Type is Natural range 1 .. 31;
9618    --  Record declaration
9620    type Date is record
9621       Years_Since_1980 : Yr_Type;
9622       Month            : Mo_Type;
9623       Day_Of_Month     : Da_Type;
9624    end record;
9626    --  Record representation clause
9628    for Date use record
9629       Years_Since_1980 at 0 range 0  ..  6;
9630       Month            at 0 range 7  .. 10;
9631       Day_Of_Month     at 0 range 11 .. 15;
9632    end record;
9634    --  Attribute definition clauses
9636    for Date'Bit_Order use System.High_Order_First;
9637    for Date'Scalar_Storage_Order use System.High_Order_First;
9638    --  If Scalar_Storage_Order is specified, it must be consistent with
9639    --  Bit_Order, so it's best to always define the latter explicitly if
9640    --  the former is used.
9641 @end smallexample
9643 @noindent
9644 Other properties are as for standard representation attribute @code{Bit_Order},
9645 as defined by Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
9647 For a record type @var{T}, if @code{@var{T}'Scalar_Storage_Order} is
9648 specified explicitly, it shall be equal to @code{@var{T}'Bit_Order}. Note:
9649 this means that if a @code{Scalar_Storage_Order} attribute definition
9650 clause is not confirming, then the type's @code{Bit_Order} shall be
9651 specified explicitly and set to the same value.
9653 Derived types inherit an explicitly set scalar storage order from their parent
9654 types. This may be overridden for the derived type by giving an explicit scalar
9655 storage order for the derived type. For a record extension, the derived type
9656 must have the same scalar storage order as the parent type.
9658 If a component of @var{T} is of a record or array type, then that type must
9659 also have a @code{Scalar_Storage_Order} attribute definition clause.
9661 A component of a record or array type that is a packed array, or that
9662 does not start on a byte boundary, must have the same scalar storage order
9663 as the enclosing record or array type.
9665 No component of a type that has an explicit @code{Scalar_Storage_Order}
9666 attribute definition may be aliased.
9668 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
9669 with a value equal to @code{System.Default_Bit_Order}) has no effect.
9671 If the opposite storage order is specified, then whenever the value of
9672 a scalar component of an object of type @var{S} is read, the storage
9673 elements of the enclosing machine scalar are first reversed (before
9674 retrieving the component value, possibly applying some shift and mask
9675 operatings on the enclosing machine scalar), and the opposite operation
9676 is done for writes.
9678 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
9679 are relaxed. Instead, the following rules apply:
9681 @itemize @bullet
9682 @item the underlying storage elements are those at positions
9683   @code{(position + first_bit / storage_element_size) ..
9684         (position + (last_bit + storage_element_size - 1) /
9685                     storage_element_size)}
9686 @item the sequence of underlying storage elements shall have
9687         a size no greater than the largest machine scalar
9688 @item the enclosing machine scalar is defined as the smallest machine
9689         scalar starting at a position no greater than
9690         @code{position + first_bit / storage_element_size} and covering
9691         storage elements at least up to @code{position + (last_bit +
9692         storage_element_size - 1) / storage_element_size}
9693 @item the position of the component is interpreted relative to that machine
9694  scalar.
9696 @end itemize
9698 If no scalar storage order is specified for a type (either directly, or by
9699 inheritance in the case of a derived type), then the default is normally
9700 the native ordering of the target, but this default can be overridden using
9701 pragma @code{Default_Scalar_Storage_Order}.
9703 @node Attribute Simple_Storage_Pool
9704 @unnumberedsec Attribute Simple_Storage_Pool
9705 @cindex Storage pool, simple
9706 @cindex Simple storage pool
9707 @findex Simple_Storage_Pool
9708 @noindent
9709 For every nonformal, nonderived access-to-object type @var{Acc}, the
9710 representation attribute @code{Simple_Storage_Pool} may be specified
9711 via an attribute_definition_clause (or by specifying the equivalent aspect):
9713 @smallexample @c ada
9715 My_Pool : My_Simple_Storage_Pool_Type;
9717 type Acc is access My_Data_Type;
9719 for Acc'Simple_Storage_Pool use My_Pool;
9721 @end smallexample
9723 @noindent
9724 The name given in an attribute_definition_clause for the
9725 @code{Simple_Storage_Pool} attribute shall denote a variable of
9726 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
9728 The use of this attribute is only allowed for a prefix denoting a type
9729 for which it has been specified. The type of the attribute is the type
9730 of the variable specified as the simple storage pool of the access type,
9731 and the attribute denotes that variable.
9733 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
9734 for the same access type.
9736 If the @code{Simple_Storage_Pool} attribute has been specified for an access
9737 type, then applying the @code{Storage_Pool} attribute to the type is flagged
9738 with a warning and its evaluation raises the exception @code{Program_Error}.
9740 If the Simple_Storage_Pool attribute has been specified for an access
9741 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
9742 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
9743 which is intended to indicate the number of storage elements reserved for
9744 the simple storage pool. If the Storage_Size function has not been defined
9745 for the simple storage pool type, then this attribute returns zero.
9747 If an access type @var{S} has a specified simple storage pool of type
9748 @var{SSP}, then the evaluation of an allocator for that access type calls
9749 the primitive @code{Allocate} procedure for type @var{SSP}, passing
9750 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
9751 semantics of such allocators is the same as those defined for allocators
9752 in section 13.11 of the Ada Reference Manual, with the term
9753 ``simple storage pool'' substituted for ``storage pool''.
9755 If an access type @var{S} has a specified simple storage pool of type
9756 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
9757 for that access type invokes the primitive @code{Deallocate} procedure
9758 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
9759 parameter. The detailed semantics of such unchecked deallocations is the same
9760 as defined in section 13.11.2 of the Ada Reference Manual, except that the
9761 term ``simple storage pool'' is substituted for ``storage pool''.
9763 @node Attribute Small
9764 @unnumberedsec Attribute Small
9765 @cindex Ada 83 attributes
9766 @findex Small
9767 @noindent
9768 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
9769 fixed-point types.
9770 GNAT also allows this attribute to be applied to floating-point types
9771 for compatibility with Ada 83.  See
9772 the Ada 83 reference manual for an exact description of the semantics of
9773 this attribute when applied to floating-point types.
9775 @node Attribute Storage_Unit
9776 @unnumberedsec Attribute Storage_Unit
9777 @findex Storage_Unit
9778 @noindent
9779 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
9780 prefix) provides the same value as @code{System.Storage_Unit}.
9782 @node Attribute Stub_Type
9783 @unnumberedsec Attribute Stub_Type
9784 @findex Stub_Type
9785 @noindent
9786 The GNAT implementation of remote access-to-classwide types is
9787 organized as described in AARM section E.4 (20.t): a value of an RACW type
9788 (designating a remote object) is represented as a normal access
9789 value, pointing to a "stub" object which in turn contains the
9790 necessary information to contact the designated remote object. A
9791 call on any dispatching operation of such a stub object does the
9792 remote call, if necessary, using the information in the stub object
9793 to locate the target partition, etc.
9795 For a prefix @code{T} that denotes a remote access-to-classwide type,
9796 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
9798 By construction, the layout of @code{T'Stub_Type} is identical to that of
9799 type @code{RACW_Stub_Type} declared in the internal implementation-defined
9800 unit @code{System.Partition_Interface}. Use of this attribute will create
9801 an implicit dependency on this unit.
9803 @node Attribute System_Allocator_Alignment
9804 @unnumberedsec Attribute System_Allocator_Alignment
9805 @cindex Alignment, allocator
9806 @findex System_Allocator_Alignment
9807 @noindent
9808 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
9809 permissible prefix) provides the observable guaranted to be honored by
9810 the system allocator (malloc). This is a static value that can be used
9811 in user storage pools based on malloc either to reject allocation
9812 with alignment too large or to enable a realignment circuitry if the
9813 alignment request is larger than this value.
9815 @node Attribute Target_Name
9816 @unnumberedsec Attribute Target_Name
9817 @findex Target_Name
9818 @noindent
9819 @code{Standard'Target_Name} (@code{Standard} is the only permissible
9820 prefix) provides a static string value that identifies the target
9821 for the current compilation. For GCC implementations, this is the
9822 standard gcc target name without the terminating slash (for
9823 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
9825 @node Attribute To_Address
9826 @unnumberedsec Attribute To_Address
9827 @findex To_Address
9828 @noindent
9829 The @code{System'To_Address}
9830 (@code{System} is the only permissible prefix)
9831 denotes a function identical to
9832 @code{System.Storage_Elements.To_Address} except that
9833 it is a static attribute.  This means that if its argument is
9834 a static expression, then the result of the attribute is a
9835 static expression.  This means that such an expression can be
9836 used in contexts (e.g.@: preelaborable packages) which require a
9837 static expression and where the function call could not be used
9838 (since the function call is always non-static, even if its
9839 argument is static). The argument must be in the range
9840 -(2**(m-1) .. 2**m-1, where m is the memory size
9841 (typically 32 or 64). Negative values are intepreted in a
9842 modular manner (e.g. -1 means the same as 16#FFFF_FFFF# on
9843 a 32 bits machine).
9845 @node Attribute To_Any
9846 @unnumberedsec Attribute To_Any
9847 @findex To_Any
9848 @noindent
9849 This internal attribute is used for the generation of remote subprogram
9850 stubs in the context of the Distributed Systems Annex.
9852 @node Attribute Type_Class
9853 @unnumberedsec Attribute Type_Class
9854 @findex Type_Class
9855 @noindent
9856 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
9857 the value of the type class for the full type of @var{type}.  If
9858 @var{type} is a generic formal type, the value is the value for the
9859 corresponding actual subtype.  The value of this attribute is of type
9860 @code{System.Aux_DEC.Type_Class}, which has the following definition:
9862 @smallexample @c ada
9863 type Type_Class is
9864   (Type_Class_Enumeration,
9865    Type_Class_Integer,
9866    Type_Class_Fixed_Point,
9867    Type_Class_Floating_Point,
9868    Type_Class_Array,
9869    Type_Class_Record,
9870    Type_Class_Access,
9871    Type_Class_Task,
9872    Type_Class_Address);
9873 @end smallexample
9875 @noindent
9876 Protected types yield the value @code{Type_Class_Task}, which thus
9877 applies to all concurrent types.  This attribute is designed to
9878 be compatible with the DEC Ada 83 attribute of the same name.
9880 @node Attribute Type_Key
9881 @unnumberedsec Attribute Type_Key
9882 @findex Type_Key
9883 @noindent
9884 The @code{Type_Key} attribute is applicable to a type or subtype and
9885 yields a value of type Standard.String containing encoded information
9886 about the type or subtype. This provides improved compatibility with
9887 other implementations that support this attribute.
9889 @node Attribute TypeCode
9890 @unnumberedsec Attribute TypeCode
9891 @findex TypeCode
9892 @noindent
9893 This internal attribute is used for the generation of remote subprogram
9894 stubs in the context of the Distributed Systems Annex.
9896 @node Attribute UET_Address
9897 @unnumberedsec Attribute UET_Address
9898 @findex UET_Address
9899 @noindent
9900 The @code{UET_Address} attribute can only be used for a prefix which
9901 denotes a library package.  It yields the address of the unit exception
9902 table when zero cost exception handling is used.  This attribute is
9903 intended only for use within the GNAT implementation.  See the unit
9904 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
9905 for details on how this attribute is used in the implementation.
9907 @node Attribute Unconstrained_Array
9908 @unnumberedsec Attribute Unconstrained_Array
9909 @findex Unconstrained_Array
9910 @noindent
9911 The @code{Unconstrained_Array} attribute can be used with a prefix that
9912 denotes any type or subtype. It is a static attribute that yields
9913 @code{True} if the prefix designates an unconstrained array,
9914 and @code{False} otherwise. In a generic instance, the result is
9915 still static, and yields the result of applying this test to the
9916 generic actual.
9918 @node Attribute Universal_Literal_String
9919 @unnumberedsec Attribute Universal_Literal_String
9920 @cindex Named numbers, representation of
9921 @findex Universal_Literal_String
9922 @noindent
9923 The prefix of @code{Universal_Literal_String} must be a named
9924 number.  The static result is the string consisting of the characters of
9925 the number as defined in the original source.  This allows the user
9926 program to access the actual text of named numbers without intermediate
9927 conversions and without the need to enclose the strings in quotes (which
9928 would preclude their use as numbers).
9930 For example, the following program prints the first 50 digits of pi:
9932 @smallexample @c ada
9933 with Text_IO; use Text_IO;
9934 with Ada.Numerics;
9935 procedure Pi is
9936 begin
9937    Put (Ada.Numerics.Pi'Universal_Literal_String);
9938 end;
9939 @end smallexample
9941 @node Attribute Unrestricted_Access
9942 @unnumberedsec Attribute Unrestricted_Access
9943 @cindex @code{Access}, unrestricted
9944 @findex Unrestricted_Access
9945 @noindent
9946 The @code{Unrestricted_Access} attribute is similar to @code{Access}
9947 except that all accessibility and aliased view checks are omitted.  This
9948 is a user-beware attribute.
9950 For objects, it is similar to @code{Address}, for which it is a
9951 desirable replacement where the value desired is an access type.
9952 In other words, its effect is similar to first applying the
9953 @code{Address} attribute and then doing an unchecked conversion to a
9954 desired access type.
9956 For subprograms, @code{P'Unrestricted_Access} may be used where
9957 @code{P'Access} would be illegal, to construct a value of a
9958 less-nested named access type that designates a more-nested
9959 subprogram. This value may be used in indirect calls, so long as the
9960 more-nested subprogram still exists; once the subprogram containing it
9961 has returned, such calls are erroneous. For example:
9963 @smallexample @c ada
9964 package body P is
9966    type Less_Nested is not null access procedure;
9967    Global : Less_Nested;
9969    procedure P1 is
9970    begin
9971       Global.all;
9972    end P1;
9974    procedure P2 is
9975       Local_Var : Integer;
9977       procedure More_Nested is
9978       begin
9979          ... Local_Var ...
9980       end More_Nested;
9981    begin
9982       Global := More_Nested'Unrestricted_Access;
9983       P1;
9984    end P2;
9986 end P;
9987 @end smallexample
9989 When P1 is called from P2, the call via Global is OK, but if P1 were
9990 called after P2 returns, it would be an erroneous use of a dangling
9991 pointer.
9993 For objects, it is possible to use @code{Unrestricted_Access} for any
9994 type, but care must be exercised if it is used to create pointers to
9995 unconstrained array objects.  In this case, the resulting pointer has
9996 the same scope as the context of the attribute, and may not be
9997 returned to some enclosing scope.  For instance, a function cannot use
9998 @code{Unrestricted_Access} to create a pointer to unconstrained and
9999 then return that value to the caller.  In addition, it is only valid
10000 to create pointers to unconstrained arrays using this attribute if the
10001 pointer has the normal default ``fat'' representation where a pointer
10002 has two components, one points to the array and one points to the
10003 bounds.  If a size clause is used to force ``thin'' representation for
10004 a pointer to unconstrained where there is only space for a single
10005 pointer, then the resulting pointer is not usable.
10007 In the simple case where a direct use of Unrestricted_Access attempts
10008 to make a thin pointer for a non-aliased object, the compiler will
10009 reject the use as illegal, as shown in the following example:
10011 @smallexample @c ada
10012 with System; use System;
10013 procedure SliceUA2 is
10014    type A is access all String;
10015    for A'Size use Standard'Address_Size;
10017    procedure P (Arg : A) is
10018    begin
10019       null;
10020    end P;
10022    X : String := "hello world!";
10023    X2 : aliased String := "hello world!";
10025    AV : A := X'Unrestricted_Access;    -- ERROR
10026              |
10027 >>> illegal use of Unrestricted_Access attribute
10028 >>> attempt to generate thin pointer to unaliased object
10030 begin
10031    P (X'Unrestricted_Access);          -- ERROR
10032       |
10033 >>> illegal use of Unrestricted_Access attribute
10034 >>> attempt to generate thin pointer to unaliased object
10036    P (X(7 .. 12)'Unrestricted_Access); -- ERROR
10037       |
10038 >>> illegal use of Unrestricted_Access attribute
10039 >>> attempt to generate thin pointer to unaliased object
10041    P (X2'Unrestricted_Access);         -- OK
10042 end;
10043 @end smallexample
10045 @noindent
10046 but other cases cannot be detected by the compiler, and are
10047 considered to be erroneous. Consider the following example:
10049 @smallexample @c ada
10050 with System; use System;
10051 with System; use System;
10052 procedure SliceUA is
10053    type AF is access all String;
10055    type A is access all String;
10056    for A'Size use Standard'Address_Size;
10058    procedure P (Arg : A) is
10059    begin
10060       if Arg'Length /= 6 then
10061          raise Program_Error;
10062       end if;
10063    end P;
10065    X : String := "hello world!";
10066    Y : AF := X (7 .. 12)'Unrestricted_Access;
10068 begin
10069    P (A (Y));
10070 end;
10071 @end smallexample
10073 @noindent
10074 A normal unconstrained array value
10075 or a constrained array object marked as aliased has the bounds in memory
10076 just before the array, so a thin pointer can retrieve both the data and
10077 the bounds.  But in this case, the non-aliased object @code{X} does not have the
10078 bounds before the string.  If the size clause for type @code{A}
10079 were not present, then the pointer
10080 would be a fat pointer, where one component is a pointer to the bounds,
10081 and all would be well.  But with the size clause present, the conversion from
10082 fat pointer to thin pointer in the call loses the bounds, and so this
10083 is erroneous, and the program likely raises a @code{Program_Error} exception.
10085 In general, it is advisable to completely
10086 avoid mixing the use of thin pointers and the use of
10087 @code{Unrestricted_Access} where the designated type is an
10088 unconstrained array.  The use of thin pointers should be restricted to
10089 cases of porting legacy code that implicitly assumes the size of pointers,
10090 and such code should not in any case be using this attribute.
10092 Another erroneous situation arises if the attribute is
10093 applied to a constant. The resulting pointer can be used to access the
10094 constant, but the effect of trying to modify a constant in this manner
10095 is not well-defined. Consider this example:
10097 @smallexample @c ada
10098 P : constant Integer := 4;
10099 type R is access all Integer;
10100 RV : R := P'Unrestricted_Access;
10102 RV.all := 3;
10103 @end smallexample
10105 @noindent
10106 Here we attempt to modify the constant P from 4 to 3, but the compiler may
10107 or may not notice this attempt, and subsequent references to P may yield
10108 either the value 3 or the value 4 or the assignment may blow up if the
10109 compiler decides to put P in read-only memory. One particular case where
10110 @code{Unrestricted_Access} can be used in this way is to modify the
10111 value of an @code{IN} parameter:
10113 @smallexample @c ada
10114 procedure K (S : in String) is
10115    type R is access all Character;
10116    RV : R := S (3)'Unrestricted_Access;
10117 begin
10118    RV.all := 'a';
10119 end;
10120 @end smallexample
10122 @noindent
10123 In general this is a risky approach. It may appear to "work" but such uses of
10124 @code{Unrestricted_Access} are potentially non-portable, even from one version
10125 of @code{GNAT} to another, so are best avoided if possible.
10127 @node Attribute Update
10128 @unnumberedsec Attribute Update
10129 @findex Update
10130 @noindent
10131 The @code{Update} attribute creates a copy of an array or record value
10132 with one or more modified components. The syntax is:
10134 @smallexample @c ada
10135 PREFIX'Update ( RECORD_COMPONENT_ASSOCIATION_LIST )
10136 PREFIX'Update ( ARRAY_COMPONENT_ASSOCIATION @{, ARRAY_COMPONENT_ASSOCIATION @} )
10137 PREFIX'Update ( MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION
10138                 @{, MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION @} )
10140 MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION ::= INDEX_EXPRESSION_LIST_LIST => EXPRESSION
10141 INDEX_EXPRESSION_LIST_LIST                   ::= INDEX_EXPRESSION_LIST @{| INDEX_EXPRESSION_LIST @}
10142 INDEX_EXPRESSION_LIST                        ::= ( EXPRESSION @{, EXPRESSION @} )
10143 @end smallexample
10145 @noindent
10146 where @code{PREFIX} is the name of an array or record object, and
10147 the association list in parentheses does not contain an @code{others}
10148 choice. The effect is to yield a copy of the array or record value which
10149 is unchanged apart from the components mentioned in the association list, which
10150 are changed to the indicated value. The original value of the array or
10151 record value is not affected. For example:
10153 @smallexample @c ada
10154 type Arr is Array (1 .. 5) of Integer;
10156 Avar1 : Arr := (1,2,3,4,5);
10157 Avar2 : Arr := Avar1'Update (2 => 10, 3 .. 4 => 20);
10158 @end smallexample
10160 @noindent
10161 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
10162 begin unmodified. Similarly:
10164 @smallexample @c ada
10165 type Rec is A, B, C : Integer;
10167 Rvar1 : Rec := (A => 1, B => 2, C => 3);
10168 Rvar2 : Rec := Rvar1'Update (B => 20);
10169 @end smallexample
10171 @noindent
10172 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
10173 with @code{Rvar1} being unmodifed.
10174 Note that the value of the attribute reference is computed
10175 completely before it is used. This means that if you write:
10177 @smallexample @c ada
10178 Avar1 := Avar1'Update (1 => 10, 2 => Function_Call);
10179 @end smallexample
10181 @noindent
10182 then the value of @code{Avar1} is not modified if @code{Function_Call}
10183 raises an exception, unlike the effect of a series of direct assignments
10184 to elements of @code{Avar1}. In general this requires that
10185 two extra complete copies of the object are required, which should be
10186 kept in mind when considering efficiency.
10188 The @code{Update} attribute cannot be applied to prefixes of a limited
10189 type, and cannot reference discriminants in the case of a record type.
10190 The accessibility level of an Update attribute result object is defined
10191 as for an aggregate.
10193 In the record case, no component can be mentioned more than once. In
10194 the array case, two overlapping ranges can appear in the association list,
10195 in which case the modifications are processed left to right.
10197 Multi-dimensional arrays can be modified, as shown by this example:
10199 @smallexample @c ada
10200 A : array (1 .. 10, 1 .. 10) of Integer;
10202 A := A'Update ((1, 2) => 20, (3, 4) => 30);
10203 @end smallexample
10205 @noindent
10206 which changes element (1,2) to 20 and (3,4) to 30.
10208 @node Attribute Valid_Scalars
10209 @unnumberedsec Attribute Valid_Scalars
10210 @findex Valid_Scalars
10211 @noindent
10212 The @code{'Valid_Scalars} attribute is intended to make it easier to
10213 check the validity of scalar subcomponents of composite objects. It
10214 is defined for any prefix @code{X} that denotes an object.
10215 The value of this attribute is of the predefined type Boolean.
10216 @code{X'Valid_Scalars} yields True if and only if evaluation of
10217 @code{P'Valid} yields True for every scalar part P of X or if X has
10218 no scalar parts. It is not specified in what order the scalar parts
10219 are checked, nor whether any more are checked after any one of them
10220 is determined to be invalid. If the prefix @code{X} is of a class-wide
10221 type @code{T'Class} (where @code{T} is the associated specific type),
10222 or if the prefix @code{X} is of a specific tagged type @code{T}, then
10223 only the scalar parts of components of @code{T} are traversed; in other
10224 words, components of extensions of @code{T} are not traversed even if
10225 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
10226 be determined at compile time that the prefix of the attribute has no
10227 scalar parts (e.g., if the prefix is of an access type, an interface type,
10228 an undiscriminated task type, or an undiscriminated protected type).
10230 For scalar types, @code{Valid_Scalars} is equivalent to @code{Valid}. The use
10231 of this attribute is not permitted for @code{Unchecked_Union} types for which
10232 in general it is not possible to determine the values of the discriminants.
10234 Note: @code{Valid_Scalars} can generate a lot of code, especially in the case
10235 of a large variant record. If the attribute is called in many places in the
10236 same program applied to objects of the same type, it can reduce program size
10237 to write a function with a single use of the attribute, and then call that
10238 function from multiple places.
10240 @node Attribute VADS_Size
10241 @unnumberedsec Attribute VADS_Size
10242 @cindex @code{Size}, VADS compatibility
10243 @findex VADS_Size
10244 @noindent
10245 The @code{'VADS_Size} attribute is intended to make it easier to port
10246 legacy code which relies on the semantics of @code{'Size} as implemented
10247 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
10248 same semantic interpretation.  In particular, @code{'VADS_Size} applied
10249 to a predefined or other primitive type with no Size clause yields the
10250 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
10251 typical machines).  In addition @code{'VADS_Size} applied to an object
10252 gives the result that would be obtained by applying the attribute to
10253 the corresponding type.
10255 @node Attribute Value_Size
10256 @unnumberedsec Attribute Value_Size
10257 @cindex @code{Size}, setting for not-first subtype
10258 @findex Value_Size
10259 @code{@var{type}'Value_Size} is the number of bits required to represent
10260 a value of the given subtype.  It is the same as @code{@var{type}'Size},
10261 but, unlike @code{Size}, may be set for non-first subtypes.
10263 @node Attribute Wchar_T_Size
10264 @unnumberedsec Attribute Wchar_T_Size
10265 @findex Wchar_T_Size
10266 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
10267 prefix) provides the size in bits of the C @code{wchar_t} type
10268 primarily for constructing the definition of this type in
10269 package @code{Interfaces.C}. The result is a static constant.
10271 @node Attribute Word_Size
10272 @unnumberedsec Attribute Word_Size
10273 @findex Word_Size
10274 @code{Standard'Word_Size} (@code{Standard} is the only permissible
10275 prefix) provides the value @code{System.Word_Size}. The result is
10276 a static constant.
10278 @node Standard and Implementation Defined Restrictions
10279 @chapter Standard and Implementation Defined Restrictions
10281 @noindent
10282 All RM defined Restriction identifiers are implemented:
10284 @itemize @bullet
10285 @item language-defined restrictions (see 13.12.1)
10286 @item tasking restrictions (see D.7)
10287 @item high integrity restrictions (see H.4)
10288 @end itemize
10290 @noindent
10291 GNAT implements additional restriction identifiers. All restrictions, whether
10292 language defined or GNAT-specific, are listed in the following.
10294 @menu
10295 * Partition-Wide Restrictions::
10296 * Program Unit Level Restrictions::
10297 @end menu
10299 @node Partition-Wide Restrictions
10300 @section Partition-Wide Restrictions
10302 There are two separate lists of restriction identifiers. The first
10303 set requires consistency throughout a partition (in other words, if the
10304 restriction identifier is used for any compilation unit in the partition,
10305 then all compilation units in the partition must obey the restriction).
10307 @menu
10308 * Immediate_Reclamation::
10309 * Max_Asynchronous_Select_Nesting::
10310 * Max_Entry_Queue_Length::
10311 * Max_Protected_Entries::
10312 * Max_Select_Alternatives::
10313 * Max_Storage_At_Blocking::
10314 * Max_Task_Entries::
10315 * Max_Tasks::
10316 * No_Abort_Statements::
10317 * No_Access_Parameter_Allocators::
10318 * No_Access_Subprograms::
10319 * No_Allocators::
10320 * No_Anonymous_Allocators::
10321 * No_Calendar::
10322 * No_Coextensions::
10323 * No_Default_Initialization::
10324 * No_Delay::
10325 * No_Dependence::
10326 * No_Direct_Boolean_Operators::
10327 * No_Dispatch::
10328 * No_Dispatching_Calls::
10329 * No_Dynamic_Attachment::
10330 * No_Dynamic_Priorities::
10331 * No_Entry_Calls_In_Elaboration_Code::
10332 * No_Enumeration_Maps::
10333 * No_Exception_Handlers::
10334 * No_Exception_Propagation::
10335 * No_Exception_Registration::
10336 * No_Exceptions::
10337 * No_Finalization::
10338 * No_Fixed_Point::
10339 * No_Floating_Point::
10340 * No_Implicit_Conditionals::
10341 * No_Implicit_Dynamic_Code::
10342 * No_Implicit_Heap_Allocations::
10343 * No_Implicit_Loops::
10344 * No_Initialize_Scalars::
10345 * No_IO::
10346 * No_Local_Allocators::
10347 * No_Local_Protected_Objects::
10348 * No_Local_Timing_Events::
10349 * No_Long_Long_Integers::
10350 * No_Multiple_Elaboration::
10351 * No_Nested_Finalization::
10352 * No_Protected_Type_Allocators::
10353 * No_Protected_Types::
10354 * No_Recursion::
10355 * No_Reentrancy::
10356 * No_Relative_Delay::
10357 * No_Requeue_Statements::
10358 * No_Secondary_Stack::
10359 * No_Select_Statements::
10360 * No_Specific_Termination_Handlers::
10361 * No_Specification_of_Aspect::
10362 * No_Standard_Allocators_After_Elaboration::
10363 * No_Standard_Storage_Pools::
10364 * No_Stream_Optimizations::
10365 * No_Streams::
10366 * No_Task_Allocators::
10367 * No_Task_Attributes_Package::
10368 * No_Task_Hierarchy::
10369 * No_Task_Termination::
10370 * No_Tasking::
10371 * No_Terminate_Alternatives::
10372 * No_Unchecked_Access::
10373 * Simple_Barriers::
10374 * Static_Priorities::
10375 * Static_Storage_Size::
10376 @end menu
10378 @node Immediate_Reclamation
10379 @unnumberedsubsec Immediate_Reclamation
10380 @findex Immediate_Reclamation
10381 [RM H.4] This restriction ensures that, except for storage occupied by
10382 objects created by allocators and not deallocated via unchecked
10383 deallocation, any storage reserved at run time for an object is
10384 immediately reclaimed when the object no longer exists.
10386 @node Max_Asynchronous_Select_Nesting
10387 @unnumberedsubsec Max_Asynchronous_Select_Nesting
10388 @findex Max_Asynchronous_Select_Nesting
10389 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
10390 selects. Violations of this restriction with a value of zero are
10391 detected at compile time. Violations of this restriction with values
10392 other than zero cause Storage_Error to be raised.
10394 @node Max_Entry_Queue_Length
10395 @unnumberedsubsec Max_Entry_Queue_Length
10396 @findex Max_Entry_Queue_Length
10397 [RM D.7] This restriction is a declaration that any protected entry compiled in
10398 the scope of the restriction has at most the specified number of
10399 tasks waiting on the entry at any one time, and so no queue is required.
10400 Note that this restriction is checked at run time. Violation of this
10401 restriction results in the raising of Program_Error exception at the point of
10402 the call.
10404 @findex Max_Entry_Queue_Depth
10405 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
10406 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
10407 compatibility purposes (and a warning will be generated for its use if
10408 warnings on obsolescent features are activated).
10410 @node Max_Protected_Entries
10411 @unnumberedsubsec Max_Protected_Entries
10412 @findex Max_Protected_Entries
10413 [RM D.7] Specifies the maximum number of entries per protected type. The
10414 bounds of every entry family of a protected unit shall be static, or shall be
10415 defined by a discriminant of a subtype whose corresponding bound is static.
10417 @node Max_Select_Alternatives
10418 @unnumberedsubsec Max_Select_Alternatives
10419 @findex Max_Select_Alternatives
10420 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
10422 @node Max_Storage_At_Blocking
10423 @unnumberedsubsec Max_Storage_At_Blocking
10424 @findex Max_Storage_At_Blocking
10425 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
10426 Storage_Size that can be retained by a blocked task. A violation of this
10427 restriction causes Storage_Error to be raised.
10429 @node Max_Task_Entries
10430 @unnumberedsubsec Max_Task_Entries
10431 @findex Max_Task_Entries
10432 [RM D.7] Specifies the maximum number of entries
10433 per task.  The bounds of every entry family
10434 of a task unit shall be static, or shall be
10435 defined by a discriminant of a subtype whose
10436 corresponding bound is static.
10438 @node Max_Tasks
10439 @unnumberedsubsec Max_Tasks
10440 @findex Max_Tasks
10441 [RM D.7] Specifies the maximum number of task that may be created, not
10442 counting the creation of the environment task.  Violations of this
10443 restriction with a value of zero are detected at compile
10444 time. Violations of this restriction with values other than zero cause
10445 Storage_Error to be raised.
10447 @node No_Abort_Statements
10448 @unnumberedsubsec No_Abort_Statements
10449 @findex No_Abort_Statements
10450 [RM D.7] There are no abort_statements, and there are
10451 no calls to Task_Identification.Abort_Task.
10453 @node No_Access_Parameter_Allocators
10454 @unnumberedsubsec No_Access_Parameter_Allocators
10455 @findex No_Access_Parameter_Allocators
10456 [RM H.4] This restriction ensures at compile time that there are no
10457 occurrences of an allocator as the actual parameter to an access
10458 parameter.
10460 @node No_Access_Subprograms
10461 @unnumberedsubsec No_Access_Subprograms
10462 @findex No_Access_Subprograms
10463 [RM H.4] This restriction ensures at compile time that there are no
10464 declarations of access-to-subprogram types.
10466 @node No_Allocators
10467 @unnumberedsubsec No_Allocators
10468 @findex No_Allocators
10469 [RM H.4] This restriction ensures at compile time that there are no
10470 occurrences of an allocator.
10472 @node No_Anonymous_Allocators
10473 @unnumberedsubsec No_Anonymous_Allocators
10474 @findex No_Anonymous_Allocators
10475 [RM H.4] This restriction ensures at compile time that there are no
10476 occurrences of an allocator of anonymous access type.
10478 @node No_Calendar
10479 @unnumberedsubsec No_Calendar
10480 @findex No_Calendar
10481 [GNAT] This restriction ensures at compile time that there is no implicit or
10482 explicit dependence on the package @code{Ada.Calendar}.
10484 @node No_Coextensions
10485 @unnumberedsubsec No_Coextensions
10486 @findex No_Coextensions
10487 [RM H.4] This restriction ensures at compile time that there are no
10488 coextensions. See 3.10.2.
10490 @node No_Default_Initialization
10491 @unnumberedsubsec No_Default_Initialization
10492 @findex No_Default_Initialization
10494 [GNAT] This restriction prohibits any instance of default initialization
10495 of variables.  The binder implements a consistency rule which prevents
10496 any unit compiled without the restriction from with'ing a unit with the
10497 restriction (this allows the generation of initialization procedures to
10498 be skipped, since you can be sure that no call is ever generated to an
10499 initialization procedure in a unit with the restriction active). If used
10500 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
10501 is to prohibit all cases of variables declared without a specific
10502 initializer (including the case of OUT scalar parameters).
10504 @node No_Delay
10505 @unnumberedsubsec No_Delay
10506 @findex No_Delay
10507 [RM H.4] This restriction ensures at compile time that there are no
10508 delay statements and no dependences on package Calendar.
10510 @node No_Dependence
10511 @unnumberedsubsec No_Dependence
10512 @findex No_Dependence
10513 [RM 13.12.1] This restriction checks at compile time that there are no
10514 dependence on a library unit.
10516 @node No_Direct_Boolean_Operators
10517 @unnumberedsubsec No_Direct_Boolean_Operators
10518 @findex No_Direct_Boolean_Operators
10519 [GNAT] This restriction ensures that no logical operators (and/or/xor)
10520 are used on operands of type Boolean (or any type derived from Boolean).
10521 This is intended for use in safety critical programs where the certification
10522 protocol requires the use of short-circuit (and then, or else) forms for all
10523 composite boolean operations.
10525 @node No_Dispatch
10526 @unnumberedsubsec No_Dispatch
10527 @findex No_Dispatch
10528 [RM H.4] This restriction ensures at compile time that there are no
10529 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
10531 @node No_Dispatching_Calls
10532 @unnumberedsubsec No_Dispatching_Calls
10533 @findex No_Dispatching_Calls
10534 [GNAT] This restriction ensures at compile time that the code generated by the
10535 compiler involves no dispatching calls. The use of this restriction allows the
10536 safe use of record extensions, classwide membership tests and other classwide
10537 features not involving implicit dispatching. This restriction ensures that
10538 the code contains no indirect calls through a dispatching mechanism. Note that
10539 this includes internally-generated calls created by the compiler, for example
10540 in the implementation of class-wide objects assignments. The
10541 membership test is allowed in the presence of this restriction, because its
10542 implementation requires no dispatching.
10543 This restriction is comparable to the official Ada restriction
10544 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
10545 all classwide constructs that do not imply dispatching.
10546 The following example indicates constructs that violate this restriction.
10548 @smallexample
10549 package Pkg is
10550   type T is tagged record
10551     Data : Natural;
10552   end record;
10553   procedure P (X : T);
10555   type DT is new T with record
10556     More_Data : Natural;
10557   end record;
10558   procedure Q (X : DT);
10559 end Pkg;
10561 with Pkg; use Pkg;
10562 procedure Example is
10563   procedure Test (O : T'Class) is
10564     N : Natural  := O'Size;--  Error: Dispatching call
10565     C : T'Class := O;      --  Error: implicit Dispatching Call
10566   begin
10567     if O in DT'Class then  --  OK   : Membership test
10568        Q (DT (O));         --  OK   : Type conversion plus direct call
10569     else
10570        P (O);              --  Error: Dispatching call
10571     end if;
10572   end Test;
10574   Obj : DT;
10575 begin
10576   P (Obj);                 --  OK   : Direct call
10577   P (T (Obj));             --  OK   : Type conversion plus direct call
10578   P (T'Class (Obj));       --  Error: Dispatching call
10580   Test (Obj);              --  OK   : Type conversion
10582   if Obj in T'Class then   --  OK   : Membership test
10583      null;
10584   end if;
10585 end Example;
10586 @end smallexample
10588 @node No_Dynamic_Attachment
10589 @unnumberedsubsec No_Dynamic_Attachment
10590 @findex No_Dynamic_Attachment
10591 [RM D.7] This restriction ensures that there is no call to any of the
10592 operations defined in package Ada.Interrupts
10593 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
10594 Detach_Handler, and Reference).
10596 @findex No_Dynamic_Interrupts
10597 The restriction @code{No_Dynamic_Interrupts} is recognized as a
10598 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
10599 compatibility purposes (and a warning will be generated for its use if
10600 warnings on obsolescent features are activated).
10602 @node No_Dynamic_Priorities
10603 @unnumberedsubsec No_Dynamic_Priorities
10604 @findex No_Dynamic_Priorities
10605 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
10607 @node No_Entry_Calls_In_Elaboration_Code
10608 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
10609 @findex No_Entry_Calls_In_Elaboration_Code
10610 [GNAT] This restriction ensures at compile time that no task or protected entry
10611 calls are made during elaboration code.  As a result of the use of this
10612 restriction, the compiler can assume that no code past an accept statement
10613 in a task can be executed at elaboration time.
10615 @node No_Enumeration_Maps
10616 @unnumberedsubsec No_Enumeration_Maps
10617 @findex No_Enumeration_Maps
10618 [GNAT] This restriction ensures at compile time that no operations requiring
10619 enumeration maps are used (that is Image and Value attributes applied
10620 to enumeration types).
10622 @node No_Exception_Handlers
10623 @unnumberedsubsec No_Exception_Handlers
10624 @findex No_Exception_Handlers
10625 [GNAT] This restriction ensures at compile time that there are no explicit
10626 exception handlers. It also indicates that no exception propagation will
10627 be provided. In this mode, exceptions may be raised but will result in
10628 an immediate call to the last chance handler, a routine that the user
10629 must define with the following profile:
10631 @smallexample @c ada
10632 procedure Last_Chance_Handler
10633   (Source_Location : System.Address; Line : Integer);
10634 pragma Export (C, Last_Chance_Handler,
10635                "__gnat_last_chance_handler");
10636 @end smallexample
10638 The parameter is a C null-terminated string representing a message to be
10639 associated with the exception (typically the source location of the raise
10640 statement generated by the compiler). The Line parameter when nonzero
10641 represents the line number in the source program where the raise occurs.
10643 @node No_Exception_Propagation
10644 @unnumberedsubsec No_Exception_Propagation
10645 @findex No_Exception_Propagation
10646 [GNAT] This restriction guarantees that exceptions are never propagated
10647 to an outer subprogram scope. The only case in which an exception may
10648 be raised is when the handler is statically in the same subprogram, so
10649 that the effect of a raise is essentially like a goto statement. Any
10650 other raise statement (implicit or explicit) will be considered
10651 unhandled. Exception handlers are allowed, but may not contain an
10652 exception occurrence identifier (exception choice). In addition, use of
10653 the package GNAT.Current_Exception is not permitted, and reraise
10654 statements (raise with no operand) are not permitted.
10656 @node No_Exception_Registration
10657 @unnumberedsubsec No_Exception_Registration
10658 @findex No_Exception_Registration
10659 [GNAT] This restriction ensures at compile time that no stream operations for
10660 types Exception_Id or Exception_Occurrence are used. This also makes it
10661 impossible to pass exceptions to or from a partition with this restriction
10662 in a distributed environment. If this restriction is active, the generated
10663 code is simplified by omitting the otherwise-required global registration
10664 of exceptions when they are declared.
10666 @node No_Exceptions
10667 @unnumberedsubsec No_Exceptions
10668 @findex No_Exceptions
10669 [RM H.4] This restriction ensures at compile time that there are no
10670 raise statements and no exception handlers.
10672 @node No_Finalization
10673 @unnumberedsubsec No_Finalization
10674 @findex No_Finalization
10675 [GNAT] This restriction disables the language features described in
10676 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
10677 performed by the compiler to support these features. The following types
10678 are no longer considered controlled when this restriction is in effect:
10679 @itemize @bullet
10680 @item
10681 @code{Ada.Finalization.Controlled}
10682 @item
10683 @code{Ada.Finalization.Limited_Controlled}
10684 @item
10685 Derivations from @code{Controlled} or @code{Limited_Controlled}
10686 @item
10687 Class-wide types
10688 @item
10689 Protected types
10690 @item
10691 Task types
10692 @item
10693 Array and record types with controlled components
10694 @end itemize
10695 The compiler no longer generates code to initialize, finalize or adjust an
10696 object or a nested component, either declared on the stack or on the heap. The
10697 deallocation of a controlled object no longer finalizes its contents.
10699 @node No_Fixed_Point
10700 @unnumberedsubsec No_Fixed_Point
10701 @findex No_Fixed_Point
10702 [RM H.4] This restriction ensures at compile time that there are no
10703 occurrences of fixed point types and operations.
10705 @node No_Floating_Point
10706 @unnumberedsubsec No_Floating_Point
10707 @findex No_Floating_Point
10708 [RM H.4] This restriction ensures at compile time that there are no
10709 occurrences of floating point types and operations.
10711 @node No_Implicit_Conditionals
10712 @unnumberedsubsec No_Implicit_Conditionals
10713 @findex No_Implicit_Conditionals
10714 [GNAT] This restriction ensures that the generated code does not contain any
10715 implicit conditionals, either by modifying the generated code where possible,
10716 or by rejecting any construct that would otherwise generate an implicit
10717 conditional. Note that this check does not include run time constraint
10718 checks, which on some targets may generate implicit conditionals as
10719 well. To control the latter, constraint checks can be suppressed in the
10720 normal manner. Constructs generating implicit conditionals include comparisons
10721 of composite objects and the Max/Min attributes.
10723 @node No_Implicit_Dynamic_Code
10724 @unnumberedsubsec No_Implicit_Dynamic_Code
10725 @findex No_Implicit_Dynamic_Code
10726 @cindex trampoline
10727 [GNAT] This restriction prevents the compiler from building ``trampolines''.
10728 This is a structure that is built on the stack and contains dynamic
10729 code to be executed at run time. On some targets, a trampoline is
10730 built for the following features: @code{Access},
10731 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
10732 nested task bodies; primitive operations of nested tagged types.
10733 Trampolines do not work on machines that prevent execution of stack
10734 data. For example, on windows systems, enabling DEP (data execution
10735 protection) will cause trampolines to raise an exception.
10736 Trampolines are also quite slow at run time.
10738 On many targets, trampolines have been largely eliminated. Look at the
10739 version of system.ads for your target --- if it has
10740 Always_Compatible_Rep equal to False, then trampolines are largely
10741 eliminated. In particular, a trampoline is built for the following
10742 features: @code{Address} of a nested subprogram;
10743 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
10744 but only if pragma Favor_Top_Level applies, or the access type has a
10745 foreign-language convention; primitive operations of nested tagged
10746 types.
10748 @node No_Implicit_Heap_Allocations
10749 @unnumberedsubsec No_Implicit_Heap_Allocations
10750 @findex No_Implicit_Heap_Allocations
10751 [RM D.7] No constructs are allowed to cause implicit heap allocation.
10753 @node No_Implicit_Loops
10754 @unnumberedsubsec No_Implicit_Loops
10755 @findex No_Implicit_Loops
10756 [GNAT] This restriction ensures that the generated code does not contain any
10757 implicit @code{for} loops, either by modifying
10758 the generated code where possible,
10759 or by rejecting any construct that would otherwise generate an implicit
10760 @code{for} loop. If this restriction is active, it is possible to build
10761 large array aggregates with all static components without generating an
10762 intermediate temporary, and without generating a loop to initialize individual
10763 components. Otherwise, a loop is created for arrays larger than about 5000
10764 scalar components.
10766 @node No_Initialize_Scalars
10767 @unnumberedsubsec No_Initialize_Scalars
10768 @findex No_Initialize_Scalars
10769 [GNAT] This restriction ensures that no unit in the partition is compiled with
10770 pragma Initialize_Scalars. This allows the generation of more efficient
10771 code, and in particular eliminates dummy null initialization routines that
10772 are otherwise generated for some record and array types.
10774 @node No_IO
10775 @unnumberedsubsec No_IO
10776 @findex No_IO
10777 [RM H.4] This restriction ensures at compile time that there are no
10778 dependences on any of the library units Sequential_IO, Direct_IO,
10779 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
10781 @node No_Local_Allocators
10782 @unnumberedsubsec No_Local_Allocators
10783 @findex No_Local_Allocators
10784 [RM H.4] This restriction ensures at compile time that there are no
10785 occurrences of an allocator in subprograms, generic subprograms, tasks,
10786 and entry bodies.
10788 @node No_Local_Protected_Objects
10789 @unnumberedsubsec No_Local_Protected_Objects
10790 @findex No_Local_Protected_Objects
10791 [RM D.7] This restriction ensures at compile time that protected objects are
10792 only declared at the library level.
10794 @node No_Local_Timing_Events
10795 @unnumberedsubsec No_Local_Timing_Events
10796 @findex No_Local_Timing_Events
10797 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
10798 declared at the library level.
10800 @node No_Long_Long_Integers
10801 @unnumberedsubsec No_Long_Long_Integers
10802 @findex No_Long_Long_Integers
10803 [GNAT] This partition-wide restriction forbids any explicit reference to
10804 type Standard.Long_Long_Integer, and also forbids declaring range types whose
10805 implicit base type is Long_Long_Integer, and modular types whose size exceeds
10806 Long_Integer'Size.
10808 @node No_Multiple_Elaboration
10809 @unnumberedsubsec No_Multiple_Elaboration
10810 @findex No_Multiple_Elaboration
10811 [GNAT] Normally each package contains a 16-bit counter used to check for access
10812 before elaboration, and to control multiple elaboration attempts.
10813 This counter is eliminated for units compiled with the static model
10814 of elaboration if restriction @code{No_Elaboration_Code}
10815 is active but because of
10816 the need to check for multiple elaboration in the general case, these
10817 counters cannot be eliminated if elaboration code may be present. The
10818 restriction @code{No_Multiple_Elaboration}
10819 allows suppression of these counters
10820 in static elaboration units even if they do have elaboration code. If this
10821 restriction is used, then the situations in which multiple elaboration is
10822 possible, including non-Ada main programs, and Stand Alone libraries, are not
10823 permitted, and will be diagnosed by the binder.
10825 @node No_Nested_Finalization
10826 @unnumberedsubsec No_Nested_Finalization
10827 @findex No_Nested_Finalization
10828 [RM D.7] All objects requiring finalization are declared at the library level.
10830 @node No_Protected_Type_Allocators
10831 @unnumberedsubsec No_Protected_Type_Allocators
10832 @findex No_Protected_Type_Allocators
10833 [RM D.7] This restriction ensures at compile time that there are no allocator
10834 expressions that attempt to allocate protected objects.
10836 @node No_Protected_Types
10837 @unnumberedsubsec No_Protected_Types
10838 @findex No_Protected_Types
10839 [RM H.4] This restriction ensures at compile time that there are no
10840 declarations of protected types or protected objects.
10842 @node No_Recursion
10843 @unnumberedsubsec No_Recursion
10844 @findex No_Recursion
10845 [RM H.4] A program execution is erroneous if a subprogram is invoked as
10846 part of its execution.
10848 @node No_Reentrancy
10849 @unnumberedsubsec No_Reentrancy
10850 @findex No_Reentrancy
10851 [RM H.4] A program execution is erroneous if a subprogram is executed by
10852 two tasks at the same time.
10854 @node No_Relative_Delay
10855 @unnumberedsubsec No_Relative_Delay
10856 @findex No_Relative_Delay
10857 [RM D.7] This restriction ensures at compile time that there are no delay
10858 relative statements and prevents expressions such as @code{delay 1.23;} from
10859 appearing in source code.
10861 @node No_Requeue_Statements
10862 @unnumberedsubsec No_Requeue_Statements
10863 @findex No_Requeue_Statements
10864 [RM D.7] This restriction ensures at compile time that no requeue statements
10865 are permitted and prevents keyword @code{requeue} from being used in source
10866 code.
10868 @findex No_Requeue
10869 The restriction @code{No_Requeue} is recognized as a
10870 synonym for @code{No_Requeue_Statements}. This is retained for historical
10871 compatibility purposes (and a warning will be generated for its use if
10872 warnings on oNobsolescent features are activated).
10874 @node No_Secondary_Stack
10875 @unnumberedsubsec No_Secondary_Stack
10876 @findex No_Secondary_Stack
10877 [GNAT] This restriction ensures at compile time that the generated code
10878 does not contain any reference to the secondary stack.  The secondary
10879 stack is used to implement functions returning unconstrained objects
10880 (arrays or records) on some targets.
10882 @node No_Select_Statements
10883 @unnumberedsubsec No_Select_Statements
10884 @findex No_Select_Statements
10885 [RM D.7] This restriction ensures at compile time no select statements of any
10886 kind are permitted, that is the keyword @code{select} may not appear.
10888 @node No_Specific_Termination_Handlers
10889 @unnumberedsubsec No_Specific_Termination_Handlers
10890 @findex No_Specific_Termination_Handlers
10891 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
10892 or to Ada.Task_Termination.Specific_Handler.
10894 @node No_Specification_of_Aspect
10895 @unnumberedsubsec No_Specification_of_Aspect
10896 @findex No_Specification_of_Aspect
10897 [RM 13.12.1] This restriction checks at compile time that no aspect
10898 specification, attribute definition clause, or pragma is given for a
10899 given aspect.
10901 @node No_Standard_Allocators_After_Elaboration
10902 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
10903 @findex No_Standard_Allocators_After_Elaboration
10904 [RM D.7] Specifies that an allocator using a standard storage pool
10905 should never be evaluated at run time after the elaboration of the
10906 library items of the partition has completed. Otherwise, Storage_Error
10907 is raised.
10909 @node No_Standard_Storage_Pools
10910 @unnumberedsubsec No_Standard_Storage_Pools
10911 @findex No_Standard_Storage_Pools
10912 [GNAT] This restriction ensures at compile time that no access types
10913 use the standard default storage pool.  Any access type declared must
10914 have an explicit Storage_Pool attribute defined specifying a
10915 user-defined storage pool.
10917 @node No_Stream_Optimizations
10918 @unnumberedsubsec No_Stream_Optimizations
10919 @findex No_Stream_Optimizations
10920 [GNAT] This restriction affects the performance of stream operations on types
10921 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
10922 compiler uses block reads and writes when manipulating @code{String} objects
10923 due to their supperior performance. When this restriction is in effect, the
10924 compiler performs all IO operations on a per-character basis.
10926 @node No_Streams
10927 @unnumberedsubsec No_Streams
10928 @findex No_Streams
10929 [GNAT] This restriction ensures at compile/bind time that there are no
10930 stream objects created and no use of stream attributes.
10931 This restriction does not forbid dependences on the package
10932 @code{Ada.Streams}. So it is permissible to with
10933 @code{Ada.Streams} (or another package that does so itself)
10934 as long as no actual stream objects are created and no
10935 stream attributes are used.
10937 Note that the use of restriction allows optimization of tagged types,
10938 since they do not need to worry about dispatching stream operations.
10939 To take maximum advantage of this space-saving optimization, any
10940 unit declaring a tagged type should be compiled with the restriction,
10941 though this is not required.
10943 @node No_Task_Allocators
10944 @unnumberedsubsec No_Task_Allocators
10945 @findex No_Task_Allocators
10946 [RM D.7] There are no allocators for task types
10947 or types containing task subcomponents.
10949 @node No_Task_Attributes_Package
10950 @unnumberedsubsec No_Task_Attributes_Package
10951 @findex No_Task_Attributes_Package
10952 [GNAT] This restriction ensures at compile time that there are no implicit or
10953 explicit dependencies on the package @code{Ada.Task_Attributes}.
10955 @findex No_Task_Attributes
10956 The restriction @code{No_Task_Attributes} is recognized as a synonym
10957 for @code{No_Task_Attributes_Package}. This is retained for historical
10958 compatibility purposes (and a warning will be generated for its use if
10959 warnings on obsolescent features are activated).
10961 @node No_Task_Hierarchy
10962 @unnumberedsubsec No_Task_Hierarchy
10963 @findex No_Task_Hierarchy
10964 [RM D.7] All (non-environment) tasks depend
10965 directly on the environment task of the partition.
10967 @node No_Task_Termination
10968 @unnumberedsubsec No_Task_Termination
10969 @findex No_Task_Termination
10970 [RM D.7] Tasks which terminate are erroneous.
10972 @node No_Tasking
10973 @unnumberedsubsec No_Tasking
10974 @findex No_Tasking
10975 [GNAT] This restriction prevents the declaration of tasks or task types
10976 throughout the partition.  It is similar in effect to the use of
10977 @code{Max_Tasks => 0} except that violations are caught at compile time
10978 and cause an error message to be output either by the compiler or
10979 binder.
10981 @node No_Terminate_Alternatives
10982 @unnumberedsubsec No_Terminate_Alternatives
10983 @findex No_Terminate_Alternatives
10984 [RM D.7] There are no selective accepts with terminate alternatives.
10986 @node No_Unchecked_Access
10987 @unnumberedsubsec No_Unchecked_Access
10988 @findex No_Unchecked_Access
10989 [RM H.4] This restriction ensures at compile time that there are no
10990 occurrences of the Unchecked_Access attribute.
10992 @node Simple_Barriers
10993 @unnumberedsubsec Simple_Barriers
10994 @findex Simple_Barriers
10995 [RM D.7] This restriction ensures at compile time that barriers in entry
10996 declarations for protected types are restricted to either static boolean
10997 expressions or references to simple boolean variables defined in the private
10998 part of the protected type.  No other form of entry barriers is permitted.
11000 @findex Boolean_Entry_Barriers
11001 The restriction @code{Boolean_Entry_Barriers} is recognized as a
11002 synonym for @code{Simple_Barriers}. This is retained for historical
11003 compatibility purposes (and a warning will be generated for its use if
11004 warnings on obsolescent features are activated).
11006 @node Static_Priorities
11007 @unnumberedsubsec Static_Priorities
11008 @findex Static_Priorities
11009 [GNAT] This restriction ensures at compile time that all priority expressions
11010 are static, and that there are no dependences on the package
11011 @code{Ada.Dynamic_Priorities}.
11013 @node Static_Storage_Size
11014 @unnumberedsubsec Static_Storage_Size
11015 @findex Static_Storage_Size
11016 [GNAT] This restriction ensures at compile time that any expression appearing
11017 in a Storage_Size pragma or attribute definition clause is static.
11019 @node Program Unit Level Restrictions
11020 @section Program Unit Level Restrictions
11022 @noindent
11023 The second set of restriction identifiers
11024 does not require partition-wide consistency.
11025 The restriction may be enforced for a single
11026 compilation unit without any effect on any of the
11027 other compilation units in the partition.
11029 @menu
11030 * No_Elaboration_Code::
11031 * No_Entry_Queue::
11032 * No_Implementation_Aspect_Specifications::
11033 * No_Implementation_Attributes::
11034 * No_Implementation_Identifiers::
11035 * No_Implementation_Pragmas::
11036 * No_Implementation_Restrictions::
11037 * No_Implementation_Units::
11038 * No_Implicit_Aliasing::
11039 * No_Obsolescent_Features::
11040 * No_Wide_Characters::
11041 * SPARK_05::
11042 @end menu
11044 @node No_Elaboration_Code
11045 @unnumberedsubsec No_Elaboration_Code
11046 @findex No_Elaboration_Code
11047 [GNAT] This restriction ensures at compile time that no elaboration code is
11048 generated.  Note that this is not the same condition as is enforced
11049 by pragma @code{Preelaborate}.  There are cases in which pragma
11050 @code{Preelaborate} still permits code to be generated (e.g.@: code
11051 to initialize a large array to all zeroes), and there are cases of units
11052 which do not meet the requirements for pragma @code{Preelaborate},
11053 but for which no elaboration code is generated.  Generally, it is
11054 the case that preelaborable units will meet the restrictions, with
11055 the exception of large aggregates initialized with an others_clause,
11056 and exception declarations (which generate calls to a run-time
11057 registry procedure).  This restriction is enforced on
11058 a unit by unit basis, it need not be obeyed consistently
11059 throughout a partition.
11061 In the case of aggregates with others, if the aggregate has a dynamic
11062 size, there is no way to eliminate the elaboration code (such dynamic
11063 bounds would be incompatible with @code{Preelaborate} in any case). If
11064 the bounds are static, then use of this restriction actually modifies
11065 the code choice of the compiler to avoid generating a loop, and instead
11066 generate the aggregate statically if possible, no matter how many times
11067 the data for the others clause must be repeatedly generated.
11069 It is not possible to precisely document
11070 the constructs which are compatible with this restriction, since,
11071 unlike most other restrictions, this is not a restriction on the
11072 source code, but a restriction on the generated object code. For
11073 example, if the source contains a declaration:
11075 @smallexample
11076    Val : constant Integer := X;
11077 @end smallexample
11079 @noindent
11080 where X is not a static constant, it may be possible, depending
11081 on complex optimization circuitry, for the compiler to figure
11082 out the value of X at compile time, in which case this initialization
11083 can be done by the loader, and requires no initialization code. It
11084 is not possible to document the precise conditions under which the
11085 optimizer can figure this out.
11087 Note that this the implementation of this restriction requires full
11088 code generation. If it is used in conjunction with "semantics only"
11089 checking, then some cases of violations may be missed.
11091 @node No_Entry_Queue
11092 @unnumberedsubsec No_Entry_Queue
11093 @findex No_Entry_Queue
11094 [GNAT] This restriction is a declaration that any protected entry compiled in
11095 the scope of the restriction has at most one task waiting on the entry
11096 at any one time, and so no queue is required.  This restriction is not
11097 checked at compile time.  A program execution is erroneous if an attempt
11098 is made to queue a second task on such an entry.
11100 @node No_Implementation_Aspect_Specifications
11101 @unnumberedsubsec No_Implementation_Aspect_Specifications
11102 @findex No_Implementation_Aspect_Specifications
11103 [RM 13.12.1] This restriction checks at compile time that no
11104 GNAT-defined aspects are present.  With this restriction, the only
11105 aspects that can be used are those defined in the Ada Reference Manual.
11107 @node No_Implementation_Attributes
11108 @unnumberedsubsec No_Implementation_Attributes
11109 @findex No_Implementation_Attributes
11110 [RM 13.12.1] This restriction checks at compile time that no
11111 GNAT-defined attributes are present.  With this restriction, the only
11112 attributes that can be used are those defined in the Ada Reference
11113 Manual.
11115 @node No_Implementation_Identifiers
11116 @unnumberedsubsec No_Implementation_Identifiers
11117 @findex No_Implementation_Identifiers
11118 [RM 13.12.1] This restriction checks at compile time that no
11119 implementation-defined identifiers (marked with pragma Implementation_Defined)
11120 occur within language-defined packages.
11122 @node No_Implementation_Pragmas
11123 @unnumberedsubsec No_Implementation_Pragmas
11124 @findex No_Implementation_Pragmas
11125 [RM 13.12.1] This restriction checks at compile time that no
11126 GNAT-defined pragmas are present.  With this restriction, the only
11127 pragmas that can be used are those defined in the Ada Reference Manual.
11129 @node No_Implementation_Restrictions
11130 @unnumberedsubsec No_Implementation_Restrictions
11131 @findex No_Implementation_Restrictions
11132 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
11133 identifiers (other than @code{No_Implementation_Restrictions} itself)
11134 are present.  With this restriction, the only other restriction identifiers
11135 that can be used are those defined in the Ada Reference Manual.
11137 @node No_Implementation_Units
11138 @unnumberedsubsec No_Implementation_Units
11139 @findex No_Implementation_Units
11140 [RM 13.12.1] This restriction checks at compile time that there is no
11141 mention in the context clause of any implementation-defined descendants
11142 of packages Ada, Interfaces, or System.
11144 @node No_Implicit_Aliasing
11145 @unnumberedsubsec No_Implicit_Aliasing
11146 @findex No_Implicit_Aliasing
11147 [GNAT] This restriction, which is not required to be partition-wide consistent,
11148 requires an explicit aliased keyword for an object to which 'Access,
11149 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
11150 the 'Unrestricted_Access attribute for objects. Note: the reason that
11151 Unrestricted_Access is forbidden is that it would require the prefix
11152 to be aliased, and in such cases, it can always be replaced by
11153 the standard attribute Unchecked_Access which is preferable.
11155 @node No_Obsolescent_Features
11156 @unnumberedsubsec No_Obsolescent_Features
11157 @findex No_Obsolescent_Features
11158 [RM 13.12.1] This restriction checks at compile time that no obsolescent
11159 features are used, as defined in Annex J of the Ada Reference Manual.
11161 @node No_Wide_Characters
11162 @unnumberedsubsec No_Wide_Characters
11163 @findex No_Wide_Characters
11164 [GNAT] This restriction ensures at compile time that no uses of the types
11165 @code{Wide_Character} or @code{Wide_String} or corresponding wide
11166 wide types
11167 appear, and that no wide or wide wide string or character literals
11168 appear in the program (that is literals representing characters not in
11169 type @code{Character}).
11171 @node SPARK_05
11172 @unnumberedsubsec SPARK_05
11173 @findex SPARK_05
11174 [GNAT] This restriction checks at compile time that some constructs
11175 forbidden in SPARK 2005 are not present. Error messages related to
11176 SPARK restriction have the form:
11178 @smallexample
11179 violation of restriction "SPARK_05" at <source-location>
11180  <error message>
11181 @end smallexample
11183 @findex SPARK
11184 The restriction @code{SPARK} is recognized as a
11185 synonym for @code{SPARK_05}. This is retained for historical
11186 compatibility purposes (and an unconditional warning will be generated
11187 for its use, advising replacement by @code{SPARK}).
11189 This is not a replacement for the semantic checks performed by the
11190 SPARK Examiner tool, as the compiler currently only deals with code,
11191 not SPARK 2005 annotations, and does not guarantee catching all
11192 cases of constructs forbidden by SPARK 2005.
11194 Thus it may well be the case that code which passes the compiler with
11195 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
11196 the different visibility rules of the Examiner based on SPARK 2005
11197 @code{inherit} annotations.
11199 This restriction can be useful in providing an initial filter for code
11200 developed using SPARK 2005, or in examining legacy code to see how far
11201 it is from meeting SPARK restrictions.
11203 The list below summarizes the checks that are performed when this
11204 restriction is in force:
11205 @itemize @bullet
11206 @item No block statements
11207 @item No case statements with only an others clause
11208 @item Exit statements in loops must respect the SPARK 2005 language restrictions
11209 @item No goto statements
11210 @item Return can only appear as last statement in function
11211 @item Function must have return statement
11212 @item Loop parameter specification must include subtype mark
11213 @item Prefix of expanded name cannot be a loop statement
11214 @item Abstract subprogram not allowed
11215 @item User-defined operators not allowed
11216 @item Access type parameters not allowed
11217 @item Default expressions for parameters not allowed
11218 @item Default expressions for record fields not allowed
11219 @item No tasking constructs allowed
11220 @item Label needed at end of subprograms and packages
11221 @item No mixing of positional and named parameter association
11222 @item No access types as result type
11223 @item No unconstrained arrays as result types
11224 @item No null procedures
11225 @item Initial and later declarations must be in correct order (declaration can't come after body)
11226 @item No attributes on private types if full declaration not visible
11227 @item No package declaration within package specification
11228 @item No controlled types
11229 @item No discriminant types
11230 @item No overloading
11231 @item Selector name cannot be operator symbol (i.e. operator symbol cannot be prefixed)
11232 @item Access attribute not allowed
11233 @item Allocator not allowed
11234 @item Result of catenation must be String
11235 @item Operands of catenation must be string literal, static char or another catenation
11236 @item No conditional expressions
11237 @item No explicit dereference
11238 @item Quantified expression not allowed
11239 @item Slicing not allowed
11240 @item No exception renaming
11241 @item No generic renaming
11242 @item No object renaming
11243 @item No use clause
11244 @item Aggregates must be qualified
11245 @item Non-static choice in array aggregates not allowed
11246 @item The only view conversions which are allowed as in-out parameters are conversions of a tagged type to an ancestor type
11247 @item No mixing of positional and named association in aggregate, no multi choice
11248 @item AND, OR and XOR for arrays only allowed when operands have same static bounds
11249 @item Fixed point operands to * or / must be qualified or converted
11250 @item Comparison operators not allowed for Booleans or arrays (except strings)
11251 @item Equality not allowed for arrays with non-matching static bounds (except strings)
11252 @item Conversion / qualification not allowed for arrays with non-matching static bounds
11253 @item Subprogram declaration only allowed in package spec (unless followed by import)
11254 @item Access types not allowed
11255 @item Incomplete type declaration not allowed
11256 @item Object and subtype declarations must respect SPARK restrictions
11257 @item Digits or delta constraint not allowed
11258 @item Decimal fixed point type not allowed
11259 @item Aliasing of objects not allowed
11260 @item Modular type modulus must be power of 2
11261 @item Base not allowed on subtype mark
11262 @item Unary operators not allowed on modular types (except not)
11263 @item Untagged record cannot be null
11264 @item No class-wide operations
11265 @item Initialization expressions must respect SPARK restrictions
11266 @item Non-static ranges not allowed except in iteration schemes
11267 @item String subtypes must have lower bound of 1
11268 @item Subtype of Boolean cannot have constraint
11269 @item At most one tagged type or extension per package
11270 @item Interface is not allowed
11271 @item Character literal cannot be prefixed (selector name cannot be character literal)
11272 @item Record aggregate cannot contain 'others'
11273 @item Component association in record aggregate must contain a single choice
11274 @item Ancestor part cannot be a type mark
11275 @item Attributes 'Image, 'Width and 'Value not allowed
11276 @item Functions may not update globals
11277 @item Subprograms may not contain direct calls to themselves (prevents recursion within unit)
11278 @item Call to subprogram not allowed in same unit before body has been seen (prevents recursion within unit)
11279 @end itemize
11281 The following restrictions are enforced, but note that they are actually more
11282 strict that the latest SPARK 2005 language definition:
11284 @itemize @bullet
11285 @item No derived types other than tagged type extensions
11286 @item Subtype of unconstrained array must have constraint
11287 @end itemize
11289 This list summarises the main SPARK 2005 language rules that are not
11290 currently checked by the SPARK_05 restriction:
11292 @itemize @bullet
11293 @item SPARK annotations are treated as comments so are not checked at all
11294 @item Based real literals not allowed
11295 @item Objects cannot be initialized at declaration by calls to user-defined functions
11296 @item Objects cannot be initialized at declaration by assignments from variables
11297 @item Objects cannot be initialized at declaration by assignments from indexed/selected components
11298 @item Ranges shall not be null
11299 @item A fixed point delta expression must be a simple expression
11300 @item Restrictions on where renaming declarations may be placed
11301 @item Externals of mode 'out' cannot be referenced
11302 @item Externals of mode 'in' cannot be updated
11303 @item Loop with no iteration scheme or exits only allowed as last statement in main program or task
11304 @item Subprogram cannot have parent unit name
11305 @item SPARK 2005 inherited subprogram must be prefixed with overriding
11306 @item External variables (or functions that reference them) may not be passed as actual parameters
11307 @item Globals must be explicitly mentioned in contract
11308 @item Deferred constants cannot be completed by pragma Import
11309 @item Package initialization cannot read/write variables from other packages
11310 @item Prefix not allowed for entities that are directly visible
11311 @item Identifier declaration can't override inherited package name
11312 @item Cannot use Standard or other predefined packages as identifiers
11313 @item After renaming, cannot use the original name
11314 @item Subprograms can only be renamed to remove package prefix
11315 @item Pragma import must be immediately after entity it names
11316 @item No mutual recursion between multiple units (this can be checked with gnatcheck)
11317 @end itemize
11319 Note that if a unit is compiled in Ada 95 mode with the SPARK restriction,
11320 violations will be reported for constructs forbidden in SPARK 95,
11321 instead of SPARK 2005.
11323 @c ------------------------
11324 @node Implementation Advice
11325 @chapter Implementation Advice
11326 @noindent
11327 The main text of the Ada Reference Manual describes the required
11328 behavior of all Ada compilers, and the GNAT compiler conforms to
11329 these requirements.
11331 In addition, there are sections throughout the Ada Reference Manual headed
11332 by the phrase ``Implementation advice''.  These sections are not normative,
11333 i.e., they do not specify requirements that all compilers must
11334 follow.  Rather they provide advice on generally desirable behavior.  You
11335 may wonder why they are not requirements.  The most typical answer is
11336 that they describe behavior that seems generally desirable, but cannot
11337 be provided on all systems, or which may be undesirable on some systems.
11339 As far as practical, GNAT follows the implementation advice sections in
11340 the Ada Reference Manual.  This chapter contains a table giving the
11341 reference manual section number, paragraph number and several keywords
11342 for each advice.  Each entry consists of the text of the advice followed
11343 by the GNAT interpretation of this advice.  Most often, this simply says
11344 ``followed'', which means that GNAT follows the advice.  However, in a
11345 number of cases, GNAT deliberately deviates from this advice, in which
11346 case the text describes what GNAT does and why.
11348 @cindex Error detection
11349 @unnumberedsec 1.1.3(20): Error Detection
11350 @sp 1
11351 @cartouche
11352 If an implementation detects the use of an unsupported Specialized Needs
11353 Annex feature at run time, it should raise @code{Program_Error} if
11354 feasible.
11355 @end cartouche
11356 Not relevant.  All specialized needs annex features are either supported,
11357 or diagnosed at compile time.
11359 @cindex Child Units
11360 @unnumberedsec 1.1.3(31): Child Units
11361 @sp 1
11362 @cartouche
11363 If an implementation wishes to provide implementation-defined
11364 extensions to the functionality of a language-defined library unit, it
11365 should normally do so by adding children to the library unit.
11366 @end cartouche
11367 Followed.
11369 @cindex Bounded errors
11370 @unnumberedsec 1.1.5(12): Bounded Errors
11371 @sp 1
11372 @cartouche
11373 If an implementation detects a bounded error or erroneous
11374 execution, it should raise @code{Program_Error}.
11375 @end cartouche
11376 Followed in all cases in which the implementation detects a bounded
11377 error or erroneous execution.  Not all such situations are detected at
11378 runtime.
11380 @cindex Pragmas
11381 @unnumberedsec 2.8(16): Pragmas
11382 @sp 1
11383 @cartouche
11384 Normally, implementation-defined pragmas should have no semantic effect
11385 for error-free programs; that is, if the implementation-defined pragmas
11386 are removed from a working program, the program should still be legal,
11387 and should still have the same semantics.
11388 @end cartouche
11389 The following implementation defined pragmas are exceptions to this
11390 rule:
11392 @table @code
11393 @item Abort_Defer
11394 Affects semantics
11395 @item Ada_83
11396 Affects legality
11397 @item Assert
11398 Affects semantics
11399 @item CPP_Class
11400 Affects semantics
11401 @item CPP_Constructor
11402 Affects semantics
11403 @item Debug
11404 Affects semantics
11405 @item Interface_Name
11406 Affects semantics
11407 @item Machine_Attribute
11408 Affects semantics
11409 @item Unimplemented_Unit
11410 Affects legality
11411 @item Unchecked_Union
11412 Affects semantics
11413 @end table
11415 @noindent
11416 In each of the above cases, it is essential to the purpose of the pragma
11417 that this advice not be followed.  For details see the separate section
11418 on implementation defined pragmas.
11420 @unnumberedsec 2.8(17-19): Pragmas
11421 @sp 1
11422 @cartouche
11423 Normally, an implementation should not define pragmas that can
11424 make an illegal program legal, except as follows:
11425 @end cartouche
11426 @sp 1
11427 @cartouche
11428 A pragma used to complete a declaration, such as a pragma @code{Import};
11429 @end cartouche
11430 @sp 1
11431 @cartouche
11432 A pragma used to configure the environment by adding, removing, or
11433 replacing @code{library_items}.
11434 @end cartouche
11435 See response to paragraph 16 of this same section.
11437 @cindex Character Sets
11438 @cindex Alternative Character Sets
11439 @unnumberedsec 3.5.2(5): Alternative Character Sets
11440 @sp 1
11441 @cartouche
11442 If an implementation supports a mode with alternative interpretations
11443 for @code{Character} and @code{Wide_Character}, the set of graphic
11444 characters of @code{Character} should nevertheless remain a proper
11445 subset of the set of graphic characters of @code{Wide_Character}.  Any
11446 character set ``localizations'' should be reflected in the results of
11447 the subprograms defined in the language-defined package
11448 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
11449 an alternative interpretation of @code{Character}, the implementation should
11450 also support a corresponding change in what is a legal
11451 @code{identifier_letter}.
11452 @end cartouche
11453 Not all wide character modes follow this advice, in particular the JIS
11454 and IEC modes reflect standard usage in Japan, and in these encoding,
11455 the upper half of the Latin-1 set is not part of the wide-character
11456 subset, since the most significant bit is used for wide character
11457 encoding.  However, this only applies to the external forms.  Internally
11458 there is no such restriction.
11460 @cindex Integer types
11461 @unnumberedsec 3.5.4(28): Integer Types
11463 @sp 1
11464 @cartouche
11465 An implementation should support @code{Long_Integer} in addition to
11466 @code{Integer} if the target machine supports 32-bit (or longer)
11467 arithmetic.  No other named integer subtypes are recommended for package
11468 @code{Standard}.  Instead, appropriate named integer subtypes should be
11469 provided in the library package @code{Interfaces} (see B.2).
11470 @end cartouche
11471 @code{Long_Integer} is supported.  Other standard integer types are supported
11472 so this advice is not fully followed.  These types
11473 are supported for convenient interface to C, and so that all hardware
11474 types of the machine are easily available.
11475 @unnumberedsec 3.5.4(29): Integer Types
11477 @sp 1
11478 @cartouche
11479 An implementation for a two's complement machine should support
11480 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
11481 implementation should support a non-binary modules up to @code{Integer'Last}.
11482 @end cartouche
11483 Followed.
11485 @cindex Enumeration values
11486 @unnumberedsec 3.5.5(8): Enumeration Values
11487 @sp 1
11488 @cartouche
11489 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
11490 subtype, if the value of the operand does not correspond to the internal
11491 code for any enumeration literal of its type (perhaps due to an
11492 un-initialized variable), then the implementation should raise
11493 @code{Program_Error}.  This is particularly important for enumeration
11494 types with noncontiguous internal codes specified by an
11495 enumeration_representation_clause.
11496 @end cartouche
11497 Followed.
11499 @cindex Float types
11500 @unnumberedsec 3.5.7(17): Float Types
11501 @sp 1
11502 @cartouche
11503 An implementation should support @code{Long_Float} in addition to
11504 @code{Float} if the target machine supports 11 or more digits of
11505 precision.  No other named floating point subtypes are recommended for
11506 package @code{Standard}.  Instead, appropriate named floating point subtypes
11507 should be provided in the library package @code{Interfaces} (see B.2).
11508 @end cartouche
11509 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
11510 former provides improved compatibility with other implementations
11511 supporting this type.  The latter corresponds to the highest precision
11512 floating-point type supported by the hardware.  On most machines, this
11513 will be the same as @code{Long_Float}, but on some machines, it will
11514 correspond to the IEEE extended form.  The notable case is all ia32
11515 (x86) implementations, where @code{Long_Long_Float} corresponds to
11516 the 80-bit extended precision format supported in hardware on this
11517 processor.  Note that the 128-bit format on SPARC is not supported,
11518 since this is a software rather than a hardware format.
11520 @cindex Multidimensional arrays
11521 @cindex Arrays, multidimensional
11522 @unnumberedsec 3.6.2(11): Multidimensional Arrays
11523 @sp 1
11524 @cartouche
11525 An implementation should normally represent multidimensional arrays in
11526 row-major order, consistent with the notation used for multidimensional
11527 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
11528 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
11529 column-major order should be used instead (see B.5, ``Interfacing with
11530 Fortran'').
11531 @end cartouche
11532 Followed.
11534 @findex Duration'Small
11535 @unnumberedsec 9.6(30-31): Duration'Small
11536 @sp 1
11537 @cartouche
11538 Whenever possible in an implementation, the value of @code{Duration'Small}
11539 should be no greater than 100 microseconds.
11540 @end cartouche
11541 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
11543 @sp 1
11544 @cartouche
11545 The time base for @code{delay_relative_statements} should be monotonic;
11546 it need not be the same time base as used for @code{Calendar.Clock}.
11547 @end cartouche
11548 Followed.
11550 @unnumberedsec 10.2.1(12): Consistent Representation
11551 @sp 1
11552 @cartouche
11553 In an implementation, a type declared in a pre-elaborated package should
11554 have the same representation in every elaboration of a given version of
11555 the package, whether the elaborations occur in distinct executions of
11556 the same program, or in executions of distinct programs or partitions
11557 that include the given version.
11558 @end cartouche
11559 Followed, except in the case of tagged types.  Tagged types involve
11560 implicit pointers to a local copy of a dispatch table, and these pointers
11561 have representations which thus depend on a particular elaboration of the
11562 package.  It is not easy to see how it would be possible to follow this
11563 advice without severely impacting efficiency of execution.
11565 @cindex Exception information
11566 @unnumberedsec 11.4.1(19): Exception Information
11567 @sp 1
11568 @cartouche
11569 @code{Exception_Message} by default and @code{Exception_Information}
11570 should produce information useful for
11571 debugging.  @code{Exception_Message} should be short, about one
11572 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
11573 should not include the
11574 @code{Exception_Name}.  @code{Exception_Information} should include both
11575 the @code{Exception_Name} and the @code{Exception_Message}.
11576 @end cartouche
11577 Followed.  For each exception that doesn't have a specified
11578 @code{Exception_Message}, the compiler generates one containing the location
11579 of the raise statement.  This location has the form ``file:line'', where
11580 file is the short file name (without path information) and line is the line
11581 number in the file.  Note that in the case of the Zero Cost Exception
11582 mechanism, these messages become redundant with the Exception_Information that
11583 contains a full backtrace of the calling sequence, so they are disabled.
11584 To disable explicitly the generation of the source location message, use the
11585 Pragma @code{Discard_Names}.
11587 @cindex Suppression of checks
11588 @cindex Checks, suppression of
11589 @unnumberedsec 11.5(28): Suppression of Checks
11590 @sp 1
11591 @cartouche
11592 The implementation should minimize the code executed for checks that
11593 have been suppressed.
11594 @end cartouche
11595 Followed.
11597 @cindex Representation clauses
11598 @unnumberedsec 13.1 (21-24): Representation Clauses
11599 @sp 1
11600 @cartouche
11601 The recommended level of support for all representation items is
11602 qualified as follows:
11603 @end cartouche
11604 @sp 1
11605 @cartouche
11606 An implementation need not support representation items containing
11607 non-static expressions, except that an implementation should support a
11608 representation item for a given entity if each non-static expression in
11609 the representation item is a name that statically denotes a constant
11610 declared before the entity.
11611 @end cartouche
11612 Followed.  In fact, GNAT goes beyond the recommended level of support
11613 by allowing nonstatic expressions in some representation clauses even
11614 without the need to declare constants initialized with the values of
11615 such expressions.
11616 For example:
11618 @smallexample @c ada
11619   X : Integer;
11620   Y : Float;
11621   for Y'Address use X'Address;>>
11622 @end smallexample
11624 @sp 1
11625 @cartouche
11626 An implementation need not support a specification for the @code{Size}
11627 for a given composite subtype, nor the size or storage place for an
11628 object (including a component) of a given composite subtype, unless the
11629 constraints on the subtype and its composite subcomponents (if any) are
11630 all static constraints.
11631 @end cartouche
11632 Followed.  Size Clauses are not permitted on non-static components, as
11633 described above.
11635 @sp 1
11636 @cartouche
11637 An aliased component, or a component whose type is by-reference, should
11638 always be allocated at an addressable location.
11639 @end cartouche
11640 Followed.
11642 @cindex Packed types
11643 @unnumberedsec 13.2(6-8): Packed Types
11644 @sp 1
11645 @cartouche
11646 If a type is packed, then the implementation should try to minimize
11647 storage allocated to objects of the type, possibly at the expense of
11648 speed of accessing components, subject to reasonable complexity in
11649 addressing calculations.
11650 @end cartouche
11651 @sp 1
11652 @cartouche
11653 The recommended level of support pragma @code{Pack} is:
11655 For a packed record type, the components should be packed as tightly as
11656 possible subject to the Sizes of the component subtypes, and subject to
11657 any @code{record_representation_clause} that applies to the type; the
11658 implementation may, but need not, reorder components or cross aligned
11659 word boundaries to improve the packing.  A component whose @code{Size} is
11660 greater than the word size may be allocated an integral number of words.
11661 @end cartouche
11662 Followed.  Tight packing of arrays is supported for all component sizes
11663 up to 64-bits. If the array component size is 1 (that is to say, if
11664 the component is a boolean type or an enumeration type with two values)
11665 then values of the type are implicitly initialized to zero. This
11666 happens both for objects of the packed type, and for objects that have a
11667 subcomponent of the packed type.
11669 @sp 1
11670 @cartouche
11671 An implementation should support Address clauses for imported
11672 subprograms.
11673 @end cartouche
11674 Followed.
11675 @cindex @code{Address} clauses
11676 @unnumberedsec 13.3(14-19): Address Clauses
11678 @sp 1
11679 @cartouche
11680 For an array @var{X}, @code{@var{X}'Address} should point at the first
11681 component of the array, and not at the array bounds.
11682 @end cartouche
11683 Followed.
11685 @sp 1
11686 @cartouche
11687 The recommended level of support for the @code{Address} attribute is:
11689 @code{@var{X}'Address} should produce a useful result if @var{X} is an
11690 object that is aliased or of a by-reference type, or is an entity whose
11691 @code{Address} has been specified.
11692 @end cartouche
11693 Followed.  A valid address will be produced even if none of those
11694 conditions have been met.  If necessary, the object is forced into
11695 memory to ensure the address is valid.
11697 @sp 1
11698 @cartouche
11699 An implementation should support @code{Address} clauses for imported
11700 subprograms.
11701 @end cartouche
11702 Followed.
11704 @sp 1
11705 @cartouche
11706 Objects (including subcomponents) that are aliased or of a by-reference
11707 type should be allocated on storage element boundaries.
11708 @end cartouche
11709 Followed.
11711 @sp 1
11712 @cartouche
11713 If the @code{Address} of an object is specified, or it is imported or exported,
11714 then the implementation should not perform optimizations based on
11715 assumptions of no aliases.
11716 @end cartouche
11717 Followed.
11719 @cindex @code{Alignment} clauses
11720 @unnumberedsec 13.3(29-35): Alignment Clauses
11721 @sp 1
11722 @cartouche
11723 The recommended level of support for the @code{Alignment} attribute for
11724 subtypes is:
11726 An implementation should support specified Alignments that are factors
11727 and multiples of the number of storage elements per word, subject to the
11728 following:
11729 @end cartouche
11730 Followed.
11732 @sp 1
11733 @cartouche
11734 An implementation need not support specified @code{Alignment}s for
11735 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
11736 loaded and stored by available machine instructions.
11737 @end cartouche
11738 Followed.
11740 @sp 1
11741 @cartouche
11742 An implementation need not support specified @code{Alignment}s that are
11743 greater than the maximum @code{Alignment} the implementation ever returns by
11744 default.
11745 @end cartouche
11746 Followed.
11748 @sp 1
11749 @cartouche
11750 The recommended level of support for the @code{Alignment} attribute for
11751 objects is:
11753 Same as above, for subtypes, but in addition:
11754 @end cartouche
11755 Followed.
11757 @sp 1
11758 @cartouche
11759 For stand-alone library-level objects of statically constrained
11760 subtypes, the implementation should support all @code{Alignment}s
11761 supported by the target linker.  For example, page alignment is likely to
11762 be supported for such objects, but not for subtypes.
11763 @end cartouche
11764 Followed.
11766 @cindex @code{Size} clauses
11767 @unnumberedsec 13.3(42-43): Size Clauses
11768 @sp 1
11769 @cartouche
11770 The recommended level of support for the @code{Size} attribute of
11771 objects is:
11773 A @code{Size} clause should be supported for an object if the specified
11774 @code{Size} is at least as large as its subtype's @code{Size}, and
11775 corresponds to a size in storage elements that is a multiple of the
11776 object's @code{Alignment} (if the @code{Alignment} is nonzero).
11777 @end cartouche
11778 Followed.
11780 @unnumberedsec 13.3(50-56): Size Clauses
11781 @sp 1
11782 @cartouche
11783 If the @code{Size} of a subtype is specified, and allows for efficient
11784 independent addressability (see 9.10) on the target architecture, then
11785 the @code{Size} of the following objects of the subtype should equal the
11786 @code{Size} of the subtype:
11788 Aliased objects (including components).
11789 @end cartouche
11790 Followed.
11792 @sp 1
11793 @cartouche
11794 @code{Size} clause on a composite subtype should not affect the
11795 internal layout of components.
11796 @end cartouche
11797 Followed. But note that this can be overridden by use of the implementation
11798 pragma Implicit_Packing in the case of packed arrays.
11800 @sp 1
11801 @cartouche
11802 The recommended level of support for the @code{Size} attribute of subtypes is:
11803 @end cartouche
11804 @sp 1
11805 @cartouche
11806 The @code{Size} (if not specified) of a static discrete or fixed point
11807 subtype should be the number of bits needed to represent each value
11808 belonging to the subtype using an unbiased representation, leaving space
11809 for a sign bit only if the subtype contains negative values.  If such a
11810 subtype is a first subtype, then an implementation should support a
11811 specified @code{Size} for it that reflects this representation.
11812 @end cartouche
11813 Followed.
11815 @sp 1
11816 @cartouche
11817 For a subtype implemented with levels of indirection, the @code{Size}
11818 should include the size of the pointers, but not the size of what they
11819 point at.
11820 @end cartouche
11821 Followed.
11823 @cindex @code{Component_Size} clauses
11824 @unnumberedsec 13.3(71-73): Component Size Clauses
11825 @sp 1
11826 @cartouche
11827 The recommended level of support for the @code{Component_Size}
11828 attribute is:
11829 @end cartouche
11830 @sp 1
11831 @cartouche
11832 An implementation need not support specified @code{Component_Sizes} that are
11833 less than the @code{Size} of the component subtype.
11834 @end cartouche
11835 Followed.
11837 @sp 1
11838 @cartouche
11839 An implementation should support specified @code{Component_Size}s that
11840 are factors and multiples of the word size.  For such
11841 @code{Component_Size}s, the array should contain no gaps between
11842 components.  For other @code{Component_Size}s (if supported), the array
11843 should contain no gaps between components when packing is also
11844 specified; the implementation should forbid this combination in cases
11845 where it cannot support a no-gaps representation.
11846 @end cartouche
11847 Followed.
11849 @cindex Enumeration representation clauses
11850 @cindex Representation clauses, enumeration
11851 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
11852 @sp 1
11853 @cartouche
11854 The recommended level of support for enumeration representation clauses
11857 An implementation need not support enumeration representation clauses
11858 for boolean types, but should at minimum support the internal codes in
11859 the range @code{System.Min_Int.System.Max_Int}.
11860 @end cartouche
11861 Followed.
11863 @cindex Record representation clauses
11864 @cindex Representation clauses, records
11865 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
11866 @sp 1
11867 @cartouche
11868 The recommended level of support for
11869 @*@code{record_representation_clauses} is:
11871 An implementation should support storage places that can be extracted
11872 with a load, mask, shift sequence of machine code, and set with a load,
11873 shift, mask, store sequence, given the available machine instructions
11874 and run-time model.
11875 @end cartouche
11876 Followed.
11878 @sp 1
11879 @cartouche
11880 A storage place should be supported if its size is equal to the
11881 @code{Size} of the component subtype, and it starts and ends on a
11882 boundary that obeys the @code{Alignment} of the component subtype.
11883 @end cartouche
11884 Followed.
11886 @sp 1
11887 @cartouche
11888 If the default bit ordering applies to the declaration of a given type,
11889 then for a component whose subtype's @code{Size} is less than the word
11890 size, any storage place that does not cross an aligned word boundary
11891 should be supported.
11892 @end cartouche
11893 Followed.
11895 @sp 1
11896 @cartouche
11897 An implementation may reserve a storage place for the tag field of a
11898 tagged type, and disallow other components from overlapping that place.
11899 @end cartouche
11900 Followed.  The storage place for the tag field is the beginning of the tagged
11901 record, and its size is Address'Size.  GNAT will reject an explicit component
11902 clause for the tag field.
11904 @sp 1
11905 @cartouche
11906 An implementation need not support a @code{component_clause} for a
11907 component of an extension part if the storage place is not after the
11908 storage places of all components of the parent type, whether or not
11909 those storage places had been specified.
11910 @end cartouche
11911 Followed.  The above advice on record representation clauses is followed,
11912 and all mentioned features are implemented.
11914 @cindex Storage place attributes
11915 @unnumberedsec 13.5.2(5): Storage Place Attributes
11916 @sp 1
11917 @cartouche
11918 If a component is represented using some form of pointer (such as an
11919 offset) to the actual data of the component, and this data is contiguous
11920 with the rest of the object, then the storage place attributes should
11921 reflect the place of the actual data, not the pointer.  If a component is
11922 allocated discontinuously from the rest of the object, then a warning
11923 should be generated upon reference to one of its storage place
11924 attributes.
11925 @end cartouche
11926 Followed.  There are no such components in GNAT@.
11928 @cindex Bit ordering
11929 @unnumberedsec 13.5.3(7-8): Bit Ordering
11930 @sp 1
11931 @cartouche
11932 The recommended level of support for the non-default bit ordering is:
11933 @end cartouche
11934 @sp 1
11935 @cartouche
11936 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
11937 should support the non-default bit ordering in addition to the default
11938 bit ordering.
11939 @end cartouche
11940 Followed.  Word size does not equal storage size in this implementation.
11941 Thus non-default bit ordering is not supported.
11943 @cindex @code{Address}, as private type
11944 @unnumberedsec 13.7(37): Address as Private
11945 @sp 1
11946 @cartouche
11947 @code{Address} should be of a private type.
11948 @end cartouche
11949 Followed.
11951 @cindex Operations, on @code{Address}
11952 @cindex @code{Address}, operations of
11953 @unnumberedsec 13.7.1(16): Address Operations
11954 @sp 1
11955 @cartouche
11956 Operations in @code{System} and its children should reflect the target
11957 environment semantics as closely as is reasonable.  For example, on most
11958 machines, it makes sense for address arithmetic to ``wrap around''.
11959 Operations that do not make sense should raise @code{Program_Error}.
11960 @end cartouche
11961 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
11962 operation raises @code{Program_Error}, since all operations make sense.
11964 @cindex Unchecked conversion
11965 @unnumberedsec 13.9(14-17): Unchecked Conversion
11966 @sp 1
11967 @cartouche
11968 The @code{Size} of an array object should not include its bounds; hence,
11969 the bounds should not be part of the converted data.
11970 @end cartouche
11971 Followed.
11973 @sp 1
11974 @cartouche
11975 The implementation should not generate unnecessary run-time checks to
11976 ensure that the representation of @var{S} is a representation of the
11977 target type.  It should take advantage of the permission to return by
11978 reference when possible.  Restrictions on unchecked conversions should be
11979 avoided unless required by the target environment.
11980 @end cartouche
11981 Followed.  There are no restrictions on unchecked conversion.  A warning is
11982 generated if the source and target types do not have the same size since
11983 the semantics in this case may be target dependent.
11985 @sp 1
11986 @cartouche
11987 The recommended level of support for unchecked conversions is:
11988 @end cartouche
11989 @sp 1
11990 @cartouche
11991 Unchecked conversions should be supported and should be reversible in
11992 the cases where this clause defines the result.  To enable meaningful use
11993 of unchecked conversion, a contiguous representation should be used for
11994 elementary subtypes, for statically constrained array subtypes whose
11995 component subtype is one of the subtypes described in this paragraph,
11996 and for record subtypes without discriminants whose component subtypes
11997 are described in this paragraph.
11998 @end cartouche
11999 Followed.
12001 @cindex Heap usage, implicit
12002 @unnumberedsec 13.11(23-25): Implicit Heap Usage
12003 @sp 1
12004 @cartouche
12005 An implementation should document any cases in which it dynamically
12006 allocates heap storage for a purpose other than the evaluation of an
12007 allocator.
12008 @end cartouche
12009 Followed, the only other points at which heap storage is dynamically
12010 allocated are as follows:
12012 @itemize @bullet
12013 @item
12014 At initial elaboration time, to allocate dynamically sized global
12015 objects.
12017 @item
12018 To allocate space for a task when a task is created.
12020 @item
12021 To extend the secondary stack dynamically when needed.  The secondary
12022 stack is used for returning variable length results.
12023 @end itemize
12025 @sp 1
12026 @cartouche
12027 A default (implementation-provided) storage pool for an
12028 access-to-constant type should not have overhead to support deallocation of
12029 individual objects.
12030 @end cartouche
12031 Followed.
12033 @sp 1
12034 @cartouche
12035 A storage pool for an anonymous access type should be created at the
12036 point of an allocator for the type, and be reclaimed when the designated
12037 object becomes inaccessible.
12038 @end cartouche
12039 Followed.
12041 @cindex Unchecked deallocation
12042 @unnumberedsec 13.11.2(17): Unchecked De-allocation
12043 @sp 1
12044 @cartouche
12045 For a standard storage pool, @code{Free} should actually reclaim the
12046 storage.
12047 @end cartouche
12048 Followed.
12050 @cindex Stream oriented attributes
12051 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
12052 @sp 1
12053 @cartouche
12054 If a stream element is the same size as a storage element, then the
12055 normal in-memory representation should be used by @code{Read} and
12056 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
12057 should use the smallest number of stream elements needed to represent
12058 all values in the base range of the scalar type.
12059 @end cartouche
12061 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
12062 which specifies using the size of the first subtype.
12063 However, such an implementation is based on direct binary
12064 representations and is therefore target- and endianness-dependent.
12065 To address this issue, GNAT also supplies an alternate implementation
12066 of the stream attributes @code{Read} and @code{Write},
12067 which uses the target-independent XDR standard representation
12068 for scalar types.
12069 @cindex XDR representation
12070 @cindex @code{Read} attribute
12071 @cindex @code{Write} attribute
12072 @cindex Stream oriented attributes
12073 The XDR implementation is provided as an alternative body of the
12074 @code{System.Stream_Attributes} package, in the file
12075 @file{s-stratt-xdr.adb} in the GNAT library.
12076 There is no @file{s-stratt-xdr.ads} file.
12077 In order to install the XDR implementation, do the following:
12078 @enumerate
12079 @item Replace the default implementation of the
12080 @code{System.Stream_Attributes} package with the XDR implementation.
12081 For example on a Unix platform issue the commands:
12082 @smallexample
12083 $ mv s-stratt.adb s-stratt-default.adb
12084 $ mv s-stratt-xdr.adb s-stratt.adb
12085 @end smallexample
12087 @item
12088 Rebuild the GNAT run-time library as documented in
12089 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
12090 @end enumerate
12092 @unnumberedsec A.1(52): Names of Predefined Numeric Types
12093 @sp 1
12094 @cartouche
12095 If an implementation provides additional named predefined integer types,
12096 then the names should end with @samp{Integer} as in
12097 @samp{Long_Integer}.  If an implementation provides additional named
12098 predefined floating point types, then the names should end with
12099 @samp{Float} as in @samp{Long_Float}.
12100 @end cartouche
12101 Followed.
12103 @findex Ada.Characters.Handling
12104 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
12105 @sp 1
12106 @cartouche
12107 If an implementation provides a localized definition of @code{Character}
12108 or @code{Wide_Character}, then the effects of the subprograms in
12109 @code{Characters.Handling} should reflect the localizations.  See also
12110 3.5.2.
12111 @end cartouche
12112 Followed.  GNAT provides no such localized definitions.
12114 @cindex Bounded-length strings
12115 @unnumberedsec A.4.4(106): Bounded-Length String Handling
12116 @sp 1
12117 @cartouche
12118 Bounded string objects should not be implemented by implicit pointers
12119 and dynamic allocation.
12120 @end cartouche
12121 Followed.  No implicit pointers or dynamic allocation are used.
12123 @cindex Random number generation
12124 @unnumberedsec A.5.2(46-47): Random Number Generation
12125 @sp 1
12126 @cartouche
12127 Any storage associated with an object of type @code{Generator} should be
12128 reclaimed on exit from the scope of the object.
12129 @end cartouche
12130 Followed.
12132 @sp 1
12133 @cartouche
12134 If the generator period is sufficiently long in relation to the number
12135 of distinct initiator values, then each possible value of
12136 @code{Initiator} passed to @code{Reset} should initiate a sequence of
12137 random numbers that does not, in a practical sense, overlap the sequence
12138 initiated by any other value.  If this is not possible, then the mapping
12139 between initiator values and generator states should be a rapidly
12140 varying function of the initiator value.
12141 @end cartouche
12142 Followed.  The generator period is sufficiently long for the first
12143 condition here to hold true.
12145 @findex Get_Immediate
12146 @unnumberedsec A.10.7(23): @code{Get_Immediate}
12147 @sp 1
12148 @cartouche
12149 The @code{Get_Immediate} procedures should be implemented with
12150 unbuffered input.  For a device such as a keyboard, input should be
12151 @dfn{available} if a key has already been typed, whereas for a disk
12152 file, input should always be available except at end of file.  For a file
12153 associated with a keyboard-like device, any line-editing features of the
12154 underlying operating system should be disabled during the execution of
12155 @code{Get_Immediate}.
12156 @end cartouche
12157 Followed on all targets except VxWorks. For VxWorks, there is no way to
12158 provide this functionality that does not result in the input buffer being
12159 flushed before the @code{Get_Immediate} call. A special unit
12160 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
12161 this functionality.
12163 @findex Export
12164 @unnumberedsec B.1(39-41): Pragma @code{Export}
12165 @sp 1
12166 @cartouche
12167 If an implementation supports pragma @code{Export} to a given language,
12168 then it should also allow the main subprogram to be written in that
12169 language.  It should support some mechanism for invoking the elaboration
12170 of the Ada library units included in the system, and for invoking the
12171 finalization of the environment task.  On typical systems, the
12172 recommended mechanism is to provide two subprograms whose link names are
12173 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
12174 elaboration code for library units.  @code{adafinal} should contain the
12175 finalization code.  These subprograms should have no effect the second
12176 and subsequent time they are called.
12177 @end cartouche
12178 Followed.
12180 @sp 1
12181 @cartouche
12182 Automatic elaboration of pre-elaborated packages should be
12183 provided when pragma @code{Export} is supported.
12184 @end cartouche
12185 Followed when the main program is in Ada.  If the main program is in a
12186 foreign language, then
12187 @code{adainit} must be called to elaborate pre-elaborated
12188 packages.
12190 @sp 1
12191 @cartouche
12192 For each supported convention @var{L} other than @code{Intrinsic}, an
12193 implementation should support @code{Import} and @code{Export} pragmas
12194 for objects of @var{L}-compatible types and for subprograms, and pragma
12195 @code{Convention} for @var{L}-eligible types and for subprograms,
12196 presuming the other language has corresponding features.  Pragma
12197 @code{Convention} need not be supported for scalar types.
12198 @end cartouche
12199 Followed.
12201 @cindex Package @code{Interfaces}
12202 @findex Interfaces
12203 @unnumberedsec B.2(12-13): Package @code{Interfaces}
12204 @sp 1
12205 @cartouche
12206 For each implementation-defined convention identifier, there should be a
12207 child package of package Interfaces with the corresponding name.  This
12208 package should contain any declarations that would be useful for
12209 interfacing to the language (implementation) represented by the
12210 convention.  Any declarations useful for interfacing to any language on
12211 the given hardware architecture should be provided directly in
12212 @code{Interfaces}.
12213 @end cartouche
12214 Followed.
12216 @sp 1
12217 @cartouche
12218 An implementation supporting an interface to C, COBOL, or Fortran should
12219 provide the corresponding package or packages described in the following
12220 clauses.
12221 @end cartouche
12222 Followed.  GNAT provides all the packages described in this section.
12224 @cindex C, interfacing with
12225 @unnumberedsec B.3(63-71): Interfacing with C
12226 @sp 1
12227 @cartouche
12228 An implementation should support the following interface correspondences
12229 between Ada and C@.
12230 @end cartouche
12231 Followed.
12233 @sp 1
12234 @cartouche
12235 An Ada procedure corresponds to a void-returning C function.
12236 @end cartouche
12237 Followed.
12239 @sp 1
12240 @cartouche
12241 An Ada function corresponds to a non-void C function.
12242 @end cartouche
12243 Followed.
12245 @sp 1
12246 @cartouche
12247 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
12248 function.
12249 @end cartouche
12250 Followed.
12252 @sp 1
12253 @cartouche
12254 An Ada @code{in} parameter of an access-to-object type with designated
12255 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
12256 where @var{t} is the C type corresponding to the Ada type @var{T}.
12257 @end cartouche
12258 Followed.
12260 @sp 1
12261 @cartouche
12262 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
12263 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
12264 argument to a C function, where @var{t} is the C type corresponding to
12265 the Ada type @var{T}.  In the case of an elementary @code{out} or
12266 @code{in out} parameter, a pointer to a temporary copy is used to
12267 preserve by-copy semantics.
12268 @end cartouche
12269 Followed.
12271 @sp 1
12272 @cartouche
12273 An Ada parameter of a record type @var{T}, of any mode, is passed as a
12274 @code{@var{t}*} argument to a C function, where @var{t} is the C
12275 structure corresponding to the Ada type @var{T}.
12276 @end cartouche
12277 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
12278 pragma, or Convention, or by explicitly specifying the mechanism for a given
12279 call using an extended import or export pragma.
12281 @sp 1
12282 @cartouche
12283 An Ada parameter of an array type with component type @var{T}, of any
12284 mode, is passed as a @code{@var{t}*} argument to a C function, where
12285 @var{t} is the C type corresponding to the Ada type @var{T}.
12286 @end cartouche
12287 Followed.
12289 @sp 1
12290 @cartouche
12291 An Ada parameter of an access-to-subprogram type is passed as a pointer
12292 to a C function whose prototype corresponds to the designated
12293 subprogram's specification.
12294 @end cartouche
12295 Followed.
12297 @cindex COBOL, interfacing with
12298 @unnumberedsec B.4(95-98): Interfacing with COBOL
12299 @sp 1
12300 @cartouche
12301 An Ada implementation should support the following interface
12302 correspondences between Ada and COBOL@.
12303 @end cartouche
12304 Followed.
12306 @sp 1
12307 @cartouche
12308 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
12309 the COBOL type corresponding to @var{T}.
12310 @end cartouche
12311 Followed.
12313 @sp 1
12314 @cartouche
12315 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
12316 the corresponding COBOL type.
12317 @end cartouche
12318 Followed.
12320 @sp 1
12321 @cartouche
12322 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
12323 COBOL type corresponding to the Ada parameter type; for scalars, a local
12324 copy is used if necessary to ensure by-copy semantics.
12325 @end cartouche
12326 Followed.
12328 @cindex Fortran, interfacing with
12329 @unnumberedsec B.5(22-26): Interfacing with Fortran
12330 @sp 1
12331 @cartouche
12332 An Ada implementation should support the following interface
12333 correspondences between Ada and Fortran:
12334 @end cartouche
12335 Followed.
12337 @sp 1
12338 @cartouche
12339 An Ada procedure corresponds to a Fortran subroutine.
12340 @end cartouche
12341 Followed.
12343 @sp 1
12344 @cartouche
12345 An Ada function corresponds to a Fortran function.
12346 @end cartouche
12347 Followed.
12349 @sp 1
12350 @cartouche
12351 An Ada parameter of an elementary, array, or record type @var{T} is
12352 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
12353 the Fortran type corresponding to the Ada type @var{T}, and where the
12354 INTENT attribute of the corresponding dummy argument matches the Ada
12355 formal parameter mode; the Fortran implementation's parameter passing
12356 conventions are used.  For elementary types, a local copy is used if
12357 necessary to ensure by-copy semantics.
12358 @end cartouche
12359 Followed.
12361 @sp 1
12362 @cartouche
12363 An Ada parameter of an access-to-subprogram type is passed as a
12364 reference to a Fortran procedure whose interface corresponds to the
12365 designated subprogram's specification.
12366 @end cartouche
12367 Followed.
12369 @cindex Machine operations
12370 @unnumberedsec C.1(3-5): Access to Machine Operations
12371 @sp 1
12372 @cartouche
12373 The machine code or intrinsic support should allow access to all
12374 operations normally available to assembly language programmers for the
12375 target environment, including privileged instructions, if any.
12376 @end cartouche
12377 Followed.
12379 @sp 1
12380 @cartouche
12381 The interfacing pragmas (see Annex B) should support interface to
12382 assembler; the default assembler should be associated with the
12383 convention identifier @code{Assembler}.
12384 @end cartouche
12385 Followed.
12387 @sp 1
12388 @cartouche
12389 If an entity is exported to assembly language, then the implementation
12390 should allocate it at an addressable location, and should ensure that it
12391 is retained by the linking process, even if not otherwise referenced
12392 from the Ada code.  The implementation should assume that any call to a
12393 machine code or assembler subprogram is allowed to read or update every
12394 object that is specified as exported.
12395 @end cartouche
12396 Followed.
12398 @unnumberedsec C.1(10-16): Access to Machine Operations
12399 @sp 1
12400 @cartouche
12401 The implementation should ensure that little or no overhead is
12402 associated with calling intrinsic and machine-code subprograms.
12403 @end cartouche
12404 Followed for both intrinsics and machine-code subprograms.
12406 @sp 1
12407 @cartouche
12408 It is recommended that intrinsic subprograms be provided for convenient
12409 access to any machine operations that provide special capabilities or
12410 efficiency and that are not otherwise available through the language
12411 constructs.
12412 @end cartouche
12413 Followed.  A full set of machine operation intrinsic subprograms is provided.
12415 @sp 1
12416 @cartouche
12417 Atomic read-modify-write operations---e.g.@:, test and set, compare and
12418 swap, decrement and test, enqueue/dequeue.
12419 @end cartouche
12420 Followed on any target supporting such operations.
12422 @sp 1
12423 @cartouche
12424 Standard numeric functions---e.g.@:, sin, log.
12425 @end cartouche
12426 Followed on any target supporting such operations.
12428 @sp 1
12429 @cartouche
12430 String manipulation operations---e.g.@:, translate and test.
12431 @end cartouche
12432 Followed on any target supporting such operations.
12434 @sp 1
12435 @cartouche
12436 Vector operations---e.g.@:, compare vector against thresholds.
12437 @end cartouche
12438 Followed on any target supporting such operations.
12440 @sp 1
12441 @cartouche
12442 Direct operations on I/O ports.
12443 @end cartouche
12444 Followed on any target supporting such operations.
12446 @cindex Interrupt support
12447 @unnumberedsec C.3(28): Interrupt Support
12448 @sp 1
12449 @cartouche
12450 If the @code{Ceiling_Locking} policy is not in effect, the
12451 implementation should provide means for the application to specify which
12452 interrupts are to be blocked during protected actions, if the underlying
12453 system allows for a finer-grain control of interrupt blocking.
12454 @end cartouche
12455 Followed.  The underlying system does not allow for finer-grain control
12456 of interrupt blocking.
12458 @cindex Protected procedure handlers
12459 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
12460 @sp 1
12461 @cartouche
12462 Whenever possible, the implementation should allow interrupt handlers to
12463 be called directly by the hardware.
12464 @end cartouche
12465 Followed on any target where the underlying operating system permits
12466 such direct calls.
12468 @sp 1
12469 @cartouche
12470 Whenever practical, violations of any
12471 implementation-defined restrictions should be detected before run time.
12472 @end cartouche
12473 Followed.  Compile time warnings are given when possible.
12475 @cindex Package @code{Interrupts}
12476 @findex Interrupts
12477 @unnumberedsec C.3.2(25): Package @code{Interrupts}
12479 @sp 1
12480 @cartouche
12481 If implementation-defined forms of interrupt handler procedures are
12482 supported, such as protected procedures with parameters, then for each
12483 such form of a handler, a type analogous to @code{Parameterless_Handler}
12484 should be specified in a child package of @code{Interrupts}, with the
12485 same operations as in the predefined package Interrupts.
12486 @end cartouche
12487 Followed.
12489 @cindex Pre-elaboration requirements
12490 @unnumberedsec C.4(14): Pre-elaboration Requirements
12491 @sp 1
12492 @cartouche
12493 It is recommended that pre-elaborated packages be implemented in such a
12494 way that there should be little or no code executed at run time for the
12495 elaboration of entities not already covered by the Implementation
12496 Requirements.
12497 @end cartouche
12498 Followed.  Executable code is generated in some cases, e.g.@: loops
12499 to initialize large arrays.
12501 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
12502 @sp 1
12503 @cartouche
12504 If the pragma applies to an entity, then the implementation should
12505 reduce the amount of storage used for storing names associated with that
12506 entity.
12507 @end cartouche
12508 Followed.
12510 @cindex Package @code{Task_Attributes}
12511 @findex Task_Attributes
12512 @unnumberedsec C.7.2(30): The Package Task_Attributes
12513 @sp 1
12514 @cartouche
12515 Some implementations are targeted to domains in which memory use at run
12516 time must be completely deterministic.  For such implementations, it is
12517 recommended that the storage for task attributes will be pre-allocated
12518 statically and not from the heap.  This can be accomplished by either
12519 placing restrictions on the number and the size of the task's
12520 attributes, or by using the pre-allocated storage for the first @var{N}
12521 attribute objects, and the heap for the others.  In the latter case,
12522 @var{N} should be documented.
12523 @end cartouche
12524 Not followed.  This implementation is not targeted to such a domain.
12526 @cindex Locking Policies
12527 @unnumberedsec D.3(17): Locking Policies
12529 @sp 1
12530 @cartouche
12531 The implementation should use names that end with @samp{_Locking} for
12532 locking policies defined by the implementation.
12533 @end cartouche
12534 Followed.  Two implementation-defined locking policies are defined,
12535 whose names (@code{Inheritance_Locking} and
12536 @code{Concurrent_Readers_Locking}) follow this suggestion.
12538 @cindex Entry queuing policies
12539 @unnumberedsec D.4(16): Entry Queuing Policies
12540 @sp 1
12541 @cartouche
12542 Names that end with @samp{_Queuing} should be used
12543 for all implementation-defined queuing policies.
12544 @end cartouche
12545 Followed.  No such implementation-defined queuing policies exist.
12547 @cindex Preemptive abort
12548 @unnumberedsec D.6(9-10): Preemptive Abort
12549 @sp 1
12550 @cartouche
12551 Even though the @code{abort_statement} is included in the list of
12552 potentially blocking operations (see 9.5.1), it is recommended that this
12553 statement be implemented in a way that never requires the task executing
12554 the @code{abort_statement} to block.
12555 @end cartouche
12556 Followed.
12558 @sp 1
12559 @cartouche
12560 On a multi-processor, the delay associated with aborting a task on
12561 another processor should be bounded; the implementation should use
12562 periodic polling, if necessary, to achieve this.
12563 @end cartouche
12564 Followed.
12566 @cindex Tasking restrictions
12567 @unnumberedsec D.7(21): Tasking Restrictions
12568 @sp 1
12569 @cartouche
12570 When feasible, the implementation should take advantage of the specified
12571 restrictions to produce a more efficient implementation.
12572 @end cartouche
12573 GNAT currently takes advantage of these restrictions by providing an optimized
12574 run time when the Ravenscar profile and the GNAT restricted run time set
12575 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
12576 pragma @code{Profile (Restricted)} for more details.
12578 @cindex Time, monotonic
12579 @unnumberedsec D.8(47-49): Monotonic Time
12580 @sp 1
12581 @cartouche
12582 When appropriate, implementations should provide configuration
12583 mechanisms to change the value of @code{Tick}.
12584 @end cartouche
12585 Such configuration mechanisms are not appropriate to this implementation
12586 and are thus not supported.
12588 @sp 1
12589 @cartouche
12590 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
12591 be implemented as transformations of the same time base.
12592 @end cartouche
12593 Followed.
12595 @sp 1
12596 @cartouche
12597 It is recommended that the @dfn{best} time base which exists in
12598 the underlying system be available to the application through
12599 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
12600 @end cartouche
12601 Followed.
12603 @cindex Partition communication subsystem
12604 @cindex PCS
12605 @unnumberedsec E.5(28-29): Partition Communication Subsystem
12606 @sp 1
12607 @cartouche
12608 Whenever possible, the PCS on the called partition should allow for
12609 multiple tasks to call the RPC-receiver with different messages and
12610 should allow them to block until the corresponding subprogram body
12611 returns.
12612 @end cartouche
12613 Followed by GLADE, a separately supplied PCS that can be used with
12614 GNAT.
12616 @sp 1
12617 @cartouche
12618 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
12619 should raise @code{Storage_Error} if it runs out of space trying to
12620 write the @code{Item} into the stream.
12621 @end cartouche
12622 Followed by GLADE, a separately supplied PCS that can be used with
12623 GNAT@.
12625 @cindex COBOL support
12626 @unnumberedsec F(7): COBOL Support
12627 @sp 1
12628 @cartouche
12629 If COBOL (respectively, C) is widely supported in the target
12630 environment, implementations supporting the Information Systems Annex
12631 should provide the child package @code{Interfaces.COBOL} (respectively,
12632 @code{Interfaces.C}) specified in Annex B and should support a
12633 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
12634 pragmas (see Annex B), thus allowing Ada programs to interface with
12635 programs written in that language.
12636 @end cartouche
12637 Followed.
12639 @cindex Decimal radix support
12640 @unnumberedsec F.1(2): Decimal Radix Support
12641 @sp 1
12642 @cartouche
12643 Packed decimal should be used as the internal representation for objects
12644 of subtype @var{S} when @var{S}'Machine_Radix = 10.
12645 @end cartouche
12646 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
12647 representations.
12649 @cindex Numerics
12650 @unnumberedsec G: Numerics
12651 @sp 2
12652 @cartouche
12653 If Fortran (respectively, C) is widely supported in the target
12654 environment, implementations supporting the Numerics Annex
12655 should provide the child package @code{Interfaces.Fortran} (respectively,
12656 @code{Interfaces.C}) specified in Annex B and should support a
12657 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
12658 pragmas (see Annex B), thus allowing Ada programs to interface with
12659 programs written in that language.
12660 @end cartouche
12661 Followed.
12663 @cindex Complex types
12664 @unnumberedsec G.1.1(56-58): Complex Types
12665 @sp 2
12666 @cartouche
12667 Because the usual mathematical meaning of multiplication of a complex
12668 operand and a real operand is that of the scaling of both components of
12669 the former by the latter, an implementation should not perform this
12670 operation by first promoting the real operand to complex type and then
12671 performing a full complex multiplication.  In systems that, in the
12672 future, support an Ada binding to IEC 559:1989, the latter technique
12673 will not generate the required result when one of the components of the
12674 complex operand is infinite.  (Explicit multiplication of the infinite
12675 component by the zero component obtained during promotion yields a NaN
12676 that propagates into the final result.) Analogous advice applies in the
12677 case of multiplication of a complex operand and a pure-imaginary
12678 operand, and in the case of division of a complex operand by a real or
12679 pure-imaginary operand.
12680 @end cartouche
12681 Not followed.
12683 @sp 1
12684 @cartouche
12685 Similarly, because the usual mathematical meaning of addition of a
12686 complex operand and a real operand is that the imaginary operand remains
12687 unchanged, an implementation should not perform this operation by first
12688 promoting the real operand to complex type and then performing a full
12689 complex addition.  In implementations in which the @code{Signed_Zeros}
12690 attribute of the component type is @code{True} (and which therefore
12691 conform to IEC 559:1989 in regard to the handling of the sign of zero in
12692 predefined arithmetic operations), the latter technique will not
12693 generate the required result when the imaginary component of the complex
12694 operand is a negatively signed zero.  (Explicit addition of the negative
12695 zero to the zero obtained during promotion yields a positive zero.)
12696 Analogous advice applies in the case of addition of a complex operand
12697 and a pure-imaginary operand, and in the case of subtraction of a
12698 complex operand and a real or pure-imaginary operand.
12699 @end cartouche
12700 Not followed.
12702 @sp 1
12703 @cartouche
12704 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
12705 attempt to provide a rational treatment of the signs of zero results and
12706 result components.  As one example, the result of the @code{Argument}
12707 function should have the sign of the imaginary component of the
12708 parameter @code{X} when the point represented by that parameter lies on
12709 the positive real axis; as another, the sign of the imaginary component
12710 of the @code{Compose_From_Polar} function should be the same as
12711 (respectively, the opposite of) that of the @code{Argument} parameter when that
12712 parameter has a value of zero and the @code{Modulus} parameter has a
12713 nonnegative (respectively, negative) value.
12714 @end cartouche
12715 Followed.
12717 @cindex Complex elementary functions
12718 @unnumberedsec G.1.2(49): Complex Elementary Functions
12719 @sp 1
12720 @cartouche
12721 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
12722 @code{True} should attempt to provide a rational treatment of the signs
12723 of zero results and result components.  For example, many of the complex
12724 elementary functions have components that are odd functions of one of
12725 the parameter components; in these cases, the result component should
12726 have the sign of the parameter component at the origin.  Other complex
12727 elementary functions have zero components whose sign is opposite that of
12728 a parameter component at the origin, or is always positive or always
12729 negative.
12730 @end cartouche
12731 Followed.
12733 @cindex Accuracy requirements
12734 @unnumberedsec G.2.4(19): Accuracy Requirements
12735 @sp 1
12736 @cartouche
12737 The versions of the forward trigonometric functions without a
12738 @code{Cycle} parameter should not be implemented by calling the
12739 corresponding version with a @code{Cycle} parameter of
12740 @code{2.0*Numerics.Pi}, since this will not provide the required
12741 accuracy in some portions of the domain.  For the same reason, the
12742 version of @code{Log} without a @code{Base} parameter should not be
12743 implemented by calling the corresponding version with a @code{Base}
12744 parameter of @code{Numerics.e}.
12745 @end cartouche
12746 Followed.
12748 @cindex Complex arithmetic accuracy
12749 @cindex Accuracy, complex arithmetic
12750 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
12752 @sp 1
12753 @cartouche
12754 The version of the @code{Compose_From_Polar} function without a
12755 @code{Cycle} parameter should not be implemented by calling the
12756 corresponding version with a @code{Cycle} parameter of
12757 @code{2.0*Numerics.Pi}, since this will not provide the required
12758 accuracy in some portions of the domain.
12759 @end cartouche
12760 Followed.
12762 @cindex Sequential elaboration policy
12763 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
12765 @sp 1
12766 @cartouche
12767 If the partition elaboration policy is @code{Sequential} and the
12768 Environment task becomes permanently blocked during elaboration then the
12769 partition is deadlocked and it is recommended that the partition be
12770 immediately terminated.
12771 @end cartouche
12772 Not followed.
12774 @c -----------------------------------------
12775 @node Implementation Defined Characteristics
12776 @chapter Implementation Defined Characteristics
12778 @noindent
12779 In addition to the implementation dependent pragmas and attributes, and the
12780 implementation advice, there are a number of other Ada features that are
12781 potentially implementation dependent and are designated as
12782 implementation-defined. These are mentioned throughout the Ada Reference
12783 Manual, and are summarized in Annex M@.
12785 A requirement for conforming Ada compilers is that they provide
12786 documentation describing how the implementation deals with each of these
12787 issues.  In this chapter you will find each point in Annex M listed,
12788 followed by a description of how GNAT
12789 handles the implementation dependence.
12791 You can use this chapter as a guide to minimizing implementation
12792 dependent features in your programs if portability to other compilers
12793 and other operating systems is an important consideration.  The numbers
12794 in each entry below correspond to the paragraph numbers in the Ada
12795 Reference Manual.
12798 @itemize @bullet
12799 @sp 1
12800 @item
12801 @cartouche
12802 @noindent
12803 Whether or not each recommendation given in Implementation
12804 Advice is followed.  See 1.1.2(37).
12805 @end cartouche
12806 @noindent
12807 @xref{Implementation Advice}.
12810 @sp 1
12811 @item
12812 @cartouche
12813 @noindent
12814 Capacity limitations of the implementation.  See 1.1.3(3).
12815 @end cartouche
12816 @noindent
12817 The complexity of programs that can be processed is limited only by the
12818 total amount of available virtual memory, and disk space for the
12819 generated object files.
12822 @sp 1
12823 @item
12824 @cartouche
12825 @noindent
12826 Variations from the standard that are impractical to avoid
12827 given the implementation's execution environment.  See 1.1.3(6).
12828 @end cartouche
12829 @noindent
12830 There are no variations from the standard.
12833 @sp 1
12834 @item
12835 @cartouche
12836 @noindent
12837 Which @code{code_statement}s cause external
12838 interactions.  See 1.1.3(10).
12839 @end cartouche
12840 @noindent
12841 Any @code{code_statement} can potentially cause external interactions.
12843 @sp 1
12844 @item
12845 @cartouche
12846 @noindent
12847 The coded representation for the text of an Ada
12848 program.  See 2.1(4).
12849 @end cartouche
12850 @noindent
12851 See separate section on source representation.
12854 @sp 1
12855 @item
12856 @cartouche
12857 @noindent
12858 The control functions allowed in comments.  See 2.1(14).
12859 @end cartouche
12860 @noindent
12861 See separate section on source representation.
12863 @sp 1
12864 @item
12865 @cartouche
12866 @noindent
12867 The representation for an end of line.  See 2.2(2).
12868 @end cartouche
12869 @noindent
12870 See separate section on source representation.
12872 @sp 1
12873 @item
12874 @cartouche
12875 @noindent
12876 Maximum supported line length and lexical element
12877 length.  See 2.2(15).
12878 @end cartouche
12879 @noindent
12880 The maximum line length is 255 characters and the maximum length of
12881 a lexical element is also 255 characters. This is the default setting
12882 if not overridden by the use of compiler switch @option{-gnaty} (which
12883 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
12884 line length to be specified to be any value up to 32767. The maximum
12885 length of a lexical element is the same as the maximum line length.
12887 @sp 1
12888 @item
12889 @cartouche
12890 @noindent
12891 Implementation defined pragmas.  See 2.8(14).
12892 @end cartouche
12893 @noindent
12895 @xref{Implementation Defined Pragmas}.
12897 @sp 1
12898 @item
12899 @cartouche
12900 @noindent
12901 Effect of pragma @code{Optimize}.  See 2.8(27).
12902 @end cartouche
12903 @noindent
12904 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
12905 parameter, checks that the optimization flag is set, and aborts if it is
12906 not.
12908 @sp 1
12909 @item
12910 @cartouche
12911 @noindent
12912 The sequence of characters of the value returned by
12913 @code{@var{S}'Image} when some of the graphic characters of
12914 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
12915 3.5(37).
12916 @end cartouche
12917 @noindent
12918 The sequence of characters is as defined by the wide character encoding
12919 method used for the source.  See section on source representation for
12920 further details.
12922 @sp 1
12923 @item
12924 @cartouche
12925 @noindent
12926 The predefined integer types declared in
12927 @code{Standard}.  See 3.5.4(25).
12928 @end cartouche
12929 @noindent
12930 @table @code
12931 @item Short_Short_Integer
12932 8 bit signed
12933 @item Short_Integer
12934 (Short) 16 bit signed
12935 @item Integer
12936 32 bit signed
12937 @item Long_Integer
12938 64 bit signed (on most 64 bit targets, depending on the C definition of long).
12939 32 bit signed (all other targets)
12940 @item Long_Long_Integer
12941 64 bit signed
12942 @end table
12944 @sp 1
12945 @item
12946 @cartouche
12947 @noindent
12948 Any nonstandard integer types and the operators defined
12949 for them.  See 3.5.4(26).
12950 @end cartouche
12951 @noindent
12952 There are no nonstandard integer types.
12954 @sp 1
12955 @item
12956 @cartouche
12957 @noindent
12958 Any nonstandard real types and the operators defined for
12959 them.  See 3.5.6(8).
12960 @end cartouche
12961 @noindent
12962 There are no nonstandard real types.
12964 @sp 1
12965 @item
12966 @cartouche
12967 @noindent
12968 What combinations of requested decimal precision and range
12969 are supported for floating point types.  See 3.5.7(7).
12970 @end cartouche
12971 @noindent
12972 The precision and range is as defined by the IEEE standard.
12974 @sp 1
12975 @item
12976 @cartouche
12977 @noindent
12978 The predefined floating point types declared in
12979 @code{Standard}.  See 3.5.7(16).
12980 @end cartouche
12981 @noindent
12982 @table @code
12983 @item Short_Float
12984 32 bit IEEE short
12985 @item Float
12986 (Short) 32 bit IEEE short
12987 @item Long_Float
12988 64 bit IEEE long
12989 @item Long_Long_Float
12990 64 bit IEEE long (80 bit IEEE long on x86 processors)
12991 @end table
12993 @sp 1
12994 @item
12995 @cartouche
12996 @noindent
12997 The small of an ordinary fixed point type.  See 3.5.9(8).
12998 @end cartouche
12999 @noindent
13000 @code{Fine_Delta} is 2**(@minus{}63)
13002 @sp 1
13003 @item
13004 @cartouche
13005 @noindent
13006 What combinations of small, range, and digits are
13007 supported for fixed point types.  See 3.5.9(10).
13008 @end cartouche
13009 @noindent
13010 Any combinations are permitted that do not result in a small less than
13011 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
13012 If the mantissa is larger than 53 bits on machines where Long_Long_Float
13013 is 64 bits (true of all architectures except ia32), then the output from
13014 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
13015 is because floating-point conversions are used to convert fixed point.
13017 @sp 1
13018 @item
13019 @cartouche
13020 @noindent
13021 The result of @code{Tags.Expanded_Name} for types declared
13022 within an unnamed @code{block_statement}.  See 3.9(10).
13023 @end cartouche
13024 @noindent
13025 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
13026 decimal integer are allocated.
13028 @sp 1
13029 @item
13030 @cartouche
13031 @noindent
13032 Implementation-defined attributes.  See 4.1.4(12).
13033 @end cartouche
13034 @noindent
13035 @xref{Implementation Defined Attributes}.
13037 @sp 1
13038 @item
13039 @cartouche
13040 @noindent
13041 Any implementation-defined time types.  See 9.6(6).
13042 @end cartouche
13043 @noindent
13044 There are no implementation-defined time types.
13046 @sp 1
13047 @item
13048 @cartouche
13049 @noindent
13050 The time base associated with relative delays.
13051 @end cartouche
13052 @noindent
13053 See 9.6(20).  The time base used is that provided by the C library
13054 function @code{gettimeofday}.
13056 @sp 1
13057 @item
13058 @cartouche
13059 @noindent
13060 The time base of the type @code{Calendar.Time}.  See
13061 9.6(23).
13062 @end cartouche
13063 @noindent
13064 The time base used is that provided by the C library function
13065 @code{gettimeofday}.
13067 @sp 1
13068 @item
13069 @cartouche
13070 @noindent
13071 The time zone used for package @code{Calendar}
13072 operations.  See 9.6(24).
13073 @end cartouche
13074 @noindent
13075 The time zone used by package @code{Calendar} is the current system time zone
13076 setting for local time, as accessed by the C library function
13077 @code{localtime}.
13079 @sp 1
13080 @item
13081 @cartouche
13082 @noindent
13083 Any limit on @code{delay_until_statements} of
13084 @code{select_statements}.  See 9.6(29).
13085 @end cartouche
13086 @noindent
13087 There are no such limits.
13089 @sp 1
13090 @item
13091 @cartouche
13092 @noindent
13093 Whether or not two non-overlapping parts of a composite
13094 object are independently addressable, in the case where packing, record
13095 layout, or @code{Component_Size} is specified for the object.  See
13096 9.10(1).
13097 @end cartouche
13098 @noindent
13099 Separate components are independently addressable if they do not share
13100 overlapping storage units.
13102 @sp 1
13103 @item
13104 @cartouche
13105 @noindent
13106 The representation for a compilation.  See 10.1(2).
13107 @end cartouche
13108 @noindent
13109 A compilation is represented by a sequence of files presented to the
13110 compiler in a single invocation of the @command{gcc} command.
13112 @sp 1
13113 @item
13114 @cartouche
13115 @noindent
13116 Any restrictions on compilations that contain multiple
13117 compilation_units.  See 10.1(4).
13118 @end cartouche
13119 @noindent
13120 No single file can contain more than one compilation unit, but any
13121 sequence of files can be presented to the compiler as a single
13122 compilation.
13124 @sp 1
13125 @item
13126 @cartouche
13127 @noindent
13128 The mechanisms for creating an environment and for adding
13129 and replacing compilation units.  See 10.1.4(3).
13130 @end cartouche
13131 @noindent
13132 See separate section on compilation model.
13134 @sp 1
13135 @item
13136 @cartouche
13137 @noindent
13138 The manner of explicitly assigning library units to a
13139 partition.  See 10.2(2).
13140 @end cartouche
13141 @noindent
13142 If a unit contains an Ada main program, then the Ada units for the partition
13143 are determined by recursive application of the rules in the Ada Reference
13144 Manual section 10.2(2-6).  In other words, the Ada units will be those that
13145 are needed by the main program, and then this definition of need is applied
13146 recursively to those units, and the partition contains the transitive
13147 closure determined by this relationship.  In short, all the necessary units
13148 are included, with no need to explicitly specify the list.  If additional
13149 units are required, e.g.@: by foreign language units, then all units must be
13150 mentioned in the context clause of one of the needed Ada units.
13152 If the partition contains no main program, or if the main program is in
13153 a language other than Ada, then GNAT
13154 provides the binder options @option{-z} and @option{-n} respectively, and in
13155 this case a list of units can be explicitly supplied to the binder for
13156 inclusion in the partition (all units needed by these units will also
13157 be included automatically).  For full details on the use of these
13158 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
13159 @value{EDITION} User's Guide}.
13161 @sp 1
13162 @item
13163 @cartouche
13164 @noindent
13165 The implementation-defined means, if any, of specifying
13166 which compilation units are needed by a given compilation unit.  See
13167 10.2(2).
13168 @end cartouche
13169 @noindent
13170 The units needed by a given compilation unit are as defined in
13171 the Ada Reference Manual section 10.2(2-6).  There are no
13172 implementation-defined pragmas or other implementation-defined
13173 means for specifying needed units.
13175 @sp 1
13176 @item
13177 @cartouche
13178 @noindent
13179 The manner of designating the main subprogram of a
13180 partition.  See 10.2(7).
13181 @end cartouche
13182 @noindent
13183 The main program is designated by providing the name of the
13184 corresponding @file{ALI} file as the input parameter to the binder.
13186 @sp 1
13187 @item
13188 @cartouche
13189 @noindent
13190 The order of elaboration of @code{library_items}.  See
13191 10.2(18).
13192 @end cartouche
13193 @noindent
13194 The first constraint on ordering is that it meets the requirements of
13195 Chapter 10 of the Ada Reference Manual.  This still leaves some
13196 implementation dependent choices, which are resolved by first
13197 elaborating bodies as early as possible (i.e., in preference to specs
13198 where there is a choice), and second by evaluating the immediate with
13199 clauses of a unit to determine the probably best choice, and
13200 third by elaborating in alphabetical order of unit names
13201 where a choice still remains.
13203 @sp 1
13204 @item
13205 @cartouche
13206 @noindent
13207 Parameter passing and function return for the main
13208 subprogram.  See 10.2(21).
13209 @end cartouche
13210 @noindent
13211 The main program has no parameters.  It may be a procedure, or a function
13212 returning an integer type.  In the latter case, the returned integer
13213 value is the return code of the program (overriding any value that
13214 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
13216 @sp 1
13217 @item
13218 @cartouche
13219 @noindent
13220 The mechanisms for building and running partitions.  See
13221 10.2(24).
13222 @end cartouche
13223 @noindent
13224 GNAT itself supports programs with only a single partition.  The GNATDIST
13225 tool provided with the GLADE package (which also includes an implementation
13226 of the PCS) provides a completely flexible method for building and running
13227 programs consisting of multiple partitions.  See the separate GLADE manual
13228 for details.
13230 @sp 1
13231 @item
13232 @cartouche
13233 @noindent
13234 The details of program execution, including program
13235 termination.  See 10.2(25).
13236 @end cartouche
13237 @noindent
13238 See separate section on compilation model.
13240 @sp 1
13241 @item
13242 @cartouche
13243 @noindent
13244 The semantics of any non-active partitions supported by the
13245 implementation.  See 10.2(28).
13246 @end cartouche
13247 @noindent
13248 Passive partitions are supported on targets where shared memory is
13249 provided by the operating system.  See the GLADE reference manual for
13250 further details.
13252 @sp 1
13253 @item
13254 @cartouche
13255 @noindent
13256 The information returned by @code{Exception_Message}.  See
13257 11.4.1(10).
13258 @end cartouche
13259 @noindent
13260 Exception message returns the null string unless a specific message has
13261 been passed by the program.
13263 @sp 1
13264 @item
13265 @cartouche
13266 @noindent
13267 The result of @code{Exceptions.Exception_Name} for types
13268 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
13269 @end cartouche
13270 @noindent
13271 Blocks have implementation defined names of the form @code{B@var{nnn}}
13272 where @var{nnn} is an integer.
13274 @sp 1
13275 @item
13276 @cartouche
13277 @noindent
13278 The information returned by
13279 @code{Exception_Information}.  See 11.4.1(13).
13280 @end cartouche
13281 @noindent
13282 @code{Exception_Information} returns a string in the following format:
13284 @smallexample
13285 @emph{Exception_Name:} nnnnn
13286 @emph{Message:} mmmmm
13287 @emph{PID:} ppp
13288 @emph{Load address:} 0xhhhh
13289 @emph{Call stack traceback locations:}
13290 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
13291 @end smallexample
13293 @noindent
13294 where
13296 @itemize @bullet
13297 @item
13298 @code{nnnn} is the fully qualified name of the exception in all upper
13299 case letters. This line is always present.
13301 @item
13302 @code{mmmm} is the message (this line present only if message is non-null)
13304 @item
13305 @code{ppp} is the Process Id value as a decimal integer (this line is
13306 present only if the Process Id is nonzero). Currently we are
13307 not making use of this field.
13309 @item
13310 The Load address line, the Call stack traceback locations line and the
13311 following values are present only if at least one traceback location was
13312 recorded. The Load address indicates the address at which the main executable
13313 was loaded; this line may not be present if operating system hasn't relocated
13314 the main executable. The values are given in C style format, with lower case
13315 letters for a-f, and only as many digits present as are necessary.
13316 @end itemize
13318 @noindent
13319 The line terminator sequence at the end of each line, including
13320 the last line is a single @code{LF} character (@code{16#0A#}).
13322 @sp 1
13323 @item
13324 @cartouche
13325 @noindent
13326 Implementation-defined check names.  See 11.5(27).
13327 @end cartouche
13328 @noindent
13329 The implementation defined check name Alignment_Check controls checking of
13330 address clause values for proper alignment (that is, the address supplied
13331 must be consistent with the alignment of the type).
13333 The implementation defined check name Predicate_Check controls whether
13334 predicate checks are generated.
13336 The implementation defined check name Validity_Check controls whether
13337 validity checks are generated.
13339 In addition, a user program can add implementation-defined check names
13340 by means of the pragma Check_Name.
13342 @sp 1
13343 @item
13344 @cartouche
13345 @noindent
13346 The interpretation of each aspect of representation.  See
13347 13.1(20).
13348 @end cartouche
13349 @noindent
13350 See separate section on data representations.
13352 @sp 1
13353 @item
13354 @cartouche
13355 @noindent
13356 Any restrictions placed upon representation items.  See
13357 13.1(20).
13358 @end cartouche
13359 @noindent
13360 See separate section on data representations.
13362 @sp 1
13363 @item
13364 @cartouche
13365 @noindent
13366 The meaning of @code{Size} for indefinite subtypes.  See
13367 13.3(48).
13368 @end cartouche
13369 @noindent
13370 Size for an indefinite subtype is the maximum possible size, except that
13371 for the case of a subprogram parameter, the size of the parameter object
13372 is the actual size.
13374 @sp 1
13375 @item
13376 @cartouche
13377 @noindent
13378 The default external representation for a type tag.  See
13379 13.3(75).
13380 @end cartouche
13381 @noindent
13382 The default external representation for a type tag is the fully expanded
13383 name of the type in upper case letters.
13385 @sp 1
13386 @item
13387 @cartouche
13388 @noindent
13389 What determines whether a compilation unit is the same in
13390 two different partitions.  See 13.3(76).
13391 @end cartouche
13392 @noindent
13393 A compilation unit is the same in two different partitions if and only
13394 if it derives from the same source file.
13396 @sp 1
13397 @item
13398 @cartouche
13399 @noindent
13400 Implementation-defined components.  See 13.5.1(15).
13401 @end cartouche
13402 @noindent
13403 The only implementation defined component is the tag for a tagged type,
13404 which contains a pointer to the dispatching table.
13406 @sp 1
13407 @item
13408 @cartouche
13409 @noindent
13410 If @code{Word_Size} = @code{Storage_Unit}, the default bit
13411 ordering.  See 13.5.3(5).
13412 @end cartouche
13413 @noindent
13414 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
13415 implementation, so no non-default bit ordering is supported.  The default
13416 bit ordering corresponds to the natural endianness of the target architecture.
13418 @sp 1
13419 @item
13420 @cartouche
13421 @noindent
13422 The contents of the visible part of package @code{System}
13423 and its language-defined children.  See 13.7(2).
13424 @end cartouche
13425 @noindent
13426 See the definition of these packages in files @file{system.ads} and
13427 @file{s-stoele.ads}. Note that two declarations are added to package
13428 System.
13430 @smallexample @c ada
13431    Max_Priority           : constant Positive :=
13432      Priority'Last;
13433    Max_Interrupt_Priority : constant Positive :=
13434      Interrupt_Priority'Last;
13435 @end smallexample
13437 @sp 1
13438 @item
13439 @cartouche
13440 @noindent
13441 The contents of the visible part of package
13442 @code{System.Machine_Code}, and the meaning of
13443 @code{code_statements}.  See 13.8(7).
13444 @end cartouche
13445 @noindent
13446 See the definition and documentation in file @file{s-maccod.ads}.
13448 @sp 1
13449 @item
13450 @cartouche
13451 @noindent
13452 The effect of unchecked conversion.  See 13.9(11).
13453 @end cartouche
13454 @noindent
13455 Unchecked conversion between types of the same size
13456 results in an uninterpreted transmission of the bits from one type
13457 to the other.  If the types are of unequal sizes, then in the case of
13458 discrete types, a shorter source is first zero or sign extended as
13459 necessary, and a shorter target is simply truncated on the left.
13460 For all non-discrete types, the source is first copied if necessary
13461 to ensure that the alignment requirements of the target are met, then
13462 a pointer is constructed to the source value, and the result is obtained
13463 by dereferencing this pointer after converting it to be a pointer to the
13464 target type. Unchecked conversions where the target subtype is an
13465 unconstrained array are not permitted. If the target alignment is
13466 greater than the source alignment, then a copy of the result is
13467 made with appropriate alignment
13469 @sp 1
13470 @item
13471 @cartouche
13472 @noindent
13473 The semantics of operations on invalid representations.
13474 See 13.9.2(10-11).
13475 @end cartouche
13476 @noindent
13477 For assignments and other operations where the use of invalid values cannot
13478 result in erroneous behavior, the compiler ignores the possibility of invalid
13479 values. An exception is raised at the point where an invalid value would
13480 result in erroneous behavior. For example executing:
13482 @smallexample @c ada
13483 procedure invalidvals is
13484    X : Integer := -1;
13485    Y : Natural range 1 .. 10;
13486    for Y'Address use X'Address;
13487    Z : Natural range 1 .. 10;
13488    A : array (Natural range 1 .. 10) of Integer;
13489 begin
13490    Z := Y;     -- no exception
13491    A (Z) := 3; -- exception raised;
13492 end;
13493 @end smallexample
13495 @noindent
13496 As indicated, an exception is raised on the array assignment, but not
13497 on the simple assignment of the invalid negative value from Y to Z.
13499 @sp 1
13500 @item
13501 @cartouche
13502 @noindent
13503 The manner of choosing a storage pool for an access type
13504 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
13505 @end cartouche
13506 @noindent
13507 There are 3 different standard pools used by the compiler when
13508 @code{Storage_Pool} is not specified depending whether the type is local
13509 to a subprogram or defined at the library level and whether
13510 @code{Storage_Size}is specified or not.  See documentation in the runtime
13511 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
13512 @code{System.Pool_Local} in files @file{s-poosiz.ads},
13513 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
13514 default pools used.
13516 @sp 1
13517 @item
13518 @cartouche
13519 @noindent
13520 Whether or not the implementation provides user-accessible
13521 names for the standard pool type(s).  See 13.11(17).
13522 @end cartouche
13523 @noindent
13525 See documentation in the sources of the run time mentioned in the previous
13526 paragraph.  All these pools are accessible by means of @code{with}'ing
13527 these units.
13529 @sp 1
13530 @item
13531 @cartouche
13532 @noindent
13533 The meaning of @code{Storage_Size}.  See 13.11(18).
13534 @end cartouche
13535 @noindent
13536 @code{Storage_Size} is measured in storage units, and refers to the
13537 total space available for an access type collection, or to the primary
13538 stack space for a task.
13540 @sp 1
13541 @item
13542 @cartouche
13543 @noindent
13544 Implementation-defined aspects of storage pools.  See
13545 13.11(22).
13546 @end cartouche
13547 @noindent
13548 See documentation in the sources of the run time mentioned in the
13549 paragraph about standard storage pools above
13550 for details on GNAT-defined aspects of storage pools.
13552 @sp 1
13553 @item
13554 @cartouche
13555 @noindent
13556 The set of restrictions allowed in a pragma
13557 @code{Restrictions}.  See 13.12(7).
13558 @end cartouche
13559 @noindent
13560 @xref{Standard and Implementation Defined Restrictions}.
13562 @sp 1
13563 @item
13564 @cartouche
13565 @noindent
13566 The consequences of violating limitations on
13567 @code{Restrictions} pragmas.  See 13.12(9).
13568 @end cartouche
13569 @noindent
13570 Restrictions that can be checked at compile time result in illegalities
13571 if violated.  Currently there are no other consequences of violating
13572 restrictions.
13574 @sp 1
13575 @item
13576 @cartouche
13577 @noindent
13578 The representation used by the @code{Read} and
13579 @code{Write} attributes of elementary types in terms of stream
13580 elements.  See 13.13.2(9).
13581 @end cartouche
13582 @noindent
13583 The representation is the in-memory representation of the base type of
13584 the type, using the number of bits corresponding to the
13585 @code{@var{type}'Size} value, and the natural ordering of the machine.
13587 @sp 1
13588 @item
13589 @cartouche
13590 @noindent
13591 The names and characteristics of the numeric subtypes
13592 declared in the visible part of package @code{Standard}.  See A.1(3).
13593 @end cartouche
13594 @noindent
13595 See items describing the integer and floating-point types supported.
13597 @sp 1
13598 @item
13599 @cartouche
13600 @noindent
13601 The string returned by @code{Character_Set_Version}.
13602 See A.3.5(3).
13603 @end cartouche
13604 @noindent
13605 @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns
13606 the string "Unicode 4.0", referring to version 4.0 of the
13607 Unicode specification.
13609 @sp 1
13610 @item
13611 @cartouche
13612 @noindent
13613 The accuracy actually achieved by the elementary
13614 functions.  See A.5.1(1).
13615 @end cartouche
13616 @noindent
13617 The elementary functions correspond to the functions available in the C
13618 library.  Only fast math mode is implemented.
13620 @sp 1
13621 @item
13622 @cartouche
13623 @noindent
13624 The sign of a zero result from some of the operators or
13625 functions in @code{Numerics.Generic_Elementary_Functions}, when
13626 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
13627 @end cartouche
13628 @noindent
13629 The sign of zeroes follows the requirements of the IEEE 754 standard on
13630 floating-point.
13632 @sp 1
13633 @item
13634 @cartouche
13635 @noindent
13636 The value of
13637 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
13638 @end cartouche
13639 @noindent
13640 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13642 @sp 1
13643 @item
13644 @cartouche
13645 @noindent
13646 The value of
13647 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
13648 @end cartouche
13649 @noindent
13650 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13652 @sp 1
13653 @item
13654 @cartouche
13655 @noindent
13656 The algorithms for random number generation.  See
13657 A.5.2(32).
13658 @end cartouche
13659 @noindent
13660 The algorithm is the Mersenne Twister, as documented in the source file
13661 @file{s-rannum.adb}. This version of the algorithm has a period of
13662 2**19937-1.
13664 @sp 1
13665 @item
13666 @cartouche
13667 @noindent
13668 The string representation of a random number generator's
13669 state.  See A.5.2(38).
13670 @end cartouche
13671 @noindent
13672 The value returned by the Image function is the concatenation of
13673 the fixed-width decimal representations of the 624 32-bit integers
13674 of the state vector.
13676 @sp 1
13677 @item
13678 @cartouche
13679 @noindent
13680 The minimum time interval between calls to the
13681 time-dependent Reset procedure that are guaranteed to initiate different
13682 random number sequences.  See A.5.2(45).
13683 @end cartouche
13684 @noindent
13685 The minimum period between reset calls to guarantee distinct series of
13686 random numbers is one microsecond.
13688 @sp 1
13689 @item
13690 @cartouche
13691 @noindent
13692 The values of the @code{Model_Mantissa},
13693 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
13694 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
13695 Annex is not supported.  See A.5.3(72).
13696 @end cartouche
13697 @noindent
13698 Run the compiler with @option{-gnatS} to produce a listing of package
13699 @code{Standard}, has the values of all numeric attributes.
13701 @sp 1
13702 @item
13703 @cartouche
13704 @noindent
13705 Any implementation-defined characteristics of the
13706 input-output packages.  See A.7(14).
13707 @end cartouche
13708 @noindent
13709 There are no special implementation defined characteristics for these
13710 packages.
13712 @sp 1
13713 @item
13714 @cartouche
13715 @noindent
13716 The value of @code{Buffer_Size} in @code{Storage_IO}.  See
13717 A.9(10).
13718 @end cartouche
13719 @noindent
13720 All type representations are contiguous, and the @code{Buffer_Size} is
13721 the value of @code{@var{type}'Size} rounded up to the next storage unit
13722 boundary.
13724 @sp 1
13725 @item
13726 @cartouche
13727 @noindent
13728 External files for standard input, standard output, and
13729 standard error See A.10(5).
13730 @end cartouche
13731 @noindent
13732 These files are mapped onto the files provided by the C streams
13733 libraries.  See source file @file{i-cstrea.ads} for further details.
13735 @sp 1
13736 @item
13737 @cartouche
13738 @noindent
13739 The accuracy of the value produced by @code{Put}.  See
13740 A.10.9(36).
13741 @end cartouche
13742 @noindent
13743 If more digits are requested in the output than are represented by the
13744 precision of the value, zeroes are output in the corresponding least
13745 significant digit positions.
13747 @sp 1
13748 @item
13749 @cartouche
13750 @noindent
13751 The meaning of @code{Argument_Count}, @code{Argument}, and
13752 @code{Command_Name}.  See A.15(1).
13753 @end cartouche
13754 @noindent
13755 These are mapped onto the @code{argv} and @code{argc} parameters of the
13756 main program in the natural manner.
13758 @sp 1
13759 @item
13760 @cartouche
13761 @noindent
13762 The interpretation of the @code{Form} parameter in procedure
13763 @code{Create_Directory}.  See A.16(56).
13764 @end cartouche
13765 @noindent
13766 The @code{Form} parameter is not used.
13768 @sp 1
13769 @item
13770 @cartouche
13771 @noindent
13772 The interpretation of the @code{Form} parameter in procedure
13773 @code{Create_Path}.  See A.16(60).
13774 @end cartouche
13775 @noindent
13776 The @code{Form} parameter is not used.
13778 @sp 1
13779 @item
13780 @cartouche
13781 @noindent
13782 The interpretation of the @code{Form} parameter in procedure
13783 @code{Copy_File}.  See A.16(68).
13784 @end cartouche
13785 @noindent
13786 The @code{Form} parameter is case-insensitive.
13788 Two fields are recognized in the @code{Form} parameter:
13790 @table @code
13792 @item preserve=<value>
13794 @item mode=<value>
13796 @end table
13798 @noindent
13799 <value> starts immediately after the character '=' and ends with the
13800 character immediately preceding the next comma (',') or with the last
13801 character of the parameter.
13803 The only possible values for preserve= are:
13805 @table @code
13807 @item no_attributes
13808 Do not try to preserve any file attributes. This is the default if no
13809 preserve= is found in Form.
13811 @item all_attributes
13812 Try to preserve all file attributes (timestamps, access rights).
13814 @item timestamps
13815 Preserve the timestamp of the copied file, but not the other file attributes.
13817 @end table
13819 @noindent
13820 The only possible values for mode= are:
13822 @table @code
13824 @item copy
13825 Only do the copy if the destination file does not already exist. If it already
13826 exists, Copy_File fails.
13828 @item overwrite
13829 Copy the file in all cases. Overwrite an already existing destination file.
13831 @item append
13832 Append the original file to the destination file. If the destination file does
13833 not exist, the destination file is a copy of the source file. When mode=append,
13834 the field preserve=, if it exists, is not taken into account.
13836 @end table
13838 @noindent
13839 If the Form parameter includes one or both of the fields and the value or
13840 values are incorrect, Copy_file fails with Use_Error.
13842 Examples of correct Forms:
13844 @smallexample
13845 Form => "preserve=no_attributes,mode=overwrite" (the default)
13846 Form => "mode=append"
13847 Form => "mode=copy, preserve=all_attributes"
13848 @end smallexample
13850 @noindent
13851 Examples of incorrect Forms
13853 @smallexample
13854 Form => "preserve=junk"
13855 Form => "mode=internal, preserve=timestamps"
13856 @end smallexample
13858 @sp 1
13859 @item
13860 @cartouche
13861 @noindent
13862 The interpretation of the @code{Pattern} parameter, when not the null string,
13863 in the @code{Start_Search} and @code{Search} procedures.
13864 See A.16(104) and A.16(112).
13865 @end cartouche
13866 @noindent
13867 When the @code{Pattern} parameter is not the null string, it is interpreted
13868 according to the syntax of regular expressions as defined in the
13869 @code{GNAT.Regexp} package.
13870 @xref{GNAT.Regexp (g-regexp.ads)}.
13872 @sp 1
13873 @item
13874 @cartouche
13875 @noindent
13876 Implementation-defined convention names.  See B.1(11).
13877 @end cartouche
13878 @noindent
13879 The following convention names are supported
13881 @table @code
13882 @item  Ada
13884 @item Ada_Pass_By_Copy
13885 Allowed for any types except by-reference types such as limited
13886 records. Compatible with convention Ada, but causes any parameters
13887 with this convention to be passed by copy.
13888 @item Ada_Pass_By_Reference
13889 Allowed for any types except by-copy types such as scalars.
13890 Compatible with convention Ada, but causes any parameters
13891 with this convention to be passed by reference.
13892 @item Assembler
13893 Assembly language
13894 @item Asm
13895 Synonym for Assembler
13896 @item Assembly
13897 Synonym for Assembler
13898 @item C
13900 @item C_Pass_By_Copy
13901 Allowed only for record types, like C, but also notes that record
13902 is to be passed by copy rather than reference.
13903 @item COBOL
13904 COBOL
13905 @item C_Plus_Plus (or CPP)
13907 @item Default
13908 Treated the same as C
13909 @item External
13910 Treated the same as C
13911 @item Fortran
13912 Fortran
13913 @item Intrinsic
13914 For support of pragma @code{Import} with convention Intrinsic, see
13915 separate section on Intrinsic Subprograms.
13916 @item Stdcall
13917 Stdcall (used for Windows implementations only).  This convention correspond
13918 to the WINAPI (previously called Pascal convention) C/C++ convention under
13919 Windows.  A routine with this convention cleans the stack before
13920 exit. This pragma cannot be applied to a dispatching call.
13921 @item DLL
13922 Synonym for Stdcall
13923 @item Win32
13924 Synonym for Stdcall
13925 @item Stubbed
13926 Stubbed is a special convention used to indicate that the body of the
13927 subprogram will be entirely ignored.  Any call to the subprogram
13928 is converted into a raise of the @code{Program_Error} exception.  If a
13929 pragma @code{Import} specifies convention @code{stubbed} then no body need
13930 be present at all.  This convention is useful during development for the
13931 inclusion of subprograms whose body has not yet been written.
13933 @end table
13934 @noindent
13935 In addition, all otherwise unrecognized convention names are also
13936 treated as being synonymous with convention C@.  In all implementations
13937 except for VMS, use of such other names results in a warning.  In VMS
13938 implementations, these names are accepted silently.
13940 @sp 1
13941 @item
13942 @cartouche
13943 @noindent
13944 The meaning of link names.  See B.1(36).
13945 @end cartouche
13946 @noindent
13947 Link names are the actual names used by the linker.
13949 @sp 1
13950 @item
13951 @cartouche
13952 @noindent
13953 The manner of choosing link names when neither the link
13954 name nor the address of an imported or exported entity is specified.  See
13955 B.1(36).
13956 @end cartouche
13957 @noindent
13958 The default linker name is that which would be assigned by the relevant
13959 external language, interpreting the Ada name as being in all lower case
13960 letters.
13962 @sp 1
13963 @item
13964 @cartouche
13965 @noindent
13966 The effect of pragma @code{Linker_Options}.  See B.1(37).
13967 @end cartouche
13968 @noindent
13969 The string passed to @code{Linker_Options} is presented uninterpreted as
13970 an argument to the link command, unless it contains ASCII.NUL characters.
13971 NUL characters if they appear act as argument separators, so for example
13973 @smallexample @c ada
13974 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
13975 @end smallexample
13977 @noindent
13978 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
13979 linker. The order of linker options is preserved for a given unit. The final
13980 list of options passed to the linker is in reverse order of the elaboration
13981 order. For example, linker options for a body always appear before the options
13982 from the corresponding package spec.
13984 @sp 1
13985 @item
13986 @cartouche
13987 @noindent
13988 The contents of the visible part of package
13989 @code{Interfaces} and its language-defined descendants.  See B.2(1).
13990 @end cartouche
13991 @noindent
13992 See files with prefix @file{i-} in the distributed library.
13994 @sp 1
13995 @item
13996 @cartouche
13997 @noindent
13998 Implementation-defined children of package
13999 @code{Interfaces}.  The contents of the visible part of package
14000 @code{Interfaces}.  See B.2(11).
14001 @end cartouche
14002 @noindent
14003 See files with prefix @file{i-} in the distributed library.
14005 @sp 1
14006 @item
14007 @cartouche
14008 @noindent
14009 The types @code{Floating}, @code{Long_Floating},
14010 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
14011 @code{COBOL_Character}; and the initialization of the variables
14012 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
14013 @code{Interfaces.COBOL}.  See B.4(50).
14014 @end cartouche
14015 @noindent
14016 @table @code
14017 @item Floating
14018 Float
14019 @item Long_Floating
14020 (Floating) Long_Float
14021 @item Binary
14022 Integer
14023 @item Long_Binary
14024 Long_Long_Integer
14025 @item Decimal_Element
14026 Character
14027 @item COBOL_Character
14028 Character
14029 @end table
14031 @noindent
14032 For initialization, see the file @file{i-cobol.ads} in the distributed library.
14034 @sp 1
14035 @item
14036 @cartouche
14037 @noindent
14038 Support for access to machine instructions.  See C.1(1).
14039 @end cartouche
14040 @noindent
14041 See documentation in file @file{s-maccod.ads} in the distributed library.
14043 @sp 1
14044 @item
14045 @cartouche
14046 @noindent
14047 Implementation-defined aspects of access to machine
14048 operations.  See C.1(9).
14049 @end cartouche
14050 @noindent
14051 See documentation in file @file{s-maccod.ads} in the distributed library.
14053 @sp 1
14054 @item
14055 @cartouche
14056 @noindent
14057 Implementation-defined aspects of interrupts.  See C.3(2).
14058 @end cartouche
14059 @noindent
14060 Interrupts are mapped to signals or conditions as appropriate.  See
14061 definition of unit
14062 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
14063 on the interrupts supported on a particular target.
14065 @sp 1
14066 @item
14067 @cartouche
14068 @noindent
14069 Implementation-defined aspects of pre-elaboration.  See
14070 C.4(13).
14071 @end cartouche
14072 @noindent
14073 GNAT does not permit a partition to be restarted without reloading,
14074 except under control of the debugger.
14076 @sp 1
14077 @item
14078 @cartouche
14079 @noindent
14080 The semantics of pragma @code{Discard_Names}.  See C.5(7).
14081 @end cartouche
14082 @noindent
14083 Pragma @code{Discard_Names} causes names of enumeration literals to
14084 be suppressed.  In the presence of this pragma, the Image attribute
14085 provides the image of the Pos of the literal, and Value accepts
14086 Pos values.
14088 @sp 1
14089 @item
14090 @cartouche
14091 @noindent
14092 The result of the @code{Task_Identification.Image}
14093 attribute.  See C.7.1(7).
14094 @end cartouche
14095 @noindent
14096 The result of this attribute is a string that identifies
14097 the object or component that denotes a given task. If a variable @code{Var}
14098 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
14099 where the suffix
14100 is the hexadecimal representation of the virtual address of the corresponding
14101 task control block. If the variable is an array of tasks, the image of each
14102 task will have the form of an indexed component indicating the position of a
14103 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
14104 component of a record, the image of the task will have the form of a selected
14105 component. These rules are fully recursive, so that the image of a task that
14106 is a subcomponent of a composite object corresponds to the expression that
14107 designates this task.
14108 @noindent
14109 If a task is created by an allocator, its image depends on the context. If the
14110 allocator is part of an object declaration, the rules described above are used
14111 to construct its image, and this image is not affected by subsequent
14112 assignments. If the allocator appears within an expression, the image
14113 includes only the name of the task type.
14114 @noindent
14115 If the configuration pragma Discard_Names is present, or if the restriction
14116 No_Implicit_Heap_Allocation is in effect,  the image reduces to
14117 the numeric suffix, that is to say the hexadecimal representation of the
14118 virtual address of the control block of the task.
14119 @sp 1
14120 @item
14121 @cartouche
14122 @noindent
14123 The value of @code{Current_Task} when in a protected entry
14124 or interrupt handler.  See C.7.1(17).
14125 @end cartouche
14126 @noindent
14127 Protected entries or interrupt handlers can be executed by any
14128 convenient thread, so the value of @code{Current_Task} is undefined.
14130 @sp 1
14131 @item
14132 @cartouche
14133 @noindent
14134 The effect of calling @code{Current_Task} from an entry
14135 body or interrupt handler.  See C.7.1(19).
14136 @end cartouche
14137 @noindent
14138 The effect of calling @code{Current_Task} from an entry body or
14139 interrupt handler is to return the identification of the task currently
14140 executing the code.
14142 @sp 1
14143 @item
14144 @cartouche
14145 @noindent
14146 Implementation-defined aspects of
14147 @code{Task_Attributes}.  See C.7.2(19).
14148 @end cartouche
14149 @noindent
14150 There are no implementation-defined aspects of @code{Task_Attributes}.
14152 @sp 1
14153 @item
14154 @cartouche
14155 @noindent
14156 Values of all @code{Metrics}.  See D(2).
14157 @end cartouche
14158 @noindent
14159 The metrics information for GNAT depends on the performance of the
14160 underlying operating system.  The sources of the run-time for tasking
14161 implementation, together with the output from @option{-gnatG} can be
14162 used to determine the exact sequence of operating systems calls made
14163 to implement various tasking constructs.  Together with appropriate
14164 information on the performance of the underlying operating system,
14165 on the exact target in use, this information can be used to determine
14166 the required metrics.
14168 @sp 1
14169 @item
14170 @cartouche
14171 @noindent
14172 The declarations of @code{Any_Priority} and
14173 @code{Priority}.  See D.1(11).
14174 @end cartouche
14175 @noindent
14176 See declarations in file @file{system.ads}.
14178 @sp 1
14179 @item
14180 @cartouche
14181 @noindent
14182 Implementation-defined execution resources.  See D.1(15).
14183 @end cartouche
14184 @noindent
14185 There are no implementation-defined execution resources.
14187 @sp 1
14188 @item
14189 @cartouche
14190 @noindent
14191 Whether, on a multiprocessor, a task that is waiting for
14192 access to a protected object keeps its processor busy.  See D.2.1(3).
14193 @end cartouche
14194 @noindent
14195 On a multi-processor, a task that is waiting for access to a protected
14196 object does not keep its processor busy.
14198 @sp 1
14199 @item
14200 @cartouche
14201 @noindent
14202 The affect of implementation defined execution resources
14203 on task dispatching.  See D.2.1(9).
14204 @end cartouche
14205 @noindent
14206 Tasks map to threads in the threads package used by GNAT@.  Where possible
14207 and appropriate, these threads correspond to native threads of the
14208 underlying operating system.
14210 @sp 1
14211 @item
14212 @cartouche
14213 @noindent
14214 Implementation-defined @code{policy_identifiers} allowed
14215 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
14216 @end cartouche
14217 @noindent
14218 There are no implementation-defined policy-identifiers allowed in this
14219 pragma.
14221 @sp 1
14222 @item
14223 @cartouche
14224 @noindent
14225 Implementation-defined aspects of priority inversion.  See
14226 D.2.2(16).
14227 @end cartouche
14228 @noindent
14229 Execution of a task cannot be preempted by the implementation processing
14230 of delay expirations for lower priority tasks.
14232 @sp 1
14233 @item
14234 @cartouche
14235 @noindent
14236 Implementation-defined task dispatching.  See D.2.2(18).
14237 @end cartouche
14238 @noindent
14239 The policy is the same as that of the underlying threads implementation.
14241 @sp 1
14242 @item
14243 @cartouche
14244 @noindent
14245 Implementation-defined @code{policy_identifiers} allowed
14246 in a pragma @code{Locking_Policy}.  See D.3(4).
14247 @end cartouche
14248 @noindent
14249 The two implementation defined policies permitted in GNAT are
14250 @code{Inheritance_Locking} and  @code{Conccurent_Readers_Locking}.  On
14251 targets that support the @code{Inheritance_Locking} policy, locking is
14252 implemented by inheritance, i.e.@: the task owning the lock operates
14253 at a priority equal to the highest priority of any task currently
14254 requesting the lock.  On targets that support the
14255 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
14256 read/write lock allowing multiple propected object functions to enter
14257 concurrently.
14259 @sp 1
14260 @item
14261 @cartouche
14262 @noindent
14263 Default ceiling priorities.  See D.3(10).
14264 @end cartouche
14265 @noindent
14266 The ceiling priority of protected objects of the type
14267 @code{System.Interrupt_Priority'Last} as described in the Ada
14268 Reference Manual D.3(10),
14270 @sp 1
14271 @item
14272 @cartouche
14273 @noindent
14274 The ceiling of any protected object used internally by
14275 the implementation.  See D.3(16).
14276 @end cartouche
14277 @noindent
14278 The ceiling priority of internal protected objects is
14279 @code{System.Priority'Last}.
14281 @sp 1
14282 @item
14283 @cartouche
14284 @noindent
14285 Implementation-defined queuing policies.  See D.4(1).
14286 @end cartouche
14287 @noindent
14288 There are no implementation-defined queuing policies.
14290 @sp 1
14291 @item
14292 @cartouche
14293 @noindent
14294 On a multiprocessor, any conditions that cause the
14295 completion of an aborted construct to be delayed later than what is
14296 specified for a single processor.  See D.6(3).
14297 @end cartouche
14298 @noindent
14299 The semantics for abort on a multi-processor is the same as on a single
14300 processor, there are no further delays.
14302 @sp 1
14303 @item
14304 @cartouche
14305 @noindent
14306 Any operations that implicitly require heap storage
14307 allocation.  See D.7(8).
14308 @end cartouche
14309 @noindent
14310 The only operation that implicitly requires heap storage allocation is
14311 task creation.
14313 @sp 1
14314 @item
14315 @cartouche
14316 @noindent
14317 Implementation-defined aspects of pragma
14318 @code{Restrictions}.  See D.7(20).
14319 @end cartouche
14320 @noindent
14321 There are no such implementation-defined aspects.
14323 @sp 1
14324 @item
14325 @cartouche
14326 @noindent
14327 Implementation-defined aspects of package
14328 @code{Real_Time}.  See D.8(17).
14329 @end cartouche
14330 @noindent
14331 There are no implementation defined aspects of package @code{Real_Time}.
14333 @sp 1
14334 @item
14335 @cartouche
14336 @noindent
14337 Implementation-defined aspects of
14338 @code{delay_statements}.  See D.9(8).
14339 @end cartouche
14340 @noindent
14341 Any difference greater than one microsecond will cause the task to be
14342 delayed (see D.9(7)).
14344 @sp 1
14345 @item
14346 @cartouche
14347 @noindent
14348 The upper bound on the duration of interrupt blocking
14349 caused by the implementation.  See D.12(5).
14350 @end cartouche
14351 @noindent
14352 The upper bound is determined by the underlying operating system.  In
14353 no cases is it more than 10 milliseconds.
14355 @sp 1
14356 @item
14357 @cartouche
14358 @noindent
14359 The means for creating and executing distributed
14360 programs.  See E(5).
14361 @end cartouche
14362 @noindent
14363 The GLADE package provides a utility GNATDIST for creating and executing
14364 distributed programs.  See the GLADE reference manual for further details.
14366 @sp 1
14367 @item
14368 @cartouche
14369 @noindent
14370 Any events that can result in a partition becoming
14371 inaccessible.  See E.1(7).
14372 @end cartouche
14373 @noindent
14374 See the GLADE reference manual for full details on such events.
14376 @sp 1
14377 @item
14378 @cartouche
14379 @noindent
14380 The scheduling policies, treatment of priorities, and
14381 management of shared resources between partitions in certain cases.  See
14382 E.1(11).
14383 @end cartouche
14384 @noindent
14385 See the GLADE reference manual for full details on these aspects of
14386 multi-partition execution.
14388 @sp 1
14389 @item
14390 @cartouche
14391 @noindent
14392 Events that cause the version of a compilation unit to
14393 change.  See E.3(5).
14394 @end cartouche
14395 @noindent
14396 Editing the source file of a compilation unit, or the source files of
14397 any units on which it is dependent in a significant way cause the version
14398 to change.  No other actions cause the version number to change.  All changes
14399 are significant except those which affect only layout, capitalization or
14400 comments.
14402 @sp 1
14403 @item
14404 @cartouche
14405 @noindent
14406 Whether the execution of the remote subprogram is
14407 immediately aborted as a result of cancellation.  See E.4(13).
14408 @end cartouche
14409 @noindent
14410 See the GLADE reference manual for details on the effect of abort in
14411 a distributed application.
14413 @sp 1
14414 @item
14415 @cartouche
14416 @noindent
14417 Implementation-defined aspects of the PCS@.  See E.5(25).
14418 @end cartouche
14419 @noindent
14420 See the GLADE reference manual for a full description of all implementation
14421 defined aspects of the PCS@.
14423 @sp 1
14424 @item
14425 @cartouche
14426 @noindent
14427 Implementation-defined interfaces in the PCS@.  See
14428 E.5(26).
14429 @end cartouche
14430 @noindent
14431 See the GLADE reference manual for a full description of all
14432 implementation defined interfaces.
14434 @sp 1
14435 @item
14436 @cartouche
14437 @noindent
14438 The values of named numbers in the package
14439 @code{Decimal}.  See F.2(7).
14440 @end cartouche
14441 @noindent
14442 @table @code
14443 @item Max_Scale
14445 @item Min_Scale
14447 @item Min_Delta
14448 1.0E-18
14449 @item Max_Delta
14450 1.0E+18
14451 @item Max_Decimal_Digits
14453 @end table
14455 @sp 1
14456 @item
14457 @cartouche
14458 @noindent
14459 The value of @code{Max_Picture_Length} in the package
14460 @code{Text_IO.Editing}.  See F.3.3(16).
14461 @end cartouche
14462 @noindent
14465 @sp 1
14466 @item
14467 @cartouche
14468 @noindent
14469 The value of @code{Max_Picture_Length} in the package
14470 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
14471 @end cartouche
14472 @noindent
14475 @sp 1
14476 @item
14477 @cartouche
14478 @noindent
14479 The accuracy actually achieved by the complex elementary
14480 functions and by other complex arithmetic operations.  See G.1(1).
14481 @end cartouche
14482 @noindent
14483 Standard library functions are used for the complex arithmetic
14484 operations.  Only fast math mode is currently supported.
14486 @sp 1
14487 @item
14488 @cartouche
14489 @noindent
14490 The sign of a zero result (or a component thereof) from
14491 any operator or function in @code{Numerics.Generic_Complex_Types}, when
14492 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
14493 @end cartouche
14494 @noindent
14495 The signs of zero values are as recommended by the relevant
14496 implementation advice.
14498 @sp 1
14499 @item
14500 @cartouche
14501 @noindent
14502 The sign of a zero result (or a component thereof) from
14503 any operator or function in
14504 @code{Numerics.Generic_Complex_Elementary_Functions}, when
14505 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
14506 @end cartouche
14507 @noindent
14508 The signs of zero values are as recommended by the relevant
14509 implementation advice.
14511 @sp 1
14512 @item
14513 @cartouche
14514 @noindent
14515 Whether the strict mode or the relaxed mode is the
14516 default.  See G.2(2).
14517 @end cartouche
14518 @noindent
14519 The strict mode is the default.  There is no separate relaxed mode.  GNAT
14520 provides a highly efficient implementation of strict mode.
14522 @sp 1
14523 @item
14524 @cartouche
14525 @noindent
14526 The result interval in certain cases of fixed-to-float
14527 conversion.  See G.2.1(10).
14528 @end cartouche
14529 @noindent
14530 For cases where the result interval is implementation dependent, the
14531 accuracy is that provided by performing all operations in 64-bit IEEE
14532 floating-point format.
14534 @sp 1
14535 @item
14536 @cartouche
14537 @noindent
14538 The result of a floating point arithmetic operation in
14539 overflow situations, when the @code{Machine_Overflows} attribute of the
14540 result type is @code{False}.  See G.2.1(13).
14541 @end cartouche
14542 @noindent
14543 Infinite and NaN values are produced as dictated by the IEEE
14544 floating-point standard.
14546 Note that on machines that are not fully compliant with the IEEE
14547 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
14548 must be used for achieving IEEE conforming behavior (although at the cost
14549 of a significant performance penalty), so infinite and NaN values are
14550 properly generated.
14552 @sp 1
14553 @item
14554 @cartouche
14555 @noindent
14556 The result interval for division (or exponentiation by a
14557 negative exponent), when the floating point hardware implements division
14558 as multiplication by a reciprocal.  See G.2.1(16).
14559 @end cartouche
14560 @noindent
14561 Not relevant, division is IEEE exact.
14563 @sp 1
14564 @item
14565 @cartouche
14566 @noindent
14567 The definition of close result set, which determines the
14568 accuracy of certain fixed point multiplications and divisions.  See
14569 G.2.3(5).
14570 @end cartouche
14571 @noindent
14572 Operations in the close result set are performed using IEEE long format
14573 floating-point arithmetic.  The input operands are converted to
14574 floating-point, the operation is done in floating-point, and the result
14575 is converted to the target type.
14577 @sp 1
14578 @item
14579 @cartouche
14580 @noindent
14581 Conditions on a @code{universal_real} operand of a fixed
14582 point multiplication or division for which the result shall be in the
14583 perfect result set.  See G.2.3(22).
14584 @end cartouche
14585 @noindent
14586 The result is only defined to be in the perfect result set if the result
14587 can be computed by a single scaling operation involving a scale factor
14588 representable in 64-bits.
14590 @sp 1
14591 @item
14592 @cartouche
14593 @noindent
14594 The result of a fixed point arithmetic operation in
14595 overflow situations, when the @code{Machine_Overflows} attribute of the
14596 result type is @code{False}.  See G.2.3(27).
14597 @end cartouche
14598 @noindent
14599 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
14600 types.
14602 @sp 1
14603 @item
14604 @cartouche
14605 @noindent
14606 The result of an elementary function reference in
14607 overflow situations, when the @code{Machine_Overflows} attribute of the
14608 result type is @code{False}.  See G.2.4(4).
14609 @end cartouche
14610 @noindent
14611 IEEE infinite and Nan values are produced as appropriate.
14613 @sp 1
14614 @item
14615 @cartouche
14616 @noindent
14617 The value of the angle threshold, within which certain
14618 elementary functions, complex arithmetic operations, and complex
14619 elementary functions yield results conforming to a maximum relative
14620 error bound.  See G.2.4(10).
14621 @end cartouche
14622 @noindent
14623 Information on this subject is not yet available.
14625 @sp 1
14626 @item
14627 @cartouche
14628 @noindent
14629 The accuracy of certain elementary functions for
14630 parameters beyond the angle threshold.  See G.2.4(10).
14631 @end cartouche
14632 @noindent
14633 Information on this subject is not yet available.
14635 @sp 1
14636 @item
14637 @cartouche
14638 @noindent
14639 The result of a complex arithmetic operation or complex
14640 elementary function reference in overflow situations, when the
14641 @code{Machine_Overflows} attribute of the corresponding real type is
14642 @code{False}.  See G.2.6(5).
14643 @end cartouche
14644 @noindent
14645 IEEE infinite and Nan values are produced as appropriate.
14647 @sp 1
14648 @item
14649 @cartouche
14650 @noindent
14651 The accuracy of certain complex arithmetic operations and
14652 certain complex elementary functions for parameters (or components
14653 thereof) beyond the angle threshold.  See G.2.6(8).
14654 @end cartouche
14655 @noindent
14656 Information on those subjects is not yet available.
14658 @sp 1
14659 @item
14660 @cartouche
14661 @noindent
14662 Information regarding bounded errors and erroneous
14663 execution.  See H.2(1).
14664 @end cartouche
14665 @noindent
14666 Information on this subject is not yet available.
14668 @sp 1
14669 @item
14670 @cartouche
14671 @noindent
14672 Implementation-defined aspects of pragma
14673 @code{Inspection_Point}.  See H.3.2(8).
14674 @end cartouche
14675 @noindent
14676 Pragma @code{Inspection_Point} ensures that the variable is live and can
14677 be examined by the debugger at the inspection point.
14679 @sp 1
14680 @item
14681 @cartouche
14682 @noindent
14683 Implementation-defined aspects of pragma
14684 @code{Restrictions}.  See H.4(25).
14685 @end cartouche
14686 @noindent
14687 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
14688 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
14689 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
14691 @sp 1
14692 @item
14693 @cartouche
14694 @noindent
14695 Any restrictions on pragma @code{Restrictions}.  See
14696 H.4(27).
14697 @end cartouche
14698 @noindent
14699 There are no restrictions on pragma @code{Restrictions}.
14701 @end itemize
14704 @c =======================
14705 @node Intrinsic Subprograms
14706 @chapter Intrinsic Subprograms
14707 @cindex Intrinsic Subprograms
14709 @menu
14710 * Intrinsic Operators::
14711 * Compilation_Date::
14712 * Compilation_Time::
14713 * Enclosing_Entity::
14714 * Exception_Information::
14715 * Exception_Message::
14716 * Exception_Name::
14717 * File::
14718 * Line::
14719 * Shifts and Rotates::
14720 * Source_Location::
14721 @end menu
14723 @noindent
14724 GNAT allows a user application program to write the declaration:
14726 @smallexample @c ada
14727    pragma Import (Intrinsic, name);
14728 @end smallexample
14730 @noindent
14731 providing that the name corresponds to one of the implemented intrinsic
14732 subprograms in GNAT, and that the parameter profile of the referenced
14733 subprogram meets the requirements.  This chapter describes the set of
14734 implemented intrinsic subprograms, and the requirements on parameter profiles.
14735 Note that no body is supplied; as with other uses of pragma Import, the
14736 body is supplied elsewhere (in this case by the compiler itself).  Note
14737 that any use of this feature is potentially non-portable, since the
14738 Ada standard does not require Ada compilers to implement this feature.
14740 @node Intrinsic Operators
14741 @section Intrinsic Operators
14742 @cindex Intrinsic operator
14744 @noindent
14745 All the predefined numeric operators in package Standard
14746 in @code{pragma Import (Intrinsic,..)}
14747 declarations.  In the binary operator case, the operands must have the same
14748 size.  The operand or operands must also be appropriate for
14749 the operator.  For example, for addition, the operands must
14750 both be floating-point or both be fixed-point, and the
14751 right operand for @code{"**"} must have a root type of
14752 @code{Standard.Integer'Base}.
14753 You can use an intrinsic operator declaration as in the following example:
14755 @smallexample @c ada
14756    type Int1 is new Integer;
14757    type Int2 is new Integer;
14759    function "+" (X1 : Int1; X2 : Int2) return Int1;
14760    function "+" (X1 : Int1; X2 : Int2) return Int2;
14761    pragma Import (Intrinsic, "+");
14762 @end smallexample
14764 @noindent
14765 This declaration would permit ``mixed mode'' arithmetic on items
14766 of the differing types @code{Int1} and @code{Int2}.
14767 It is also possible to specify such operators for private types, if the
14768 full views are appropriate arithmetic types.
14770 @node Compilation_Date
14771 @section Compilation_Date
14772 @cindex Compilation_Date
14773 @noindent
14774 This intrinsic subprogram is used in the implementation of the
14775 library package @code{GNAT.Source_Info}.  The only useful use of the
14776 intrinsic import in this case is the one in this unit, so an
14777 application program should simply call the function
14778 @code{GNAT.Source_Info.Compilation_Date} to obtain the date of
14779 the current compilation (in local time format MMM DD YYYY).
14781 @node Compilation_Time
14782 @section Compilation_Time
14783 @cindex Compilation_Time
14784 @noindent
14785 This intrinsic subprogram is used in the implementation of the
14786 library package @code{GNAT.Source_Info}.  The only useful use of the
14787 intrinsic import in this case is the one in this unit, so an
14788 application program should simply call the function
14789 @code{GNAT.Source_Info.Compilation_Time} to obtain the time of
14790 the current compilation (in local time format HH:MM:SS).
14792 @node Enclosing_Entity
14793 @section Enclosing_Entity
14794 @cindex Enclosing_Entity
14795 @noindent
14796 This intrinsic subprogram is used in the implementation of the
14797 library package @code{GNAT.Source_Info}.  The only useful use of the
14798 intrinsic import in this case is the one in this unit, so an
14799 application program should simply call the function
14800 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
14801 the current subprogram, package, task, entry, or protected subprogram.
14803 @node Exception_Information
14804 @section Exception_Information
14805 @cindex Exception_Information'
14806 @noindent
14807 This intrinsic subprogram is used in the implementation of the
14808 library package @code{GNAT.Current_Exception}.  The only useful
14809 use of the intrinsic import in this case is the one in this unit,
14810 so an application program should simply call the function
14811 @code{GNAT.Current_Exception.Exception_Information} to obtain
14812 the exception information associated with the current exception.
14814 @node Exception_Message
14815 @section Exception_Message
14816 @cindex Exception_Message
14817 @noindent
14818 This intrinsic subprogram is used in the implementation of the
14819 library package @code{GNAT.Current_Exception}.  The only useful
14820 use of the intrinsic import in this case is the one in this unit,
14821 so an application program should simply call the function
14822 @code{GNAT.Current_Exception.Exception_Message} to obtain
14823 the message associated with the current exception.
14825 @node Exception_Name
14826 @section Exception_Name
14827 @cindex Exception_Name
14828 @noindent
14829 This intrinsic subprogram is used in the implementation of the
14830 library package @code{GNAT.Current_Exception}.  The only useful
14831 use of the intrinsic import in this case is the one in this unit,
14832 so an application program should simply call the function
14833 @code{GNAT.Current_Exception.Exception_Name} to obtain
14834 the name of the current exception.
14836 @node File
14837 @section File
14838 @cindex File
14839 @noindent
14840 This intrinsic subprogram is used in the implementation of the
14841 library package @code{GNAT.Source_Info}.  The only useful use of the
14842 intrinsic import in this case is the one in this unit, so an
14843 application program should simply call the function
14844 @code{GNAT.Source_Info.File} to obtain the name of the current
14845 file.
14847 @node Line
14848 @section Line
14849 @cindex Line
14850 @noindent
14851 This intrinsic subprogram is used in the implementation of the
14852 library package @code{GNAT.Source_Info}.  The only useful use of the
14853 intrinsic import in this case is the one in this unit, so an
14854 application program should simply call the function
14855 @code{GNAT.Source_Info.Line} to obtain the number of the current
14856 source line.
14858 @node Shifts and Rotates
14859 @section Shifts and Rotates
14860 @cindex Shift_Left
14861 @cindex Shift_Right
14862 @cindex Shift_Right_Arithmetic
14863 @cindex Rotate_Left
14864 @cindex Rotate_Right
14865 @noindent
14866 In standard Ada, the shift and rotate functions are available only
14867 for the predefined modular types in package @code{Interfaces}.  However, in
14868 GNAT it is possible to define these functions for any integer
14869 type (signed or modular), as in this example:
14871 @smallexample @c ada
14872    function Shift_Left
14873      (Value  : T;
14874       Amount : Natural) return T;
14875 @end smallexample
14877 @noindent
14878 The function name must be one of
14879 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
14880 Rotate_Right. T must be an integer type. T'Size must be
14881 8, 16, 32 or 64 bits; if T is modular, the modulus
14882 must be 2**8, 2**16, 2**32 or 2**64.
14883 The result type must be the same as the type of @code{Value}.
14884 The shift amount must be Natural.
14885 The formal parameter names can be anything.
14887 A more convenient way of providing these shift operators is to use
14888 the Provide_Shift_Operators pragma, which provides the function declarations
14889 and corresponding pragma Import's for all five shift functions.
14891 @node Source_Location
14892 @section Source_Location
14893 @cindex Source_Location
14894 @noindent
14895 This intrinsic subprogram is used in the implementation of the
14896 library routine @code{GNAT.Source_Info}.  The only useful use of the
14897 intrinsic import in this case is the one in this unit, so an
14898 application program should simply call the function
14899 @code{GNAT.Source_Info.Source_Location} to obtain the current
14900 source file location.
14902 @node Representation Clauses and Pragmas
14903 @chapter Representation Clauses and Pragmas
14904 @cindex Representation Clauses
14906 @menu
14907 * Alignment Clauses::
14908 * Size Clauses::
14909 * Storage_Size Clauses::
14910 * Size of Variant Record Objects::
14911 * Biased Representation ::
14912 * Value_Size and Object_Size Clauses::
14913 * Component_Size Clauses::
14914 * Bit_Order Clauses::
14915 * Effect of Bit_Order on Byte Ordering::
14916 * Pragma Pack for Arrays::
14917 * Pragma Pack for Records::
14918 * Record Representation Clauses::
14919 * Handling of Records with Holes::
14920 * Enumeration Clauses::
14921 * Address Clauses::
14922 * Use of Address Clauses for Memory-Mapped I/O::
14923 * Effect of Convention on Representation::
14924 * Conventions and Anonymous Access Types::
14925 * Determining the Representations chosen by GNAT::
14926 @end menu
14928 @noindent
14929 @cindex Representation Clause
14930 @cindex Representation Pragma
14931 @cindex Pragma, representation
14932 This section describes the representation clauses accepted by GNAT, and
14933 their effect on the representation of corresponding data objects.
14935 GNAT fully implements Annex C (Systems Programming).  This means that all
14936 the implementation advice sections in chapter 13 are fully implemented.
14937 However, these sections only require a minimal level of support for
14938 representation clauses.  GNAT provides much more extensive capabilities,
14939 and this section describes the additional capabilities provided.
14941 @node Alignment Clauses
14942 @section Alignment Clauses
14943 @cindex Alignment Clause
14945 @noindent
14946 GNAT requires that all alignment clauses specify a power of 2, and all
14947 default alignments are always a power of 2.  The default alignment
14948 values are as follows:
14950 @itemize @bullet
14951 @item @emph{Primitive Types}.
14952 For primitive types, the alignment is the minimum of the actual size of
14953 objects of the type divided by @code{Storage_Unit},
14954 and the maximum alignment supported by the target.
14955 (This maximum alignment is given by the GNAT-specific attribute
14956 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
14957 @cindex @code{Maximum_Alignment} attribute
14958 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
14959 default alignment will be 8 on any target that supports alignments
14960 this large, but on some targets, the maximum alignment may be smaller
14961 than 8, in which case objects of type @code{Long_Float} will be maximally
14962 aligned.
14964 @item @emph{Arrays}.
14965 For arrays, the alignment is equal to the alignment of the component type
14966 for the normal case where no packing or component size is given.  If the
14967 array is packed, and the packing is effective (see separate section on
14968 packed arrays), then the alignment will be one for long packed arrays,
14969 or arrays whose length is not known at compile time.  For short packed
14970 arrays, which are handled internally as modular types, the alignment
14971 will be as described for primitive types, e.g.@: a packed array of length
14972 31 bits will have an object size of four bytes, and an alignment of 4.
14974 @item @emph{Records}.
14975 For the normal non-packed case, the alignment of a record is equal to
14976 the maximum alignment of any of its components.  For tagged records, this
14977 includes the implicit access type used for the tag.  If a pragma @code{Pack}
14978 is used and all components are packable (see separate section on pragma
14979 @code{Pack}), then the resulting alignment is 1, unless the layout of the
14980 record makes it profitable to increase it.
14982 A special case is when:
14983 @itemize @bullet
14984 @item
14985 the size of the record is given explicitly, or a
14986 full record representation clause is given, and
14987 @item
14988 the size of the record is 2, 4, or 8 bytes.
14989 @end itemize
14990 @noindent
14991 In this case, an alignment is chosen to match the
14992 size of the record. For example, if we have:
14994 @smallexample @c ada
14995    type Small is record
14996       A, B : Character;
14997    end record;
14998    for Small'Size use 16;
14999 @end smallexample
15001 @noindent
15002 then the default alignment of the record type @code{Small} is 2, not 1. This
15003 leads to more efficient code when the record is treated as a unit, and also
15004 allows the type to specified as @code{Atomic} on architectures requiring
15005 strict alignment.
15007 @end itemize
15009 @noindent
15010 An alignment clause may specify a larger alignment than the default value
15011 up to some maximum value dependent on the target (obtainable by using the
15012 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
15013 a smaller alignment than the default value for enumeration, integer and
15014 fixed point types, as well as for record types, for example
15016 @smallexample @c ada
15017   type V is record
15018      A : Integer;
15019   end record;
15021   for V'alignment use 1;
15022 @end smallexample
15024 @noindent
15025 @cindex Alignment, default
15026 The default alignment for the type @code{V} is 4, as a result of the
15027 Integer field in the record, but it is permissible, as shown, to
15028 override the default alignment of the record with a smaller value.
15030 @cindex Alignment, subtypes
15031 Note that according to the Ada standard, an alignment clause applies only
15032 to the first named subtype. If additional subtypes are declared, then the
15033 compiler is allowed to choose any alignment it likes, and there is no way
15034 to control this choice. Consider:
15036 @smallexample @c ada
15037    type R is range 1 .. 10_000;
15038    for R'Alignment use 1;
15039    subtype RS is R range 1 .. 1000;
15040 @end smallexample
15042 @noindent
15043 The alignment clause specifies an alignment of 1 for the first named subtype
15044 @code{R} but this does not necessarily apply to @code{RS}. When writing
15045 portable Ada code, you should avoid writing code that explicitly or
15046 implicitly relies on the alignment of such subtypes.
15048 For the GNAT compiler, if an explicit alignment clause is given, this
15049 value is also used for any subsequent subtypes. So for GNAT, in the
15050 above example, you can count on the alignment of @code{RS} being 1. But this
15051 assumption is non-portable, and other compilers may choose different
15052 alignments for the subtype @code{RS}.
15054 @node Size Clauses
15055 @section Size Clauses
15056 @cindex Size Clause
15058 @noindent
15059 The default size for a type @code{T} is obtainable through the
15060 language-defined attribute @code{T'Size} and also through the
15061 equivalent GNAT-defined attribute @code{T'Value_Size}.
15062 For objects of type @code{T}, GNAT will generally increase the type size
15063 so that the object size (obtainable through the GNAT-defined attribute
15064 @code{T'Object_Size})
15065 is a multiple of @code{T'Alignment * Storage_Unit}.
15066 For example
15068 @smallexample @c ada
15069    type Smallint is range 1 .. 6;
15071    type Rec is record
15072       Y1 : integer;
15073       Y2 : boolean;
15074    end record;
15075 @end smallexample
15077 @noindent
15078 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
15079 as specified by the RM rules,
15080 but objects of this type will have a size of 8
15081 (@code{Smallint'Object_Size} = 8),
15082 since objects by default occupy an integral number
15083 of storage units.  On some targets, notably older
15084 versions of the Digital Alpha, the size of stand
15085 alone objects of this type may be 32, reflecting
15086 the inability of the hardware to do byte load/stores.
15088 Similarly, the size of type @code{Rec} is 40 bits
15089 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
15090 the alignment is 4, so objects of this type will have
15091 their size increased to 64 bits so that it is a multiple
15092 of the alignment (in bits).  This decision is
15093 in accordance with the specific Implementation Advice in RM 13.3(43):
15095 @quotation
15096 A @code{Size} clause should be supported for an object if the specified
15097 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
15098 to a size in storage elements that is a multiple of the object's
15099 @code{Alignment} (if the @code{Alignment} is nonzero).
15100 @end quotation
15102 @noindent
15103 An explicit size clause may be used to override the default size by
15104 increasing it.  For example, if we have:
15106 @smallexample @c ada
15107    type My_Boolean is new Boolean;
15108    for My_Boolean'Size use 32;
15109 @end smallexample
15111 @noindent
15112 then values of this type will always be 32 bits long.  In the case of
15113 discrete types, the size can be increased up to 64 bits, with the effect
15114 that the entire specified field is used to hold the value, sign- or
15115 zero-extended as appropriate.  If more than 64 bits is specified, then
15116 padding space is allocated after the value, and a warning is issued that
15117 there are unused bits.
15119 Similarly the size of records and arrays may be increased, and the effect
15120 is to add padding bits after the value.  This also causes a warning message
15121 to be generated.
15123 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
15124 Size in bits, this corresponds to an object of size 256 megabytes (minus
15125 one).  This limitation is true on all targets.  The reason for this
15126 limitation is that it improves the quality of the code in many cases
15127 if it is known that a Size value can be accommodated in an object of
15128 type Integer.
15130 @node Storage_Size Clauses
15131 @section Storage_Size Clauses
15132 @cindex Storage_Size Clause
15134 @noindent
15135 For tasks, the @code{Storage_Size} clause specifies the amount of space
15136 to be allocated for the task stack.  This cannot be extended, and if the
15137 stack is exhausted, then @code{Storage_Error} will be raised (if stack
15138 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
15139 or a @code{Storage_Size} pragma in the task definition to set the
15140 appropriate required size.  A useful technique is to include in every
15141 task definition a pragma of the form:
15143 @smallexample @c ada
15144    pragma Storage_Size (Default_Stack_Size);
15145 @end smallexample
15147 @noindent
15148 Then @code{Default_Stack_Size} can be defined in a global package, and
15149 modified as required. Any tasks requiring stack sizes different from the
15150 default can have an appropriate alternative reference in the pragma.
15152 You can also use the @option{-d} binder switch to modify the default stack
15153 size.
15155 For access types, the @code{Storage_Size} clause specifies the maximum
15156 space available for allocation of objects of the type.  If this space is
15157 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
15158 In the case where the access type is declared local to a subprogram, the
15159 use of a @code{Storage_Size} clause triggers automatic use of a special
15160 predefined storage pool (@code{System.Pool_Size}) that ensures that all
15161 space for the pool is automatically reclaimed on exit from the scope in
15162 which the type is declared.
15164 A special case recognized by the compiler is the specification of a
15165 @code{Storage_Size} of zero for an access type.  This means that no
15166 items can be allocated from the pool, and this is recognized at compile
15167 time, and all the overhead normally associated with maintaining a fixed
15168 size storage pool is eliminated.  Consider the following example:
15170 @smallexample @c ada
15171    procedure p is
15172       type R is array (Natural) of Character;
15173       type P is access all R;
15174       for P'Storage_Size use 0;
15175       --  Above access type intended only for interfacing purposes
15177       y : P;
15179       procedure g (m : P);
15180       pragma Import (C, g);
15182       --  @dots{}
15184    begin
15185       --  @dots{}
15186       y := new R;
15187    end;
15188 @end smallexample
15190 @noindent
15191 As indicated in this example, these dummy storage pools are often useful in
15192 connection with interfacing where no object will ever be allocated.  If you
15193 compile the above example, you get the warning:
15195 @smallexample
15196    p.adb:16:09: warning: allocation from empty storage pool
15197    p.adb:16:09: warning: Storage_Error will be raised at run time
15198 @end smallexample
15200 @noindent
15201 Of course in practice, there will not be any explicit allocators in the
15202 case of such an access declaration.
15204 @node Size of Variant Record Objects
15205 @section Size of Variant Record Objects
15206 @cindex Size, variant record objects
15207 @cindex Variant record objects, size
15209 @noindent
15210 In the case of variant record objects, there is a question whether Size gives
15211 information about a particular variant, or the maximum size required
15212 for any variant.  Consider the following program
15214 @smallexample @c ada
15215 with Text_IO; use Text_IO;
15216 procedure q is
15217    type R1 (A : Boolean := False) is record
15218      case A is
15219        when True  => X : Character;
15220        when False => null;
15221      end case;
15222    end record;
15224    V1 : R1 (False);
15225    V2 : R1;
15227 begin
15228    Put_Line (Integer'Image (V1'Size));
15229    Put_Line (Integer'Image (V2'Size));
15230 end q;
15231 @end smallexample
15233 @noindent
15234 Here we are dealing with a variant record, where the True variant
15235 requires 16 bits, and the False variant requires 8 bits.
15236 In the above example, both V1 and V2 contain the False variant,
15237 which is only 8 bits long.  However, the result of running the
15238 program is:
15240 @smallexample
15243 @end smallexample
15245 @noindent
15246 The reason for the difference here is that the discriminant value of
15247 V1 is fixed, and will always be False.  It is not possible to assign
15248 a True variant value to V1, therefore 8 bits is sufficient.  On the
15249 other hand, in the case of V2, the initial discriminant value is
15250 False (from the default), but it is possible to assign a True
15251 variant value to V2, therefore 16 bits must be allocated for V2
15252 in the general case, even fewer bits may be needed at any particular
15253 point during the program execution.
15255 As can be seen from the output of this program, the @code{'Size}
15256 attribute applied to such an object in GNAT gives the actual allocated
15257 size of the variable, which is the largest size of any of the variants.
15258 The Ada Reference Manual is not completely clear on what choice should
15259 be made here, but the GNAT behavior seems most consistent with the
15260 language in the RM@.
15262 In some cases, it may be desirable to obtain the size of the current
15263 variant, rather than the size of the largest variant.  This can be
15264 achieved in GNAT by making use of the fact that in the case of a
15265 subprogram parameter, GNAT does indeed return the size of the current
15266 variant (because a subprogram has no way of knowing how much space
15267 is actually allocated for the actual).
15269 Consider the following modified version of the above program:
15271 @smallexample @c ada
15272 with Text_IO; use Text_IO;
15273 procedure q is
15274    type R1 (A : Boolean := False) is record
15275      case A is
15276        when True  => X : Character;
15277        when False => null;
15278      end case;
15279    end record;
15281    V2 : R1;
15283    function Size (V : R1) return Integer is
15284    begin
15285       return V'Size;
15286    end Size;
15288 begin
15289    Put_Line (Integer'Image (V2'Size));
15290    Put_Line (Integer'IMage (Size (V2)));
15291    V2 := (True, 'x');
15292    Put_Line (Integer'Image (V2'Size));
15293    Put_Line (Integer'IMage (Size (V2)));
15294 end q;
15295 @end smallexample
15297 @noindent
15298 The output from this program is
15300 @smallexample
15305 @end smallexample
15307 @noindent
15308 Here we see that while the @code{'Size} attribute always returns
15309 the maximum size, regardless of the current variant value, the
15310 @code{Size} function does indeed return the size of the current
15311 variant value.
15313 @node Biased Representation
15314 @section Biased Representation
15315 @cindex Size for biased representation
15316 @cindex Biased representation
15318 @noindent
15319 In the case of scalars with a range starting at other than zero, it is
15320 possible in some cases to specify a size smaller than the default minimum
15321 value, and in such cases, GNAT uses an unsigned biased representation,
15322 in which zero is used to represent the lower bound, and successive values
15323 represent successive values of the type.
15325 For example, suppose we have the declaration:
15327 @smallexample @c ada
15328    type Small is range -7 .. -4;
15329    for Small'Size use 2;
15330 @end smallexample
15332 @noindent
15333 Although the default size of type @code{Small} is 4, the @code{Size}
15334 clause is accepted by GNAT and results in the following representation
15335 scheme:
15337 @smallexample
15338   -7 is represented as 2#00#
15339   -6 is represented as 2#01#
15340   -5 is represented as 2#10#
15341   -4 is represented as 2#11#
15342 @end smallexample
15344 @noindent
15345 Biased representation is only used if the specified @code{Size} clause
15346 cannot be accepted in any other manner.  These reduced sizes that force
15347 biased representation can be used for all discrete types except for
15348 enumeration types for which a representation clause is given.
15350 @node Value_Size and Object_Size Clauses
15351 @section Value_Size and Object_Size Clauses
15352 @findex Value_Size
15353 @findex Object_Size
15354 @cindex Size, of objects
15356 @noindent
15357 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
15358 number of bits required to hold values of type @code{T}.
15359 Although this interpretation was allowed in Ada 83, it was not required,
15360 and this requirement in practice can cause some significant difficulties.
15361 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
15362 However, in Ada 95 and Ada 2005,
15363 @code{Natural'Size} is
15364 typically 31.  This means that code may change in behavior when moving
15365 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
15367 @smallexample @c ada
15368    type Rec is record;
15369       A : Natural;
15370       B : Natural;
15371    end record;
15373    for Rec use record
15374       at 0  range 0 .. Natural'Size - 1;
15375       at 0  range Natural'Size .. 2 * Natural'Size - 1;
15376    end record;
15377 @end smallexample
15379 @noindent
15380 In the above code, since the typical size of @code{Natural} objects
15381 is 32 bits and @code{Natural'Size} is 31, the above code can cause
15382 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
15383 there are cases where the fact that the object size can exceed the
15384 size of the type causes surprises.
15386 To help get around this problem GNAT provides two implementation
15387 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
15388 applied to a type, these attributes yield the size of the type
15389 (corresponding to the RM defined size attribute), and the size of
15390 objects of the type respectively.
15392 The @code{Object_Size} is used for determining the default size of
15393 objects and components.  This size value can be referred to using the
15394 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
15395 the basis of the determination of the size.  The backend is free to
15396 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
15397 character might be stored in 32 bits on a machine with no efficient
15398 byte access instructions such as the Alpha.
15400 The default rules for the value of @code{Object_Size} for
15401 discrete types are as follows:
15403 @itemize @bullet
15404 @item
15405 The @code{Object_Size} for base subtypes reflect the natural hardware
15406 size in bits (run the compiler with @option{-gnatS} to find those values
15407 for numeric types). Enumeration types and fixed-point base subtypes have
15408 8, 16, 32 or 64 bits for this size, depending on the range of values
15409 to be stored.
15411 @item
15412 The @code{Object_Size} of a subtype is the same as the
15413 @code{Object_Size} of
15414 the type from which it is obtained.
15416 @item
15417 The @code{Object_Size} of a derived base type is copied from the parent
15418 base type, and the @code{Object_Size} of a derived first subtype is copied
15419 from the parent first subtype.
15420 @end itemize
15422 @noindent
15423 The @code{Value_Size} attribute
15424 is the (minimum) number of bits required to store a value
15425 of the type.
15426 This value is used to determine how tightly to pack
15427 records or arrays with components of this type, and also affects
15428 the semantics of unchecked conversion (unchecked conversions where
15429 the @code{Value_Size} values differ generate a warning, and are potentially
15430 target dependent).
15432 The default rules for the value of @code{Value_Size} are as follows:
15434 @itemize @bullet
15435 @item
15436 The @code{Value_Size} for a base subtype is the minimum number of bits
15437 required to store all values of the type (including the sign bit
15438 only if negative values are possible).
15440 @item
15441 If a subtype statically matches the first subtype of a given type, then it has
15442 by default the same @code{Value_Size} as the first subtype.  This is a
15443 consequence of RM 13.1(14) (``if two subtypes statically match,
15444 then their subtype-specific aspects are the same''.)
15446 @item
15447 All other subtypes have a @code{Value_Size} corresponding to the minimum
15448 number of bits required to store all values of the subtype.  For
15449 dynamic bounds, it is assumed that the value can range down or up
15450 to the corresponding bound of the ancestor
15451 @end itemize
15453 @noindent
15454 The RM defined attribute @code{Size} corresponds to the
15455 @code{Value_Size} attribute.
15457 The @code{Size} attribute may be defined for a first-named subtype.  This sets
15458 the @code{Value_Size} of
15459 the first-named subtype to the given value, and the
15460 @code{Object_Size} of this first-named subtype to the given value padded up
15461 to an appropriate boundary.  It is a consequence of the default rules
15462 above that this @code{Object_Size} will apply to all further subtypes.  On the
15463 other hand, @code{Value_Size} is affected only for the first subtype, any
15464 dynamic subtypes obtained from it directly, and any statically matching
15465 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
15467 @code{Value_Size} and
15468 @code{Object_Size} may be explicitly set for any subtype using
15469 an attribute definition clause.  Note that the use of these attributes
15470 can cause the RM 13.1(14) rule to be violated.  If two access types
15471 reference aliased objects whose subtypes have differing @code{Object_Size}
15472 values as a result of explicit attribute definition clauses, then it
15473 is illegal to convert from one access subtype to the other. For a more
15474 complete description of this additional legality rule, see the
15475 description of the @code{Object_Size} attribute.
15477 At the implementation level, Esize stores the Object_Size and the
15478 RM_Size field stores the @code{Value_Size} (and hence the value of the
15479 @code{Size} attribute,
15480 which, as noted above, is equivalent to @code{Value_Size}).
15482 To get a feel for the difference, consider the following examples (note
15483 that in each case the base is @code{Short_Short_Integer} with a size of 8):
15485 @smallexample
15486                                        Object_Size     Value_Size
15488 type x1 is range 0 .. 5;                    8               3
15490 type x2 is range 0 .. 5;
15491 for x2'size use 12;                        16              12
15493 subtype x3 is x2 range 0 .. 3;             16               2
15495 subtype x4 is x2'base range 0 .. 10;        8               4
15497 subtype x5 is x2 range 0 .. dynamic;       16               3*
15499 subtype x6 is x2'base range 0 .. dynamic;   8               3*
15501 @end smallexample
15503 @noindent
15504 Note: the entries marked ``3*'' are not actually specified by the Ada
15505 Reference Manual, but it seems in the spirit of the RM rules to allocate
15506 the minimum number of bits (here 3, given the range for @code{x2})
15507 known to be large enough to hold the given range of values.
15509 So far, so good, but GNAT has to obey the RM rules, so the question is
15510 under what conditions must the RM @code{Size} be used.
15511 The following is a list
15512 of the occasions on which the RM @code{Size} must be used:
15514 @itemize @bullet
15515 @item
15516 Component size for packed arrays or records
15518 @item
15519 Value of the attribute @code{Size} for a type
15521 @item
15522 Warning about sizes not matching for unchecked conversion
15523 @end itemize
15525 @noindent
15526 For record types, the @code{Object_Size} is always a multiple of the
15527 alignment of the type (this is true for all types). In some cases the
15528 @code{Value_Size} can be smaller. Consider:
15530 @smallexample
15531    type R is record
15532      X : Integer;
15533      Y : Character;
15534    end record;
15535 @end smallexample
15537 @noindent
15538 On a typical 32-bit architecture, the X component will be four bytes, and
15539 require four-byte alignment, and the Y component will be one byte. In this
15540 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
15541 required to store a value of this type, and for example, it is permissible
15542 to have a component of type R in an outer array whose component size is
15543 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
15544 since it must be rounded up so that this value is a multiple of the
15545 alignment (4 bytes = 32 bits).
15547 @noindent
15548 For all other types, the @code{Object_Size}
15549 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
15550 Only @code{Size} may be specified for such types.
15552 Note that @code{Value_Size} can be used to force biased representation
15553 for a particular subtype. Consider this example:
15555 @smallexample
15556    type R is (A, B, C, D, E, F);
15557    subtype RAB is R range A .. B;
15558    subtype REF is R range E .. F;
15559 @end smallexample
15561 @noindent
15562 By default, @code{RAB}
15563 has a size of 1 (sufficient to accommodate the representation
15564 of @code{A} and @code{B}, 0 and 1), and @code{REF}
15565 has a size of 3 (sufficient to accommodate the representation
15566 of @code{E} and @code{F}, 4 and 5). But if we add the
15567 following @code{Value_Size} attribute definition clause:
15569 @smallexample
15570    for REF'Value_Size use 1;
15571 @end smallexample
15573 @noindent
15574 then biased representation is forced for @code{REF},
15575 and 0 will represent @code{E} and 1 will represent @code{F}.
15576 A warning is issued when a @code{Value_Size} attribute
15577 definition clause forces biased representation. This
15578 warning can be turned off using @code{-gnatw.B}.
15580 @node Component_Size Clauses
15581 @section Component_Size Clauses
15582 @cindex Component_Size Clause
15584 @noindent
15585 Normally, the value specified in a component size clause must be consistent
15586 with the subtype of the array component with regard to size and alignment.
15587 In other words, the value specified must be at least equal to the size
15588 of this subtype, and must be a multiple of the alignment value.
15590 In addition, component size clauses are allowed which cause the array
15591 to be packed, by specifying a smaller value.  A first case is for
15592 component size values in the range 1 through 63.  The value specified
15593 must not be smaller than the Size of the subtype.  GNAT will accurately
15594 honor all packing requests in this range.  For example, if we have:
15596 @smallexample @c ada
15597 type r is array (1 .. 8) of Natural;
15598 for r'Component_Size use 31;
15599 @end smallexample
15601 @noindent
15602 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
15603 Of course access to the components of such an array is considerably
15604 less efficient than if the natural component size of 32 is used.
15605 A second case is when the subtype of the component is a record type
15606 padded because of its default alignment.  For example, if we have:
15608 @smallexample @c ada
15609 type r is record
15610   i : Integer;
15611   j : Integer;
15612   b : Boolean;
15613 end record;
15615 type a is array (1 .. 8) of r;
15616 for a'Component_Size use 72;
15617 @end smallexample
15619 @noindent
15620 then the resulting array has a length of 72 bytes, instead of 96 bytes
15621 if the alignment of the record (4) was obeyed.
15623 Note that there is no point in giving both a component size clause
15624 and a pragma Pack for the same array type. if such duplicate
15625 clauses are given, the pragma Pack will be ignored.
15627 @node Bit_Order Clauses
15628 @section Bit_Order Clauses
15629 @cindex Bit_Order Clause
15630 @cindex bit ordering
15631 @cindex ordering, of bits
15633 @noindent
15634 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
15635 attribute.  The specification may either correspond to the default bit
15636 order for the target, in which case the specification has no effect and
15637 places no additional restrictions, or it may be for the non-standard
15638 setting (that is the opposite of the default).
15640 In the case where the non-standard value is specified, the effect is
15641 to renumber bits within each byte, but the ordering of bytes is not
15642 affected.  There are certain
15643 restrictions placed on component clauses as follows:
15645 @itemize @bullet
15647 @item Components fitting within a single storage unit.
15648 @noindent
15649 These are unrestricted, and the effect is merely to renumber bits.  For
15650 example if we are on a little-endian machine with @code{Low_Order_First}
15651 being the default, then the following two declarations have exactly
15652 the same effect:
15654 @smallexample @c ada
15655    type R1 is record
15656       A : Boolean;
15657       B : Integer range 1 .. 120;
15658    end record;
15660    for R1 use record
15661       A at 0 range 0 .. 0;
15662       B at 0 range 1 .. 7;
15663    end record;
15665    type R2 is record
15666       A : Boolean;
15667       B : Integer range 1 .. 120;
15668    end record;
15670    for R2'Bit_Order use High_Order_First;
15672    for R2 use record
15673       A at 0 range 7 .. 7;
15674       B at 0 range 0 .. 6;
15675    end record;
15676 @end smallexample
15678 @noindent
15679 The useful application here is to write the second declaration with the
15680 @code{Bit_Order} attribute definition clause, and know that it will be treated
15681 the same, regardless of whether the target is little-endian or big-endian.
15683 @item Components occupying an integral number of bytes.
15684 @noindent
15685 These are components that exactly fit in two or more bytes.  Such component
15686 declarations are allowed, but have no effect, since it is important to realize
15687 that the @code{Bit_Order} specification does not affect the ordering of bytes.
15688 In particular, the following attempt at getting an endian-independent integer
15689 does not work:
15691 @smallexample @c ada
15692    type R2 is record
15693       A : Integer;
15694    end record;
15696    for R2'Bit_Order use High_Order_First;
15698    for R2 use record
15699       A at 0 range 0 .. 31;
15700    end record;
15701 @end smallexample
15703 @noindent
15704 This declaration will result in a little-endian integer on a
15705 little-endian machine, and a big-endian integer on a big-endian machine.
15706 If byte flipping is required for interoperability between big- and
15707 little-endian machines, this must be explicitly programmed.  This capability
15708 is not provided by @code{Bit_Order}.
15710 @item Components that are positioned across byte boundaries
15711 @noindent
15712 but do not occupy an integral number of bytes.  Given that bytes are not
15713 reordered, such fields would occupy a non-contiguous sequence of bits
15714 in memory, requiring non-trivial code to reassemble.  They are for this
15715 reason not permitted, and any component clause specifying such a layout
15716 will be flagged as illegal by GNAT@.
15718 @end itemize
15720 @noindent
15721 Since the misconception that Bit_Order automatically deals with all
15722 endian-related incompatibilities is a common one, the specification of
15723 a component field that is an integral number of bytes will always
15724 generate a warning.  This warning may be suppressed using @code{pragma
15725 Warnings (Off)} if desired.  The following section contains additional
15726 details regarding the issue of byte ordering.
15728 @node Effect of Bit_Order on Byte Ordering
15729 @section Effect of Bit_Order on Byte Ordering
15730 @cindex byte ordering
15731 @cindex ordering, of bytes
15733 @noindent
15734 In this section we will review the effect of the @code{Bit_Order} attribute
15735 definition clause on byte ordering.  Briefly, it has no effect at all, but
15736 a detailed example will be helpful.  Before giving this
15737 example, let us review the precise
15738 definition of the effect of defining @code{Bit_Order}.  The effect of a
15739 non-standard bit order is described in section 15.5.3 of the Ada
15740 Reference Manual:
15742 @quotation
15743 2   A bit ordering is a method of interpreting the meaning of
15744 the storage place attributes.
15745 @end quotation
15747 @noindent
15748 To understand the precise definition of storage place attributes in
15749 this context, we visit section 13.5.1 of the manual:
15751 @quotation
15752 13   A record_representation_clause (without the mod_clause)
15753 specifies the layout.  The storage place attributes (see 13.5.2)
15754 are taken from the values of the position, first_bit, and last_bit
15755 expressions after normalizing those values so that first_bit is
15756 less than Storage_Unit.
15757 @end quotation
15759 @noindent
15760 The critical point here is that storage places are taken from
15761 the values after normalization, not before.  So the @code{Bit_Order}
15762 interpretation applies to normalized values.  The interpretation
15763 is described in the later part of the 15.5.3 paragraph:
15765 @quotation
15766 2   A bit ordering is a method of interpreting the meaning of
15767 the storage place attributes.  High_Order_First (known in the
15768 vernacular as ``big endian'') means that the first bit of a
15769 storage element (bit 0) is the most significant bit (interpreting
15770 the sequence of bits that represent a component as an unsigned
15771 integer value).  Low_Order_First (known in the vernacular as
15772 ``little endian'') means the opposite: the first bit is the
15773 least significant.
15774 @end quotation
15776 @noindent
15777 Note that the numbering is with respect to the bits of a storage
15778 unit.  In other words, the specification affects only the numbering
15779 of bits within a single storage unit.
15781 We can make the effect clearer by giving an example.
15783 Suppose that we have an external device which presents two bytes, the first
15784 byte presented, which is the first (low addressed byte) of the two byte
15785 record is called Master, and the second byte is called Slave.
15787 The left most (most significant bit is called Control for each byte, and
15788 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
15789 (least significant) bit.
15791 On a big-endian machine, we can write the following representation clause
15793 @smallexample @c ada
15794    type Data is record
15795       Master_Control : Bit;
15796       Master_V1      : Bit;
15797       Master_V2      : Bit;
15798       Master_V3      : Bit;
15799       Master_V4      : Bit;
15800       Master_V5      : Bit;
15801       Master_V6      : Bit;
15802       Master_V7      : Bit;
15803       Slave_Control  : Bit;
15804       Slave_V1       : Bit;
15805       Slave_V2       : Bit;
15806       Slave_V3       : Bit;
15807       Slave_V4       : Bit;
15808       Slave_V5       : Bit;
15809       Slave_V6       : Bit;
15810       Slave_V7       : Bit;
15811    end record;
15813    for Data use record
15814       Master_Control at 0 range 0 .. 0;
15815       Master_V1      at 0 range 1 .. 1;
15816       Master_V2      at 0 range 2 .. 2;
15817       Master_V3      at 0 range 3 .. 3;
15818       Master_V4      at 0 range 4 .. 4;
15819       Master_V5      at 0 range 5 .. 5;
15820       Master_V6      at 0 range 6 .. 6;
15821       Master_V7      at 0 range 7 .. 7;
15822       Slave_Control  at 1 range 0 .. 0;
15823       Slave_V1       at 1 range 1 .. 1;
15824       Slave_V2       at 1 range 2 .. 2;
15825       Slave_V3       at 1 range 3 .. 3;
15826       Slave_V4       at 1 range 4 .. 4;
15827       Slave_V5       at 1 range 5 .. 5;
15828       Slave_V6       at 1 range 6 .. 6;
15829       Slave_V7       at 1 range 7 .. 7;
15830    end record;
15831 @end smallexample
15833 @noindent
15834 Now if we move this to a little endian machine, then the bit ordering within
15835 the byte is backwards, so we have to rewrite the record rep clause as:
15837 @smallexample @c ada
15838    for Data use record
15839       Master_Control at 0 range 7 .. 7;
15840       Master_V1      at 0 range 6 .. 6;
15841       Master_V2      at 0 range 5 .. 5;
15842       Master_V3      at 0 range 4 .. 4;
15843       Master_V4      at 0 range 3 .. 3;
15844       Master_V5      at 0 range 2 .. 2;
15845       Master_V6      at 0 range 1 .. 1;
15846       Master_V7      at 0 range 0 .. 0;
15847       Slave_Control  at 1 range 7 .. 7;
15848       Slave_V1       at 1 range 6 .. 6;
15849       Slave_V2       at 1 range 5 .. 5;
15850       Slave_V3       at 1 range 4 .. 4;
15851       Slave_V4       at 1 range 3 .. 3;
15852       Slave_V5       at 1 range 2 .. 2;
15853       Slave_V6       at 1 range 1 .. 1;
15854       Slave_V7       at 1 range 0 .. 0;
15855    end record;
15856 @end smallexample
15858 @noindent
15859 It is a nuisance to have to rewrite the clause, especially if
15860 the code has to be maintained on both machines.  However,
15861 this is a case that we can handle with the
15862 @code{Bit_Order} attribute if it is implemented.
15863 Note that the implementation is not required on byte addressed
15864 machines, but it is indeed implemented in GNAT.
15865 This means that we can simply use the
15866 first record clause, together with the declaration
15868 @smallexample @c ada
15869    for Data'Bit_Order use High_Order_First;
15870 @end smallexample
15872 @noindent
15873 and the effect is what is desired, namely the layout is exactly the same,
15874 independent of whether the code is compiled on a big-endian or little-endian
15875 machine.
15877 The important point to understand is that byte ordering is not affected.
15878 A @code{Bit_Order} attribute definition never affects which byte a field
15879 ends up in, only where it ends up in that byte.
15880 To make this clear, let us rewrite the record rep clause of the previous
15881 example as:
15883 @smallexample @c ada
15884    for Data'Bit_Order use High_Order_First;
15885    for Data use record
15886       Master_Control at 0 range  0 .. 0;
15887       Master_V1      at 0 range  1 .. 1;
15888       Master_V2      at 0 range  2 .. 2;
15889       Master_V3      at 0 range  3 .. 3;
15890       Master_V4      at 0 range  4 .. 4;
15891       Master_V5      at 0 range  5 .. 5;
15892       Master_V6      at 0 range  6 .. 6;
15893       Master_V7      at 0 range  7 .. 7;
15894       Slave_Control  at 0 range  8 .. 8;
15895       Slave_V1       at 0 range  9 .. 9;
15896       Slave_V2       at 0 range 10 .. 10;
15897       Slave_V3       at 0 range 11 .. 11;
15898       Slave_V4       at 0 range 12 .. 12;
15899       Slave_V5       at 0 range 13 .. 13;
15900       Slave_V6       at 0 range 14 .. 14;
15901       Slave_V7       at 0 range 15 .. 15;
15902    end record;
15903 @end smallexample
15905 @noindent
15906 This is exactly equivalent to saying (a repeat of the first example):
15908 @smallexample @c ada
15909    for Data'Bit_Order use High_Order_First;
15910    for Data use record
15911       Master_Control at 0 range 0 .. 0;
15912       Master_V1      at 0 range 1 .. 1;
15913       Master_V2      at 0 range 2 .. 2;
15914       Master_V3      at 0 range 3 .. 3;
15915       Master_V4      at 0 range 4 .. 4;
15916       Master_V5      at 0 range 5 .. 5;
15917       Master_V6      at 0 range 6 .. 6;
15918       Master_V7      at 0 range 7 .. 7;
15919       Slave_Control  at 1 range 0 .. 0;
15920       Slave_V1       at 1 range 1 .. 1;
15921       Slave_V2       at 1 range 2 .. 2;
15922       Slave_V3       at 1 range 3 .. 3;
15923       Slave_V4       at 1 range 4 .. 4;
15924       Slave_V5       at 1 range 5 .. 5;
15925       Slave_V6       at 1 range 6 .. 6;
15926       Slave_V7       at 1 range 7 .. 7;
15927    end record;
15928 @end smallexample
15930 @noindent
15931 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
15932 field.  The storage place attributes are obtained by normalizing the
15933 values given so that the @code{First_Bit} value is less than 8.  After
15934 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
15935 we specified in the other case.
15937 Now one might expect that the @code{Bit_Order} attribute might affect
15938 bit numbering within the entire record component (two bytes in this
15939 case, thus affecting which byte fields end up in), but that is not
15940 the way this feature is defined, it only affects numbering of bits,
15941 not which byte they end up in.
15943 Consequently it never makes sense to specify a starting bit number
15944 greater than 7 (for a byte addressable field) if an attribute
15945 definition for @code{Bit_Order} has been given, and indeed it
15946 may be actively confusing to specify such a value, so the compiler
15947 generates a warning for such usage.
15949 If you do need to control byte ordering then appropriate conditional
15950 values must be used.  If in our example, the slave byte came first on
15951 some machines we might write:
15953 @smallexample @c ada
15954    Master_Byte_First constant Boolean := @dots{};
15956    Master_Byte : constant Natural :=
15957                    1 - Boolean'Pos (Master_Byte_First);
15958    Slave_Byte  : constant Natural :=
15959                    Boolean'Pos (Master_Byte_First);
15961    for Data'Bit_Order use High_Order_First;
15962    for Data use record
15963       Master_Control at Master_Byte range 0 .. 0;
15964       Master_V1      at Master_Byte range 1 .. 1;
15965       Master_V2      at Master_Byte range 2 .. 2;
15966       Master_V3      at Master_Byte range 3 .. 3;
15967       Master_V4      at Master_Byte range 4 .. 4;
15968       Master_V5      at Master_Byte range 5 .. 5;
15969       Master_V6      at Master_Byte range 6 .. 6;
15970       Master_V7      at Master_Byte range 7 .. 7;
15971       Slave_Control  at Slave_Byte  range 0 .. 0;
15972       Slave_V1       at Slave_Byte  range 1 .. 1;
15973       Slave_V2       at Slave_Byte  range 2 .. 2;
15974       Slave_V3       at Slave_Byte  range 3 .. 3;
15975       Slave_V4       at Slave_Byte  range 4 .. 4;
15976       Slave_V5       at Slave_Byte  range 5 .. 5;
15977       Slave_V6       at Slave_Byte  range 6 .. 6;
15978       Slave_V7       at Slave_Byte  range 7 .. 7;
15979    end record;
15980 @end smallexample
15982 @noindent
15983 Now to switch between machines, all that is necessary is
15984 to set the boolean constant @code{Master_Byte_First} in
15985 an appropriate manner.
15987 @node Pragma Pack for Arrays
15988 @section Pragma Pack for Arrays
15989 @cindex Pragma Pack (for arrays)
15991 @noindent
15992 Pragma @code{Pack} applied to an array has no effect unless the component type
15993 is packable.  For a component type to be packable, it must be one of the
15994 following cases:
15996 @itemize @bullet
15997 @item
15998 Any scalar type
15999 @item
16000 Any type whose size is specified with a size clause
16001 @item
16002 Any packed array type with a static size
16003 @item
16004 Any record type padded because of its default alignment
16005 @end itemize
16007 @noindent
16008 For all these cases, if the component subtype size is in the range
16009 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
16010 component size were specified giving the component subtype size.
16011 For example if we have:
16013 @smallexample @c ada
16014    type r is range 0 .. 17;
16016    type ar is array (1 .. 8) of r;
16017    pragma Pack (ar);
16018 @end smallexample
16020 @noindent
16021 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
16022 and the size of the array @code{ar} will be exactly 40 bits.
16024 Note that in some cases this rather fierce approach to packing can produce
16025 unexpected effects.  For example, in Ada 95 and Ada 2005,
16026 subtype @code{Natural} typically has a size of 31, meaning that if you
16027 pack an array of @code{Natural}, you get 31-bit
16028 close packing, which saves a few bits, but results in far less efficient
16029 access.  Since many other Ada compilers will ignore such a packing request,
16030 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
16031 might not be what is intended.  You can easily remove this warning by
16032 using an explicit @code{Component_Size} setting instead, which never generates
16033 a warning, since the intention of the programmer is clear in this case.
16035 GNAT treats packed arrays in one of two ways.  If the size of the array is
16036 known at compile time and is less than 64 bits, then internally the array
16037 is represented as a single modular type, of exactly the appropriate number
16038 of bits.  If the length is greater than 63 bits, or is not known at compile
16039 time, then the packed array is represented as an array of bytes, and the
16040 length is always a multiple of 8 bits.
16042 Note that to represent a packed array as a modular type, the alignment must
16043 be suitable for the modular type involved. For example, on typical machines
16044 a 32-bit packed array will be represented by a 32-bit modular integer with
16045 an alignment of four bytes. If you explicitly override the default alignment
16046 with an alignment clause that is too small, the modular representation
16047 cannot be used. For example, consider the following set of declarations:
16049 @smallexample @c ada
16050    type R is range 1 .. 3;
16051    type S is array (1 .. 31) of R;
16052    for S'Component_Size use 2;
16053    for S'Size use 62;
16054    for S'Alignment use 1;
16055 @end smallexample
16057 @noindent
16058 If the alignment clause were not present, then a 62-bit modular
16059 representation would be chosen (typically with an alignment of 4 or 8
16060 bytes depending on the target). But the default alignment is overridden
16061 with the explicit alignment clause. This means that the modular
16062 representation cannot be used, and instead the array of bytes
16063 representation must be used, meaning that the length must be a multiple
16064 of 8. Thus the above set of declarations will result in a diagnostic
16065 rejecting the size clause and noting that the minimum size allowed is 64.
16067 @cindex Pragma Pack (for type Natural)
16068 @cindex Pragma Pack warning
16070 One special case that is worth noting occurs when the base type of the
16071 component size is 8/16/32 and the subtype is one bit less. Notably this
16072 occurs with subtype @code{Natural}. Consider:
16074 @smallexample @c ada
16075    type Arr is array (1 .. 32) of Natural;
16076    pragma Pack (Arr);
16077 @end smallexample
16079 @noindent
16080 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
16081 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
16082 Ada 83 compilers did not attempt 31 bit packing.
16084 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
16085 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
16086 substantial unintended performance penalty when porting legacy Ada 83 code.
16087 To help prevent this, GNAT generates a warning in such cases. If you really
16088 want 31 bit packing in a case like this, you can set the component size
16089 explicitly:
16091 @smallexample @c ada
16092    type Arr is array (1 .. 32) of Natural;
16093    for Arr'Component_Size use 31;
16094 @end smallexample
16096 @noindent
16097 Here 31-bit packing is achieved as required, and no warning is generated,
16098 since in this case the programmer intention is clear.
16100 @node Pragma Pack for Records
16101 @section Pragma Pack for Records
16102 @cindex Pragma Pack (for records)
16104 @noindent
16105 Pragma @code{Pack} applied to a record will pack the components to reduce
16106 wasted space from alignment gaps and by reducing the amount of space
16107 taken by components.  We distinguish between @emph{packable} components and
16108 @emph{non-packable} components.
16109 Components of the following types are considered packable:
16110 @itemize @bullet
16111 @item
16112 Components of a primitive type are packable unless they are aliased
16113 or of an atomic type.
16115 @item
16116 Small packed arrays, whose size does not exceed 64 bits, and where the
16117 size is statically known at compile time, are represented internally
16118 as modular integers, and so they are also packable.
16120 @end itemize
16122 @noindent
16123 All packable components occupy the exact number of bits corresponding to
16124 their @code{Size} value, and are packed with no padding bits, i.e.@: they
16125 can start on an arbitrary bit boundary.
16127 All other types are non-packable, they occupy an integral number of
16128 storage units, and
16129 are placed at a boundary corresponding to their alignment requirements.
16131 For example, consider the record
16133 @smallexample @c ada
16134    type Rb1 is array (1 .. 13) of Boolean;
16135    pragma Pack (Rb1);
16137    type Rb2 is array (1 .. 65) of Boolean;
16138    pragma Pack (Rb2);
16140    type AF is new Float with Atomic;
16142    type X2 is record
16143       L1 : Boolean;
16144       L2 : Duration;
16145       L3 : AF;
16146       L4 : Boolean;
16147       L5 : Rb1;
16148       L6 : Rb2;
16149    end record;
16150    pragma Pack (X2);
16151 @end smallexample
16153 @noindent
16154 The representation for the record X2 is as follows:
16156 @smallexample @c ada
16157 for X2'Size use 224;
16158 for X2 use record
16159    L1 at  0 range  0 .. 0;
16160    L2 at  0 range  1 .. 64;
16161    L3 at 12 range  0 .. 31;
16162    L4 at 16 range  0 .. 0;
16163    L5 at 16 range  1 .. 13;
16164    L6 at 18 range  0 .. 71;
16165 end record;
16166 @end smallexample
16168 @noindent
16169 Studying this example, we see that the packable fields @code{L1}
16170 and @code{L2} are
16171 of length equal to their sizes, and placed at specific bit boundaries (and
16172 not byte boundaries) to
16173 eliminate padding.  But @code{L3} is of a non-packable float type (because
16174 it is aliased), so it is on the next appropriate alignment boundary.
16176 The next two fields are fully packable, so @code{L4} and @code{L5} are
16177 minimally packed with no gaps.  However, type @code{Rb2} is a packed
16178 array that is longer than 64 bits, so it is itself non-packable.  Thus
16179 the @code{L6} field is aligned to the next byte boundary, and takes an
16180 integral number of bytes, i.e.@: 72 bits.
16182 @node Record Representation Clauses
16183 @section Record Representation Clauses
16184 @cindex Record Representation Clause
16186 @noindent
16187 Record representation clauses may be given for all record types, including
16188 types obtained by record extension.  Component clauses are allowed for any
16189 static component.  The restrictions on component clauses depend on the type
16190 of the component.
16192 @cindex Component Clause
16193 For all components of an elementary type, the only restriction on component
16194 clauses is that the size must be at least the 'Size value of the type
16195 (actually the Value_Size).  There are no restrictions due to alignment,
16196 and such components may freely cross storage boundaries.
16198 Packed arrays with a size up to and including 64 bits are represented
16199 internally using a modular type with the appropriate number of bits, and
16200 thus the same lack of restriction applies.  For example, if you declare:
16202 @smallexample @c ada
16203    type R is array (1 .. 49) of Boolean;
16204    pragma Pack (R);
16205    for R'Size use 49;
16206 @end smallexample
16208 @noindent
16209 then a component clause for a component of type R may start on any
16210 specified bit boundary, and may specify a value of 49 bits or greater.
16212 For packed bit arrays that are longer than 64 bits, there are two
16213 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
16214 including the important case of single bits or boolean values, then
16215 there are no limitations on placement of such components, and they
16216 may start and end at arbitrary bit boundaries.
16218 If the component size is not a power of 2 (e.g.@: 3 or 5), then
16219 an array of this type longer than 64 bits must always be placed on
16220 on a storage unit (byte) boundary and occupy an integral number
16221 of storage units (bytes). Any component clause that does not
16222 meet this requirement will be rejected.
16224 Any aliased component, or component of an aliased type, must
16225 have its normal alignment and size. A component clause that
16226 does not meet this requirement will be rejected.
16228 The tag field of a tagged type always occupies an address sized field at
16229 the start of the record.  No component clause may attempt to overlay this
16230 tag. When a tagged type appears as a component, the tag field must have
16231 proper alignment
16233 In the case of a record extension T1, of a type T, no component clause applied
16234 to the type T1 can specify a storage location that would overlap the first
16235 T'Size bytes of the record.
16237 For all other component types, including non-bit-packed arrays,
16238 the component can be placed at an arbitrary bit boundary,
16239 so for example, the following is permitted:
16241 @smallexample @c ada
16242    type R is array (1 .. 10) of Boolean;
16243    for R'Size use 80;
16245    type Q is record
16246       G, H : Boolean;
16247       L, M : R;
16248    end record;
16250    for Q use record
16251       G at 0 range  0 ..   0;
16252       H at 0 range  1 ..   1;
16253       L at 0 range  2 ..  81;
16254       R at 0 range 82 .. 161;
16255    end record;
16256 @end smallexample
16258 @noindent
16259 Note: the above rules apply to recent releases of GNAT 5.
16260 In GNAT 3, there are more severe restrictions on larger components.
16261 For non-primitive types, including packed arrays with a size greater than
16262 64 bits, component clauses must respect the alignment requirement of the
16263 type, in particular, always starting on a byte boundary, and the length
16264 must be a multiple of the storage unit.
16266 @node Handling of Records with Holes
16267 @section Handling of Records with Holes
16268 @cindex Handling of Records with Holes
16270 As a result of alignment considerations, records may contain "holes"
16271 or gaps
16272 which do not correspond to the data bits of any of the components.
16273 Record representation clauses can also result in holes in records.
16275 GNAT does not attempt to clear these holes, so in record objects,
16276 they should be considered to hold undefined rubbish. The generated
16277 equality routine just tests components so does not access these
16278 undefined bits, and assignment and copy operations may or may not
16279 preserve the contents of these holes (for assignments, the holes
16280 in the target will in practice contain either the bits that are
16281 present in the holes in the source, or the bits that were present
16282 in the target before the assignment).
16284 If it is necessary to ensure that holes in records have all zero
16285 bits, then record objects for which this initialization is desired
16286 should be explicitly set to all zero values using Unchecked_Conversion
16287 or address overlays. For example
16289 @smallexample @c ada
16290 type HRec is record
16291    C : Character;
16292    I : Integer;
16293 end record;
16294 @end smallexample
16296 @noindent
16297 On typical machines, integers need to be aligned on a four-byte
16298 boundary, resulting in three bytes of undefined rubbish following
16299 the 8-bit field for C. To ensure that the hole in a variable of
16300 type HRec is set to all zero bits,
16301 you could for example do:
16303 @smallexample @c ada
16304 type Base is record
16305    Dummy1, Dummy2 : Integer := 0;
16306 end record;
16308 BaseVar : Base;
16309 RealVar : Hrec;
16310 for RealVar'Address use BaseVar'Address;
16311 @end smallexample
16313 @noindent
16314 Now the 8-bytes of the value of RealVar start out containing all zero
16315 bits. A safer approach is to just define dummy fields, avoiding the
16316 holes, as in:
16318 @smallexample @c ada
16319 type HRec is record
16320    C      : Character;
16321    Dummy1 : Short_Short_Integer := 0;
16322    Dummy2 : Short_Short_Integer := 0;
16323    Dummy3 : Short_Short_Integer := 0;
16324    I      : Integer;
16325 end record;
16326 @end smallexample
16328 @noindent
16329 And to make absolutely sure that the intent of this is followed, you
16330 can use representation clauses:
16332 @smallexample @c ada
16333 for Hrec use record
16334    C      at 0 range 0 .. 7;
16335    Dummy1 at 1 range 0 .. 7;
16336    Dummy2 at 2 range 0 .. 7;
16337    Dummy3 at 3 range 0 .. 7;
16338    I      at 4 range 0 .. 31;
16339 end record;
16340 for Hrec'Size use 64;
16341 @end smallexample
16343 @node Enumeration Clauses
16344 @section Enumeration Clauses
16346 The only restriction on enumeration clauses is that the range of values
16347 must be representable.  For the signed case, if one or more of the
16348 representation values are negative, all values must be in the range:
16350 @smallexample @c ada
16351    System.Min_Int .. System.Max_Int
16352 @end smallexample
16354 @noindent
16355 For the unsigned case, where all values are nonnegative, the values must
16356 be in the range:
16358 @smallexample @c ada
16359    0 .. System.Max_Binary_Modulus;
16360 @end smallexample
16362 @noindent
16363 A @emph{confirming} representation clause is one in which the values range
16364 from 0 in sequence, i.e.@: a clause that confirms the default representation
16365 for an enumeration type.
16366 Such a confirming representation
16367 is permitted by these rules, and is specially recognized by the compiler so
16368 that no extra overhead results from the use of such a clause.
16370 If an array has an index type which is an enumeration type to which an
16371 enumeration clause has been applied, then the array is stored in a compact
16372 manner.  Consider the declarations:
16374 @smallexample @c ada
16375    type r is (A, B, C);
16376    for r use (A => 1, B => 5, C => 10);
16377    type t is array (r) of Character;
16378 @end smallexample
16380 @noindent
16381 The array type t corresponds to a vector with exactly three elements and
16382 has a default size equal to @code{3*Character'Size}.  This ensures efficient
16383 use of space, but means that accesses to elements of the array will incur
16384 the overhead of converting representation values to the corresponding
16385 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
16387 @node Address Clauses
16388 @section Address Clauses
16389 @cindex Address Clause
16391 The reference manual allows a general restriction on representation clauses,
16392 as found in RM 13.1(22):
16394 @quotation
16395 An implementation need not support representation
16396 items containing nonstatic expressions, except that
16397 an implementation should support a representation item
16398 for a given entity if each nonstatic expression in the
16399 representation item is a name that statically denotes
16400 a constant declared before the entity.
16401 @end quotation
16403 @noindent
16404 In practice this is applicable only to address clauses, since this is the
16405 only case in which a non-static expression is permitted by the syntax.  As
16406 the AARM notes in sections 13.1 (22.a-22.h):
16408 @display
16409   22.a   Reason: This is to avoid the following sort of thing:
16411   22.b        X : Integer := F(@dots{});
16412               Y : Address := G(@dots{});
16413               for X'Address use Y;
16415   22.c   In the above, we have to evaluate the
16416          initialization expression for X before we
16417          know where to put the result.  This seems
16418          like an unreasonable implementation burden.
16420   22.d   The above code should instead be written
16421          like this:
16423   22.e        Y : constant Address := G(@dots{});
16424               X : Integer := F(@dots{});
16425               for X'Address use Y;
16427   22.f   This allows the expression ``Y'' to be safely
16428          evaluated before X is created.
16430   22.g   The constant could be a formal parameter of mode in.
16432   22.h   An implementation can support other nonstatic
16433          expressions if it wants to.  Expressions of type
16434          Address are hardly ever static, but their value
16435          might be known at compile time anyway in many
16436          cases.
16437 @end display
16439 @noindent
16440 GNAT does indeed permit many additional cases of non-static expressions.  In
16441 particular, if the type involved is elementary there are no restrictions
16442 (since in this case, holding a temporary copy of the initialization value,
16443 if one is present, is inexpensive).  In addition, if there is no implicit or
16444 explicit initialization, then there are no restrictions.  GNAT will reject
16445 only the case where all three of these conditions hold:
16447 @itemize @bullet
16449 @item
16450 The type of the item is non-elementary (e.g.@: a record or array).
16452 @item
16453 There is explicit or implicit initialization required for the object.
16454 Note that access values are always implicitly initialized.
16456 @item
16457 The address value is non-static.  Here GNAT is more permissive than the
16458 RM, and allows the address value to be the address of a previously declared
16459 stand-alone variable, as long as it does not itself have an address clause.
16461 @smallexample @c ada
16462            Anchor  : Some_Initialized_Type;
16463            Overlay : Some_Initialized_Type;
16464            for Overlay'Address use Anchor'Address;
16465 @end smallexample
16467 @noindent
16468 However, the prefix of the address clause cannot be an array component, or
16469 a component of a discriminated record.
16471 @end itemize
16473 @noindent
16474 As noted above in section 22.h, address values are typically non-static.  In
16475 particular the To_Address function, even if applied to a literal value, is
16476 a non-static function call.  To avoid this minor annoyance, GNAT provides
16477 the implementation defined attribute 'To_Address.  The following two
16478 expressions have identical values:
16480 @findex Attribute
16481 @findex To_Address
16482 @smallexample @c ada
16483    To_Address (16#1234_0000#)
16484    System'To_Address (16#1234_0000#);
16485 @end smallexample
16487 @noindent
16488 except that the second form is considered to be a static expression, and
16489 thus when used as an address clause value is always permitted.
16491 @noindent
16492 Additionally, GNAT treats as static an address clause that is an
16493 unchecked_conversion of a static integer value.  This simplifies the porting
16494 of legacy code, and provides a portable equivalent to the GNAT attribute
16495 @code{To_Address}.
16497 Another issue with address clauses is the interaction with alignment
16498 requirements.  When an address clause is given for an object, the address
16499 value must be consistent with the alignment of the object (which is usually
16500 the same as the alignment of the type of the object).  If an address clause
16501 is given that specifies an inappropriately aligned address value, then the
16502 program execution is erroneous.
16504 Since this source of erroneous behavior can have unfortunate effects, GNAT
16505 checks (at compile time if possible, generating a warning, or at execution
16506 time with a run-time check) that the alignment is appropriate.  If the
16507 run-time check fails, then @code{Program_Error} is raised.  This run-time
16508 check is suppressed if range checks are suppressed, or if the special GNAT
16509 check Alignment_Check is suppressed, or if
16510 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
16512 Finally, GNAT does not permit overlaying of objects of controlled types or
16513 composite types containing a controlled component. In most cases, the compiler
16514 can detect an attempt at such overlays and will generate a warning at compile
16515 time and a Program_Error exception at run time.
16517 @findex Export
16518 An address clause cannot be given for an exported object.  More
16519 understandably the real restriction is that objects with an address
16520 clause cannot be exported.  This is because such variables are not
16521 defined by the Ada program, so there is no external object to export.
16523 @findex Import
16524 It is permissible to give an address clause and a pragma Import for the
16525 same object.  In this case, the variable is not really defined by the
16526 Ada program, so there is no external symbol to be linked.  The link name
16527 and the external name are ignored in this case.  The reason that we allow this
16528 combination is that it provides a useful idiom to avoid unwanted
16529 initializations on objects with address clauses.
16531 When an address clause is given for an object that has implicit or
16532 explicit initialization, then by default initialization takes place.  This
16533 means that the effect of the object declaration is to overwrite the
16534 memory at the specified address.  This is almost always not what the
16535 programmer wants, so GNAT will output a warning:
16537 @smallexample
16538   with System;
16539   package G is
16540      type R is record
16541         M : Integer := 0;
16542      end record;
16544      Ext : R;
16545      for Ext'Address use System'To_Address (16#1234_1234#);
16546          |
16547   >>> warning: implicit initialization of "Ext" may
16548       modify overlaid storage
16549   >>> warning: use pragma Import for "Ext" to suppress
16550       initialization (RM B(24))
16552   end G;
16553 @end smallexample
16555 @noindent
16556 As indicated by the warning message, the solution is to use a (dummy) pragma
16557 Import to suppress this initialization.  The pragma tell the compiler that the
16558 object is declared and initialized elsewhere.  The following package compiles
16559 without warnings (and the initialization is suppressed):
16561 @smallexample @c ada
16562    with System;
16563    package G is
16564       type R is record
16565          M : Integer := 0;
16566       end record;
16568       Ext : R;
16569       for Ext'Address use System'To_Address (16#1234_1234#);
16570       pragma Import (Ada, Ext);
16571    end G;
16572 @end smallexample
16574 @noindent
16575 A final issue with address clauses involves their use for overlaying
16576 variables, as in the following example:
16577 @cindex Overlaying of objects
16579 @smallexample @c ada
16580   A : Integer;
16581   B : Integer;
16582   for B'Address use A'Address;
16583 @end smallexample
16585 @noindent
16586 or alternatively, using the form recommended by the RM:
16588 @smallexample @c ada
16589   A    : Integer;
16590   Addr : constant Address := A'Address;
16591   B    : Integer;
16592   for B'Address use Addr;
16593 @end smallexample
16595 @noindent
16596 In both of these cases, @code{A}
16597 and @code{B} become aliased to one another via the
16598 address clause. This use of address clauses to overlay
16599 variables, achieving an effect similar to unchecked
16600 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
16601 the effect is implementation defined. Furthermore, the
16602 Ada RM specifically recommends that in a situation
16603 like this, @code{B} should be subject to the following
16604 implementation advice (RM 13.3(19)):
16606 @quotation
16607 19  If the Address of an object is specified, or it is imported
16608     or exported, then the implementation should not perform
16609     optimizations based on assumptions of no aliases.
16610 @end quotation
16612 @noindent
16613 GNAT follows this recommendation, and goes further by also applying
16614 this recommendation to the overlaid variable (@code{A}
16615 in the above example) in this case. This means that the overlay
16616 works "as expected", in that a modification to one of the variables
16617 will affect the value of the other.
16619 Note that when address clause overlays are used in this way, there is an
16620 issue of unintentional initialization, as shown by this example:
16622 @smallexample @c ada
16623 package Overwrite_Record is
16624    type R is record
16625       A : Character := 'C';
16626       B : Character := 'A';
16627    end record;
16628    X : Short_Integer := 3;
16629    Y : R;
16630    for Y'Address use X'Address;
16631        |
16632 >>> warning: default initialization of "Y" may
16633     modify "X", use pragma Import for "Y" to
16634     suppress initialization (RM B.1(24))
16636 end Overwrite_Record;
16637 @end smallexample
16639 @noindent
16640 Here the default initialization of @code{Y} will clobber the value
16641 of @code{X}, which justifies the warning. The warning notes that
16642 this effect can be eliminated by adding a @code{pragma Import}
16643 which suppresses the initialization:
16645 @smallexample @c ada
16646 package Overwrite_Record is
16647    type R is record
16648       A : Character := 'C';
16649       B : Character := 'A';
16650    end record;
16651    X : Short_Integer := 3;
16652    Y : R;
16653    for Y'Address use X'Address;
16654    pragma Import (Ada, Y);
16655 end Overwrite_Record;
16656 @end smallexample
16658 @noindent
16659 Note that the use of @code{pragma Initialize_Scalars} may cause variables to
16660 be initialized when they would not otherwise have been in the absence
16661 of the use of this pragma. This may cause an overlay to have this
16662 unintended clobbering effect. The compiler avoids this for scalar
16663 types, but not for composite objects (where in general the effect
16664 of @code{Initialize_Scalars} is part of the initialization routine
16665 for the composite object:
16667 @smallexample @c ada
16668 pragma Initialize_Scalars;
16669 with Ada.Text_IO;  use Ada.Text_IO;
16670 procedure Overwrite_Array is
16671    type Arr is array (1 .. 5) of Integer;
16672    X : Arr := (others => 1);
16673    A : Arr;
16674    for A'Address use X'Address;
16675        |
16676 >>> warning: default initialization of "A" may
16677     modify "X", use pragma Import for "A" to
16678     suppress initialization (RM B.1(24))
16680 begin
16681    if X /= Arr'(others => 1) then
16682       Put_Line ("X was clobbered");
16683    else
16684       Put_Line ("X was not clobbered");
16685    end if;
16686 end Overwrite_Array;
16687 @end smallexample
16689 @noindent
16690 The above program generates the warning as shown, and at execution
16691 time, prints @code{X was clobbered}. If the @code{pragma Import} is
16692 added as suggested:
16694 @smallexample @c ada
16695 pragma Initialize_Scalars;
16696 with Ada.Text_IO;  use Ada.Text_IO;
16697 procedure Overwrite_Array is
16698    type Arr is array (1 .. 5) of Integer;
16699    X : Arr := (others => 1);
16700    A : Arr;
16701    for A'Address use X'Address;
16702    pragma Import (Ada, A);
16703 begin
16704    if X /= Arr'(others => 1) then
16705       Put_Line ("X was clobbered");
16706    else
16707       Put_Line ("X was not clobbered");
16708    end if;
16709 end Overwrite_Array;
16710 @end smallexample
16712 @noindent
16713 then the program compiles without the warning and when run will generate
16714 the output @code{X was not clobbered}.
16716 @node Use of Address Clauses for Memory-Mapped I/O
16717 @section Use of Address Clauses for Memory-Mapped I/O
16718 @cindex Memory-mapped I/O
16720 A common pattern is to use an address clause to map an atomic variable to
16721 a location in memory that corresponds to a memory-mapped I/O operation or
16722 operations, for example:
16724 @smallexample @c ada
16725     type Mem_Word is record
16726        A,B,C,D : Byte;
16727     end record;
16728     pragma Atomic (Mem_Word);
16729     for Mem_Word_Size use 32;
16731     Mem : Mem_Word;
16732     for Mem'Address use some-address;
16733     ...
16734     Temp := Mem;
16735     Temp.A := 32;
16736     Mem := Temp;
16737 @end smallexample
16739 @noindent
16740 For a full access (reference or modification) of the variable (Mem) in
16741 this case, as in the above examples, GNAT guarantees that the entire atomic
16742 word will be accessed. It is not clear whether the RM requires this. For
16743 example in the above, can the compiler reference only the Mem.A field as
16744 an optimization? Whatever the answer to this question is, GNAT makes the
16745 guarantee that for such a reference, the entire word is read or written.
16747 A problem arises with a component access such as:
16749 @smallexample @c ada
16750     Mem.A := 32;
16751 @end smallexample
16753 @noindent
16754 Note that the component A is not declared as atomic. This means that it is
16755 not clear what this assignment means. It could correspond to full word read
16756 and write as given in the first example, or on architectures that supported
16757 such an operation it might be a single byte store instruction. The RM does
16758 not have anything to say in this situation, and GNAT does not make any
16759 guarantee. The code generated may vary from target to target. GNAT will issue
16760 a warning in such a case:
16762 @smallexample @c ada
16763     Mem.A := 32;
16764     |
16765     >>> warning: access to non-atomic component of atomic array,
16766         may cause unexpected accesses to atomic object
16767 @end smallexample
16769 @noindent
16770 It is best to be explicit in this situation, by either declaring the
16771 components to be atomic if you want the byte store, or explicitly writing
16772 the full word access sequence if that is what the hardware requires.
16774 @node Effect of Convention on Representation
16775 @section Effect of Convention on Representation
16776 @cindex Convention, effect on representation
16778 @noindent
16779 Normally the specification of a foreign language convention for a type or
16780 an object has no effect on the chosen representation.  In particular, the
16781 representation chosen for data in GNAT generally meets the standard system
16782 conventions, and for example records are laid out in a manner that is
16783 consistent with C@.  This means that specifying convention C (for example)
16784 has no effect.
16786 There are four exceptions to this general rule:
16788 @itemize @bullet
16790 @item Convention Fortran and array subtypes
16791 If pragma Convention Fortran is specified for an array subtype, then in
16792 accordance with the implementation advice in section 3.6.2(11) of the
16793 Ada Reference Manual, the array will be stored in a Fortran-compatible
16794 column-major manner, instead of the normal default row-major order.
16796 @item Convention C and enumeration types
16797 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
16798 to accommodate all values of the type.  For example, for the enumeration
16799 type declared by:
16801 @smallexample @c ada
16802    type Color is (Red, Green, Blue);
16803 @end smallexample
16805 @noindent
16806 8 bits is sufficient to store all values of the type, so by default, objects
16807 of type @code{Color} will be represented using 8 bits.  However, normal C
16808 convention is to use 32 bits for all enum values in C, since enum values
16809 are essentially of type int.  If pragma @code{Convention C} is specified for an
16810 Ada enumeration type, then the size is modified as necessary (usually to
16811 32 bits) to be consistent with the C convention for enum values.
16813 Note that this treatment applies only to types. If Convention C is given for
16814 an enumeration object, where the enumeration type is not Convention C, then
16815 Object_Size bits are allocated. For example, for a normal enumeration type,
16816 with less than 256 elements, only 8 bits will be allocated for the object.
16817 Since this may be a surprise in terms of what C expects, GNAT will issue a
16818 warning in this situation. The warning can be suppressed by giving an explicit
16819 size clause specifying the desired size.
16821 @item Convention C/Fortran and Boolean types
16822 In C, the usual convention for boolean values, that is values used for
16823 conditions, is that zero represents false, and nonzero values represent
16824 true.  In Ada, the normal convention is that two specific values, typically
16825 0/1, are used to represent false/true respectively.
16827 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
16828 value represents true).
16830 To accommodate the Fortran and C conventions, if a pragma Convention specifies
16831 C or Fortran convention for a derived Boolean, as in the following example:
16833 @smallexample @c ada
16834    type C_Switch is new Boolean;
16835    pragma Convention (C, C_Switch);
16836 @end smallexample
16838 @noindent
16839 then the GNAT generated code will treat any nonzero value as true.  For truth
16840 values generated by GNAT, the conventional value 1 will be used for True, but
16841 when one of these values is read, any nonzero value is treated as True.
16843 @item Access types on OpenVMS
16844 For 64-bit OpenVMS systems, access types (other than those for unconstrained
16845 arrays) are 64-bits long. An exception to this rule is for the case of
16846 C-convention access types where there is no explicit size clause present (or
16847 inherited for derived types). In this case, GNAT chooses to make these
16848 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
16849 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
16851 @end itemize
16853 @node Conventions and Anonymous Access Types
16854 @section Conventions and Anonymous Access Types
16855 @cindex Anonymous access types
16856 @cindex Convention for anonymous access types
16858 The RM is not entirely clear on convention handling in a number of cases,
16859 and in particular, it is not clear on the convention to be given to
16860 anonymous access types in general, and in particular what is to be
16861 done for the case of anonymous access-to-subprogram.
16863 In GNAT, we decide that if an explicit Convention is applied
16864 to an object or component, and its type is such an anonymous type,
16865 then the convention will apply to this anonymous type as well. This
16866 seems to make sense since it is anomolous in any case to have a
16867 different convention for an object and its type, and there is clearly
16868 no way to explicitly specify a convention for an anonymous type, since
16869 it doesn't have a name to specify!
16871 Furthermore, we decide that if a convention is applied to a record type,
16872 then this convention is inherited by any of its components that are of an
16873 anonymous access type which do not have an explicitly specified convention.
16875 The following program shows these conventions in action:
16877 @smallexample @c ada
16878 package ConvComp is
16879    type Foo is range 1 .. 10;
16880    type T1 is record
16881       A : access function (X : Foo) return Integer;
16882       B : Integer;
16883    end record;
16884    pragma Convention (C, T1);
16886    type T2 is record
16887       A : access function (X : Foo) return Integer;
16888       pragma Convention  (C, A);
16889       B : Integer;
16890    end record;
16891    pragma Convention (COBOL, T2);
16893    type T3 is record
16894       A : access function (X : Foo) return Integer;
16895       pragma Convention  (COBOL, A);
16896       B : Integer;
16897    end record;
16898    pragma Convention (C, T3);
16900    type T4 is record
16901       A : access function (X : Foo) return Integer;
16902       B : Integer;
16903    end record;
16904    pragma Convention (COBOL, T4);
16906    function F (X : Foo) return Integer;
16907    pragma Convention (C, F);
16909    function F (X : Foo) return Integer is (13);
16911    TV1 : T1 := (F'Access, 12);  -- OK
16912    TV2 : T2 := (F'Access, 13);  -- OK
16914    TV3 : T3 := (F'Access, 13);  -- ERROR
16915                 |
16916 >>> subprogram "F" has wrong convention
16917 >>> does not match access to subprogram declared at line 17
16918      38.    TV4 : T4 := (F'Access, 13);  -- ERROR
16919                 |
16920 >>> subprogram "F" has wrong convention
16921 >>> does not match access to subprogram declared at line 24
16922      39. end ConvComp;
16923 @end smallexample
16925 @node Determining the Representations chosen by GNAT
16926 @section Determining the Representations chosen by GNAT
16927 @cindex Representation, determination of
16928 @cindex @option{-gnatR} switch
16930 @noindent
16931 Although the descriptions in this section are intended to be complete, it is
16932 often easier to simply experiment to see what GNAT accepts and what the
16933 effect is on the layout of types and objects.
16935 As required by the Ada RM, if a representation clause is not accepted, then
16936 it must be rejected as illegal by the compiler.  However, when a
16937 representation clause or pragma is accepted, there can still be questions
16938 of what the compiler actually does.  For example, if a partial record
16939 representation clause specifies the location of some components and not
16940 others, then where are the non-specified components placed? Or if pragma
16941 @code{Pack} is used on a record, then exactly where are the resulting
16942 fields placed? The section on pragma @code{Pack} in this chapter can be
16943 used to answer the second question, but it is often easier to just see
16944 what the compiler does.
16946 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
16947 with this option, then the compiler will output information on the actual
16948 representations chosen, in a format similar to source representation
16949 clauses.  For example, if we compile the package:
16951 @smallexample @c ada
16952 package q is
16953    type r (x : boolean) is tagged record
16954       case x is
16955          when True => S : String (1 .. 100);
16956          when False => null;
16957       end case;
16958    end record;
16960    type r2 is new r (false) with record
16961       y2 : integer;
16962    end record;
16964    for r2 use record
16965       y2 at 16 range 0 .. 31;
16966    end record;
16968    type x is record
16969       y : character;
16970    end record;
16972    type x1 is array (1 .. 10) of x;
16973    for x1'component_size use 11;
16975    type ia is access integer;
16977    type Rb1 is array (1 .. 13) of Boolean;
16978    pragma Pack (rb1);
16980    type Rb2 is array (1 .. 65) of Boolean;
16981    pragma Pack (rb2);
16983    type x2 is record
16984       l1 : Boolean;
16985       l2 : Duration;
16986       l3 : Float;
16987       l4 : Boolean;
16988       l5 : Rb1;
16989       l6 : Rb2;
16990    end record;
16991    pragma Pack (x2);
16992 end q;
16993 @end smallexample
16995 @noindent
16996 using the switch @option{-gnatR} we obtain the following output:
16998 @smallexample
16999 Representation information for unit q
17000 -------------------------------------
17002 for r'Size use ??;
17003 for r'Alignment use 4;
17004 for r use record
17005    x    at 4 range  0 .. 7;
17006    _tag at 0 range  0 .. 31;
17007    s    at 5 range  0 .. 799;
17008 end record;
17010 for r2'Size use 160;
17011 for r2'Alignment use 4;
17012 for r2 use record
17013    x       at  4 range  0 .. 7;
17014    _tag    at  0 range  0 .. 31;
17015    _parent at  0 range  0 .. 63;
17016    y2      at 16 range  0 .. 31;
17017 end record;
17019 for x'Size use 8;
17020 for x'Alignment use 1;
17021 for x use record
17022    y at 0 range  0 .. 7;
17023 end record;
17025 for x1'Size use 112;
17026 for x1'Alignment use 1;
17027 for x1'Component_Size use 11;
17029 for rb1'Size use 13;
17030 for rb1'Alignment use 2;
17031 for rb1'Component_Size use 1;
17033 for rb2'Size use 72;
17034 for rb2'Alignment use 1;
17035 for rb2'Component_Size use 1;
17037 for x2'Size use 224;
17038 for x2'Alignment use 4;
17039 for x2 use record
17040    l1 at  0 range  0 .. 0;
17041    l2 at  0 range  1 .. 64;
17042    l3 at 12 range  0 .. 31;
17043    l4 at 16 range  0 .. 0;
17044    l5 at 16 range  1 .. 13;
17045    l6 at 18 range  0 .. 71;
17046 end record;
17047 @end smallexample
17049 @noindent
17050 The Size values are actually the Object_Size, i.e.@: the default size that
17051 will be allocated for objects of the type.
17052 The ?? size for type r indicates that we have a variant record, and the
17053 actual size of objects will depend on the discriminant value.
17055 The Alignment values show the actual alignment chosen by the compiler
17056 for each record or array type.
17058 The record representation clause for type r shows where all fields
17059 are placed, including the compiler generated tag field (whose location
17060 cannot be controlled by the programmer).
17062 The record representation clause for the type extension r2 shows all the
17063 fields present, including the parent field, which is a copy of the fields
17064 of the parent type of r2, i.e.@: r1.
17066 The component size and size clauses for types rb1 and rb2 show
17067 the exact effect of pragma @code{Pack} on these arrays, and the record
17068 representation clause for type x2 shows how pragma @code{Pack} affects
17069 this record type.
17071 In some cases, it may be useful to cut and paste the representation clauses
17072 generated by the compiler into the original source to fix and guarantee
17073 the actual representation to be used.
17075 @node Standard Library Routines
17076 @chapter Standard Library Routines
17078 @noindent
17079 The Ada Reference Manual contains in Annex A a full description of an
17080 extensive set of standard library routines that can be used in any Ada
17081 program, and which must be provided by all Ada compilers.  They are
17082 analogous to the standard C library used by C programs.
17084 GNAT implements all of the facilities described in annex A, and for most
17085 purposes the description in the Ada Reference Manual, or appropriate Ada
17086 text book, will be sufficient for making use of these facilities.
17088 In the case of the input-output facilities,
17089 @xref{The Implementation of Standard I/O},
17090 gives details on exactly how GNAT interfaces to the
17091 file system.  For the remaining packages, the Ada Reference Manual
17092 should be sufficient.  The following is a list of the packages included,
17093 together with a brief description of the functionality that is provided.
17095 For completeness, references are included to other predefined library
17096 routines defined in other sections of the Ada Reference Manual (these are
17097 cross-indexed from Annex A). For further details see the relevant
17098 package declarations in the run-time library. In particular, a few units
17099 are not implemented, as marked by the presence of pragma Unimplemented_Unit,
17100 and in this case the package declaration contains comments explaining why
17101 the unit is not implemented.
17103 @table @code
17104 @item Ada (A.2)
17105 This is a parent package for all the standard library packages.  It is
17106 usually included implicitly in your program, and itself contains no
17107 useful data or routines.
17109 @item Ada.Assertions (11.4.2)
17110 @code{Assertions} provides the @code{Assert} subprograms, and also
17111 the declaration of the @code{Assertion_Error} exception.
17113 @item Ada.Asynchronous_Task_Control (D.11)
17114 @code{Asynchronous_Task_Control} provides low level facilities for task
17115 synchronization. It is typically not implemented. See package spec for details.
17117 @item Ada.Calendar (9.6)
17118 @code{Calendar} provides time of day access, and routines for
17119 manipulating times and durations.
17121 @item Ada.Calendar.Arithmetic (9.6.1)
17122 This package provides additional arithmetic
17123 operations for @code{Calendar}.
17125 @item Ada.Calendar.Formatting (9.6.1)
17126 This package provides formatting operations for @code{Calendar}.
17128 @item Ada.Calendar.Time_Zones (9.6.1)
17129 This package provides additional @code{Calendar} facilities
17130 for handling time zones.
17132 @item Ada.Characters (A.3.1)
17133 This is a dummy parent package that contains no useful entities
17135 @item Ada.Characters.Conversions (A.3.2)
17136 This package provides character conversion functions.
17138 @item Ada.Characters.Handling (A.3.2)
17139 This package provides some basic character handling capabilities,
17140 including classification functions for classes of characters (e.g.@: test
17141 for letters, or digits).
17143 @item Ada.Characters.Latin_1 (A.3.3)
17144 This package includes a complete set of definitions of the characters
17145 that appear in type CHARACTER@.  It is useful for writing programs that
17146 will run in international environments.  For example, if you want an
17147 upper case E with an acute accent in a string, it is often better to use
17148 the definition of @code{UC_E_Acute} in this package.  Then your program
17149 will print in an understandable manner even if your environment does not
17150 support these extended characters.
17152 @item Ada.Command_Line (A.15)
17153 This package provides access to the command line parameters and the name
17154 of the current program (analogous to the use of @code{argc} and @code{argv}
17155 in C), and also allows the exit status for the program to be set in a
17156 system-independent manner.
17158 @item Ada.Complex_Text_IO (G.1.3)
17159 This package provides text input and output of complex numbers.
17161 @item Ada.Containers (A.18.1)
17162 A top level package providing a few basic definitions used by all the
17163 following specific child packages that provide specific kinds of
17164 containers.
17166 @item Ada.Containers.Bounded_Priority_Queues (A.18.31)
17168 @item Ada.Containers.Bounded_Synchronized_Queues (A.18.29)
17170 @item Ada.Containers.Doubly_Linked_Lists (A.18.3)
17172 @item Ada.Containers.Generic_Array_Sort (A.18.26)
17174 @item Ada.Containers.Generic_Constrained_Array_Sort (A.18.26)
17176 @item Ada.Containers.Generic_Sort (A.18.26)
17178 @item Ada.Containers.Hashed_Maps (A.18.5)
17180 @item Ada.Containers.Hashed_Sets (A.18.8)
17182 @item Ada.Containers.Indefinite_Doubly_Linked_Lists (A.18.12)
17184 @item Ada.Containers.Indefinite_Hashed_Maps (A.18.13)
17186 @item Ada.Containers.Indefinite_Hashed_Sets (A.18.15)
17188 @item Ada.Containers.Indefinite_Holders (A.18.18)
17190 @item Ada.Containers.Indefinite_Multiway_Trees (A.18.17)
17192 @item Ada.Containers.Indefinite_Ordered_Maps (A.18.14)
17194 @item Ada.Containers.Indefinite_Ordered_Sets (A.18.16)
17196 @item Ada.Containers.Indefinite_Vectors (A.18.11)
17198 @item Ada.Containers.Multiway_Trees (A.18.10)
17200 @item Ada.Containers.Ordered_Maps (A.18.6)
17202 @item Ada.Containers.Ordered_Sets (A.18.9)
17204 @item Ada.Containers.Synchronized_Queue_Interfaces (A.18.27)
17206 @item Ada.Containers.Unbounded_Priority_Queues (A.18.30)
17208 @item Ada.Containers.Unbounded_Synchronized_Queues (A.18.28)
17210 @item Ada.Containers.Vectors (A.18.2)
17212 @item Ada.Directories (A.16)
17213 This package provides operations on directories.
17215 @item Ada.Directories.Hierarchical_File_Names (A.16.1)
17216 This package provides additional directory operations handling
17217 hiearchical file names.
17219 @item Ada.Directories.Information (A.16)
17220 This is an implementation defined package for additional directory
17221 operations, which is not implemented in GNAT.
17223 @item Ada.Decimal (F.2)
17224 This package provides constants describing the range of decimal numbers
17225 implemented, and also a decimal divide routine (analogous to the COBOL
17226 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
17228 @item Ada.Direct_IO (A.8.4)
17229 This package provides input-output using a model of a set of records of
17230 fixed-length, containing an arbitrary definite Ada type, indexed by an
17231 integer record number.
17233 @item Ada.Dispatching (D.2.1)
17234 A parent package containing definitions for task dispatching operations.
17236 @item Ada.Dispatching.EDF (D.2.6)
17237 Not implemented in GNAT.
17239 @item Ada.Dispatching.Non_Preemptive (D.2.4)
17240 Not implemented in GNAT.
17242 @item Ada.Dispatching.Round_Robin (D.2.5)
17243 Not implemented in GNAT.
17245 @item Ada.Dynamic_Priorities (D.5)
17246 This package allows the priorities of a task to be adjusted dynamically
17247 as the task is running.
17249 @item Ada.Environment_Variables (A.17)
17250 This package provides facilities for accessing environment variables.
17252 @item Ada.Exceptions (11.4.1)
17253 This package provides additional information on exceptions, and also
17254 contains facilities for treating exceptions as data objects, and raising
17255 exceptions with associated messages.
17257 @item Ada.Execution_Time (D.14)
17258 Not implemented in GNAT.
17260 @item Ada.Execution_Time.Group_Budgets (D.14.2)
17261 Not implemented in GNAT.
17263 @item Ada.Execution_Time.Timers (D.14.1)'
17264 Not implemented in GNAT.
17266 @item Ada.Finalization (7.6)
17267 This package contains the declarations and subprograms to support the
17268 use of controlled types, providing for automatic initialization and
17269 finalization (analogous to the constructors and destructors of C++).
17271 @item Ada.Float_Text_IO (A.10.9)
17272 A library level instantiation of Text_IO.Float_IO for type Float.
17274 @item Ada.Float_Wide_Text_IO (A.10.9)
17275 A library level instantiation of Wide_Text_IO.Float_IO for type Float.
17277 @item Ada.Float_Wide_Wide_Text_IO (A.10.9)
17278 A library level instantiation of Wide_Wide_Text_IO.Float_IO for type Float.
17280 @item Ada.Integer_Text_IO (A.10.9)
17281 A library level instantiation of Text_IO.Integer_IO for type Integer.
17283 @item Ada.Integer_Wide_Text_IO (A.10.9)
17284 A library level instantiation of Wide_Text_IO.Integer_IO for type Integer.
17286 @item Ada.Integer_Wide_Wide_Text_IO (A.10.9)
17287 A library level instantiation of Wide_Wide_Text_IO.Integer_IO for type Integer.
17289 @item Ada.Interrupts (C.3.2)
17290 This package provides facilities for interfacing to interrupts, which
17291 includes the set of signals or conditions that can be raised and
17292 recognized as interrupts.
17294 @item Ada.Interrupts.Names (C.3.2)
17295 This package provides the set of interrupt names (actually signal
17296 or condition names) that can be handled by GNAT@.
17298 @item Ada.IO_Exceptions (A.13)
17299 This package defines the set of exceptions that can be raised by use of
17300 the standard IO packages.
17302 @item Ada.Iterator_Interfaces (5.5.1)
17303 This package provides a generic interface to generalized iterators.
17305 @item Ada.Locales (A.19)
17306 This package provides declarations providing information (Language
17307 and Country) about the current locale.
17309 @item Ada.Numerics
17310 This package contains some standard constants and exceptions used
17311 throughout the numerics packages.  Note that the constants pi and e are
17312 defined here, and it is better to use these definitions than rolling
17313 your own.
17315 @item Ada.Numerics.Complex_Arrays (G.3.2)
17316 Provides operations on arrays of complex numbers.
17318 @item Ada.Numerics.Complex_Elementary_Functions
17319 Provides the implementation of standard elementary functions (such as
17320 log and trigonometric functions) operating on complex numbers using the
17321 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
17322 created by the package @code{Numerics.Complex_Types}.
17324 @item Ada.Numerics.Complex_Types
17325 This is a predefined instantiation of
17326 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
17327 build the type @code{Complex} and @code{Imaginary}.
17329 @item Ada.Numerics.Discrete_Random
17330 This generic package provides a random number generator suitable for generating
17331 uniformly distributed values of a specified discrete subtype.
17333 @item Ada.Numerics.Float_Random
17334 This package provides a random number generator suitable for generating
17335 uniformly distributed floating point values in the unit interval.
17337 @item Ada.Numerics.Generic_Complex_Elementary_Functions
17338 This is a generic version of the package that provides the
17339 implementation of standard elementary functions (such as log and
17340 trigonometric functions) for an arbitrary complex type.
17342 The following predefined instantiations of this package are provided:
17344 @table @code
17345 @item Short_Float
17346 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
17347 @item Float
17348 @code{Ada.Numerics.Complex_Elementary_Functions}
17349 @item Long_Float
17350 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
17351 @end table
17353 @item Ada.Numerics.Generic_Complex_Types
17354 This is a generic package that allows the creation of complex types,
17355 with associated complex arithmetic operations.
17357 The following predefined instantiations of this package exist
17358 @table @code
17359 @item Short_Float
17360 @code{Ada.Numerics.Short_Complex_Complex_Types}
17361 @item Float
17362 @code{Ada.Numerics.Complex_Complex_Types}
17363 @item Long_Float
17364 @code{Ada.Numerics.Long_Complex_Complex_Types}
17365 @end table
17367 @item Ada.Numerics.Generic_Elementary_Functions
17368 This is a generic package that provides the implementation of standard
17369 elementary functions (such as log an trigonometric functions) for an
17370 arbitrary float type.
17372 The following predefined instantiations of this package exist
17374 @table @code
17375 @item Short_Float
17376 @code{Ada.Numerics.Short_Elementary_Functions}
17377 @item Float
17378 @code{Ada.Numerics.Elementary_Functions}
17379 @item Long_Float
17380 @code{Ada.Numerics.Long_Elementary_Functions}
17381 @end table
17383 @item Ada.Numerics.Generic_Real_Arrays (G.3.1)
17384 Generic operations on arrays of reals
17386 @item Ada.Numerics.Real_Arrays (G.3.1)
17387 Preinstantiation of Ada.Numerics.Generic_Real_Arrays (Float).
17389 @item Ada.Real_Time (D.8)
17390 This package provides facilities similar to those of @code{Calendar}, but
17391 operating with a finer clock suitable for real time control. Note that
17392 annex D requires that there be no backward clock jumps, and GNAT generally
17393 guarantees this behavior, but of course if the external clock on which
17394 the GNAT runtime depends is deliberately reset by some external event,
17395 then such a backward jump may occur.
17397 @item Ada.Real_Time.Timing_Events (D.15)
17398 Not implemented in GNAT.
17400 @item Ada.Sequential_IO (A.8.1)
17401 This package provides input-output facilities for sequential files,
17402 which can contain a sequence of values of a single type, which can be
17403 any Ada type, including indefinite (unconstrained) types.
17405 @item Ada.Storage_IO (A.9)
17406 This package provides a facility for mapping arbitrary Ada types to and
17407 from a storage buffer.  It is primarily intended for the creation of new
17408 IO packages.
17410 @item Ada.Streams (13.13.1)
17411 This is a generic package that provides the basic support for the
17412 concept of streams as used by the stream attributes (@code{Input},
17413 @code{Output}, @code{Read} and @code{Write}).
17415 @item Ada.Streams.Stream_IO (A.12.1)
17416 This package is a specialization of the type @code{Streams} defined in
17417 package @code{Streams} together with a set of operations providing
17418 Stream_IO capability.  The Stream_IO model permits both random and
17419 sequential access to a file which can contain an arbitrary set of values
17420 of one or more Ada types.
17422 @item Ada.Strings (A.4.1)
17423 This package provides some basic constants used by the string handling
17424 packages.
17426 @item Ada.Strings.Bounded (A.4.4)
17427 This package provides facilities for handling variable length
17428 strings.  The bounded model requires a maximum length.  It is thus
17429 somewhat more limited than the unbounded model, but avoids the use of
17430 dynamic allocation or finalization.
17432 @item Ada.Strings.Bounded.Equal_Case_Insensitive (A.4.10)
17433 Provides case-insensitive comparisons of bounded strings
17435 @item Ada.Strings.Bounded.Hash (A.4.9)
17436 This package provides a generic hash function for bounded strings
17438 @item Ada.Strings.Bounded.Hash_Case_Insensitive (A.4.9)
17439 This package provides a generic hash function for bounded strings that
17440 converts the string to be hashed to lower case.
17442 @item Ada.Strings.Bounded.Less_Case_Insensitive (A.4.10)
17443 This package provides a comparison function for bounded strings that works
17444 in a case insensitive manner by converting to lower case before the comparison.
17446 @item Ada.Strings.Fixed (A.4.3)
17447 This package provides facilities for handling fixed length strings.
17449 @item Ada.Strings.Fixed.Equal_Case_Insensitive (A.4.10)
17450 This package provides an equality function for fixed strings that compares
17451 the strings after converting both to lower case.
17453 @item Ada.Strings.Fixed.Hash_Case_Insensitive (A.4.9)
17454 This package provides a case insensitive hash function for fixed strings that
17455 converts the string to lower case before computing the hash.
17457 @item Ada.Strings.Fixed.Less_Case_Insensitive (A.4.10)
17458 This package provides a comparison function for fixed strings that works
17459 in a case insensitive manner by converting to lower case before the comparison.
17461 Ada.Strings.Hash (A.4.9)
17462 This package provides a hash function for strings.
17464 Ada.Strings.Hash_Case_Insensitive (A.4.9)
17465 This package provides a hash function for strings that is case insensitive.
17466 The string is converted to lower case before computing the hash.
17468 @item Ada.Strings.Less_Case_Insensitive (A.4.10)
17469 This package provides a comparison function for\strings that works
17470 in a case insensitive manner by converting to lower case before the comparison.
17472 @item Ada.Strings.Maps (A.4.2)
17473 This package provides facilities for handling character mappings and
17474 arbitrarily defined subsets of characters.  For instance it is useful in
17475 defining specialized translation tables.
17477 @item Ada.Strings.Maps.Constants (A.4.6)
17478 This package provides a standard set of predefined mappings and
17479 predefined character sets.  For example, the standard upper to lower case
17480 conversion table is found in this package.  Note that upper to lower case
17481 conversion is non-trivial if you want to take the entire set of
17482 characters, including extended characters like E with an acute accent,
17483 into account.  You should use the mappings in this package (rather than
17484 adding 32 yourself) to do case mappings.
17486 @item Ada.Strings.Unbounded (A.4.5)
17487 This package provides facilities for handling variable length
17488 strings.  The unbounded model allows arbitrary length strings, but
17489 requires the use of dynamic allocation and finalization.
17491 @item Ada.Strings.Unbounded.Equal_Case_Insensitive (A.4.10)
17492 Provides case-insensitive comparisons of unbounded strings
17494 @item Ada.Strings.Unbounded.Hash (A.4.9)
17495 This package provides a generic hash function for unbounded strings
17497 @item Ada.Strings.Unbounded.Hash_Case_Insensitive (A.4.9)
17498 This package provides a generic hash function for unbounded strings that
17499 converts the string to be hashed to lower case.
17501 @item Ada.Strings.Unbounded.Less_Case_Insensitive (A.4.10)
17502 This package provides a comparison function for unbounded strings that works
17503 in a case insensitive manner by converting to lower case before the comparison.
17505 @item Ada.Strings.UTF_Encoding (A.4.11)
17506 This package provides basic definitions for dealing with UTF-encoded strings.
17508 @item Ada.Strings.UTF_Encoding.Conversions (A.4.11)
17509 This package provides conversion functions for UTF-encoded strings.
17511 @item Ada.Strings.UTF_Encoding.Strings (A.4.11)
17512 @itemx Ada.Strings.UTF_Encoding.Wide_Strings (A.4.11)
17513 @itemx Ada.Strings.UTF_Encoding.Wide_Wide_Strings (A.4.11)
17514 These packages provide facilities for handling UTF encodings for
17515 Strings, Wide_Strings and Wide_Wide_Strings.
17517 @item Ada.Strings.Wide_Bounded (A.4.7)
17518 @itemx Ada.Strings.Wide_Fixed (A.4.7)
17519 @itemx Ada.Strings.Wide_Maps (A.4.7)
17520 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
17521 These packages provide analogous capabilities to the corresponding
17522 packages without @samp{Wide_} in the name, but operate with the types
17523 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
17524 and @code{Character}. Versions of all the child packages are available.
17526 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
17527 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
17528 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
17529 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
17530 These packages provide analogous capabilities to the corresponding
17531 packages without @samp{Wide_} in the name, but operate with the types
17532 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
17533 of @code{String} and @code{Character}.
17535 @item Ada.Synchronous_Barriers (D.10.1)
17536 This package provides facilities for synchronizing tasks at a low level
17537 with barriers.
17539 @item Ada.Synchronous_Task_Control (D.10)
17540 This package provides some standard facilities for controlling task
17541 communication in a synchronous manner.
17543 @item Ada.Synchronous_Task_Control.EDF (D.10)
17544 Not implemented in GNAT.
17546 @item Ada.Tags
17547 This package contains definitions for manipulation of the tags of tagged
17548 values.
17550 @item Ada.Tags.Generic_Dispatching_Constructor (3.9)
17551 This package provides a way of constructing tagged class-wide values given
17552 only the tag value.
17554 @item Ada.Task_Attributes (C.7.2)
17555 This package provides the capability of associating arbitrary
17556 task-specific data with separate tasks.
17558 @item Ada.Task_Identifification (C.7.1)
17559 This package provides capabilities for task identification.
17561 @item Ada.Task_Termination (C.7.3)
17562 This package provides control over task termination.
17564 @item Ada.Text_IO
17565 This package provides basic text input-output capabilities for
17566 character, string and numeric data.  The subpackages of this
17567 package are listed next. Note that although these are defined
17568 as subpackages in the RM, they are actually transparently
17569 implemented as child packages in GNAT, meaning that they
17570 are only loaded if needed.
17572 @item Ada.Text_IO.Decimal_IO
17573 Provides input-output facilities for decimal fixed-point types
17575 @item Ada.Text_IO.Enumeration_IO
17576 Provides input-output facilities for enumeration types.
17578 @item Ada.Text_IO.Fixed_IO
17579 Provides input-output facilities for ordinary fixed-point types.
17581 @item Ada.Text_IO.Float_IO
17582 Provides input-output facilities for float types.  The following
17583 predefined instantiations of this generic package are available:
17585 @table @code
17586 @item Short_Float
17587 @code{Short_Float_Text_IO}
17588 @item Float
17589 @code{Float_Text_IO}
17590 @item Long_Float
17591 @code{Long_Float_Text_IO}
17592 @end table
17594 @item Ada.Text_IO.Integer_IO
17595 Provides input-output facilities for integer types.  The following
17596 predefined instantiations of this generic package are available:
17598 @table @code
17599 @item Short_Short_Integer
17600 @code{Ada.Short_Short_Integer_Text_IO}
17601 @item Short_Integer
17602 @code{Ada.Short_Integer_Text_IO}
17603 @item Integer
17604 @code{Ada.Integer_Text_IO}
17605 @item Long_Integer
17606 @code{Ada.Long_Integer_Text_IO}
17607 @item Long_Long_Integer
17608 @code{Ada.Long_Long_Integer_Text_IO}
17609 @end table
17611 @item Ada.Text_IO.Modular_IO
17612 Provides input-output facilities for modular (unsigned) types.
17614 @item Ada.Text_IO.Bounded_IO (A.10.11)
17615 Provides input-output facilities for bounded strings.
17617 @item Ada.Text_IO.Complex_IO (G.1.3)
17618 This package provides basic text input-output capabilities for complex
17619 data.
17621 @item Ada.Text_IO.Editing (F.3.3)
17622 This package contains routines for edited output, analogous to the use
17623 of pictures in COBOL@.  The picture formats used by this package are a
17624 close copy of the facility in COBOL@.
17626 @item Ada.Text_IO.Text_Streams (A.12.2)
17627 This package provides a facility that allows Text_IO files to be treated
17628 as streams, so that the stream attributes can be used for writing
17629 arbitrary data, including binary data, to Text_IO files.
17631 @item Ada.Text_IO.Unbounded_IO (A.10.12)
17632 This package provides input-output facilities for unbounded strings.
17634 @item Ada.Unchecked_Conversion (13.9)
17635 This generic package allows arbitrary conversion from one type to
17636 another of the same size, providing for breaking the type safety in
17637 special circumstances.
17639 If the types have the same Size (more accurately the same Value_Size),
17640 then the effect is simply to transfer the bits from the source to the
17641 target type without any modification.  This usage is well defined, and
17642 for simple types whose representation is typically the same across
17643 all implementations, gives a portable method of performing such
17644 conversions.
17646 If the types do not have the same size, then the result is implementation
17647 defined, and thus may be non-portable.  The following describes how GNAT
17648 handles such unchecked conversion cases.
17650 If the types are of different sizes, and are both discrete types, then
17651 the effect is of a normal type conversion without any constraint checking.
17652 In particular if the result type has a larger size, the result will be
17653 zero or sign extended.  If the result type has a smaller size, the result
17654 will be truncated by ignoring high order bits.
17656 If the types are of different sizes, and are not both discrete types,
17657 then the conversion works as though pointers were created to the source
17658 and target, and the pointer value is converted.  The effect is that bits
17659 are copied from successive low order storage units and bits of the source
17660 up to the length of the target type.
17662 A warning is issued if the lengths differ, since the effect in this
17663 case is implementation dependent, and the above behavior may not match
17664 that of some other compiler.
17666 A pointer to one type may be converted to a pointer to another type using
17667 unchecked conversion.  The only case in which the effect is undefined is
17668 when one or both pointers are pointers to unconstrained array types.  In
17669 this case, the bounds information may get incorrectly transferred, and in
17670 particular, GNAT uses double size pointers for such types, and it is
17671 meaningless to convert between such pointer types.  GNAT will issue a
17672 warning if the alignment of the target designated type is more strict
17673 than the alignment of the source designated type (since the result may
17674 be unaligned in this case).
17676 A pointer other than a pointer to an unconstrained array type may be
17677 converted to and from System.Address.  Such usage is common in Ada 83
17678 programs, but note that Ada.Address_To_Access_Conversions is the
17679 preferred method of performing such conversions in Ada 95 and Ada 2005.
17680 Neither
17681 unchecked conversion nor Ada.Address_To_Access_Conversions should be
17682 used in conjunction with pointers to unconstrained objects, since
17683 the bounds information cannot be handled correctly in this case.
17685 @item Ada.Unchecked_Deallocation (13.11.2)
17686 This generic package allows explicit freeing of storage previously
17687 allocated by use of an allocator.
17689 @item Ada.Wide_Text_IO (A.11)
17690 This package is similar to @code{Ada.Text_IO}, except that the external
17691 file supports wide character representations, and the internal types are
17692 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17693 and @code{String}. The corresponding set of nested packages and child
17694 packages are defined.
17696 @item Ada.Wide_Wide_Text_IO (A.11)
17697 This package is similar to @code{Ada.Text_IO}, except that the external
17698 file supports wide character representations, and the internal types are
17699 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17700 and @code{String}. The corresponding set of nested packages and child
17701 packages are defined.
17703 @end table
17705 For packages in Interfaces and System, all the RM defined packages are
17706 available in GNAT, see the Ada 2012 RM for full details.
17708 @node The Implementation of Standard I/O
17709 @chapter The Implementation of Standard I/O
17711 @noindent
17712 GNAT implements all the required input-output facilities described in
17713 A.6 through A.14.  These sections of the Ada Reference Manual describe the
17714 required behavior of these packages from the Ada point of view, and if
17715 you are writing a portable Ada program that does not need to know the
17716 exact manner in which Ada maps to the outside world when it comes to
17717 reading or writing external files, then you do not need to read this
17718 chapter.  As long as your files are all regular files (not pipes or
17719 devices), and as long as you write and read the files only from Ada, the
17720 description in the Ada Reference Manual is sufficient.
17722 However, if you want to do input-output to pipes or other devices, such
17723 as the keyboard or screen, or if the files you are dealing with are
17724 either generated by some other language, or to be read by some other
17725 language, then you need to know more about the details of how the GNAT
17726 implementation of these input-output facilities behaves.
17728 In this chapter we give a detailed description of exactly how GNAT
17729 interfaces to the file system.  As always, the sources of the system are
17730 available to you for answering questions at an even more detailed level,
17731 but for most purposes the information in this chapter will suffice.
17733 Another reason that you may need to know more about how input-output is
17734 implemented arises when you have a program written in mixed languages
17735 where, for example, files are shared between the C and Ada sections of
17736 the same program.  GNAT provides some additional facilities, in the form
17737 of additional child library packages, that facilitate this sharing, and
17738 these additional facilities are also described in this chapter.
17740 @menu
17741 * Standard I/O Packages::
17742 * FORM Strings::
17743 * Direct_IO::
17744 * Sequential_IO::
17745 * Text_IO::
17746 * Wide_Text_IO::
17747 * Wide_Wide_Text_IO::
17748 * Stream_IO::
17749 * Text Translation::
17750 * Shared Files::
17751 * Filenames encoding::
17752 * File content encoding::
17753 * Open Modes::
17754 * Operations on C Streams::
17755 * Interfacing to C Streams::
17756 @end menu
17758 @node Standard I/O Packages
17759 @section Standard I/O Packages
17761 @noindent
17762 The Standard I/O packages described in Annex A for
17764 @itemize @bullet
17765 @item
17766 Ada.Text_IO
17767 @item
17768 Ada.Text_IO.Complex_IO
17769 @item
17770 Ada.Text_IO.Text_Streams
17771 @item
17772 Ada.Wide_Text_IO
17773 @item
17774 Ada.Wide_Text_IO.Complex_IO
17775 @item
17776 Ada.Wide_Text_IO.Text_Streams
17777 @item
17778 Ada.Wide_Wide_Text_IO
17779 @item
17780 Ada.Wide_Wide_Text_IO.Complex_IO
17781 @item
17782 Ada.Wide_Wide_Text_IO.Text_Streams
17783 @item
17784 Ada.Stream_IO
17785 @item
17786 Ada.Sequential_IO
17787 @item
17788 Ada.Direct_IO
17789 @end itemize
17791 @noindent
17792 are implemented using the C
17793 library streams facility; where
17795 @itemize @bullet
17796 @item
17797 All files are opened using @code{fopen}.
17798 @item
17799 All input/output operations use @code{fread}/@code{fwrite}.
17800 @end itemize
17802 @noindent
17803 There is no internal buffering of any kind at the Ada library level. The only
17804 buffering is that provided at the system level in the implementation of the
17805 library routines that support streams. This facilitates shared use of these
17806 streams by mixed language programs. Note though that system level buffering is
17807 explicitly enabled at elaboration of the standard I/O packages and that can
17808 have an impact on mixed language programs, in particular those using I/O before
17809 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
17810 the Ada elaboration routine before performing any I/O or when impractical,
17811 flush the common I/O streams and in particular Standard_Output before
17812 elaborating the Ada code.
17814 @node FORM Strings
17815 @section FORM Strings
17817 @noindent
17818 The format of a FORM string in GNAT is:
17820 @smallexample
17821 "keyword=value,keyword=value,@dots{},keyword=value"
17822 @end smallexample
17824 @noindent
17825 where letters may be in upper or lower case, and there are no spaces
17826 between values.  The order of the entries is not important.  Currently
17827 the following keywords defined.
17829 @smallexample
17830 TEXT_TRANSLATION=[YES|NO|TEXT|BINARY|U8TEXT|WTEXT|U16TEXT]
17831 SHARED=[YES|NO]
17832 WCEM=[n|h|u|s|e|8|b]
17833 ENCODING=[UTF8|8BITS]
17834 @end smallexample
17836 @noindent
17837 The use of these parameters is described later in this section. If an
17838 unrecognized keyword appears in a form string, it is silently ignored
17839 and not considered invalid.
17841 @noindent
17842 For OpenVMS additional FORM string keywords are available for use with
17843 RMS services.  The syntax is:
17845 @smallexample
17846 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
17847 @end smallexample
17849 @noindent
17850 The following RMS keywords and values are currently defined:
17852 @smallexample
17853 Context=Force_Stream_Mode|Force_Record_Mode
17854 @end smallexample
17856 @noindent
17857 VMS RMS keys are silently ignored on non-VMS systems.  On OpenVMS
17858 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
17860 @node Direct_IO
17861 @section Direct_IO
17863 @noindent
17864 Direct_IO can only be instantiated for definite types.  This is a
17865 restriction of the Ada language, which means that the records are fixed
17866 length (the length being determined by @code{@var{type}'Size}, rounded
17867 up to the next storage unit boundary if necessary).
17869 The records of a Direct_IO file are simply written to the file in index
17870 sequence, with the first record starting at offset zero, and subsequent
17871 records following.  There is no control information of any kind.  For
17872 example, if 32-bit integers are being written, each record takes
17873 4-bytes, so the record at index @var{K} starts at offset
17874 (@var{K}@minus{}1)*4.
17876 There is no limit on the size of Direct_IO files, they are expanded as
17877 necessary to accommodate whatever records are written to the file.
17879 @node Sequential_IO
17880 @section Sequential_IO
17882 @noindent
17883 Sequential_IO may be instantiated with either a definite (constrained)
17884 or indefinite (unconstrained) type.
17886 For the definite type case, the elements written to the file are simply
17887 the memory images of the data values with no control information of any
17888 kind.  The resulting file should be read using the same type, no validity
17889 checking is performed on input.
17891 For the indefinite type case, the elements written consist of two
17892 parts.  First is the size of the data item, written as the memory image
17893 of a @code{Interfaces.C.size_t} value, followed by the memory image of
17894 the data value.  The resulting file can only be read using the same
17895 (unconstrained) type.  Normal assignment checks are performed on these
17896 read operations, and if these checks fail, @code{Data_Error} is
17897 raised.  In particular, in the array case, the lengths must match, and in
17898 the variant record case, if the variable for a particular read operation
17899 is constrained, the discriminants must match.
17901 Note that it is not possible to use Sequential_IO to write variable
17902 length array items, and then read the data back into different length
17903 arrays.  For example, the following will raise @code{Data_Error}:
17905 @smallexample @c ada
17906  package IO is new Sequential_IO (String);
17907  F : IO.File_Type;
17908  S : String (1..4);
17909  @dots{}
17910  IO.Create (F)
17911  IO.Write (F, "hello!")
17912  IO.Reset (F, Mode=>In_File);
17913  IO.Read (F, S);
17914  Put_Line (S);
17916 @end smallexample
17918 @noindent
17919 On some Ada implementations, this will print @code{hell}, but the program is
17920 clearly incorrect, since there is only one element in the file, and that
17921 element is the string @code{hello!}.
17923 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
17924 using Stream_IO, and this is the preferred mechanism.  In particular, the
17925 above program fragment rewritten to use Stream_IO will work correctly.
17927 @node Text_IO
17928 @section Text_IO
17930 @noindent
17931 Text_IO files consist of a stream of characters containing the following
17932 special control characters:
17934 @smallexample
17935 LF (line feed, 16#0A#) Line Mark
17936 FF (form feed, 16#0C#) Page Mark
17937 @end smallexample
17939 @noindent
17940 A canonical Text_IO file is defined as one in which the following
17941 conditions are met:
17943 @itemize @bullet
17944 @item
17945 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
17946 of the line.
17948 @item
17949 The character @code{FF} is used only as a page mark, i.e.@: to mark the
17950 end of a page and consequently can appear only immediately following a
17951 @code{LF} (line mark) character.
17953 @item
17954 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
17955 (line mark, page mark).  In the former case, the page mark is implicitly
17956 assumed to be present.
17957 @end itemize
17959 @noindent
17960 A file written using Text_IO will be in canonical form provided that no
17961 explicit @code{LF} or @code{FF} characters are written using @code{Put}
17962 or @code{Put_Line}.  There will be no @code{FF} character at the end of
17963 the file unless an explicit @code{New_Page} operation was performed
17964 before closing the file.
17966 A canonical Text_IO file that is a regular file (i.e., not a device or a
17967 pipe) can be read using any of the routines in Text_IO@.  The
17968 semantics in this case will be exactly as defined in the Ada Reference
17969 Manual, and all the routines in Text_IO are fully implemented.
17971 A text file that does not meet the requirements for a canonical Text_IO
17972 file has one of the following:
17974 @itemize @bullet
17975 @item
17976 The file contains @code{FF} characters not immediately following a
17977 @code{LF} character.
17979 @item
17980 The file contains @code{LF} or @code{FF} characters written by
17981 @code{Put} or @code{Put_Line}, which are not logically considered to be
17982 line marks or page marks.
17984 @item
17985 The file ends in a character other than @code{LF} or @code{FF},
17986 i.e.@: there is no explicit line mark or page mark at the end of the file.
17987 @end itemize
17989 @noindent
17990 Text_IO can be used to read such non-standard text files but subprograms
17991 to do with line or page numbers do not have defined meanings.  In
17992 particular, a @code{FF} character that does not follow a @code{LF}
17993 character may or may not be treated as a page mark from the point of
17994 view of page and line numbering.  Every @code{LF} character is considered
17995 to end a line, and there is an implied @code{LF} character at the end of
17996 the file.
17998 @menu
17999 * Text_IO Stream Pointer Positioning::
18000 * Text_IO Reading and Writing Non-Regular Files::
18001 * Get_Immediate::
18002 * Treating Text_IO Files as Streams::
18003 * Text_IO Extensions::
18004 * Text_IO Facilities for Unbounded Strings::
18005 @end menu
18007 @node Text_IO Stream Pointer Positioning
18008 @subsection Stream Pointer Positioning
18010 @noindent
18011 @code{Ada.Text_IO} has a definition of current position for a file that
18012 is being read.  No internal buffering occurs in Text_IO, and usually the
18013 physical position in the stream used to implement the file corresponds
18014 to this logical position defined by Text_IO@.  There are two exceptions:
18016 @itemize @bullet
18017 @item
18018 After a call to @code{End_Of_Page} that returns @code{True}, the stream
18019 is positioned past the @code{LF} (line mark) that precedes the page
18020 mark.  Text_IO maintains an internal flag so that subsequent read
18021 operations properly handle the logical position which is unchanged by
18022 the @code{End_Of_Page} call.
18024 @item
18025 After a call to @code{End_Of_File} that returns @code{True}, if the
18026 Text_IO file was positioned before the line mark at the end of file
18027 before the call, then the logical position is unchanged, but the stream
18028 is physically positioned right at the end of file (past the line mark,
18029 and past a possible page mark following the line mark.  Again Text_IO
18030 maintains internal flags so that subsequent read operations properly
18031 handle the logical position.
18032 @end itemize
18034 @noindent
18035 These discrepancies have no effect on the observable behavior of
18036 Text_IO, but if a single Ada stream is shared between a C program and
18037 Ada program, or shared (using @samp{shared=yes} in the form string)
18038 between two Ada files, then the difference may be observable in some
18039 situations.
18041 @node Text_IO Reading and Writing Non-Regular Files
18042 @subsection Reading and Writing Non-Regular Files
18044 @noindent
18045 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
18046 can be used for reading and writing.  Writing is not affected and the
18047 sequence of characters output is identical to the normal file case, but
18048 for reading, the behavior of Text_IO is modified to avoid undesirable
18049 look-ahead as follows:
18051 An input file that is not a regular file is considered to have no page
18052 marks.  Any @code{Ascii.FF} characters (the character normally used for a
18053 page mark) appearing in the file are considered to be data
18054 characters.  In particular:
18056 @itemize @bullet
18057 @item
18058 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
18059 following a line mark.  If a page mark appears, it will be treated as a
18060 data character.
18062 @item
18063 This avoids the need to wait for an extra character to be typed or
18064 entered from the pipe to complete one of these operations.
18066 @item
18067 @code{End_Of_Page} always returns @code{False}
18069 @item
18070 @code{End_Of_File} will return @code{False} if there is a page mark at
18071 the end of the file.
18072 @end itemize
18074 @noindent
18075 Output to non-regular files is the same as for regular files.  Page marks
18076 may be written to non-regular files using @code{New_Page}, but as noted
18077 above they will not be treated as page marks on input if the output is
18078 piped to another Ada program.
18080 Another important discrepancy when reading non-regular files is that the end
18081 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
18082 pressing the @key{EOT} key,
18083 then end of file
18084 is signaled once (i.e.@: the test @code{End_Of_File}
18085 will yield @code{True}, or a read will
18086 raise @code{End_Error}), but then reading can resume
18087 to read data past that end of
18088 file indication, until another end of file indication is entered.
18090 @node Get_Immediate
18091 @subsection Get_Immediate
18092 @cindex Get_Immediate
18094 @noindent
18095 Get_Immediate returns the next character (including control characters)
18096 from the input file.  In particular, Get_Immediate will return LF or FF
18097 characters used as line marks or page marks.  Such operations leave the
18098 file positioned past the control character, and it is thus not treated
18099 as having its normal function.  This means that page, line and column
18100 counts after this kind of Get_Immediate call are set as though the mark
18101 did not occur.  In the case where a Get_Immediate leaves the file
18102 positioned between the line mark and page mark (which is not normally
18103 possible), it is undefined whether the FF character will be treated as a
18104 page mark.
18106 @node Treating Text_IO Files as Streams
18107 @subsection Treating Text_IO Files as Streams
18108 @cindex Stream files
18110 @noindent
18111 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
18112 as a stream.  Data written to a Text_IO file in this stream mode is
18113 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
18114 16#0C# (@code{FF}), the resulting file may have non-standard
18115 format.  Similarly if read operations are used to read from a Text_IO
18116 file treated as a stream, then @code{LF} and @code{FF} characters may be
18117 skipped and the effect is similar to that described above for
18118 @code{Get_Immediate}.
18120 @node Text_IO Extensions
18121 @subsection Text_IO Extensions
18122 @cindex Text_IO extensions
18124 @noindent
18125 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
18126 to the standard @code{Text_IO} package:
18128 @itemize @bullet
18129 @item function File_Exists (Name : String) return Boolean;
18130 Determines if a file of the given name exists.
18132 @item function Get_Line return String;
18133 Reads a string from the standard input file.  The value returned is exactly
18134 the length of the line that was read.
18136 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
18137 Similar, except that the parameter File specifies the file from which
18138 the string is to be read.
18140 @end itemize
18142 @node Text_IO Facilities for Unbounded Strings
18143 @subsection Text_IO Facilities for Unbounded Strings
18144 @cindex Text_IO for unbounded strings
18145 @cindex Unbounded_String, Text_IO operations
18147 @noindent
18148 The package @code{Ada.Strings.Unbounded.Text_IO}
18149 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
18150 subprograms useful for Text_IO operations on unbounded strings:
18152 @itemize @bullet
18154 @item function Get_Line (File : File_Type) return Unbounded_String;
18155 Reads a line from the specified file
18156 and returns the result as an unbounded string.
18158 @item procedure Put (File : File_Type; U : Unbounded_String);
18159 Writes the value of the given unbounded string to the specified file
18160 Similar to the effect of
18161 @code{Put (To_String (U))} except that an extra copy is avoided.
18163 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
18164 Writes the value of the given unbounded string to the specified file,
18165 followed by a @code{New_Line}.
18166 Similar to the effect of @code{Put_Line (To_String (U))} except
18167 that an extra copy is avoided.
18168 @end itemize
18170 @noindent
18171 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
18172 and is optional.  If the parameter is omitted, then the standard input or
18173 output file is referenced as appropriate.
18175 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
18176 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
18177 @code{Wide_Text_IO} functionality for unbounded wide strings.
18179 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
18180 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
18181 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
18183 @node Wide_Text_IO
18184 @section Wide_Text_IO
18186 @noindent
18187 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
18188 both input and output files may contain special sequences that represent
18189 wide character values.  The encoding scheme for a given file may be
18190 specified using a FORM parameter:
18192 @smallexample
18193 WCEM=@var{x}
18194 @end smallexample
18196 @noindent
18197 as part of the FORM string (WCEM = wide character encoding method),
18198 where @var{x} is one of the following characters
18200 @table @samp
18201 @item h
18202 Hex ESC encoding
18203 @item u
18204 Upper half encoding
18205 @item s
18206 Shift-JIS encoding
18207 @item e
18208 EUC Encoding
18209 @item 8
18210 UTF-8 encoding
18211 @item b
18212 Brackets encoding
18213 @end table
18215 @noindent
18216 The encoding methods match those that
18217 can be used in a source
18218 program, but there is no requirement that the encoding method used for
18219 the source program be the same as the encoding method used for files,
18220 and different files may use different encoding methods.
18222 The default encoding method for the standard files, and for opened files
18223 for which no WCEM parameter is given in the FORM string matches the
18224 wide character encoding specified for the main program (the default
18225 being brackets encoding if no coding method was specified with -gnatW).
18227 @table @asis
18228 @item Hex Coding
18229 In this encoding, a wide character is represented by a five character
18230 sequence:
18232 @smallexample
18233 ESC a b c d
18234 @end smallexample
18236 @noindent
18237 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
18238 characters (using upper case letters) of the wide character code.  For
18239 example, ESC A345 is used to represent the wide character with code
18240 16#A345#.  This scheme is compatible with use of the full
18241 @code{Wide_Character} set.
18243 @item Upper Half Coding
18244 The wide character with encoding 16#abcd#, where the upper bit is on
18245 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
18246 16#cd#.  The second byte may never be a format control character, but is
18247 not required to be in the upper half.  This method can be also used for
18248 shift-JIS or EUC where the internal coding matches the external coding.
18250 @item Shift JIS Coding
18251 A wide character is represented by a two character sequence 16#ab# and
18252 16#cd#, with the restrictions described for upper half encoding as
18253 described above.  The internal character code is the corresponding JIS
18254 character according to the standard algorithm for Shift-JIS
18255 conversion.  Only characters defined in the JIS code set table can be
18256 used with this encoding method.
18258 @item EUC Coding
18259 A wide character is represented by a two character sequence 16#ab# and
18260 16#cd#, with both characters being in the upper half.  The internal
18261 character code is the corresponding JIS character according to the EUC
18262 encoding algorithm.  Only characters defined in the JIS code set table
18263 can be used with this encoding method.
18265 @item UTF-8 Coding
18266 A wide character is represented using
18267 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
18268 10646-1/Am.2.  Depending on the character value, the representation
18269 is a one, two, or three byte sequence:
18271 @smallexample
18272 16#0000#-16#007f#: 2#0xxxxxxx#
18273 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
18274 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
18275 @end smallexample
18277 @noindent
18278 where the @var{xxx} bits correspond to the left-padded bits of the
18279 16-bit character value.  Note that all lower half ASCII characters
18280 are represented as ASCII bytes and all upper half characters and
18281 other wide characters are represented as sequences of upper-half
18282 (The full UTF-8 scheme allows for encoding 31-bit characters as
18283 6-byte sequences, but in this implementation, all UTF-8 sequences
18284 of four or more bytes length will raise a Constraint_Error, as
18285 will all invalid UTF-8 sequences.)
18287 @item Brackets Coding
18288 In this encoding, a wide character is represented by the following eight
18289 character sequence:
18291 @smallexample
18292 [ " a b c d " ]
18293 @end smallexample
18295 @noindent
18296 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
18297 characters (using uppercase letters) of the wide character code.  For
18298 example, @code{["A345"]} is used to represent the wide character with code
18299 @code{16#A345#}.
18300 This scheme is compatible with use of the full Wide_Character set.
18301 On input, brackets coding can also be used for upper half characters,
18302 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
18303 is only used for wide characters with a code greater than @code{16#FF#}.
18305 Note that brackets coding is not normally used in the context of
18306 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
18307 a portable way of encoding source files. In the context of Wide_Text_IO
18308 or Wide_Wide_Text_IO, it can only be used if the file does not contain
18309 any instance of the left bracket character other than to encode wide
18310 character values using the brackets encoding method. In practice it is
18311 expected that some standard wide character encoding method such
18312 as UTF-8 will be used for text input output.
18314 If brackets notation is used, then any occurrence of a left bracket
18315 in the input file which is not the start of a valid wide character
18316 sequence will cause Constraint_Error to be raised. It is possible to
18317 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
18318 input will interpret this as a left bracket.
18320 However, when a left bracket is output, it will be output as a left bracket
18321 and not as ["5B"]. We make this decision because for normal use of
18322 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
18323 brackets. For example, if we write:
18325 @smallexample
18326    Put_Line ("Start of output [first run]");
18327 @end smallexample
18329 @noindent
18330 we really do not want to have the left bracket in this message clobbered so
18331 that the output reads:
18333 @smallexample
18334    Start of output ["5B"]first run]
18335 @end smallexample
18337 @noindent
18338 In practice brackets encoding is reasonably useful for normal Put_Line use
18339 since we won't get confused between left brackets and wide character
18340 sequences in the output. But for input, or when files are written out
18341 and read back in, it really makes better sense to use one of the standard
18342 encoding methods such as UTF-8.
18344 @end table
18346 @noindent
18347 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
18348 not all wide character
18349 values can be represented.  An attempt to output a character that cannot
18350 be represented using the encoding scheme for the file causes
18351 Constraint_Error to be raised.  An invalid wide character sequence on
18352 input also causes Constraint_Error to be raised.
18354 @menu
18355 * Wide_Text_IO Stream Pointer Positioning::
18356 * Wide_Text_IO Reading and Writing Non-Regular Files::
18357 @end menu
18359 @node Wide_Text_IO Stream Pointer Positioning
18360 @subsection Stream Pointer Positioning
18362 @noindent
18363 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
18364 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
18365 case:
18367 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
18368 normal lower ASCII set (i.e.@: a character in the range:
18370 @smallexample @c ada
18371 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
18372 @end smallexample
18374 @noindent
18375 then although the logical position of the file pointer is unchanged by
18376 the @code{Look_Ahead} call, the stream is physically positioned past the
18377 wide character sequence.  Again this is to avoid the need for buffering
18378 or backup, and all @code{Wide_Text_IO} routines check the internal
18379 indication that this situation has occurred so that this is not visible
18380 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
18381 can be observed if the wide text file shares a stream with another file.
18383 @node Wide_Text_IO Reading and Writing Non-Regular Files
18384 @subsection Reading and Writing Non-Regular Files
18386 @noindent
18387 As in the case of Text_IO, when a non-regular file is read, it is
18388 assumed that the file contains no page marks (any form characters are
18389 treated as data characters), and @code{End_Of_Page} always returns
18390 @code{False}.  Similarly, the end of file indication is not sticky, so
18391 it is possible to read beyond an end of file.
18393 @node Wide_Wide_Text_IO
18394 @section Wide_Wide_Text_IO
18396 @noindent
18397 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
18398 both input and output files may contain special sequences that represent
18399 wide wide character values.  The encoding scheme for a given file may be
18400 specified using a FORM parameter:
18402 @smallexample
18403 WCEM=@var{x}
18404 @end smallexample
18406 @noindent
18407 as part of the FORM string (WCEM = wide character encoding method),
18408 where @var{x} is one of the following characters
18410 @table @samp
18411 @item h
18412 Hex ESC encoding
18413 @item u
18414 Upper half encoding
18415 @item s
18416 Shift-JIS encoding
18417 @item e
18418 EUC Encoding
18419 @item 8
18420 UTF-8 encoding
18421 @item b
18422 Brackets encoding
18423 @end table
18425 @noindent
18426 The encoding methods match those that
18427 can be used in a source
18428 program, but there is no requirement that the encoding method used for
18429 the source program be the same as the encoding method used for files,
18430 and different files may use different encoding methods.
18432 The default encoding method for the standard files, and for opened files
18433 for which no WCEM parameter is given in the FORM string matches the
18434 wide character encoding specified for the main program (the default
18435 being brackets encoding if no coding method was specified with -gnatW).
18437 @table @asis
18439 @item UTF-8 Coding
18440 A wide character is represented using
18441 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
18442 10646-1/Am.2.  Depending on the character value, the representation
18443 is a one, two, three, or four byte sequence:
18445 @smallexample
18446 16#000000#-16#00007f#: 2#0xxxxxxx#
18447 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
18448 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
18449 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
18450 @end smallexample
18452 @noindent
18453 where the @var{xxx} bits correspond to the left-padded bits of the
18454 21-bit character value.  Note that all lower half ASCII characters
18455 are represented as ASCII bytes and all upper half characters and
18456 other wide characters are represented as sequences of upper-half
18457 characters.
18459 @item Brackets Coding
18460 In this encoding, a wide wide character is represented by the following eight
18461 character sequence if is in wide character range
18463 @smallexample
18464 [ " a b c d " ]
18465 @end smallexample
18467 and by the following ten character sequence if not
18469 @smallexample
18470 [ " a b c d e f " ]
18471 @end smallexample
18473 @noindent
18474 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
18475 are the four or six hexadecimal
18476 characters (using uppercase letters) of the wide wide character code.  For
18477 example, @code{["01A345"]} is used to represent the wide wide character
18478 with code @code{16#01A345#}.
18480 This scheme is compatible with use of the full Wide_Wide_Character set.
18481 On input, brackets coding can also be used for upper half characters,
18482 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
18483 is only used for wide characters with a code greater than @code{16#FF#}.
18485 @end table
18487 @noindent
18488 If is also possible to use the other Wide_Character encoding methods,
18489 such as Shift-JIS, but the other schemes cannot support the full range
18490 of wide wide characters.
18491 An attempt to output a character that cannot
18492 be represented using the encoding scheme for the file causes
18493 Constraint_Error to be raised.  An invalid wide character sequence on
18494 input also causes Constraint_Error to be raised.
18496 @menu
18497 * Wide_Wide_Text_IO Stream Pointer Positioning::
18498 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
18499 @end menu
18501 @node Wide_Wide_Text_IO Stream Pointer Positioning
18502 @subsection Stream Pointer Positioning
18504 @noindent
18505 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
18506 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
18507 case:
18509 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
18510 normal lower ASCII set (i.e.@: a character in the range:
18512 @smallexample @c ada
18513 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
18514 @end smallexample
18516 @noindent
18517 then although the logical position of the file pointer is unchanged by
18518 the @code{Look_Ahead} call, the stream is physically positioned past the
18519 wide character sequence.  Again this is to avoid the need for buffering
18520 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
18521 indication that this situation has occurred so that this is not visible
18522 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
18523 can be observed if the wide text file shares a stream with another file.
18525 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
18526 @subsection Reading and Writing Non-Regular Files
18528 @noindent
18529 As in the case of Text_IO, when a non-regular file is read, it is
18530 assumed that the file contains no page marks (any form characters are
18531 treated as data characters), and @code{End_Of_Page} always returns
18532 @code{False}.  Similarly, the end of file indication is not sticky, so
18533 it is possible to read beyond an end of file.
18535 @node Stream_IO
18536 @section Stream_IO
18538 @noindent
18539 A stream file is a sequence of bytes, where individual elements are
18540 written to the file as described in the Ada Reference Manual.  The type
18541 @code{Stream_Element} is simply a byte.  There are two ways to read or
18542 write a stream file.
18544 @itemize @bullet
18545 @item
18546 The operations @code{Read} and @code{Write} directly read or write a
18547 sequence of stream elements with no control information.
18549 @item
18550 The stream attributes applied to a stream file transfer data in the
18551 manner described for stream attributes.
18552 @end itemize
18554 @node Text Translation
18555 @section Text Translation
18557 @noindent
18558 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
18559 passed to Text_IO.Create and Text_IO.Open. @samp{Text_Translation=@var{xxx}}
18560 has no effect on Unix systems. Possible values are:
18562 @itemize @bullet
18564 @item
18565 @samp{@var{Yes} or @var{Text}} is the default, which means to
18566 translate LF to/from CR/LF on Windows systems.
18568 @samp{@var{No}} disables this translation; i.e. it
18569 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
18570 may be used to create Unix-style files on
18571 Windows.
18573 @item
18574 @samp{@var{wtext}} translation enabled in Unicode mode.
18575 (corresponds to _O_WTEXT).
18577 @item
18578 @samp{@var{u8text}} translation enabled in Unicode UTF-8 mode.
18579 (corresponds to O_U8TEXT).
18581 @item
18582 @samp{@var{u16text}} translation enabled in Unicode UTF-16
18583 mode. (corresponds to_O_U16TEXT).
18585 @end itemize
18589 @node Shared Files
18590 @section Shared Files
18592 @noindent
18593 Section A.14 of the Ada Reference Manual allows implementations to
18594 provide a wide variety of behavior if an attempt is made to access the
18595 same external file with two or more internal files.
18597 To provide a full range of functionality, while at the same time
18598 minimizing the problems of portability caused by this implementation
18599 dependence, GNAT handles file sharing as follows:
18601 @itemize @bullet
18602 @item
18603 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
18604 to open two or more files with the same full name is considered an error
18605 and is not supported.  The exception @code{Use_Error} will be
18606 raised.  Note that a file that is not explicitly closed by the program
18607 remains open until the program terminates.
18609 @item
18610 If the form parameter @samp{shared=no} appears in the form string, the
18611 file can be opened or created with its own separate stream identifier,
18612 regardless of whether other files sharing the same external file are
18613 opened.  The exact effect depends on how the C stream routines handle
18614 multiple accesses to the same external files using separate streams.
18616 @item
18617 If the form parameter @samp{shared=yes} appears in the form string for
18618 each of two or more files opened using the same full name, the same
18619 stream is shared between these files, and the semantics are as described
18620 in Ada Reference Manual, Section A.14.
18621 @end itemize
18623 @noindent
18624 When a program that opens multiple files with the same name is ported
18625 from another Ada compiler to GNAT, the effect will be that
18626 @code{Use_Error} is raised.
18628 The documentation of the original compiler and the documentation of the
18629 program should then be examined to determine if file sharing was
18630 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
18631 and @code{Create} calls as required.
18633 When a program is ported from GNAT to some other Ada compiler, no
18634 special attention is required unless the @samp{shared=@var{xxx}} form
18635 parameter is used in the program.  In this case, you must examine the
18636 documentation of the new compiler to see if it supports the required
18637 file sharing semantics, and form strings modified appropriately.  Of
18638 course it may be the case that the program cannot be ported if the
18639 target compiler does not support the required functionality.  The best
18640 approach in writing portable code is to avoid file sharing (and hence
18641 the use of the @samp{shared=@var{xxx}} parameter in the form string)
18642 completely.
18644 One common use of file sharing in Ada 83 is the use of instantiations of
18645 Sequential_IO on the same file with different types, to achieve
18646 heterogeneous input-output.  Although this approach will work in GNAT if
18647 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
18648 for this purpose (using the stream attributes)
18650 @node Filenames encoding
18651 @section Filenames encoding
18653 @noindent
18654 An encoding form parameter can be used to specify the filename
18655 encoding @samp{encoding=@var{xxx}}.
18657 @itemize @bullet
18658 @item
18659 If the form parameter @samp{encoding=utf8} appears in the form string, the
18660 filename must be encoded in UTF-8.
18662 @item
18663 If the form parameter @samp{encoding=8bits} appears in the form
18664 string, the filename must be a standard 8bits string.
18665 @end itemize
18667 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
18668 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
18669 variable. And if not set @samp{utf8} is assumed.
18671 @table @samp
18672 @item CP_ACP
18673 The current system Windows ANSI code page.
18674 @item CP_UTF8
18675 UTF-8 encoding
18676 @end table
18678 This encoding form parameter is only supported on the Windows
18679 platform. On the other Operating Systems the run-time is supporting
18680 UTF-8 natively.
18682 @node File content encoding
18683 @section File content encoding
18685 @noindent
18686 For text files it is possible to specify the encoding to use. This is
18687 controlled by the by the @samp{GNAT_CCS_ENCODING} environment
18688 variable. And if not set @samp{TEXT} is assumed.
18690 The possible values are those supported on Windows:
18692 @table @samp
18693 @item TEXT
18694 Translated text mode
18695 @item WTEXT
18696 Translated unicode encoding
18697 @item U16TEXT
18698 Unicode 16-bit encoding
18699 @item U8TEXT
18700 Unicode 8-bit encoding
18701 @end table
18703 This encoding is only supported on the Windows platform.
18705 @node Open Modes
18706 @section Open Modes
18708 @noindent
18709 @code{Open} and @code{Create} calls result in a call to @code{fopen}
18710 using the mode shown in the following table:
18712 @sp 2
18713 @center @code{Open} and @code{Create} Call Modes
18714 @smallexample
18715                                @b{OPEN }           @b{CREATE}
18716 Append_File                    "r+"             "w+"
18717 In_File                        "r"              "w+"
18718 Out_File (Direct_IO)           "r+"             "w"
18719 Out_File (all other cases)     "w"              "w"
18720 Inout_File                     "r+"             "w+"
18721 @end smallexample
18723 @noindent
18724 If text file translation is required, then either @samp{b} or @samp{t}
18725 is added to the mode, depending on the setting of Text.  Text file
18726 translation refers to the mapping of CR/LF sequences in an external file
18727 to LF characters internally.  This mapping only occurs in DOS and
18728 DOS-like systems, and is not relevant to other systems.
18730 A special case occurs with Stream_IO@.  As shown in the above table, the
18731 file is initially opened in @samp{r} or @samp{w} mode for the
18732 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
18733 subsequently requires switching from reading to writing or vice-versa,
18734 then the file is reopened in @samp{r+} mode to permit the required operation.
18736 @node Operations on C Streams
18737 @section Operations on C Streams
18738 The package @code{Interfaces.C_Streams} provides an Ada program with direct
18739 access to the C library functions for operations on C streams:
18741 @smallexample @c adanocomment
18742 package Interfaces.C_Streams is
18743   -- Note: the reason we do not use the types that are in
18744   -- Interfaces.C is that we want to avoid dragging in the
18745   -- code in this unit if possible.
18746   subtype chars is System.Address;
18747   -- Pointer to null-terminated array of characters
18748   subtype FILEs is System.Address;
18749   -- Corresponds to the C type FILE*
18750   subtype voids is System.Address;
18751   -- Corresponds to the C type void*
18752   subtype int is Integer;
18753   subtype long is Long_Integer;
18754   -- Note: the above types are subtypes deliberately, and it
18755   -- is part of this spec that the above correspondences are
18756   -- guaranteed.  This means that it is legitimate to, for
18757   -- example, use Integer instead of int.  We provide these
18758   -- synonyms for clarity, but in some cases it may be
18759   -- convenient to use the underlying types (for example to
18760   -- avoid an unnecessary dependency of a spec on the spec
18761   -- of this unit).
18762   type size_t is mod 2 ** Standard'Address_Size;
18763   NULL_Stream : constant FILEs;
18764   -- Value returned (NULL in C) to indicate an
18765   -- fdopen/fopen/tmpfile error
18766   ----------------------------------
18767   -- Constants Defined in stdio.h --
18768   ----------------------------------
18769   EOF : constant int;
18770   -- Used by a number of routines to indicate error or
18771   -- end of file
18772   IOFBF : constant int;
18773   IOLBF : constant int;
18774   IONBF : constant int;
18775   -- Used to indicate buffering mode for setvbuf call
18776   SEEK_CUR : constant int;
18777   SEEK_END : constant int;
18778   SEEK_SET : constant int;
18779   -- Used to indicate origin for fseek call
18780   function stdin return FILEs;
18781   function stdout return FILEs;
18782   function stderr return FILEs;
18783   -- Streams associated with standard files
18784   --------------------------
18785   -- Standard C functions --
18786   --------------------------
18787   -- The functions selected below are ones that are
18788   -- available in UNIX (but not necessarily in ANSI C).
18789   -- These are very thin interfaces
18790   -- which copy exactly the C headers.  For more
18791   -- documentation on these functions, see the Microsoft C
18792   -- "Run-Time Library Reference" (Microsoft Press, 1990,
18793   -- ISBN 1-55615-225-6), which includes useful information
18794   -- on system compatibility.
18795   procedure clearerr (stream : FILEs);
18796   function fclose (stream : FILEs) return int;
18797   function fdopen (handle : int; mode : chars) return FILEs;
18798   function feof (stream : FILEs) return int;
18799   function ferror (stream : FILEs) return int;
18800   function fflush (stream : FILEs) return int;
18801   function fgetc (stream : FILEs) return int;
18802   function fgets (strng : chars; n : int; stream : FILEs)
18803       return chars;
18804   function fileno (stream : FILEs) return int;
18805   function fopen (filename : chars; Mode : chars)
18806       return FILEs;
18807   -- Note: to maintain target independence, use
18808   -- text_translation_required, a boolean variable defined in
18809   -- a-sysdep.c to deal with the target dependent text
18810   -- translation requirement.  If this variable is set,
18811   -- then  b/t should be appended to the standard mode
18812   -- argument to set the text translation mode off or on
18813   -- as required.
18814   function fputc (C : int; stream : FILEs) return int;
18815   function fputs (Strng : chars; Stream : FILEs) return int;
18816   function fread
18817      (buffer : voids;
18818       size : size_t;
18819       count : size_t;
18820       stream : FILEs)
18821       return size_t;
18822   function freopen
18823      (filename : chars;
18824       mode : chars;
18825       stream : FILEs)
18826       return FILEs;
18827   function fseek
18828      (stream : FILEs;
18829       offset : long;
18830       origin : int)
18831       return int;
18832   function ftell (stream : FILEs) return long;
18833   function fwrite
18834      (buffer : voids;
18835       size : size_t;
18836       count : size_t;
18837       stream : FILEs)
18838       return size_t;
18839   function isatty (handle : int) return int;
18840   procedure mktemp (template : chars);
18841   -- The return value (which is just a pointer to template)
18842   -- is discarded
18843   procedure rewind (stream : FILEs);
18844   function rmtmp return int;
18845   function setvbuf
18846      (stream : FILEs;
18847       buffer : chars;
18848       mode : int;
18849       size : size_t)
18850       return int;
18852   function tmpfile return FILEs;
18853   function ungetc (c : int; stream : FILEs) return int;
18854   function unlink (filename : chars) return int;
18855   ---------------------
18856   -- Extra functions --
18857   ---------------------
18858   -- These functions supply slightly thicker bindings than
18859   -- those above.  They are derived from functions in the
18860   -- C Run-Time Library, but may do a bit more work than
18861   -- just directly calling one of the Library functions.
18862   function is_regular_file (handle : int) return int;
18863   -- Tests if given handle is for a regular file (result 1)
18864   -- or for a non-regular file (pipe or device, result 0).
18865   ---------------------------------
18866   -- Control of Text/Binary Mode --
18867   ---------------------------------
18868   -- If text_translation_required is true, then the following
18869   -- functions may be used to dynamically switch a file from
18870   -- binary to text mode or vice versa.  These functions have
18871   -- no effect if text_translation_required is false (i.e.@: in
18872   -- normal UNIX mode).  Use fileno to get a stream handle.
18873   procedure set_binary_mode (handle : int);
18874   procedure set_text_mode (handle : int);
18875   ----------------------------
18876   -- Full Path Name support --
18877   ----------------------------
18878   procedure full_name (nam : chars; buffer : chars);
18879   -- Given a NUL terminated string representing a file
18880   -- name, returns in buffer a NUL terminated string
18881   -- representing the full path name for the file name.
18882   -- On systems where it is relevant the   drive is also
18883   -- part of the full path name.  It is the responsibility
18884   -- of the caller to pass an actual parameter for buffer
18885   -- that is big enough for any full path name.  Use
18886   -- max_path_len given below as the size of buffer.
18887   max_path_len : integer;
18888   -- Maximum length of an allowable full path name on the
18889   -- system, including a terminating NUL character.
18890 end Interfaces.C_Streams;
18891 @end smallexample
18893 @node Interfacing to C Streams
18894 @section Interfacing to C Streams
18896 @noindent
18897 The packages in this section permit interfacing Ada files to C Stream
18898 operations.
18900 @smallexample @c ada
18901  with Interfaces.C_Streams;
18902  package Ada.Sequential_IO.C_Streams is
18903     function C_Stream (F : File_Type)
18904        return Interfaces.C_Streams.FILEs;
18905     procedure Open
18906       (File : in out File_Type;
18907        Mode : in File_Mode;
18908        C_Stream : in Interfaces.C_Streams.FILEs;
18909        Form : in String := "");
18910  end Ada.Sequential_IO.C_Streams;
18912   with Interfaces.C_Streams;
18913   package Ada.Direct_IO.C_Streams is
18914      function C_Stream (F : File_Type)
18915         return Interfaces.C_Streams.FILEs;
18916      procedure Open
18917        (File : in out File_Type;
18918         Mode : in File_Mode;
18919         C_Stream : in Interfaces.C_Streams.FILEs;
18920         Form : in String := "");
18921   end Ada.Direct_IO.C_Streams;
18923   with Interfaces.C_Streams;
18924   package Ada.Text_IO.C_Streams is
18925      function C_Stream (F : File_Type)
18926         return Interfaces.C_Streams.FILEs;
18927      procedure Open
18928        (File : in out File_Type;
18929         Mode : in File_Mode;
18930         C_Stream : in Interfaces.C_Streams.FILEs;
18931         Form : in String := "");
18932   end Ada.Text_IO.C_Streams;
18934   with Interfaces.C_Streams;
18935   package Ada.Wide_Text_IO.C_Streams is
18936      function C_Stream (F : File_Type)
18937         return Interfaces.C_Streams.FILEs;
18938      procedure Open
18939        (File : in out File_Type;
18940         Mode : in File_Mode;
18941         C_Stream : in Interfaces.C_Streams.FILEs;
18942         Form : in String := "");
18943  end Ada.Wide_Text_IO.C_Streams;
18945   with Interfaces.C_Streams;
18946   package Ada.Wide_Wide_Text_IO.C_Streams is
18947      function C_Stream (F : File_Type)
18948         return Interfaces.C_Streams.FILEs;
18949      procedure Open
18950        (File : in out File_Type;
18951         Mode : in File_Mode;
18952         C_Stream : in Interfaces.C_Streams.FILEs;
18953         Form : in String := "");
18954  end Ada.Wide_Wide_Text_IO.C_Streams;
18956  with Interfaces.C_Streams;
18957  package Ada.Stream_IO.C_Streams is
18958     function C_Stream (F : File_Type)
18959        return Interfaces.C_Streams.FILEs;
18960     procedure Open
18961       (File : in out File_Type;
18962        Mode : in File_Mode;
18963        C_Stream : in Interfaces.C_Streams.FILEs;
18964        Form : in String := "");
18965  end Ada.Stream_IO.C_Streams;
18966 @end smallexample
18968 @noindent
18969 In each of these six packages, the @code{C_Stream} function obtains the
18970 @code{FILE} pointer from a currently opened Ada file.  It is then
18971 possible to use the @code{Interfaces.C_Streams} package to operate on
18972 this stream, or the stream can be passed to a C program which can
18973 operate on it directly.  Of course the program is responsible for
18974 ensuring that only appropriate sequences of operations are executed.
18976 One particular use of relevance to an Ada program is that the
18977 @code{setvbuf} function can be used to control the buffering of the
18978 stream used by an Ada file.  In the absence of such a call the standard
18979 default buffering is used.
18981 The @code{Open} procedures in these packages open a file giving an
18982 existing C Stream instead of a file name.  Typically this stream is
18983 imported from a C program, allowing an Ada file to operate on an
18984 existing C file.
18986 @node The GNAT Library
18987 @chapter The GNAT Library
18989 @noindent
18990 The GNAT library contains a number of general and special purpose packages.
18991 It represents functionality that the GNAT developers have found useful, and
18992 which is made available to GNAT users.  The packages described here are fully
18993 supported, and upwards compatibility will be maintained in future releases,
18994 so you can use these facilities with the confidence that the same functionality
18995 will be available in future releases.
18997 The chapter here simply gives a brief summary of the facilities available.
18998 The full documentation is found in the spec file for the package.  The full
18999 sources of these library packages, including both spec and body, are provided
19000 with all GNAT releases.  For example, to find out the full specifications of
19001 the SPITBOL pattern matching capability, including a full tutorial and
19002 extensive examples, look in the @file{g-spipat.ads} file in the library.
19004 For each entry here, the package name (as it would appear in a @code{with}
19005 clause) is given, followed by the name of the corresponding spec file in
19006 parentheses.  The packages are children in four hierarchies, @code{Ada},
19007 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
19008 GNAT-specific hierarchy.
19010 Note that an application program should only use packages in one of these
19011 four hierarchies if the package is defined in the Ada Reference Manual,
19012 or is listed in this section of the GNAT Programmers Reference Manual.
19013 All other units should be considered internal implementation units and
19014 should not be directly @code{with}'ed by application code.  The use of
19015 a @code{with} statement that references one of these internal implementation
19016 units makes an application potentially dependent on changes in versions
19017 of GNAT, and will generate a warning message.
19019 @menu
19020 * Ada.Characters.Latin_9 (a-chlat9.ads)::
19021 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
19022 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
19023 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
19024 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
19025 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
19026 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
19027 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
19028 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
19029 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
19030 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
19031 * Ada.Containers.Formal_Indefinite_Vectors (a-cfinve.ads)::
19032 * Ada.Containers.Bounded_Holders (a-coboho.ads)::
19033 * Ada.Command_Line.Environment (a-colien.ads)::
19034 * Ada.Command_Line.Remove (a-colire.ads)::
19035 * Ada.Command_Line.Response_File (a-clrefi.ads)::
19036 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
19037 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
19038 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
19039 * Ada.Exceptions.Traceback (a-exctra.ads)::
19040 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
19041 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
19042 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
19043 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
19044 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
19045 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
19046 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
19047 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
19048 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
19049 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
19050 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
19051 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
19052 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
19053 * GNAT.Altivec (g-altive.ads)::
19054 * GNAT.Altivec.Conversions (g-altcon.ads)::
19055 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
19056 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
19057 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
19058 * GNAT.Array_Split (g-arrspl.ads)::
19059 * GNAT.AWK (g-awk.ads)::
19060 * GNAT.Bounded_Buffers (g-boubuf.ads)::
19061 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
19062 * GNAT.Bubble_Sort (g-bubsor.ads)::
19063 * GNAT.Bubble_Sort_A (g-busora.ads)::
19064 * GNAT.Bubble_Sort_G (g-busorg.ads)::
19065 * GNAT.Byte_Order_Mark (g-byorma.ads)::
19066 * GNAT.Byte_Swapping (g-bytswa.ads)::
19067 * GNAT.Calendar (g-calend.ads)::
19068 * GNAT.Calendar.Time_IO (g-catiio.ads)::
19069 * GNAT.Case_Util (g-casuti.ads)::
19070 * GNAT.CGI (g-cgi.ads)::
19071 * GNAT.CGI.Cookie (g-cgicoo.ads)::
19072 * GNAT.CGI.Debug (g-cgideb.ads)::
19073 * GNAT.Command_Line (g-comlin.ads)::
19074 * GNAT.Compiler_Version (g-comver.ads)::
19075 * GNAT.Ctrl_C (g-ctrl_c.ads)::
19076 * GNAT.CRC32 (g-crc32.ads)::
19077 * GNAT.Current_Exception (g-curexc.ads)::
19078 * GNAT.Debug_Pools (g-debpoo.ads)::
19079 * GNAT.Debug_Utilities (g-debuti.ads)::
19080 * GNAT.Decode_String (g-decstr.ads)::
19081 * GNAT.Decode_UTF8_String (g-deutst.ads)::
19082 * GNAT.Directory_Operations (g-dirope.ads)::
19083 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
19084 * GNAT.Dynamic_HTables (g-dynhta.ads)::
19085 * GNAT.Dynamic_Tables (g-dyntab.ads)::
19086 * GNAT.Encode_String (g-encstr.ads)::
19087 * GNAT.Encode_UTF8_String (g-enutst.ads)::
19088 * GNAT.Exception_Actions (g-excact.ads)::
19089 * GNAT.Exception_Traces (g-exctra.ads)::
19090 * GNAT.Exceptions (g-except.ads)::
19091 * GNAT.Expect (g-expect.ads)::
19092 * GNAT.Expect.TTY (g-exptty.ads)::
19093 * GNAT.Float_Control (g-flocon.ads)::
19094 * GNAT.Formatted_String (g-forstr.ads)::
19095 * GNAT.Heap_Sort (g-heasor.ads)::
19096 * GNAT.Heap_Sort_A (g-hesora.ads)::
19097 * GNAT.Heap_Sort_G (g-hesorg.ads)::
19098 * GNAT.HTable (g-htable.ads)::
19099 * GNAT.IO (g-io.ads)::
19100 * GNAT.IO_Aux (g-io_aux.ads)::
19101 * GNAT.Lock_Files (g-locfil.ads)::
19102 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
19103 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
19104 * GNAT.MD5 (g-md5.ads)::
19105 * GNAT.Memory_Dump (g-memdum.ads)::
19106 * GNAT.Most_Recent_Exception (g-moreex.ads)::
19107 * GNAT.OS_Lib (g-os_lib.ads)::
19108 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
19109 * GNAT.Random_Numbers (g-rannum.ads)::
19110 * GNAT.Regexp (g-regexp.ads)::
19111 * GNAT.Registry (g-regist.ads)::
19112 * GNAT.Regpat (g-regpat.ads)::
19113 * GNAT.Rewrite_Data (g-rewdat.ads)::
19114 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
19115 * GNAT.Semaphores (g-semaph.ads)::
19116 * GNAT.Serial_Communications (g-sercom.ads)::
19117 * GNAT.SHA1 (g-sha1.ads)::
19118 * GNAT.SHA224 (g-sha224.ads)::
19119 * GNAT.SHA256 (g-sha256.ads)::
19120 * GNAT.SHA384 (g-sha384.ads)::
19121 * GNAT.SHA512 (g-sha512.ads)::
19122 * GNAT.Signals (g-signal.ads)::
19123 * GNAT.Sockets (g-socket.ads)::
19124 * GNAT.Source_Info (g-souinf.ads)::
19125 * GNAT.Spelling_Checker (g-speche.ads)::
19126 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
19127 * GNAT.Spitbol.Patterns (g-spipat.ads)::
19128 * GNAT.Spitbol (g-spitbo.ads)::
19129 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
19130 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
19131 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
19132 * GNAT.SSE (g-sse.ads)::
19133 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
19134 * GNAT.Strings (g-string.ads)::
19135 * GNAT.String_Split (g-strspl.ads)::
19136 * GNAT.Table (g-table.ads)::
19137 * GNAT.Task_Lock (g-tasloc.ads)::
19138 * GNAT.Threads (g-thread.ads)::
19139 * GNAT.Time_Stamp (g-timsta.ads)::
19140 * GNAT.Traceback (g-traceb.ads)::
19141 * GNAT.Traceback.Symbolic (g-trasym.ads)::
19142 * GNAT.UTF_32 (g-utf_32.ads)::
19143 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
19144 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
19145 * GNAT.Wide_String_Split (g-wistsp.ads)::
19146 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
19147 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
19148 * Interfaces.C.Extensions (i-cexten.ads)::
19149 * Interfaces.C.Streams (i-cstrea.ads)::
19150 * Interfaces.Packed_Decimal (i-pacdec.ads)::
19151 * Interfaces.VxWorks (i-vxwork.ads)::
19152 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
19153 * System.Address_Image (s-addima.ads)::
19154 * System.Assertions (s-assert.ads)::
19155 * System.Atomic_Counters (s-atocou.ads)::
19156 * System.Memory (s-memory.ads)::
19157 * System.Multiprocessors (s-multip.ads)::
19158 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
19159 * System.Partition_Interface (s-parint.ads)::
19160 * System.Pool_Global (s-pooglo.ads)::
19161 * System.Pool_Local (s-pooloc.ads)::
19162 * System.Restrictions (s-restri.ads)::
19163 * System.Rident (s-rident.ads)::
19164 * System.Strings.Stream_Ops (s-ststop.ads)::
19165 * System.Unsigned_Types (s-unstyp.ads)::
19166 * System.Wch_Cnv (s-wchcnv.ads)::
19167 * System.Wch_Con (s-wchcon.ads)::
19168 @end menu
19170 @node Ada.Characters.Latin_9 (a-chlat9.ads)
19171 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
19172 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
19173 @cindex Latin_9 constants for Character
19175 @noindent
19176 This child of @code{Ada.Characters}
19177 provides a set of definitions corresponding to those in the
19178 RM-defined package @code{Ada.Characters.Latin_1} but with the
19179 few modifications required for @code{Latin-9}
19180 The provision of such a package
19181 is specifically authorized by the Ada Reference Manual
19182 (RM A.3.3(27)).
19184 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
19185 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
19186 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
19187 @cindex Latin_1 constants for Wide_Character
19189 @noindent
19190 This child of @code{Ada.Characters}
19191 provides a set of definitions corresponding to those in the
19192 RM-defined package @code{Ada.Characters.Latin_1} but with the
19193 types of the constants being @code{Wide_Character}
19194 instead of @code{Character}.  The provision of such a package
19195 is specifically authorized by the Ada Reference Manual
19196 (RM A.3.3(27)).
19198 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
19199 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
19200 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
19201 @cindex Latin_9 constants for Wide_Character
19203 @noindent
19204 This child of @code{Ada.Characters}
19205 provides a set of definitions corresponding to those in the
19206 GNAT defined package @code{Ada.Characters.Latin_9} but with the
19207 types of the constants being @code{Wide_Character}
19208 instead of @code{Character}.  The provision of such a package
19209 is specifically authorized by the Ada Reference Manual
19210 (RM A.3.3(27)).
19212 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
19213 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
19214 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
19215 @cindex Latin_1 constants for Wide_Wide_Character
19217 @noindent
19218 This child of @code{Ada.Characters}
19219 provides a set of definitions corresponding to those in the
19220 RM-defined package @code{Ada.Characters.Latin_1} but with the
19221 types of the constants being @code{Wide_Wide_Character}
19222 instead of @code{Character}.  The provision of such a package
19223 is specifically authorized by the Ada Reference Manual
19224 (RM A.3.3(27)).
19226 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
19227 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
19228 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
19229 @cindex Latin_9 constants for Wide_Wide_Character
19231 @noindent
19232 This child of @code{Ada.Characters}
19233 provides a set of definitions corresponding to those in the
19234 GNAT defined package @code{Ada.Characters.Latin_9} but with the
19235 types of the constants being @code{Wide_Wide_Character}
19236 instead of @code{Character}.  The provision of such a package
19237 is specifically authorized by the Ada Reference Manual
19238 (RM A.3.3(27)).
19240 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
19241 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
19242 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
19243 @cindex Formal container for doubly linked lists
19245 @noindent
19246 This child of @code{Ada.Containers} defines a modified version of the
19247 Ada 2005 container for doubly linked lists, meant to facilitate formal
19248 verification of code using such containers. The specification of this
19249 unit is compatible with SPARK 2014.
19251 Note that although this container was designed with formal verification
19252 in mind, it may well be generally useful in that it is a simplified more
19253 efficient version than the one defined in the standard. In particular it
19254 does not have the complex overhead required to detect cursor tampering.
19256 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
19257 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
19258 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
19259 @cindex Formal container for hashed maps
19261 @noindent
19262 This child of @code{Ada.Containers} defines a modified version of the
19263 Ada 2005 container for hashed maps, meant to facilitate formal
19264 verification of code using such containers. The specification of this
19265 unit is compatible with SPARK 2014.
19267 Note that although this container was designed with formal verification
19268 in mind, it may well be generally useful in that it is a simplified more
19269 efficient version than the one defined in the standard. In particular it
19270 does not have the complex overhead required to detect cursor tampering.
19272 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
19273 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
19274 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
19275 @cindex Formal container for hashed sets
19277 @noindent
19278 This child of @code{Ada.Containers} defines a modified version of the
19279 Ada 2005 container for hashed sets, meant to facilitate formal
19280 verification of code using such containers. The specification of this
19281 unit is compatible with SPARK 2014.
19283 Note that although this container was designed with formal verification
19284 in mind, it may well be generally useful in that it is a simplified more
19285 efficient version than the one defined in the standard. In particular it
19286 does not have the complex overhead required to detect cursor tampering.
19288 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
19289 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
19290 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
19291 @cindex Formal container for ordered maps
19293 @noindent
19294 This child of @code{Ada.Containers} defines a modified version of the
19295 Ada 2005 container for ordered maps, meant to facilitate formal
19296 verification of code using such containers. The specification of this
19297 unit is compatible with SPARK 2014.
19299 Note that although this container was designed with formal verification
19300 in mind, it may well be generally useful in that it is a simplified more
19301 efficient version than the one defined in the standard. In particular it
19302 does not have the complex overhead required to detect cursor tampering.
19304 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
19305 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
19306 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
19307 @cindex Formal container for ordered sets
19309 @noindent
19310 This child of @code{Ada.Containers} defines a modified version of the
19311 Ada 2005 container for ordered sets, meant to facilitate formal
19312 verification of code using such containers. The specification of this
19313 unit is compatible with SPARK 2014.
19315 Note that although this container was designed with formal verification
19316 in mind, it may well be generally useful in that it is a simplified more
19317 efficient version than the one defined in the standard. In particular it
19318 does not have the complex overhead required to detect cursor tampering.
19320 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
19321 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
19322 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
19323 @cindex Formal container for vectors
19325 @noindent
19326 This child of @code{Ada.Containers} defines a modified version of the
19327 Ada 2005 container for vectors, meant to facilitate formal
19328 verification of code using such containers. The specification of this
19329 unit is compatible with SPARK 2014.
19331 Note that although this container was designed with formal verification
19332 in mind, it may well be generally useful in that it is a simplified more
19333 efficient version than the one defined in the standard. In particular it
19334 does not have the complex overhead required to detect cursor tampering.
19336 @node Ada.Containers.Formal_Indefinite_Vectors (a-cfinve.ads)
19337 @section @code{Ada.Containers.Formal_Indefinite_Vectors} (@file{a-cfinve.ads})
19338 @cindex @code{Ada.Containers.Formal_Indefinite_Vectors} (@file{a-cfinve.ads})
19339 @cindex Formal container for vectors
19341 @noindent
19342 This child of @code{Ada.Containers} defines a modified version of the
19343 Ada 2005 container for vectors of indefinite elements, meant to
19344 facilitate formal verification of code using such containers. The
19345 specification of this unit is compatible with SPARK 2014.
19347 Note that although this container was designed with formal verification
19348 in mind, it may well be generally useful in that it is a simplified more
19349 efficient version than the one defined in the standard. In particular it
19350 does not have the complex overhead required to detect cursor tampering.
19352 @node Ada.Containers.Bounded_Holders (a-coboho.ads)
19353 @section @code{Ada.Containers.Bounded_Holders} (@file{a-coboho.ads})
19354 @cindex @code{Ada.Containers.Bounded_Holders} (@file{a-coboho.ads})
19355 @cindex Formal container for vectors
19357 @noindent
19358 This child of @code{Ada.Containers} defines a modified version of
19359 Indefinite_Holders that avoids heap allocation.
19361 @node Ada.Command_Line.Environment (a-colien.ads)
19362 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
19363 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
19364 @cindex Environment entries
19366 @noindent
19367 This child of @code{Ada.Command_Line}
19368 provides a mechanism for obtaining environment values on systems
19369 where this concept makes sense.
19371 @node Ada.Command_Line.Remove (a-colire.ads)
19372 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
19373 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
19374 @cindex Removing command line arguments
19375 @cindex Command line, argument removal
19377 @noindent
19378 This child of @code{Ada.Command_Line}
19379 provides a mechanism for logically removing
19380 arguments from the argument list.  Once removed, an argument is not visible
19381 to further calls on the subprograms in @code{Ada.Command_Line} will not
19382 see the removed argument.
19384 @node Ada.Command_Line.Response_File (a-clrefi.ads)
19385 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
19386 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
19387 @cindex Response file for command line
19388 @cindex Command line, response file
19389 @cindex Command line, handling long command lines
19391 @noindent
19392 This child of @code{Ada.Command_Line} provides a mechanism facilities for
19393 getting command line arguments from a text file, called a "response file".
19394 Using a response file allow passing a set of arguments to an executable longer
19395 than the maximum allowed by the system on the command line.
19397 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
19398 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
19399 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
19400 @cindex C Streams, Interfacing with Direct_IO
19402 @noindent
19403 This package provides subprograms that allow interfacing between
19404 C streams and @code{Direct_IO}.  The stream identifier can be
19405 extracted from a file opened on the Ada side, and an Ada file
19406 can be constructed from a stream opened on the C side.
19408 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
19409 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
19410 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
19411 @cindex Null_Occurrence, testing for
19413 @noindent
19414 This child subprogram provides a way of testing for the null
19415 exception occurrence (@code{Null_Occurrence}) without raising
19416 an exception.
19418 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
19419 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
19420 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
19421 @cindex Null_Occurrence, testing for
19423 @noindent
19424 This child subprogram is used for handling otherwise unhandled
19425 exceptions (hence the name last chance), and perform clean ups before
19426 terminating the program. Note that this subprogram never returns.
19428 @node Ada.Exceptions.Traceback (a-exctra.ads)
19429 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
19430 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
19431 @cindex Traceback for Exception Occurrence
19433 @noindent
19434 This child package provides the subprogram (@code{Tracebacks}) to
19435 give a traceback array of addresses based on an exception
19436 occurrence.
19438 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
19439 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
19440 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
19441 @cindex C Streams, Interfacing with Sequential_IO
19443 @noindent
19444 This package provides subprograms that allow interfacing between
19445 C streams and @code{Sequential_IO}.  The stream identifier can be
19446 extracted from a file opened on the Ada side, and an Ada file
19447 can be constructed from a stream opened on the C side.
19449 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
19450 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
19451 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
19452 @cindex C Streams, Interfacing with Stream_IO
19454 @noindent
19455 This package provides subprograms that allow interfacing between
19456 C streams and @code{Stream_IO}.  The stream identifier can be
19457 extracted from a file opened on the Ada side, and an Ada file
19458 can be constructed from a stream opened on the C side.
19460 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
19461 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
19462 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
19463 @cindex @code{Unbounded_String}, IO support
19464 @cindex @code{Text_IO}, extensions for unbounded strings
19466 @noindent
19467 This package provides subprograms for Text_IO for unbounded
19468 strings, avoiding the necessity for an intermediate operation
19469 with ordinary strings.
19471 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
19472 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
19473 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
19474 @cindex @code{Unbounded_Wide_String}, IO support
19475 @cindex @code{Text_IO}, extensions for unbounded wide strings
19477 @noindent
19478 This package provides subprograms for Text_IO for unbounded
19479 wide strings, avoiding the necessity for an intermediate operation
19480 with ordinary wide strings.
19482 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
19483 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
19484 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
19485 @cindex @code{Unbounded_Wide_Wide_String}, IO support
19486 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
19488 @noindent
19489 This package provides subprograms for Text_IO for unbounded
19490 wide wide strings, avoiding the necessity for an intermediate operation
19491 with ordinary wide wide strings.
19493 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
19494 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
19495 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
19496 @cindex C Streams, Interfacing with @code{Text_IO}
19498 @noindent
19499 This package provides subprograms that allow interfacing between
19500 C streams and @code{Text_IO}.  The stream identifier can be
19501 extracted from a file opened on the Ada side, and an Ada file
19502 can be constructed from a stream opened on the C side.
19504 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
19505 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
19506 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
19507 @cindex @code{Text_IO} resetting standard files
19509 @noindent
19510 This procedure is used to reset the status of the standard files used
19511 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
19512 embedded application) where the status of the files may change during
19513 execution (for example a standard input file may be redefined to be
19514 interactive).
19516 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
19517 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
19518 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
19519 @cindex Unicode categorization, Wide_Character
19521 @noindent
19522 This package provides subprograms that allow categorization of
19523 Wide_Character values according to Unicode categories.
19525 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
19526 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
19527 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
19528 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
19530 @noindent
19531 This package provides subprograms that allow interfacing between
19532 C streams and @code{Wide_Text_IO}.  The stream identifier can be
19533 extracted from a file opened on the Ada side, and an Ada file
19534 can be constructed from a stream opened on the C side.
19536 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
19537 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
19538 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
19539 @cindex @code{Wide_Text_IO} resetting standard files
19541 @noindent
19542 This procedure is used to reset the status of the standard files used
19543 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
19544 embedded application) where the status of the files may change during
19545 execution (for example a standard input file may be redefined to be
19546 interactive).
19548 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
19549 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
19550 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
19551 @cindex Unicode categorization, Wide_Wide_Character
19553 @noindent
19554 This package provides subprograms that allow categorization of
19555 Wide_Wide_Character values according to Unicode categories.
19557 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
19558 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
19559 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
19560 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
19562 @noindent
19563 This package provides subprograms that allow interfacing between
19564 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
19565 extracted from a file opened on the Ada side, and an Ada file
19566 can be constructed from a stream opened on the C side.
19568 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
19569 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
19570 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
19571 @cindex @code{Wide_Wide_Text_IO} resetting standard files
19573 @noindent
19574 This procedure is used to reset the status of the standard files used
19575 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
19576 restart in an embedded application) where the status of the files may
19577 change during execution (for example a standard input file may be
19578 redefined to be interactive).
19580 @node GNAT.Altivec (g-altive.ads)
19581 @section @code{GNAT.Altivec} (@file{g-altive.ads})
19582 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
19583 @cindex AltiVec
19585 @noindent
19586 This is the root package of the GNAT AltiVec binding. It provides
19587 definitions of constants and types common to all the versions of the
19588 binding.
19590 @node GNAT.Altivec.Conversions (g-altcon.ads)
19591 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
19592 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
19593 @cindex AltiVec
19595 @noindent
19596 This package provides the Vector/View conversion routines.
19598 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
19599 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
19600 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
19601 @cindex AltiVec
19603 @noindent
19604 This package exposes the Ada interface to the AltiVec operations on
19605 vector objects. A soft emulation is included by default in the GNAT
19606 library. The hard binding is provided as a separate package. This unit
19607 is common to both bindings.
19609 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
19610 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
19611 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
19612 @cindex AltiVec
19614 @noindent
19615 This package exposes the various vector types part of the Ada binding
19616 to AltiVec facilities.
19618 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
19619 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19620 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19621 @cindex AltiVec
19623 @noindent
19624 This package provides public 'View' data types from/to which private
19625 vector representations can be converted via
19626 GNAT.Altivec.Conversions. This allows convenient access to individual
19627 vector elements and provides a simple way to initialize vector
19628 objects.
19630 @node GNAT.Array_Split (g-arrspl.ads)
19631 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19632 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19633 @cindex Array splitter
19635 @noindent
19636 Useful array-manipulation routines: given a set of separators, split
19637 an array wherever the separators appear, and provide direct access
19638 to the resulting slices.
19640 @node GNAT.AWK (g-awk.ads)
19641 @section @code{GNAT.AWK} (@file{g-awk.ads})
19642 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
19643 @cindex Parsing
19644 @cindex AWK
19646 @noindent
19647 Provides AWK-like parsing functions, with an easy interface for parsing one
19648 or more files containing formatted data.  The file is viewed as a database
19649 where each record is a line and a field is a data element in this line.
19651 @node GNAT.Bounded_Buffers (g-boubuf.ads)
19652 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19653 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19654 @cindex Parsing
19655 @cindex Bounded Buffers
19657 @noindent
19658 Provides a concurrent generic bounded buffer abstraction.  Instances are
19659 useful directly or as parts of the implementations of other abstractions,
19660 such as mailboxes.
19662 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
19663 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19664 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19665 @cindex Parsing
19666 @cindex Mailboxes
19668 @noindent
19669 Provides a thread-safe asynchronous intertask mailbox communication facility.
19671 @node GNAT.Bubble_Sort (g-bubsor.ads)
19672 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19673 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19674 @cindex Sorting
19675 @cindex Bubble sort
19677 @noindent
19678 Provides a general implementation of bubble sort usable for sorting arbitrary
19679 data items.  Exchange and comparison procedures are provided by passing
19680 access-to-procedure values.
19682 @node GNAT.Bubble_Sort_A (g-busora.ads)
19683 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19684 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19685 @cindex Sorting
19686 @cindex Bubble sort
19688 @noindent
19689 Provides a general implementation of bubble sort usable for sorting arbitrary
19690 data items.  Move and comparison procedures are provided by passing
19691 access-to-procedure values. This is an older version, retained for
19692 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
19694 @node GNAT.Bubble_Sort_G (g-busorg.ads)
19695 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19696 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19697 @cindex Sorting
19698 @cindex Bubble sort
19700 @noindent
19701 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
19702 are provided as generic parameters, this improves efficiency, especially
19703 if the procedures can be inlined, at the expense of duplicating code for
19704 multiple instantiations.
19706 @node GNAT.Byte_Order_Mark (g-byorma.ads)
19707 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19708 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19709 @cindex UTF-8 representation
19710 @cindex Wide characte representations
19712 @noindent
19713 Provides a routine which given a string, reads the start of the string to
19714 see whether it is one of the standard byte order marks (BOM's) which signal
19715 the encoding of the string. The routine includes detection of special XML
19716 sequences for various UCS input formats.
19718 @node GNAT.Byte_Swapping (g-bytswa.ads)
19719 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19720 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19721 @cindex Byte swapping
19722 @cindex Endianness
19724 @noindent
19725 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
19726 Machine-specific implementations are available in some cases.
19728 @node GNAT.Calendar (g-calend.ads)
19729 @section @code{GNAT.Calendar} (@file{g-calend.ads})
19730 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
19731 @cindex @code{Calendar}
19733 @noindent
19734 Extends the facilities provided by @code{Ada.Calendar} to include handling
19735 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
19736 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
19737 C @code{timeval} format.
19739 @node GNAT.Calendar.Time_IO (g-catiio.ads)
19740 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19741 @cindex @code{Calendar}
19742 @cindex Time
19743 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19745 @node GNAT.Case_Util (g-casuti.ads)
19746 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
19747 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
19748 @cindex Casing utilities
19749 @cindex Character handling (@code{GNAT.Case_Util})
19751 @noindent
19752 A set of simple routines for handling upper and lower casing of strings
19753 without the overhead of the full casing tables
19754 in @code{Ada.Characters.Handling}.
19756 @node GNAT.CGI (g-cgi.ads)
19757 @section @code{GNAT.CGI} (@file{g-cgi.ads})
19758 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
19759 @cindex CGI (Common Gateway Interface)
19761 @noindent
19762 This is a package for interfacing a GNAT program with a Web server via the
19763 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
19764 parameters, which are a set of key/value pairs sent by the Web server.  It
19765 builds a table whose index is the key and provides some services to deal
19766 with this table.
19768 @node GNAT.CGI.Cookie (g-cgicoo.ads)
19769 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19770 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19771 @cindex CGI (Common Gateway Interface) cookie support
19772 @cindex Cookie support in CGI
19774 @noindent
19775 This is a package to interface a GNAT program with a Web server via the
19776 Common Gateway Interface (CGI).  It exports services to deal with Web
19777 cookies (piece of information kept in the Web client software).
19779 @node GNAT.CGI.Debug (g-cgideb.ads)
19780 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19781 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19782 @cindex CGI (Common Gateway Interface) debugging
19784 @noindent
19785 This is a package to help debugging CGI (Common Gateway Interface)
19786 programs written in Ada.
19788 @node GNAT.Command_Line (g-comlin.ads)
19789 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
19790 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
19791 @cindex Command line
19793 @noindent
19794 Provides a high level interface to @code{Ada.Command_Line} facilities,
19795 including the ability to scan for named switches with optional parameters
19796 and expand file names using wild card notations.
19798 @node GNAT.Compiler_Version (g-comver.ads)
19799 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19800 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19801 @cindex Compiler Version
19802 @cindex Version, of compiler
19804 @noindent
19805 Provides a routine for obtaining the version of the compiler used to
19806 compile the program. More accurately this is the version of the binder
19807 used to bind the program (this will normally be the same as the version
19808 of the compiler if a consistent tool set is used to compile all units
19809 of a partition).
19811 @node GNAT.Ctrl_C (g-ctrl_c.ads)
19812 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19813 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19814 @cindex Interrupt
19816 @noindent
19817 Provides a simple interface to handle Ctrl-C keyboard events.
19819 @node GNAT.CRC32 (g-crc32.ads)
19820 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
19821 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
19822 @cindex CRC32
19823 @cindex Cyclic Redundancy Check
19825 @noindent
19826 This package implements the CRC-32 algorithm.  For a full description
19827 of this algorithm see
19828 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
19829 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
19830 Aug.@: 1988.  Sarwate, D.V@.
19832 @node GNAT.Current_Exception (g-curexc.ads)
19833 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19834 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19835 @cindex Current exception
19836 @cindex Exception retrieval
19838 @noindent
19839 Provides access to information on the current exception that has been raised
19840 without the need for using the Ada 95 / Ada 2005 exception choice parameter
19841 specification syntax.
19842 This is particularly useful in simulating typical facilities for
19843 obtaining information about exceptions provided by Ada 83 compilers.
19845 @node GNAT.Debug_Pools (g-debpoo.ads)
19846 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19847 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19848 @cindex Debugging
19849 @cindex Debug pools
19850 @cindex Memory corruption debugging
19852 @noindent
19853 Provide a debugging storage pools that helps tracking memory corruption
19854 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
19855 @value{EDITION} User's Guide}.
19857 @node GNAT.Debug_Utilities (g-debuti.ads)
19858 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19859 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19860 @cindex Debugging
19862 @noindent
19863 Provides a few useful utilities for debugging purposes, including conversion
19864 to and from string images of address values. Supports both C and Ada formats
19865 for hexadecimal literals.
19867 @node GNAT.Decode_String (g-decstr.ads)
19868 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
19869 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
19870 @cindex Decoding strings
19871 @cindex String decoding
19872 @cindex Wide character encoding
19873 @cindex UTF-8
19874 @cindex Unicode
19876 @noindent
19877 A generic package providing routines for decoding wide character and wide wide
19878 character strings encoded as sequences of 8-bit characters using a specified
19879 encoding method. Includes validation routines, and also routines for stepping
19880 to next or previous encoded character in an encoded string.
19881 Useful in conjunction with Unicode character coding. Note there is a
19882 preinstantiation for UTF-8. See next entry.
19884 @node GNAT.Decode_UTF8_String (g-deutst.ads)
19885 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19886 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19887 @cindex Decoding strings
19888 @cindex Decoding UTF-8 strings
19889 @cindex UTF-8 string decoding
19890 @cindex Wide character decoding
19891 @cindex UTF-8
19892 @cindex Unicode
19894 @noindent
19895 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
19897 @node GNAT.Directory_Operations (g-dirope.ads)
19898 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19899 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19900 @cindex Directory operations
19902 @noindent
19903 Provides a set of routines for manipulating directories, including changing
19904 the current directory, making new directories, and scanning the files in a
19905 directory.
19907 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
19908 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19909 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19910 @cindex Directory operations iteration
19912 @noindent
19913 A child unit of GNAT.Directory_Operations providing additional operations
19914 for iterating through directories.
19916 @node GNAT.Dynamic_HTables (g-dynhta.ads)
19917 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19918 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19919 @cindex Hash tables
19921 @noindent
19922 A generic implementation of hash tables that can be used to hash arbitrary
19923 data.  Provided in two forms, a simple form with built in hash functions,
19924 and a more complex form in which the hash function is supplied.
19926 @noindent
19927 This package provides a facility similar to that of @code{GNAT.HTable},
19928 except that this package declares a type that can be used to define
19929 dynamic instances of the hash table, while an instantiation of
19930 @code{GNAT.HTable} creates a single instance of the hash table.
19932 @node GNAT.Dynamic_Tables (g-dyntab.ads)
19933 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19934 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19935 @cindex Table implementation
19936 @cindex Arrays, extendable
19938 @noindent
19939 A generic package providing a single dimension array abstraction where the
19940 length of the array can be dynamically modified.
19942 @noindent
19943 This package provides a facility similar to that of @code{GNAT.Table},
19944 except that this package declares a type that can be used to define
19945 dynamic instances of the table, while an instantiation of
19946 @code{GNAT.Table} creates a single instance of the table type.
19948 @node GNAT.Encode_String (g-encstr.ads)
19949 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
19950 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
19951 @cindex Encoding strings
19952 @cindex String encoding
19953 @cindex Wide character encoding
19954 @cindex UTF-8
19955 @cindex Unicode
19957 @noindent
19958 A generic package providing routines for encoding wide character and wide
19959 wide character strings as sequences of 8-bit characters using a specified
19960 encoding method. Useful in conjunction with Unicode character coding.
19961 Note there is a preinstantiation for UTF-8. See next entry.
19963 @node GNAT.Encode_UTF8_String (g-enutst.ads)
19964 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19965 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19966 @cindex Encoding strings
19967 @cindex Encoding UTF-8 strings
19968 @cindex UTF-8 string encoding
19969 @cindex Wide character encoding
19970 @cindex UTF-8
19971 @cindex Unicode
19973 @noindent
19974 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
19976 @node GNAT.Exception_Actions (g-excact.ads)
19977 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19978 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19979 @cindex Exception actions
19981 @noindent
19982 Provides callbacks when an exception is raised. Callbacks can be registered
19983 for specific exceptions, or when any exception is raised. This
19984 can be used for instance to force a core dump to ease debugging.
19986 @node GNAT.Exception_Traces (g-exctra.ads)
19987 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19988 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19989 @cindex Exception traces
19990 @cindex Debugging
19992 @noindent
19993 Provides an interface allowing to control automatic output upon exception
19994 occurrences.
19996 @node GNAT.Exceptions (g-except.ads)
19997 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
19998 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
19999 @cindex Exceptions, Pure
20000 @cindex Pure packages, exceptions
20002 @noindent
20003 Normally it is not possible to raise an exception with
20004 a message from a subprogram in a pure package, since the
20005 necessary types and subprograms are in @code{Ada.Exceptions}
20006 which is not a pure unit. @code{GNAT.Exceptions} provides a
20007 facility for getting around this limitation for a few
20008 predefined exceptions, and for example allow raising
20009 @code{Constraint_Error} with a message from a pure subprogram.
20011 @node GNAT.Expect (g-expect.ads)
20012 @section @code{GNAT.Expect} (@file{g-expect.ads})
20013 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
20015 @noindent
20016 Provides a set of subprograms similar to what is available
20017 with the standard Tcl Expect tool.
20018 It allows you to easily spawn and communicate with an external process.
20019 You can send commands or inputs to the process, and compare the output
20020 with some expected regular expression. Currently @code{GNAT.Expect}
20021 is implemented on all native GNAT ports except for OpenVMS@.
20022 It is not implemented for cross ports, and in particular is not
20023 implemented for VxWorks or LynxOS@.
20025 @node GNAT.Expect.TTY (g-exptty.ads)
20026 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
20027 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
20029 @noindent
20030 As GNAT.Expect but using pseudo-terminal.
20031 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
20032 ports except for OpenVMS@. It is not implemented for cross ports, and
20033 in particular is not implemented for VxWorks or LynxOS@.
20035 @node GNAT.Float_Control (g-flocon.ads)
20036 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
20037 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
20038 @cindex Floating-Point Processor
20040 @noindent
20041 Provides an interface for resetting the floating-point processor into the
20042 mode required for correct semantic operation in Ada.  Some third party
20043 library calls may cause this mode to be modified, and the Reset procedure
20044 in this package can be used to reestablish the required mode.
20046 @node GNAT.Formatted_String (g-forstr.ads)
20047 @section @code{GNAT.Formatted_String} (@file{g-forstr.ads})
20048 @cindex @code{GNAT.Formatted_String} (@file{g-forstr.ads})
20049 @cindex Formatted String
20051 @noindent
20052 Provides support for C/C++ printf() formatted strings. The format is
20053 copied from the printf() routine and should therefore gives identical
20054 output. Some generic routines are provided to be able to use types
20055 derived from Integer, Float or enumerations as values for the
20056 formatted string.
20058 @node GNAT.Heap_Sort (g-heasor.ads)
20059 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
20060 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
20061 @cindex Sorting
20063 @noindent
20064 Provides a general implementation of heap sort usable for sorting arbitrary
20065 data items. Exchange and comparison procedures are provided by passing
20066 access-to-procedure values.  The algorithm used is a modified heap sort
20067 that performs approximately N*log(N) comparisons in the worst case.
20069 @node GNAT.Heap_Sort_A (g-hesora.ads)
20070 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
20071 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
20072 @cindex Sorting
20074 @noindent
20075 Provides a general implementation of heap sort usable for sorting arbitrary
20076 data items. Move and comparison procedures are provided by passing
20077 access-to-procedure values.  The algorithm used is a modified heap sort
20078 that performs approximately N*log(N) comparisons in the worst case.
20079 This differs from @code{GNAT.Heap_Sort} in having a less convenient
20080 interface, but may be slightly more efficient.
20082 @node GNAT.Heap_Sort_G (g-hesorg.ads)
20083 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
20084 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
20085 @cindex Sorting
20087 @noindent
20088 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
20089 are provided as generic parameters, this improves efficiency, especially
20090 if the procedures can be inlined, at the expense of duplicating code for
20091 multiple instantiations.
20093 @node GNAT.HTable (g-htable.ads)
20094 @section @code{GNAT.HTable} (@file{g-htable.ads})
20095 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
20096 @cindex Hash tables
20098 @noindent
20099 A generic implementation of hash tables that can be used to hash arbitrary
20100 data.  Provides two approaches, one a simple static approach, and the other
20101 allowing arbitrary dynamic hash tables.
20103 @node GNAT.IO (g-io.ads)
20104 @section @code{GNAT.IO} (@file{g-io.ads})
20105 @cindex @code{GNAT.IO} (@file{g-io.ads})
20106 @cindex Simple I/O
20107 @cindex Input/Output facilities
20109 @noindent
20110 A simple preelaborable input-output package that provides a subset of
20111 simple Text_IO functions for reading characters and strings from
20112 Standard_Input, and writing characters, strings and integers to either
20113 Standard_Output or Standard_Error.
20115 @node GNAT.IO_Aux (g-io_aux.ads)
20116 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
20117 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
20118 @cindex Text_IO
20119 @cindex Input/Output facilities
20121 Provides some auxiliary functions for use with Text_IO, including a test
20122 for whether a file exists, and functions for reading a line of text.
20124 @node GNAT.Lock_Files (g-locfil.ads)
20125 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
20126 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
20127 @cindex File locking
20128 @cindex Locking using files
20130 @noindent
20131 Provides a general interface for using files as locks.  Can be used for
20132 providing program level synchronization.
20134 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
20135 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
20136 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
20137 @cindex Random number generation
20139 @noindent
20140 The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
20141 a modified version of the Blum-Blum-Shub generator.
20143 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
20144 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
20145 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
20146 @cindex Random number generation
20148 @noindent
20149 The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
20150 a modified version of the Blum-Blum-Shub generator.
20152 @node GNAT.MD5 (g-md5.ads)
20153 @section @code{GNAT.MD5} (@file{g-md5.ads})
20154 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
20155 @cindex Message Digest MD5
20157 @noindent
20158 Implements the MD5 Message-Digest Algorithm as described in RFC 1321, and
20159 the HMAC-MD5 message authentication function as described in RFC 2104 and
20160 FIPS PUB 198.
20162 @node GNAT.Memory_Dump (g-memdum.ads)
20163 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
20164 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
20165 @cindex Dump Memory
20167 @noindent
20168 Provides a convenient routine for dumping raw memory to either the
20169 standard output or standard error files. Uses GNAT.IO for actual
20170 output.
20172 @node GNAT.Most_Recent_Exception (g-moreex.ads)
20173 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
20174 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
20175 @cindex Exception, obtaining most recent
20177 @noindent
20178 Provides access to the most recently raised exception.  Can be used for
20179 various logging purposes, including duplicating functionality of some
20180 Ada 83 implementation dependent extensions.
20182 @node GNAT.OS_Lib (g-os_lib.ads)
20183 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
20184 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
20185 @cindex Operating System interface
20186 @cindex Spawn capability
20188 @noindent
20189 Provides a range of target independent operating system interface functions,
20190 including time/date management, file operations, subprocess management,
20191 including a portable spawn procedure, and access to environment variables
20192 and error return codes.
20194 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
20195 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
20196 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
20197 @cindex Hash functions
20199 @noindent
20200 Provides a generator of static minimal perfect hash functions. No
20201 collisions occur and each item can be retrieved from the table in one
20202 probe (perfect property). The hash table size corresponds to the exact
20203 size of the key set and no larger (minimal property). The key set has to
20204 be know in advance (static property). The hash functions are also order
20205 preserving. If w2 is inserted after w1 in the generator, their
20206 hashcode are in the same order. These hashing functions are very
20207 convenient for use with realtime applications.
20209 @node GNAT.Random_Numbers (g-rannum.ads)
20210 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
20211 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
20212 @cindex Random number generation
20214 @noindent
20215 Provides random number capabilities which extend those available in the
20216 standard Ada library and are more convenient to use.
20218 @node GNAT.Regexp (g-regexp.ads)
20219 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
20220 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
20221 @cindex Regular expressions
20222 @cindex Pattern matching
20224 @noindent
20225 A simple implementation of regular expressions, using a subset of regular
20226 expression syntax copied from familiar Unix style utilities.  This is the
20227 simplest of the three pattern matching packages provided, and is particularly
20228 suitable for ``file globbing'' applications.
20230 @node GNAT.Registry (g-regist.ads)
20231 @section @code{GNAT.Registry} (@file{g-regist.ads})
20232 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
20233 @cindex Windows Registry
20235 @noindent
20236 This is a high level binding to the Windows registry.  It is possible to
20237 do simple things like reading a key value, creating a new key.  For full
20238 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
20239 package provided with the Win32Ada binding
20241 @node GNAT.Regpat (g-regpat.ads)
20242 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
20243 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
20244 @cindex Regular expressions
20245 @cindex Pattern matching
20247 @noindent
20248 A complete implementation of Unix-style regular expression matching, copied
20249 from the original V7 style regular expression library written in C by
20250 Henry Spencer (and binary compatible with this C library).
20252 @node GNAT.Rewrite_Data (g-rewdat.ads)
20253 @section @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
20254 @cindex @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
20255 @cindex Rewrite data
20257 @noindent
20258 A unit to rewrite on-the-fly string occurrences in a stream of
20259 data. The implementation has a very minimal memory footprint as the
20260 full content to be processed is not loaded into memory all at once. This makes
20261 this interface usable for large files or socket streams.
20263 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
20264 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
20265 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
20266 @cindex Secondary Stack Info
20268 @noindent
20269 Provide the capability to query the high water mark of the current task's
20270 secondary stack.
20272 @node GNAT.Semaphores (g-semaph.ads)
20273 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
20274 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
20275 @cindex Semaphores
20277 @noindent
20278 Provides classic counting and binary semaphores using protected types.
20280 @node GNAT.Serial_Communications (g-sercom.ads)
20281 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
20282 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
20283 @cindex Serial_Communications
20285 @noindent
20286 Provides a simple interface to send and receive data over a serial
20287 port. This is only supported on GNU/Linux and Windows.
20289 @node GNAT.SHA1 (g-sha1.ads)
20290 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
20291 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
20292 @cindex Secure Hash Algorithm SHA-1
20294 @noindent
20295 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
20296 and RFC 3174, and the HMAC-SHA1 message authentication function as described
20297 in RFC 2104 and FIPS PUB 198.
20299 @node GNAT.SHA224 (g-sha224.ads)
20300 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
20301 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
20302 @cindex Secure Hash Algorithm SHA-224
20304 @noindent
20305 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3,
20306 and the HMAC-SHA224 message authentication function as described
20307 in RFC 2104 and FIPS PUB 198.
20309 @node GNAT.SHA256 (g-sha256.ads)
20310 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
20311 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
20312 @cindex Secure Hash Algorithm SHA-256
20314 @noindent
20315 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3,
20316 and the HMAC-SHA256 message authentication function as described
20317 in RFC 2104 and FIPS PUB 198.
20319 @node GNAT.SHA384 (g-sha384.ads)
20320 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
20321 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
20322 @cindex Secure Hash Algorithm SHA-384
20324 @noindent
20325 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3,
20326 and the HMAC-SHA384 message authentication function as described
20327 in RFC 2104 and FIPS PUB 198.
20329 @node GNAT.SHA512 (g-sha512.ads)
20330 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
20331 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
20332 @cindex Secure Hash Algorithm SHA-512
20334 @noindent
20335 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3,
20336 and the HMAC-SHA512 message authentication function as described
20337 in RFC 2104 and FIPS PUB 198.
20339 @node GNAT.Signals (g-signal.ads)
20340 @section @code{GNAT.Signals} (@file{g-signal.ads})
20341 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
20342 @cindex Signals
20344 @noindent
20345 Provides the ability to manipulate the blocked status of signals on supported
20346 targets.
20348 @node GNAT.Sockets (g-socket.ads)
20349 @section @code{GNAT.Sockets} (@file{g-socket.ads})
20350 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
20351 @cindex Sockets
20353 @noindent
20354 A high level and portable interface to develop sockets based applications.
20355 This package is based on the sockets thin binding found in
20356 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
20357 on all native GNAT ports except for OpenVMS@.  It is not implemented
20358 for the LynxOS@ cross port.
20360 @node GNAT.Source_Info (g-souinf.ads)
20361 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
20362 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
20363 @cindex Source Information
20365 @noindent
20366 Provides subprograms that give access to source code information known at
20367 compile time, such as the current file name and line number. Also provides
20368 subprograms yielding the date and time of the current compilation (like the
20369 C macros @code{__DATE__} and @code{__TIME__})
20371 @node GNAT.Spelling_Checker (g-speche.ads)
20372 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
20373 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
20374 @cindex Spell checking
20376 @noindent
20377 Provides a function for determining whether one string is a plausible
20378 near misspelling of another string.
20380 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
20381 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
20382 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
20383 @cindex Spell checking
20385 @noindent
20386 Provides a generic function that can be instantiated with a string type for
20387 determining whether one string is a plausible near misspelling of another
20388 string.
20390 @node GNAT.Spitbol.Patterns (g-spipat.ads)
20391 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
20392 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
20393 @cindex SPITBOL pattern matching
20394 @cindex Pattern matching
20396 @noindent
20397 A complete implementation of SNOBOL4 style pattern matching.  This is the
20398 most elaborate of the pattern matching packages provided.  It fully duplicates
20399 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
20400 efficient algorithm developed by Robert Dewar for the SPITBOL system.
20402 @node GNAT.Spitbol (g-spitbo.ads)
20403 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
20404 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
20405 @cindex SPITBOL interface
20407 @noindent
20408 The top level package of the collection of SPITBOL-style functionality, this
20409 package provides basic SNOBOL4 string manipulation functions, such as
20410 Pad, Reverse, Trim, Substr capability, as well as a generic table function
20411 useful for constructing arbitrary mappings from strings in the style of
20412 the SNOBOL4 TABLE function.
20414 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
20415 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
20416 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
20417 @cindex Sets of strings
20418 @cindex SPITBOL Tables
20420 @noindent
20421 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
20422 for type @code{Standard.Boolean}, giving an implementation of sets of
20423 string values.
20425 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
20426 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
20427 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
20428 @cindex Integer maps
20429 @cindex Maps
20430 @cindex SPITBOL Tables
20432 @noindent
20433 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
20434 for type @code{Standard.Integer}, giving an implementation of maps
20435 from string to integer values.
20437 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
20438 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
20439 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
20440 @cindex String maps
20441 @cindex Maps
20442 @cindex SPITBOL Tables
20444 @noindent
20445 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
20446 a variable length string type, giving an implementation of general
20447 maps from strings to strings.
20449 @node GNAT.SSE (g-sse.ads)
20450 @section @code{GNAT.SSE} (@file{g-sse.ads})
20451 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
20453 @noindent
20454 Root of a set of units aimed at offering Ada bindings to a subset of
20455 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
20456 targets.  It exposes vector component types together with a general
20457 introduction to the binding contents and use.
20459 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
20460 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
20461 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
20463 @noindent
20464 SSE vector types for use with SSE related intrinsics.
20466 @node GNAT.Strings (g-string.ads)
20467 @section @code{GNAT.Strings} (@file{g-string.ads})
20468 @cindex @code{GNAT.Strings} (@file{g-string.ads})
20470 @noindent
20471 Common String access types and related subprograms. Basically it
20472 defines a string access and an array of string access types.
20474 @node GNAT.String_Split (g-strspl.ads)
20475 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
20476 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
20477 @cindex String splitter
20479 @noindent
20480 Useful string manipulation routines: given a set of separators, split
20481 a string wherever the separators appear, and provide direct access
20482 to the resulting slices. This package is instantiated from
20483 @code{GNAT.Array_Split}.
20485 @node GNAT.Table (g-table.ads)
20486 @section @code{GNAT.Table} (@file{g-table.ads})
20487 @cindex @code{GNAT.Table} (@file{g-table.ads})
20488 @cindex Table implementation
20489 @cindex Arrays, extendable
20491 @noindent
20492 A generic package providing a single dimension array abstraction where the
20493 length of the array can be dynamically modified.
20495 @noindent
20496 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
20497 except that this package declares a single instance of the table type,
20498 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
20499 used to define dynamic instances of the table.
20501 @node GNAT.Task_Lock (g-tasloc.ads)
20502 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
20503 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
20504 @cindex Task synchronization
20505 @cindex Task locking
20506 @cindex Locking
20508 @noindent
20509 A very simple facility for locking and unlocking sections of code using a
20510 single global task lock.  Appropriate for use in situations where contention
20511 between tasks is very rarely expected.
20513 @node GNAT.Threads (g-thread.ads)
20514 @section @code{GNAT.Threads} (@file{g-thread.ads})
20515 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
20516 @cindex Foreign threads
20517 @cindex Threads, foreign
20519 @noindent
20520 Provides facilities for dealing with foreign threads which need to be known
20521 by the GNAT run-time system. Consult the documentation of this package for
20522 further details if your program has threads that are created by a non-Ada
20523 environment which then accesses Ada code.
20525 @node GNAT.Time_Stamp (g-timsta.ads)
20526 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
20527 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
20528 @cindex Time stamp
20529 @cindex Current time
20531 @noindent
20532 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
20533 represents the current date and time in ISO 8601 format. This is a very simple
20534 routine with minimal code and there are no dependencies on any other unit.
20536 @node GNAT.Traceback (g-traceb.ads)
20537 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
20538 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
20539 @cindex Trace back facilities
20541 @noindent
20542 Provides a facility for obtaining non-symbolic traceback information, useful
20543 in various debugging situations.
20545 @node GNAT.Traceback.Symbolic (g-trasym.ads)
20546 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
20547 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
20548 @cindex Trace back facilities
20550 @node GNAT.UTF_32 (g-utf_32.ads)
20551 @section @code{GNAT.UTF_32} (@file{g-table.ads})
20552 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
20553 @cindex Wide character codes
20555 @noindent
20556 This is a package intended to be used in conjunction with the
20557 @code{Wide_Character} type in Ada 95 and the
20558 @code{Wide_Wide_Character} type in Ada 2005 (available
20559 in @code{GNAT} in Ada 2005 mode). This package contains
20560 Unicode categorization routines, as well as lexical
20561 categorization routines corresponding to the Ada 2005
20562 lexical rules for identifiers and strings, and also a
20563 lower case to upper case fold routine corresponding to
20564 the Ada 2005 rules for identifier equivalence.
20566 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
20567 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
20568 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
20569 @cindex Spell checking
20571 @noindent
20572 Provides a function for determining whether one wide wide string is a plausible
20573 near misspelling of another wide wide string, where the strings are represented
20574 using the UTF_32_String type defined in System.Wch_Cnv.
20576 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
20577 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
20578 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
20579 @cindex Spell checking
20581 @noindent
20582 Provides a function for determining whether one wide string is a plausible
20583 near misspelling of another wide string.
20585 @node GNAT.Wide_String_Split (g-wistsp.ads)
20586 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
20587 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
20588 @cindex Wide_String splitter
20590 @noindent
20591 Useful wide string manipulation routines: given a set of separators, split
20592 a wide string wherever the separators appear, and provide direct access
20593 to the resulting slices. This package is instantiated from
20594 @code{GNAT.Array_Split}.
20596 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
20597 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
20598 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
20599 @cindex Spell checking
20601 @noindent
20602 Provides a function for determining whether one wide wide string is a plausible
20603 near misspelling of another wide wide string.
20605 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
20606 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
20607 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
20608 @cindex Wide_Wide_String splitter
20610 @noindent
20611 Useful wide wide string manipulation routines: given a set of separators, split
20612 a wide wide string wherever the separators appear, and provide direct access
20613 to the resulting slices. This package is instantiated from
20614 @code{GNAT.Array_Split}.
20616 @node Interfaces.C.Extensions (i-cexten.ads)
20617 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
20618 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
20620 @noindent
20621 This package contains additional C-related definitions, intended
20622 for use with either manually or automatically generated bindings
20623 to C libraries.
20625 @node Interfaces.C.Streams (i-cstrea.ads)
20626 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
20627 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
20628 @cindex  C streams, interfacing
20630 @noindent
20631 This package is a binding for the most commonly used operations
20632 on C streams.
20634 @node Interfaces.Packed_Decimal (i-pacdec.ads)
20635 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20636 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20637 @cindex  IBM Packed Format
20638 @cindex  Packed Decimal
20640 @noindent
20641 This package provides a set of routines for conversions to and
20642 from a packed decimal format compatible with that used on IBM
20643 mainframes.
20645 @node Interfaces.VxWorks (i-vxwork.ads)
20646 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20647 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20648 @cindex Interfacing to VxWorks
20649 @cindex VxWorks, interfacing
20651 @noindent
20652 This package provides a limited binding to the VxWorks API.
20653 In particular, it interfaces with the
20654 VxWorks hardware interrupt facilities.
20656 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
20657 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20658 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20659 @cindex Interfacing to VxWorks' I/O
20660 @cindex VxWorks, I/O interfacing
20661 @cindex VxWorks, Get_Immediate
20662 @cindex Get_Immediate, VxWorks
20664 @noindent
20665 This package provides a binding to the ioctl (IO/Control)
20666 function of VxWorks, defining a set of option values and
20667 function codes. A particular use of this package is
20668 to enable the use of Get_Immediate under VxWorks.
20670 @node System.Address_Image (s-addima.ads)
20671 @section @code{System.Address_Image} (@file{s-addima.ads})
20672 @cindex @code{System.Address_Image} (@file{s-addima.ads})
20673 @cindex Address image
20674 @cindex Image, of an address
20676 @noindent
20677 This function provides a useful debugging
20678 function that gives an (implementation dependent)
20679 string which identifies an address.
20681 @node System.Assertions (s-assert.ads)
20682 @section @code{System.Assertions} (@file{s-assert.ads})
20683 @cindex @code{System.Assertions} (@file{s-assert.ads})
20684 @cindex Assertions
20685 @cindex Assert_Failure, exception
20687 @noindent
20688 This package provides the declaration of the exception raised
20689 by an run-time assertion failure, as well as the routine that
20690 is used internally to raise this assertion.
20692 @node System.Atomic_Counters (s-atocou.ads)
20693 @section @code{System.Atomic_Counters} (@file{s-atocou.ads})
20694 @cindex @code{System.Atomic_Counters} (@file{s-atocou.ads})
20696 @noindent
20697 This package provides the declaration of an atomic counter type,
20698 together with efficient routines (using hardware
20699 synchronization primitives) for incrementing, decrementing,
20700 and testing of these counters. This package is implemented
20701 on most targets, including all Alpha, ia64, PowerPC, SPARC V9,
20702 x86, and x86_64 platforms.
20704 @node System.Memory (s-memory.ads)
20705 @section @code{System.Memory} (@file{s-memory.ads})
20706 @cindex @code{System.Memory} (@file{s-memory.ads})
20707 @cindex Memory allocation
20709 @noindent
20710 This package provides the interface to the low level routines used
20711 by the generated code for allocation and freeing storage for the
20712 default storage pool (analogous to the C routines malloc and free.
20713 It also provides a reallocation interface analogous to the C routine
20714 realloc. The body of this unit may be modified to provide alternative
20715 allocation mechanisms for the default pool, and in addition, direct
20716 calls to this unit may be made for low level allocation uses (for
20717 example see the body of @code{GNAT.Tables}).
20719 @node System.Multiprocessors (s-multip.ads)
20720 @section @code{System.Multiprocessors} (@file{s-multip.ads})
20721 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
20722 @cindex Multiprocessor interface
20723 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20724 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20725 technically an implementation-defined addition).
20727 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
20728 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20729 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20730 @cindex Multiprocessor interface
20731 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20732 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20733 technically an implementation-defined addition).
20735 @node System.Partition_Interface (s-parint.ads)
20736 @section @code{System.Partition_Interface} (@file{s-parint.ads})
20737 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
20738 @cindex Partition interfacing functions
20740 @noindent
20741 This package provides facilities for partition interfacing.  It
20742 is used primarily in a distribution context when using Annex E
20743 with @code{GLADE}.
20745 @node System.Pool_Global (s-pooglo.ads)
20746 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
20747 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
20748 @cindex Storage pool, global
20749 @cindex Global storage pool
20751 @noindent
20752 This package provides a storage pool that is equivalent to the default
20753 storage pool used for access types for which no pool is specifically
20754 declared. It uses malloc/free to allocate/free and does not attempt to
20755 do any automatic reclamation.
20757 @node System.Pool_Local (s-pooloc.ads)
20758 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
20759 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
20760 @cindex Storage pool, local
20761 @cindex Local storage pool
20763 @noindent
20764 This package provides a storage pool that is intended for use with locally
20765 defined access types. It uses malloc/free for allocate/free, and maintains
20766 a list of allocated blocks, so that all storage allocated for the pool can
20767 be freed automatically when the pool is finalized.
20769 @node System.Restrictions (s-restri.ads)
20770 @section @code{System.Restrictions} (@file{s-restri.ads})
20771 @cindex @code{System.Restrictions} (@file{s-restri.ads})
20772 @cindex Run-time restrictions access
20774 @noindent
20775 This package provides facilities for accessing at run time
20776 the status of restrictions specified at compile time for
20777 the partition. Information is available both with regard
20778 to actual restrictions specified, and with regard to
20779 compiler determined information on which restrictions
20780 are violated by one or more packages in the partition.
20782 @node System.Rident (s-rident.ads)
20783 @section @code{System.Rident} (@file{s-rident.ads})
20784 @cindex @code{System.Rident} (@file{s-rident.ads})
20785 @cindex Restrictions definitions
20787 @noindent
20788 This package provides definitions of the restrictions
20789 identifiers supported by GNAT, and also the format of
20790 the restrictions provided in package System.Restrictions.
20791 It is not normally necessary to @code{with} this generic package
20792 since the necessary instantiation is included in
20793 package System.Restrictions.
20795 @node System.Strings.Stream_Ops (s-ststop.ads)
20796 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20797 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20798 @cindex Stream operations
20799 @cindex String stream operations
20801 @noindent
20802 This package provides a set of stream subprograms for standard string types.
20803 It is intended primarily to support implicit use of such subprograms when
20804 stream attributes are applied to string types, but the subprograms in this
20805 package can be used directly by application programs.
20807 @node System.Unsigned_Types (s-unstyp.ads)
20808 @section @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20809 @cindex @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20811 @noindent
20812 This package contains definitions of standard unsigned types that
20813 correspond in size to the standard signed types declared in Standard,
20814 and (unlike the types in Interfaces) have corresponding names. It
20815 also contains some related definitions for other specialized types
20816 used by the compiler in connection with packed array types.
20818 @node System.Wch_Cnv (s-wchcnv.ads)
20819 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20820 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20821 @cindex Wide Character, Representation
20822 @cindex Wide String, Conversion
20823 @cindex Representation of wide characters
20825 @noindent
20826 This package provides routines for converting between
20827 wide and wide wide characters and a representation as a value of type
20828 @code{Standard.String}, using a specified wide character
20829 encoding method.  It uses definitions in
20830 package @code{System.Wch_Con}.
20832 @node System.Wch_Con (s-wchcon.ads)
20833 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
20834 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
20836 @noindent
20837 This package provides definitions and descriptions of
20838 the various methods used for encoding wide characters
20839 in ordinary strings.  These definitions are used by
20840 the package @code{System.Wch_Cnv}.
20842 @node Interfacing to Other Languages
20843 @chapter Interfacing to Other Languages
20844 @noindent
20845 The facilities in annex B of the Ada Reference Manual are fully
20846 implemented in GNAT, and in addition, a full interface to C++ is
20847 provided.
20849 @menu
20850 * Interfacing to C::
20851 * Interfacing to C++::
20852 * Interfacing to COBOL::
20853 * Interfacing to Fortran::
20854 * Interfacing to non-GNAT Ada code::
20855 @end menu
20857 @node Interfacing to C
20858 @section Interfacing to C
20860 @noindent
20861 Interfacing to C with GNAT can use one of two approaches:
20863 @itemize @bullet
20864 @item
20865 The types in the package @code{Interfaces.C} may be used.
20866 @item
20867 Standard Ada types may be used directly.  This may be less portable to
20868 other compilers, but will work on all GNAT compilers, which guarantee
20869 correspondence between the C and Ada types.
20870 @end itemize
20872 @noindent
20873 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
20874 effect, since this is the default.  The following table shows the
20875 correspondence between Ada scalar types and the corresponding C types.
20877 @table @code
20878 @item Integer
20879 @code{int}
20880 @item Short_Integer
20881 @code{short}
20882 @item Short_Short_Integer
20883 @code{signed char}
20884 @item Long_Integer
20885 @code{long}
20886 @item Long_Long_Integer
20887 @code{long long}
20888 @item Short_Float
20889 @code{float}
20890 @item Float
20891 @code{float}
20892 @item Long_Float
20893 @code{double}
20894 @item Long_Long_Float
20895 This is the longest floating-point type supported by the hardware.
20896 @end table
20898 @noindent
20899 Additionally, there are the following general correspondences between Ada
20900 and C types:
20901 @itemize @bullet
20902 @item
20903 Ada enumeration types map to C enumeration types directly if pragma
20904 @code{Convention C} is specified, which causes them to have int
20905 length.  Without pragma @code{Convention C}, Ada enumeration types map to
20906 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
20907 @code{int}, respectively) depending on the number of values passed.
20908 This is the only case in which pragma @code{Convention C} affects the
20909 representation of an Ada type.
20911 @item
20912 Ada access types map to C pointers, except for the case of pointers to
20913 unconstrained types in Ada, which have no direct C equivalent.
20915 @item
20916 Ada arrays map directly to C arrays.
20918 @item
20919 Ada records map directly to C structures.
20921 @item
20922 Packed Ada records map to C structures where all members are bit fields
20923 of the length corresponding to the @code{@var{type}'Size} value in Ada.
20924 @end itemize
20926 @node Interfacing to C++
20927 @section Interfacing to C++
20929 @noindent
20930 The interface to C++ makes use of the following pragmas, which are
20931 primarily intended to be constructed automatically using a binding generator
20932 tool, although it is possible to construct them by hand.
20934 Using these pragmas it is possible to achieve complete
20935 inter-operability between Ada tagged types and C++ class definitions.
20936 See @ref{Implementation Defined Pragmas}, for more details.
20938 @table @code
20939 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
20940 The argument denotes an entity in the current declarative region that is
20941 declared as a tagged or untagged record type. It indicates that the type
20942 corresponds to an externally declared C++ class type, and is to be laid
20943 out the same way that C++ would lay out the type.
20945 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
20946 for backward compatibility but its functionality is available
20947 using pragma @code{Import} with @code{Convention} = @code{CPP}.
20949 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
20950 This pragma identifies an imported function (imported in the usual way
20951 with pragma @code{Import}) as corresponding to a C++ constructor.
20952 @end table
20954 A few restrictions are placed on the use of the @code{Access} attribute
20955 in conjunction with subprograms subject to convention @code{CPP}: the
20956 attribute may be used neither on primitive operations of a tagged
20957 record type with convention @code{CPP}, imported or not, nor on
20958 subprograms imported with pragma @code{CPP_Constructor}.
20960 In addition, C++ exceptions are propagated and can be handled in an
20961 @code{others} choice of an exception handler. The corresponding Ada
20962 occurrence has no message, and the simple name of the exception identity
20963 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
20964 tasks works properly when such foreign exceptions are propagated.
20966 It is also possible to import a C++ exception using the following syntax:
20968 @smallexample @c ada
20969 LOCAL_NAME : exception;
20970 pragma Import (Cpp,
20971   [Entity =>] LOCAL_NAME,
20972   [External_Name =>] static_string_EXPRESSION);
20973 @end smallexample
20975 @noindent
20976 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
20977 cover a specific C++ exception in an exception handler.
20979 @node Interfacing to COBOL
20980 @section Interfacing to COBOL
20982 @noindent
20983 Interfacing to COBOL is achieved as described in section B.4 of
20984 the Ada Reference Manual.
20986 @node Interfacing to Fortran
20987 @section Interfacing to Fortran
20989 @noindent
20990 Interfacing to Fortran is achieved as described in section B.5 of the
20991 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
20992 multi-dimensional array causes the array to be stored in column-major
20993 order as required for convenient interface to Fortran.
20995 @node Interfacing to non-GNAT Ada code
20996 @section Interfacing to non-GNAT Ada code
20998 It is possible to specify the convention @code{Ada} in a pragma
20999 @code{Import} or pragma @code{Export}.  However this refers to
21000 the calling conventions used by GNAT, which may or may not be
21001 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
21002 compiler to allow interoperation.
21004 If arguments types are kept simple, and if the foreign compiler generally
21005 follows system calling conventions, then it may be possible to integrate
21006 files compiled by other Ada compilers, provided that the elaboration
21007 issues are adequately addressed (for example by eliminating the
21008 need for any load time elaboration).
21010 In particular, GNAT running on VMS is designed to
21011 be highly compatible with the DEC Ada 83 compiler, so this is one
21012 case in which it is possible to import foreign units of this type,
21013 provided that the data items passed are restricted to simple scalar
21014 values or simple record types without variants, or simple array
21015 types with fixed bounds.
21017 @node Specialized Needs Annexes
21018 @chapter Specialized Needs Annexes
21020 @noindent
21021 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
21022 required in all implementations.  However, as described in this chapter,
21023 GNAT implements all of these annexes:
21025 @table @asis
21026 @item Systems Programming (Annex C)
21027 The Systems Programming Annex is fully implemented.
21029 @item Real-Time Systems (Annex D)
21030 The Real-Time Systems Annex is fully implemented.
21032 @item Distributed Systems (Annex E)
21033 Stub generation is fully implemented in the GNAT compiler.  In addition,
21034 a complete compatible PCS is available as part of the GLADE system,
21035 a separate product.  When the two
21036 products are used in conjunction, this annex is fully implemented.
21038 @item Information Systems (Annex F)
21039 The Information Systems annex is fully implemented.
21041 @item Numerics (Annex G)
21042 The Numerics Annex is fully implemented.
21044 @item Safety and Security / High-Integrity Systems (Annex H)
21045 The Safety and Security Annex (termed the High-Integrity Systems Annex
21046 in Ada 2005) is fully implemented.
21047 @end table
21049 @node Implementation of Specific Ada Features
21050 @chapter Implementation of Specific Ada Features
21052 @noindent
21053 This chapter describes the GNAT implementation of several Ada language
21054 facilities.
21056 @menu
21057 * Machine Code Insertions::
21058 * GNAT Implementation of Tasking::
21059 * GNAT Implementation of Shared Passive Packages::
21060 * Code Generation for Array Aggregates::
21061 * The Size of Discriminated Records with Default Discriminants::
21062 * Strict Conformance to the Ada Reference Manual::
21063 @end menu
21065 @node Machine Code Insertions
21066 @section Machine Code Insertions
21067 @cindex Machine Code insertions
21069 @noindent
21070 Package @code{Machine_Code} provides machine code support as described
21071 in the Ada Reference Manual in two separate forms:
21072 @itemize @bullet
21073 @item
21074 Machine code statements, consisting of qualified expressions that
21075 fit the requirements of RM section 13.8.
21076 @item
21077 An intrinsic callable procedure, providing an alternative mechanism of
21078 including machine instructions in a subprogram.
21079 @end itemize
21081 @noindent
21082 The two features are similar, and both are closely related to the mechanism
21083 provided by the asm instruction in the GNU C compiler.  Full understanding
21084 and use of the facilities in this package requires understanding the asm
21085 instruction, see @ref{Extended Asm,,, gcc, Using the GNU Compiler
21086 Collection (GCC)}.
21088 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
21089 semantic restrictions and effects as described below.  Both are provided so
21090 that the procedure call can be used as a statement, and the function call
21091 can be used to form a code_statement.
21093 Consider this C @code{asm} instruction:
21094 @smallexample
21095    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
21096 @end smallexample
21098 @noindent
21099 The equivalent can be written for GNAT as:
21101 @smallexample @c ada
21102 Asm ("fsinx %1 %0",
21103      My_Float'Asm_Output ("=f", result),
21104      My_Float'Asm_Input  ("f",  angle));
21105 @end smallexample
21107 @noindent
21108 The first argument to @code{Asm} is the assembler template, and is
21109 identical to what is used in GNU C@.  This string must be a static
21110 expression.  The second argument is the output operand list.  It is
21111 either a single @code{Asm_Output} attribute reference, or a list of such
21112 references enclosed in parentheses (technically an array aggregate of
21113 such references).
21115 The @code{Asm_Output} attribute denotes a function that takes two
21116 parameters.  The first is a string, the second is the name of a variable
21117 of the type designated by the attribute prefix.  The first (string)
21118 argument is required to be a static expression and designates the
21119 constraint (@pxref{Constraints,,, gcc, Using the GNU Compiler
21120 Collection (GCC)})
21121 for the parameter (e.g.@: what kind of register is required).  The second
21122 argument is the variable to be written or updated with the
21123 result.  The possible values for constraint are the same as those used in
21124 the RTL, and are dependent on the configuration file used to build the
21125 GCC back end.  If there are no output operands, then this argument may
21126 either be omitted, or explicitly given as @code{No_Output_Operands}.
21127 No support is provided for GNU C's symbolic names for output parameters.
21129 The second argument of @code{@var{my_float}'Asm_Output} functions as
21130 though it were an @code{out} parameter, which is a little curious, but
21131 all names have the form of expressions, so there is no syntactic
21132 irregularity, even though normally functions would not be permitted
21133 @code{out} parameters.  The third argument is the list of input
21134 operands.  It is either a single @code{Asm_Input} attribute reference, or
21135 a list of such references enclosed in parentheses (technically an array
21136 aggregate of such references).
21138 The @code{Asm_Input} attribute denotes a function that takes two
21139 parameters.  The first is a string, the second is an expression of the
21140 type designated by the prefix.  The first (string) argument is required
21141 to be a static expression, and is the constraint for the parameter,
21142 (e.g.@: what kind of register is required).  The second argument is the
21143 value to be used as the input argument.  The possible values for the
21144 constraint are the same as those used in the RTL, and are dependent on
21145 the configuration file used to built the GCC back end.
21146 No support is provided for GNU C's symbolic names for input parameters.
21148 If there are no input operands, this argument may either be omitted, or
21149 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
21150 present in the above example, is a list of register names, called the
21151 @dfn{clobber} argument.  This argument, if given, must be a static string
21152 expression, and is a space or comma separated list of names of registers
21153 that must be considered destroyed as a result of the @code{Asm} call.  If
21154 this argument is the null string (the default value), then the code
21155 generator assumes that no additional registers are destroyed.
21156 In addition to registers, the special clobbers @code{memory} and
21157 @code{cc} as described in the GNU C docs are both supported.
21159 The fifth argument, not present in the above example, called the
21160 @dfn{volatile} argument, is by default @code{False}.  It can be set to
21161 the literal value @code{True} to indicate to the code generator that all
21162 optimizations with respect to the instruction specified should be
21163 suppressed, and in particular an instruction that has outputs
21164 will still be generated, even if none of the outputs are
21165 used.  @xref{Volatile,,,
21166 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
21167 Generally it is strongly advisable to use Volatile for any ASM statement
21168 that is missing either input or output operands or to avoid unwanted
21169 optimizations. A warning is generated if this advice is not followed.
21171 No support is provided for GNU C's @code{asm goto} feature.
21173 The @code{Asm} subprograms may be used in two ways.  First the procedure
21174 forms can be used anywhere a procedure call would be valid, and
21175 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
21176 be used to intersperse machine instructions with other Ada statements.
21177 Second, the function forms, which return a dummy value of the limited
21178 private type @code{Asm_Insn}, can be used in code statements, and indeed
21179 this is the only context where such calls are allowed.  Code statements
21180 appear as aggregates of the form:
21182 @smallexample @c ada
21183 Asm_Insn'(Asm (@dots{}));
21184 Asm_Insn'(Asm_Volatile (@dots{}));
21185 @end smallexample
21187 @noindent
21188 In accordance with RM rules, such code statements are allowed only
21189 within subprograms whose entire body consists of such statements.  It is
21190 not permissible to intermix such statements with other Ada statements.
21192 Typically the form using intrinsic procedure calls is more convenient
21193 and more flexible.  The code statement form is provided to meet the RM
21194 suggestion that such a facility should be made available.  The following
21195 is the exact syntax of the call to @code{Asm}. As usual, if named notation
21196 is used, the arguments may be given in arbitrary order, following the
21197 normal rules for use of positional and named arguments:
21199 @smallexample
21200 ASM_CALL ::= Asm (
21201                  [Template =>] static_string_EXPRESSION
21202                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
21203                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
21204                [,[Clobber  =>] static_string_EXPRESSION ]
21205                [,[Volatile =>] static_boolean_EXPRESSION] )
21207 OUTPUT_OPERAND_LIST ::=
21208   [PREFIX.]No_Output_Operands
21209 | OUTPUT_OPERAND_ATTRIBUTE
21210 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
21212 OUTPUT_OPERAND_ATTRIBUTE ::=
21213   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
21215 INPUT_OPERAND_LIST ::=
21216   [PREFIX.]No_Input_Operands
21217 | INPUT_OPERAND_ATTRIBUTE
21218 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
21220 INPUT_OPERAND_ATTRIBUTE ::=
21221   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
21222 @end smallexample
21224 @noindent
21225 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
21226 are declared in the package @code{Machine_Code} and must be referenced
21227 according to normal visibility rules. In particular if there is no
21228 @code{use} clause for this package, then appropriate package name
21229 qualification is required.
21231 @node GNAT Implementation of Tasking
21232 @section GNAT Implementation of Tasking
21234 @noindent
21235 This chapter outlines the basic GNAT approach to tasking (in particular,
21236 a multi-layered library for portability) and discusses issues related
21237 to compliance with the Real-Time Systems Annex.
21239 @menu
21240 * Mapping Ada Tasks onto the Underlying Kernel Threads::
21241 * Ensuring Compliance with the Real-Time Annex::
21242 @end menu
21244 @node Mapping Ada Tasks onto the Underlying Kernel Threads
21245 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
21247 @noindent
21248 GNAT's run-time support comprises two layers:
21250 @itemize @bullet
21251 @item GNARL (GNAT Run-time Layer)
21252 @item GNULL (GNAT Low-level Library)
21253 @end itemize
21255 @noindent
21256 In GNAT, Ada's tasking services rely on a platform and OS independent
21257 layer known as GNARL@.  This code is responsible for implementing the
21258 correct semantics of Ada's task creation, rendezvous, protected
21259 operations etc.
21261 GNARL decomposes Ada's tasking semantics into simpler lower level
21262 operations such as create a thread, set the priority of a thread,
21263 yield, create a lock, lock/unlock, etc.  The spec for these low-level
21264 operations constitutes GNULLI, the GNULL Interface.  This interface is
21265 directly inspired from the POSIX real-time API@.
21267 If the underlying executive or OS implements the POSIX standard
21268 faithfully, the GNULL Interface maps as is to the services offered by
21269 the underlying kernel.  Otherwise, some target dependent glue code maps
21270 the services offered by the underlying kernel to the semantics expected
21271 by GNARL@.
21273 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
21274 key point is that each Ada task is mapped on a thread in the underlying
21275 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
21277 In addition Ada task priorities map onto the underlying thread priorities.
21278 Mapping Ada tasks onto the underlying kernel threads has several advantages:
21280 @itemize @bullet
21281 @item
21282 The underlying scheduler is used to schedule the Ada tasks.  This
21283 makes Ada tasks as efficient as kernel threads from a scheduling
21284 standpoint.
21286 @item
21287 Interaction with code written in C containing threads is eased
21288 since at the lowest level Ada tasks and C threads map onto the same
21289 underlying kernel concept.
21291 @item
21292 When an Ada task is blocked during I/O the remaining Ada tasks are
21293 able to proceed.
21295 @item
21296 On multiprocessor systems Ada tasks can execute in parallel.
21297 @end itemize
21299 @noindent
21300 Some threads libraries offer a mechanism to fork a new process, with the
21301 child process duplicating the threads from the parent.
21302 GNAT does not
21303 support this functionality when the parent contains more than one task.
21304 @cindex Forking a new process
21306 @node Ensuring Compliance with the Real-Time Annex
21307 @subsection Ensuring Compliance with the Real-Time Annex
21308 @cindex Real-Time Systems Annex compliance
21310 @noindent
21311 Although mapping Ada tasks onto
21312 the underlying threads has significant advantages, it does create some
21313 complications when it comes to respecting the scheduling semantics
21314 specified in the real-time annex (Annex D).
21316 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
21317 scheduling policy states:
21319 @quotation
21320 @emph{When the active priority of a ready task that is not running
21321 changes, or the setting of its base priority takes effect, the
21322 task is removed from the ready queue for its old active priority
21323 and is added at the tail of the ready queue for its new active
21324 priority, except in the case where the active priority is lowered
21325 due to the loss of inherited priority, in which case the task is
21326 added at the head of the ready queue for its new active priority.}
21327 @end quotation
21329 @noindent
21330 While most kernels do put tasks at the end of the priority queue when
21331 a task changes its priority, (which respects the main
21332 FIFO_Within_Priorities requirement), almost none keep a thread at the
21333 beginning of its priority queue when its priority drops from the loss
21334 of inherited priority.
21336 As a result most vendors have provided incomplete Annex D implementations.
21338 The GNAT run-time, has a nice cooperative solution to this problem
21339 which ensures that accurate FIFO_Within_Priorities semantics are
21340 respected.
21342 The principle is as follows.  When an Ada task T is about to start
21343 running, it checks whether some other Ada task R with the same
21344 priority as T has been suspended due to the loss of priority
21345 inheritance.  If this is the case, T yields and is placed at the end of
21346 its priority queue.  When R arrives at the front of the queue it
21347 executes.
21349 Note that this simple scheme preserves the relative order of the tasks
21350 that were ready to execute in the priority queue where R has been
21351 placed at the end.
21353 @node GNAT Implementation of Shared Passive Packages
21354 @section GNAT Implementation of Shared Passive Packages
21355 @cindex Shared passive packages
21357 @noindent
21358 GNAT fully implements the pragma @code{Shared_Passive} for
21359 @cindex pragma @code{Shared_Passive}
21360 the purpose of designating shared passive packages.
21361 This allows the use of passive partitions in the
21362 context described in the Ada Reference Manual; i.e., for communication
21363 between separate partitions of a distributed application using the
21364 features in Annex E.
21365 @cindex Annex E
21366 @cindex Distribution Systems Annex
21368 However, the implementation approach used by GNAT provides for more
21369 extensive usage as follows:
21371 @table @emph
21372 @item Communication between separate programs
21374 This allows separate programs to access the data in passive
21375 partitions, using protected objects for synchronization where
21376 needed. The only requirement is that the two programs have a
21377 common shared file system. It is even possible for programs
21378 running on different machines with different architectures
21379 (e.g.@: different endianness) to communicate via the data in
21380 a passive partition.
21382 @item Persistence between program runs
21384 The data in a passive package can persist from one run of a
21385 program to another, so that a later program sees the final
21386 values stored by a previous run of the same program.
21388 @end table
21390 @noindent
21391 The implementation approach used is to store the data in files. A
21392 separate stream file is created for each object in the package, and
21393 an access to an object causes the corresponding file to be read or
21394 written.
21396 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
21397 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
21398 set to the directory to be used for these files.
21399 The files in this directory
21400 have names that correspond to their fully qualified names. For
21401 example, if we have the package
21403 @smallexample @c ada
21404 package X is
21405   pragma Shared_Passive (X);
21406   Y : Integer;
21407   Z : Float;
21408 end X;
21409 @end smallexample
21411 @noindent
21412 and the environment variable is set to @code{/stemp/}, then the files created
21413 will have the names:
21415 @smallexample
21416 /stemp/x.y
21417 /stemp/x.z
21418 @end smallexample
21420 @noindent
21421 These files are created when a value is initially written to the object, and
21422 the files are retained until manually deleted. This provides the persistence
21423 semantics. If no file exists, it means that no partition has assigned a value
21424 to the variable; in this case the initial value declared in the package
21425 will be used. This model ensures that there are no issues in synchronizing
21426 the elaboration process, since elaboration of passive packages elaborates the
21427 initial values, but does not create the files.
21429 The files are written using normal @code{Stream_IO} access.
21430 If you want to be able
21431 to communicate between programs or partitions running on different
21432 architectures, then you should use the XDR versions of the stream attribute
21433 routines, since these are architecture independent.
21435 If active synchronization is required for access to the variables in the
21436 shared passive package, then as described in the Ada Reference Manual, the
21437 package may contain protected objects used for this purpose. In this case
21438 a lock file (whose name is @file{___lock} (three underscores)
21439 is created in the shared memory directory.
21440 @cindex @file{___lock} file (for shared passive packages)
21441 This is used to provide the required locking
21442 semantics for proper protected object synchronization.
21444 As of January 2003, GNAT supports shared passive packages on all platforms
21445 except for OpenVMS.
21447 @node Code Generation for Array Aggregates
21448 @section Code Generation for Array Aggregates
21450 @menu
21451 * Static constant aggregates with static bounds::
21452 * Constant aggregates with unconstrained nominal types::
21453 * Aggregates with static bounds::
21454 * Aggregates with non-static bounds::
21455 * Aggregates in assignment statements::
21456 @end menu
21458 @noindent
21459 Aggregates have a rich syntax and allow the user to specify the values of
21460 complex data structures by means of a single construct.  As a result, the
21461 code generated for aggregates can be quite complex and involve loops, case
21462 statements and multiple assignments.  In the simplest cases, however, the
21463 compiler will recognize aggregates whose components and constraints are
21464 fully static, and in those cases the compiler will generate little or no
21465 executable code.  The following is an outline of the code that GNAT generates
21466 for various aggregate constructs.  For further details, you will find it
21467 useful to examine the output produced by the -gnatG flag to see the expanded
21468 source that is input to the code generator.  You may also want to examine
21469 the assembly code generated at various levels of optimization.
21471 The code generated for aggregates depends on the context, the component values,
21472 and the type.  In the context of an object declaration the code generated is
21473 generally simpler than in the case of an assignment.  As a general rule, static
21474 component values and static subtypes also lead to simpler code.
21476 @node Static constant aggregates with static bounds
21477 @subsection Static constant aggregates with static bounds
21479 @noindent
21480 For the declarations:
21481 @smallexample @c ada
21482     type One_Dim is array (1..10) of integer;
21483     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
21484 @end smallexample
21486 @noindent
21487 GNAT generates no executable code: the constant ar0 is placed in static memory.
21488 The same is true for constant aggregates with named associations:
21490 @smallexample @c ada
21491     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
21492     Cr3 : constant One_Dim := (others => 7777);
21493 @end smallexample
21495 @noindent
21496 The same is true for multidimensional constant arrays such as:
21498 @smallexample @c ada
21499     type two_dim is array (1..3, 1..3) of integer;
21500     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
21501 @end smallexample
21503 @noindent
21504 The same is true for arrays of one-dimensional arrays: the following are
21505 static:
21507 @smallexample @c ada
21508 type ar1b  is array (1..3) of boolean;
21509 type ar_ar is array (1..3) of ar1b;
21510 None  : constant ar1b := (others => false);     --  fully static
21511 None2 : constant ar_ar := (1..3 => None);       --  fully static
21512 @end smallexample
21514 @noindent
21515 However, for multidimensional aggregates with named associations, GNAT will
21516 generate assignments and loops, even if all associations are static.  The
21517 following two declarations generate a loop for the first dimension, and
21518 individual component assignments for the second dimension:
21520 @smallexample @c ada
21521 Zero1: constant two_dim := (1..3 => (1..3 => 0));
21522 Zero2: constant two_dim := (others => (others => 0));
21523 @end smallexample
21525 @node Constant aggregates with unconstrained nominal types
21526 @subsection Constant aggregates with unconstrained nominal types
21528 @noindent
21529 In such cases the aggregate itself establishes the subtype, so that
21530 associations with @code{others} cannot be used.  GNAT determines the
21531 bounds for the actual subtype of the aggregate, and allocates the
21532 aggregate statically as well.  No code is generated for the following:
21534 @smallexample @c ada
21535     type One_Unc is array (natural range <>) of integer;
21536     Cr_Unc : constant One_Unc := (12,24,36);
21537 @end smallexample
21539 @node Aggregates with static bounds
21540 @subsection Aggregates with static bounds
21542 @noindent
21543 In all previous examples the aggregate was the initial (and immutable) value
21544 of a constant.  If the aggregate initializes a variable, then code is generated
21545 for it as a combination of individual assignments and loops over the target
21546 object.  The declarations
21548 @smallexample @c ada
21549        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
21550        Cr_Var2 : One_Dim := (others > -1);
21551 @end smallexample
21553 @noindent
21554 generate the equivalent of
21556 @smallexample @c ada
21557        Cr_Var1 (1) := 2;
21558        Cr_Var1 (2) := 3;
21559        Cr_Var1 (3) := 5;
21560        Cr_Var1 (4) := 11;
21562        for I in Cr_Var2'range loop
21563           Cr_Var2 (I) := -1;
21564        end loop;
21565 @end smallexample
21567 @node Aggregates with non-static bounds
21568 @subsection Aggregates with non-static bounds
21570 @noindent
21571 If the bounds of the aggregate are not statically compatible with the bounds
21572 of the nominal subtype  of the target, then constraint checks have to be
21573 generated on the bounds.  For a multidimensional array, constraint checks may
21574 have to be applied to sub-arrays individually, if they do not have statically
21575 compatible subtypes.
21577 @node Aggregates in assignment statements
21578 @subsection Aggregates in assignment statements
21580 @noindent
21581 In general, aggregate assignment requires the construction of a temporary,
21582 and a copy from the temporary to the target of the assignment.  This is because
21583 it is not always possible to convert the assignment into a series of individual
21584 component assignments.  For example, consider the simple case:
21586 @smallexample @c ada
21587         A := (A(2), A(1));
21588 @end smallexample
21590 @noindent
21591 This cannot be converted into:
21593 @smallexample @c ada
21594         A(1) := A(2);
21595         A(2) := A(1);
21596 @end smallexample
21598 @noindent
21599 So the aggregate has to be built first in a separate location, and then
21600 copied into the target.  GNAT recognizes simple cases where this intermediate
21601 step is not required, and the assignments can be performed in place, directly
21602 into the target.  The following sufficient criteria are applied:
21604 @itemize @bullet
21605 @item
21606 The bounds of the aggregate are static, and the associations are static.
21607 @item
21608 The components of the aggregate are static constants, names of
21609 simple variables that are not renamings, or expressions not involving
21610 indexed components whose operands obey these rules.
21611 @end itemize
21613 @noindent
21614 If any of these conditions are violated, the aggregate will be built in
21615 a temporary (created either by the front-end or the code generator) and then
21616 that temporary will be copied onto the target.
21618 @node The Size of Discriminated Records with Default Discriminants
21619 @section The Size of Discriminated Records with Default Discriminants
21621 @noindent
21622 If a discriminated type @code{T} has discriminants with default values, it is
21623 possible to declare an object of this type without providing an explicit
21624 constraint:
21626 @smallexample @c ada
21627 @group
21628 type Size is range 1..100;
21630 type Rec (D : Size := 15) is record
21631    Name : String (1..D);
21632 end T;
21634 Word : Rec;
21635 @end group
21636 @end smallexample
21638 @noindent
21639 Such an object is said to be @emph{unconstrained}.
21640 The discriminant of the object
21641 can be modified by a full assignment to the object, as long as it preserves the
21642 relation between the value of the discriminant, and the value of the components
21643 that depend on it:
21645 @smallexample @c ada
21646 @group
21647 Word := (3, "yes");
21649 Word := (5, "maybe");
21651 Word := (5, "no"); -- raises Constraint_Error
21652 @end group
21653 @end smallexample
21655 @noindent
21656 In order to support this behavior efficiently, an unconstrained object is
21657 given the maximum size that any value of the type requires. In the case
21658 above, @code{Word} has storage for the discriminant and for
21659 a @code{String} of length 100.
21660 It is important to note that unconstrained objects do not require dynamic
21661 allocation. It would be an improper implementation to place on the heap those
21662 components whose size depends on discriminants. (This improper implementation
21663 was used by some Ada83 compilers, where the @code{Name} component above
21664 would have
21665 been stored as a pointer to a dynamic string). Following the principle that
21666 dynamic storage management should never be introduced implicitly,
21667 an Ada compiler should reserve the full size for an unconstrained declared
21668 object, and place it on the stack.
21670 This maximum size approach
21671 has been a source of surprise to some users, who expect the default
21672 values of the discriminants to determine the size reserved for an
21673 unconstrained object: ``If the default is 15, why should the object occupy
21674 a larger size?''
21675 The answer, of course, is that the discriminant may be later modified,
21676 and its full range of values must be taken into account. This is why the
21677 declaration:
21679 @smallexample
21680 @group
21681 type Rec (D : Positive := 15) is record
21682    Name : String (1..D);
21683 end record;
21685 Too_Large : Rec;
21686 @end group
21687 @end smallexample
21689 @noindent
21690 is flagged by the compiler with a warning:
21691 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
21692 because the required size includes @code{Positive'Last}
21693 bytes. As the first example indicates, the proper approach is to declare an
21694 index type of ``reasonable'' range so that unconstrained objects are not too
21695 large.
21697 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
21698 created in the heap by means of an allocator, then it is @emph{not}
21699 unconstrained:
21700 it is constrained by the default values of the discriminants, and those values
21701 cannot be modified by full assignment. This is because in the presence of
21702 aliasing all views of the object (which may be manipulated by different tasks,
21703 say) must be consistent, so it is imperative that the object, once created,
21704 remain invariant.
21706 @node Strict Conformance to the Ada Reference Manual
21707 @section Strict Conformance to the Ada Reference Manual
21709 @noindent
21710 The dynamic semantics defined by the Ada Reference Manual impose a set of
21711 run-time checks to be generated. By default, the GNAT compiler will insert many
21712 run-time checks into the compiled code, including most of those required by the
21713 Ada Reference Manual. However, there are three checks that are not enabled
21714 in the default mode for efficiency reasons: arithmetic overflow checking for
21715 integer operations (including division by zero), checks for access before
21716 elaboration on subprogram calls, and stack overflow checking (most operating
21717 systems do not perform this check by default).
21719 Strict conformance to the Ada Reference Manual can be achieved by adding
21720 three compiler options for overflow checking for integer operations
21721 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
21722 calls and generic instantiations (@option{-gnatE}), and stack overflow
21723 checking (@option{-fstack-check}).
21725 Note that the result of a floating point arithmetic operation in overflow and
21726 invalid situations, when the @code{Machine_Overflows} attribute of the result
21727 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
21728 case for machines compliant with the IEEE floating-point standard, but on
21729 machines that are not fully compliant with this standard, such as Alpha, the
21730 @option{-mieee} compiler flag must be used for achieving IEEE confirming
21731 behavior (although at the cost of a significant performance penalty), so
21732 infinite and NaN values are properly generated.
21735 @node Implementation of Ada 2012 Features
21736 @chapter Implementation of Ada 2012 Features
21737 @cindex Ada 2012 implementation status
21739 This chapter contains a complete list of Ada 2012 features that have been
21740 implemented as of GNAT version 6.4. Generally, these features are only
21741 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
21742 @cindex @option{-gnat12} option
21743 or if the configuration pragma @code{Ada_2012} is used.
21744 @cindex pragma @code{Ada_2012}
21745 @cindex configuration pragma @code{Ada_2012}
21746 @cindex @code{Ada_2012} configuration pragma
21747 However, new pragmas, attributes, and restrictions are
21748 unconditionally available, since the Ada 95 standard allows the addition of
21749 new pragmas, attributes, and restrictions (there are exceptions, which are
21750 documented in the individual descriptions), and also certain packages
21751 were made available in earlier versions of Ada.
21753 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
21754 This date shows the implementation date of the feature. Any wavefront
21755 subsequent to this date will contain the indicated feature, as will any
21756 subsequent releases. A date of 0000-00-00 means that GNAT has always
21757 implemented the feature, or implemented it as soon as it appeared as a
21758 binding interpretation.
21760 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
21761 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
21762 The features are ordered based on the relevant sections of the Ada
21763 Reference Manual (``RM'').  When a given AI relates to multiple points
21764 in the RM, the earliest is used.
21766 A complete description of the AIs may be found in
21767 @url{www.ada-auth.org/ai05-summary.html}.
21769 @itemize @bullet
21771 @item
21772 @emph{AI-0176 Quantified expressions (2010-09-29)}
21773 @cindex AI-0176 (Ada 2012 feature)
21775 @noindent
21776   Both universally and existentially quantified expressions are implemented.
21777   They use the new syntax for iterators proposed in AI05-139-2, as well as
21778   the standard Ada loop syntax.
21780 @noindent
21781   RM References:  1.01.04 (12)   2.09 (2/2)   4.04 (7)   4.05.09 (0)
21783 @item
21784 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
21785 @cindex AI-0079 (Ada 2012 feature)
21787 @noindent
21788   Wide characters in the unicode category @i{other_format} are now allowed in
21789   source programs between tokens, but not within a token such as an identifier.
21791 @noindent
21792   RM References:  2.01 (4/2)   2.02 (7)
21794 @item
21795 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
21796 @cindex AI-0091 (Ada 2012 feature)
21798 @noindent
21799   Wide characters in the unicode category @i{other_format} are not permitted
21800   within  an identifier, since this can be a security problem. The error
21801   message for this case has been improved to be more specific, but GNAT has
21802   never allowed such characters to appear in identifiers.
21804 @noindent
21805   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)
21807 @item
21808 @emph{AI-0100 Placement of pragmas  (2010-07-01)}
21809 @cindex AI-0100 (Ada 2012 feature)
21811 @noindent
21812   This AI is an earlier version of AI-163. It simplifies the rules
21813   for legal placement of pragmas. In the case of lists that allow pragmas, if
21814   the list may have no elements, then the list may consist solely of pragmas.
21816 @noindent
21817   RM References:  2.08 (7)
21819 @item
21820 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
21821 @cindex AI-0163 (Ada 2012 feature)
21823 @noindent
21824   A statement sequence may be composed entirely of pragmas. It is no longer
21825   necessary to add a dummy @code{null} statement to make the sequence legal.
21827 @noindent
21828   RM References:  2.08 (7)   2.08 (16)
21831 @item
21832 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
21833 @cindex AI-0080 (Ada 2012 feature)
21835 @noindent
21836   This is an editorial change only, described as non-testable in the AI.
21838 @noindent
21839   RM References:  3.01 (7)
21842 @item
21843 @emph{AI-0183 Aspect specifications (2010-08-16)}
21844 @cindex AI-0183 (Ada 2012 feature)
21846 @noindent
21847   Aspect specifications have been fully implemented except for pre and post-
21848   conditions, and type invariants, which have their own separate AI's. All
21849   forms of declarations listed in the AI are supported. The following is a
21850   list of the aspects supported (with GNAT implementation aspects marked)
21852 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
21853 @item @code{Ada_2005} @tab                      -- GNAT
21854 @item @code{Ada_2012} @tab                      -- GNAT
21855 @item @code{Address} @tab
21856 @item @code{Alignment} @tab
21857 @item @code{Atomic} @tab
21858 @item @code{Atomic_Components} @tab
21859 @item @code{Bit_Order} @tab
21860 @item @code{Component_Size} @tab
21861 @item @code{Contract_Cases} @tab                -- GNAT
21862 @item @code{Discard_Names} @tab
21863 @item @code{External_Tag} @tab
21864 @item @code{Favor_Top_Level} @tab               -- GNAT
21865 @item @code{Inline} @tab
21866 @item @code{Inline_Always} @tab                 -- GNAT
21867 @item @code{Invariant} @tab                     -- GNAT
21868 @item @code{Machine_Radix} @tab
21869 @item @code{No_Return} @tab
21870 @item @code{Object_Size} @tab                   -- GNAT
21871 @item @code{Pack} @tab
21872 @item @code{Persistent_BSS} @tab                -- GNAT
21873 @item @code{Post} @tab
21874 @item @code{Pre} @tab
21875 @item @code{Predicate} @tab
21876 @item @code{Preelaborable_Initialization} @tab
21877 @item @code{Pure_Function} @tab                 -- GNAT
21878 @item @code{Remote_Access_Type} @tab            -- GNAT
21879 @item @code{Shared} @tab                        -- GNAT
21880 @item @code{Size} @tab
21881 @item @code{Storage_Pool} @tab
21882 @item @code{Storage_Size} @tab
21883 @item @code{Stream_Size} @tab
21884 @item @code{Suppress} @tab
21885 @item @code{Suppress_Debug_Info} @tab           -- GNAT
21886 @item @code{Test_Case} @tab                     -- GNAT
21887 @item @code{Thread_Local_Storage} @tab          -- GNAT
21888 @item @code{Type_Invariant} @tab
21889 @item @code{Unchecked_Union} @tab
21890 @item @code{Universal_Aliasing} @tab            -- GNAT
21891 @item @code{Unmodified} @tab                    -- GNAT
21892 @item @code{Unreferenced} @tab                  -- GNAT
21893 @item @code{Unreferenced_Objects} @tab          -- GNAT
21894 @item @code{Unsuppress} @tab
21895 @item @code{Value_Size} @tab                    -- GNAT
21896 @item @code{Volatile} @tab
21897 @item @code{Volatile_Components}
21898 @item @code{Warnings} @tab                      -- GNAT
21899 @end multitable
21901 @noindent
21902   Note that for aspects with an expression, e.g. @code{Size}, the expression is
21903   treated like a default expression (visibility is analyzed at the point of
21904   occurrence of the aspect, but evaluation of the expression occurs at the
21905   freeze point of the entity involved).
21907 @noindent
21908   RM References:  3.02.01 (3)   3.02.02 (2)   3.03.01 (2/2)   3.08 (6)
21909   3.09.03 (1.1/2)   6.01 (2/2)   6.07 (2/2)   9.05.02 (2/2)   7.01 (3)   7.03
21910   (2)   7.03 (3)   9.01 (2/2)   9.01 (3/2)   9.04 (2/2)   9.04 (3/2)
21911   9.05.02 (2/2)   11.01 (2)   12.01 (3)   12.03 (2/2)   12.04 (2/2)   12.05 (2)
21912   12.06 (2.1/2)   12.06 (2.2/2)   12.07 (2)   13.01 (0.1/2)   13.03 (5/1)
21913   13.03.01 (0)
21916 @item
21917 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
21918 @cindex AI-0128 (Ada 2012 feature)
21920 @noindent
21921   If an equality operator ("=") is declared for a type, then the implicitly
21922   declared inequality operator ("/=") is a primitive operation of the type.
21923   This is the only reasonable interpretation, and is the one always implemented
21924   by GNAT, but the RM was not entirely clear in making this point.
21926 @noindent
21927   RM References:  3.02.03 (6)   6.06 (6)
21929 @item
21930 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
21931 @cindex AI-0003 (Ada 2012 feature)
21933 @noindent
21934    In Ada 2012, a qualified expression is considered to be syntactically a name,
21935    meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
21936    useful in disambiguating some cases of overloading.
21938 @noindent
21939   RM References:  3.03 (11)   3.03 (21)   4.01 (2)   4.04 (7)   4.07 (3)
21940   5.04 (7)
21942 @item
21943 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
21944 @cindex AI-0120 (Ada 2012 feature)
21946 @noindent
21947   This is an RM editorial change only. The section that lists objects that are
21948   constant failed to include the current instance of a protected object
21949   within a protected function. This has always been treated as a constant
21950   in GNAT.
21952 @noindent
21953   RM References:  3.03 (21)
21955 @item
21956 @emph{AI-0008 General access to constrained objects (0000-00-00)}
21957 @cindex AI-0008 (Ada 2012 feature)
21959 @noindent
21960   The wording in the RM implied that if you have a general access to a
21961   constrained object, it could be used to modify the discriminants. This was
21962   obviously not intended. @code{Constraint_Error} should be raised, and GNAT
21963   has always done so in this situation.
21965 @noindent
21966   RM References:  3.03 (23)   3.10.02 (26/2)   4.01 (9)   6.04.01 (17)   8.05.01 (5/2)
21969 @item
21970 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
21971 @cindex AI-0093 (Ada 2012 feature)
21973 @noindent
21974   This is an editorial change only, to make more widespread use of the Ada 2012
21975   ``immutably limited''.
21977 @noindent
21978   RM References:  3.03 (23.4/3)
21982 @item
21983 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
21984 @cindex AI-0096 (Ada 2012 feature)
21986 @noindent
21987   In general it is illegal for a type derived from a formal limited type to be
21988   nonlimited.  This AI makes an exception to this rule: derivation is legal
21989   if it appears in the private part of the generic, and the formal type is not
21990   tagged. If the type is tagged, the legality check must be applied to the
21991   private part of the package.
21993 @noindent
21994   RM References:  3.04 (5.1/2)   6.02 (7)
21997 @item
21998 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
21999 @cindex AI-0181 (Ada 2012 feature)
22001 @noindent
22002   From Ada 2005 on, soft hyphen is considered a non-graphic character, which
22003   means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
22004   @code{Image} and @code{Value} attributes for the character types. Strictly
22005   speaking this is an inconsistency with Ada 95, but in practice the use of
22006   these attributes is so obscure that it will not cause problems.
22008 @noindent
22009   RM References:  3.05.02 (2/2)   A.01 (35/2)   A.03.03 (21)
22012 @item
22013 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
22014 @cindex AI-0182 (Ada 2012 feature)
22016 @noindent
22017   This AI allows @code{Character'Value} to accept the string @code{'?'} where
22018   @code{?} is any character including non-graphic control characters. GNAT has
22019   always accepted such strings. It also allows strings such as
22020   @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
22021   permission and raises @code{Constraint_Error}, as is certainly still
22022   permitted.
22024 @noindent
22025   RM References:  3.05 (56/2)
22028 @item
22029 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
22030 @cindex AI-0214 (Ada 2012 feature)
22032 @noindent
22033   Ada 2012 relaxes the restriction that forbids discriminants of tagged types
22034   to have default expressions by allowing them when the type is limited. It
22035   is often useful to define a default value for a discriminant even though
22036   it can't be changed by assignment.
22038 @noindent
22039   RM References:  3.07 (9.1/2)   3.07.02 (3)
22042 @item
22043 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
22044 @cindex AI-0102 (Ada 2012 feature)
22046 @noindent
22047   It is illegal to assign an anonymous access constant to an anonymous access
22048   variable. The RM did not have a clear rule to prevent this, but GNAT has
22049   always generated an error for this usage.
22051 @noindent
22052   RM References:  3.07 (16)   3.07.01 (9)   6.04.01 (6)   8.06 (27/2)
22055 @item
22056 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
22057 @cindex AI-0158 (Ada 2012 feature)
22059 @noindent
22060   This AI extends the syntax of membership tests to simplify complex conditions
22061   that can be expressed as membership in a subset of values of any type. It
22062   introduces syntax for a list of expressions that may be used in loop contexts
22063   as well.
22065 @noindent
22066   RM References:  3.08.01 (5)   4.04 (3)   4.05.02 (3)   4.05.02 (5)   4.05.02 (27)
22069 @item
22070 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
22071 @cindex AI-0173 (Ada 2012 feature)
22073 @noindent
22074   The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
22075   with the tag of an abstract type, and @code{False} otherwise.
22077 @noindent
22078   RM References:  3.09 (7.4/2)   3.09 (12.4/2)
22082 @item
22083 @emph{AI-0076 function with controlling result (0000-00-00)}
22084 @cindex AI-0076 (Ada 2012 feature)
22086 @noindent
22087   This is an editorial change only. The RM defines calls with controlling
22088   results, but uses the term ``function with controlling result'' without an
22089   explicit definition.
22091 @noindent
22092   RM References:  3.09.02 (2/2)
22095 @item
22096 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
22097 @cindex AI-0126 (Ada 2012 feature)
22099 @noindent
22100   This AI clarifies dispatching rules, and simply confirms that dispatching
22101   executes the operation of the parent type when there is no explicitly or
22102   implicitly declared operation for the descendant type. This has always been
22103   the case in all versions of GNAT.
22105 @noindent
22106   RM References:  3.09.02 (20/2)   3.09.02 (20.1/2)   3.09.02 (20.2/2)
22109 @item
22110 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
22111 @cindex AI-0097 (Ada 2012 feature)
22113 @noindent
22114   The RM as written implied that in some cases it was possible to create an
22115   object of an abstract type, by having an abstract extension inherit a non-
22116   abstract constructor from its parent type. This mistake has been corrected
22117   in GNAT and in the RM, and this construct is now illegal.
22119 @noindent
22120   RM References:  3.09.03 (4/2)
22123 @item
22124 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
22125 @cindex AI-0203 (Ada 2012 feature)
22127 @noindent
22128   A return_subtype_indication cannot denote an abstract subtype. GNAT has never
22129   permitted such usage.
22131 @noindent
22132   RM References:  3.09.03 (8/3)
22135 @item
22136 @emph{AI-0198 Inheriting abstract operators  (0000-00-00)}
22137 @cindex AI-0198 (Ada 2012 feature)
22139 @noindent
22140   This AI resolves a conflict between two rules involving inherited abstract
22141   operations and predefined operators. If a derived numeric type inherits
22142   an abstract operator, it overrides the predefined one. This interpretation
22143   was always the one implemented in GNAT.
22145 @noindent
22146   RM References:  3.09.03 (4/3)
22148 @item
22149 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
22150 @cindex AI-0073 (Ada 2012 feature)
22152 @noindent
22153   This AI covers a number of issues regarding returning abstract types. In
22154   particular generic functions cannot have abstract result types or access
22155   result types designated an abstract type. There are some other cases which
22156   are detailed in the AI. Note that this binding interpretation has not been
22157   retrofitted to operate before Ada 2012 mode, since it caused a significant
22158   number of regressions.
22160 @noindent
22161   RM References:  3.09.03 (8)   3.09.03 (10)   6.05 (8/2)
22164 @item
22165 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
22166 @cindex AI-0070 (Ada 2012 feature)
22168 @noindent
22169   This is an editorial change only, there are no testable consequences short of
22170   checking for the absence of generated code for an interface declaration.
22172 @noindent
22173   RM References:  3.09.04 (18/2)
22176 @item
22177 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
22178 @cindex AI-0208 (Ada 2012 feature)
22180 @noindent
22181   The wording in the Ada 2005 RM concerning characteristics of incomplete views
22182   was incorrect and implied that some programs intended to be legal were now
22183   illegal. GNAT had never considered such programs illegal, so it has always
22184   implemented the intent of this AI.
22186 @noindent
22187   RM References:  3.10.01 (2.4/2)   3.10.01 (2.6/2)
22190 @item
22191 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
22192 @cindex AI-0162 (Ada 2012 feature)
22194 @noindent
22195   Incomplete types are made more useful by allowing them to be completed by
22196   private types and private extensions.
22198 @noindent
22199   RM References:  3.10.01 (2.5/2)   3.10.01 (2.6/2)   3.10.01 (3)   3.10.01 (4/2)
22203 @item
22204 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
22205 @cindex AI-0098 (Ada 2012 feature)
22207 @noindent
22208   An unintentional omission in the RM implied some inconsistent restrictions on
22209   the use of anonymous access to subprogram values. These restrictions were not
22210   intentional, and have never been enforced by GNAT.
22212 @noindent
22213   RM References:  3.10.01 (6)   3.10.01 (9.2/2)
22216 @item
22217 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
22218 @cindex AI-0199 (Ada 2012 feature)
22220 @noindent
22221   A choice list in a record aggregate can include several components of
22222   (distinct) anonymous access types as long as they have matching designated
22223   subtypes.
22225 @noindent
22226   RM References:  4.03.01 (16)
22229 @item
22230 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
22231 @cindex AI-0220 (Ada 2012 feature)
22233 @noindent
22234   This AI addresses a wording problem in the RM that appears to permit some
22235   complex cases of aggregates with non-static discriminants. GNAT has always
22236   implemented the intended semantics.
22238 @noindent
22239   RM References:  4.03.01 (17)
22241 @item
22242 @emph{AI-0147 Conditional expressions (2009-03-29)}
22243 @cindex AI-0147 (Ada 2012 feature)
22245 @noindent
22246   Conditional expressions are permitted. The form of such an expression is:
22248 @smallexample
22249     (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
22250 @end smallexample
22252   The parentheses can be omitted in contexts where parentheses are present
22253   anyway, such as subprogram arguments and pragma arguments. If the @b{else}
22254   clause is omitted, @b{else True} is assumed;
22255   thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
22256   @emph{(A implies B)} in standard logic.
22258 @noindent
22259   RM References:  4.03.03 (15)   4.04 (1)   4.04 (7)   4.05.07 (0)   4.07 (2)
22260   4.07 (3)   4.09 (12)   4.09 (33)   5.03 (3)   5.03 (4)   7.05 (2.1/2)
22263 @item
22264 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
22265 @cindex AI-0037 (Ada 2012 feature)
22267 @noindent
22268   This AI confirms that an association of the form @code{Indx => <>} in an
22269   array aggregate must raise @code{Constraint_Error} if @code{Indx}
22270   is out of range. The RM specified a range check on other associations, but
22271   not when the value of the association was defaulted. GNAT has always inserted
22272   a constraint check on the index value.
22274 @noindent
22275   RM References:  4.03.03 (29)
22278 @item
22279 @emph{AI-0123 Composability of equality (2010-04-13)}
22280 @cindex AI-0123 (Ada 2012 feature)
22282 @noindent
22283   Equality of untagged record composes, so that the predefined equality for a
22284   composite type that includes a component of some untagged record type
22285   @code{R} uses the equality operation of @code{R} (which may be user-defined
22286   or predefined). This makes the behavior of untagged records identical to that
22287   of tagged types in this respect.
22289   This change is an incompatibility with previous versions of Ada, but it
22290   corrects a non-uniformity that was often a source of confusion. Analysis of
22291   a large number of industrial programs indicates that in those rare cases
22292   where a composite type had an untagged record component with a user-defined
22293   equality, either there was no use of the composite equality, or else the code
22294   expected the same composability as for tagged types, and thus had a bug that
22295   would be fixed by this change.
22297 @noindent
22298   RM References:  4.05.02 (9.7/2)   4.05.02 (14)   4.05.02 (15)   4.05.02 (24)
22299   8.05.04 (8)
22302 @item
22303 @emph{AI-0088 The value of exponentiation (0000-00-00)}
22304 @cindex AI-0088 (Ada 2012 feature)
22306 @noindent
22307   This AI clarifies the equivalence rule given for the dynamic semantics of
22308   exponentiation: the value of the operation can be obtained by repeated
22309   multiplication, but the operation can be implemented otherwise (for example
22310   using the familiar divide-by-two-and-square algorithm, even if this is less
22311   accurate), and does not imply repeated reads of a volatile base.
22313 @noindent
22314   RM References:  4.05.06 (11)
22316 @item
22317 @emph{AI-0188 Case expressions (2010-01-09)}
22318 @cindex AI-0188 (Ada 2012 feature)
22320 @noindent
22321   Case expressions are permitted. This allows use of constructs such as:
22322 @smallexample
22323   X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
22324 @end smallexample
22326 @noindent
22327   RM References:  4.05.07 (0)   4.05.08 (0)   4.09 (12)   4.09 (33)
22329 @item
22330 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
22331 @cindex AI-0104 (Ada 2012 feature)
22333 @noindent
22334   The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
22335   @code{Constraint_Error} because the default value of the allocated object is
22336   @b{null}. This useless construct is illegal in Ada 2012.
22338 @noindent
22339   RM References:  4.08 (2)
22341 @item
22342 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
22343 @cindex AI-0157 (Ada 2012 feature)
22345 @noindent
22346   Allocation and Deallocation from an empty storage pool (i.e. allocation or
22347   deallocation of a pointer for which a static storage size clause of zero
22348   has been given) is now illegal and is detected as such. GNAT
22349   previously gave a warning but not an error.
22351 @noindent
22352   RM References:  4.08 (5.3/2)   13.11.02 (4)   13.11.02 (17)
22354 @item
22355 @emph{AI-0179 Statement not required after label (2010-04-10)}
22356 @cindex AI-0179 (Ada 2012 feature)
22358 @noindent
22359   It is not necessary to have a statement following a label, so a label
22360   can appear at the end of a statement sequence without the need for putting a
22361   null statement afterwards, but it is not allowable to have only labels and
22362   no real statements in a statement sequence.
22364 @noindent
22365   RM References:  5.01 (2)
22368 @item
22369 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
22370 @cindex AI-139-2 (Ada 2012 feature)
22372 @noindent
22373   The new syntax for iterating over arrays and containers is now implemented.
22374   Iteration over containers is for now limited to read-only iterators. Only
22375   default iterators are supported, with the syntax:  @code{@b{for} Elem @b{of} C}.
22377 @noindent
22378   RM References:  5.05
22380 @item
22381 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
22382 @cindex AI-0134 (Ada 2012 feature)
22384 @noindent
22385   For full conformance, the profiles of anonymous-access-to-subprogram
22386   parameters must match. GNAT has always enforced this rule.
22388 @noindent
22389   RM References:  6.03.01 (18)
22391 @item
22392 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
22393 @cindex AI-0207 (Ada 2012 feature)
22395 @noindent
22396   This AI confirms that access_to_constant indication must match for mode
22397   conformance. This was implemented in GNAT when the qualifier was originally
22398   introduced in Ada 2005.
22400 @noindent
22401   RM References:  6.03.01 (16/2)
22404 @item
22405 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
22406 @cindex AI-0046 (Ada 2012 feature)
22408 @noindent
22409   For full conformance, in the case of access parameters, the null exclusion
22410   must match (either both or neither must have @code{@b{not null}}).
22412 @noindent
22413   RM References:  6.03.02 (18)
22416 @item
22417 @emph{AI-0118 The association of parameter associations (0000-00-00)}
22418 @cindex AI-0118 (Ada 2012 feature)
22420 @noindent
22421   This AI clarifies the rules for named associations in subprogram calls and
22422   generic instantiations. The rules have been in place since Ada 83.
22424 @noindent
22425   RM References:  6.04.01 (2)   12.03 (9)
22428 @item
22429 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
22430 @cindex AI-0196 (Ada 2012 feature)
22432 @noindent
22433   Null exclusion checks are not made for @code{@b{out}} parameters when
22434   evaluating the actual parameters. GNAT has never generated these checks.
22436 @noindent
22437   RM References:  6.04.01 (13)
22439 @item
22440 @emph{AI-0015 Constant return objects (0000-00-00)}
22441 @cindex AI-0015 (Ada 2012 feature)
22443 @noindent
22444   The return object declared in an @i{extended_return_statement} may be
22445   declared constant. This was always intended, and GNAT has always allowed it.
22447 @noindent
22448   RM References:  6.05 (2.1/2)   3.03 (10/2)   3.03 (21)   6.05 (5/2)
22449   6.05 (5.7/2)
22452 @item
22453 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
22454 @cindex AI-0032 (Ada 2012 feature)
22456 @noindent
22457   If a function returns a class-wide type, the object of an extended return
22458   statement can be declared with a specific type that is covered by the class-
22459   wide type. This has been implemented in GNAT since the introduction of
22460   extended returns. Note AI-0103 complements this AI by imposing matching
22461   rules for constrained return types.
22463 @noindent
22464   RM References:  6.05 (5.2/2)   6.05 (5.3/2)   6.05 (5.6/2)   6.05 (5.8/2)
22465   6.05 (8/2)
22467 @item
22468 @emph{AI-0103 Static matching for extended return (2010-07-23)}
22469 @cindex AI-0103 (Ada 2012 feature)
22471 @noindent
22472   If the return subtype of a function is an elementary type or a constrained
22473   type, the subtype indication in an extended return statement must match
22474   statically this return subtype.
22476 @noindent
22477   RM References:  6.05 (5.2/2)
22480 @item
22481 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
22482 @cindex AI-0058 (Ada 2012 feature)
22484 @noindent
22485   The RM had some incorrect wording implying wrong treatment of abnormal
22486   completion in an extended return. GNAT has always implemented the intended
22487   correct semantics as described by this AI.
22489 @noindent
22490   RM References:  6.05 (22/2)
22493 @item
22494 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
22495 @cindex AI-0050 (Ada 2012 feature)
22497 @noindent
22498   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
22499   not take advantage of these incorrect permissions in any case.
22501 @noindent
22502   RM References:  6.05 (24/2)
22505 @item
22506 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
22507 @cindex AI-0125 (Ada 2012 feature)
22509 @noindent
22510   In Ada 2012, the declaration of a primitive operation of a type extension
22511   or private extension can also override an inherited primitive that is not
22512   visible at the point of this declaration.
22514 @noindent
22515   RM References:  7.03.01 (6)   8.03 (23)   8.03.01 (5/2)   8.03.01 (6/2)
22517 @item
22518 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
22519 @cindex AI-0062 (Ada 2012 feature)
22521 @noindent
22522   A full constant may have a null exclusion even if its associated deferred
22523   constant does not. GNAT has always allowed this.
22525 @noindent
22526   RM References:  7.04 (6/2)   7.04 (7.1/2)
22529 @item
22530 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
22531 @cindex AI-0178 (Ada 2012 feature)
22533 @noindent
22534   This AI clarifies the role of incomplete views and plugs an omission in the
22535   RM. GNAT always correctly restricted the use of incomplete views and types.
22537 @noindent
22538   RM References:  7.05 (3/2)   7.05 (6/2)
22540 @item
22541 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
22542 @cindex AI-0087 (Ada 2012 feature)
22544 @noindent
22545   The actual for a formal nonlimited derived type cannot be limited. In
22546   particular, a formal derived type that extends a limited interface but which
22547   is not explicitly limited cannot be instantiated with a limited type.
22549 @noindent
22550   RM References:  7.05 (5/2)   12.05.01 (5.1/2)
22552 @item
22553 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
22554 @cindex AI-0099 (Ada 2012 feature)
22556 @noindent
22557   This AI clarifies that ``needs finalization'' is part of dynamic semantics,
22558   and therefore depends on the run-time characteristics of an object (i.e. its
22559   tag) and not on its nominal type. As the AI indicates: ``we do not expect
22560   this to affect any implementation''.
22562 @noindent
22563   RM References:  7.06.01 (6)   7.06.01 (7)   7.06.01 (8)   7.06.01 (9/2)
22567 @item
22568 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
22569 @cindex AI-0064 (Ada 2012 feature)
22571 @noindent
22572   This is an editorial change only. The intended behavior is already checked
22573   by an existing ACATS test, which GNAT has always executed correctly.
22575 @noindent
22576   RM References:  7.06.01 (17.1/1)
22578 @item
22579 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
22580 @cindex AI-0026 (Ada 2012 feature)
22582 @noindent
22583   Record representation clauses concerning Unchecked_Union types cannot mention
22584   the discriminant of the type. The type of a component declared in the variant
22585   part of an Unchecked_Union cannot be controlled, have controlled components,
22586   nor have protected or task parts. If an Unchecked_Union type is declared
22587   within the body of a generic unit or its descendants, then the type of a
22588   component declared in the variant part cannot be a formal private type or a
22589   formal private extension declared within the same generic unit.
22591 @noindent
22592   RM References:  7.06 (9.4/2)   B.03.03 (9/2)   B.03.03 (10/2)
22595 @item
22596 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
22597 @cindex AI-0205 (Ada 2012 feature)
22599 @noindent
22600   This AI corrects a simple omission in the RM. Return objects have always
22601   been visible within an extended return statement.
22603 @noindent
22604   RM References:  8.03 (17)
22607 @item
22608 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
22609 @cindex AI-0042 (Ada 2012 feature)
22611 @noindent
22612   This AI fixes a wording gap in the RM. An operation of a synchronized
22613   interface can be implemented by a protected or task entry, but the abstract
22614   operation is not being overridden in the usual sense, and it must be stated
22615   separately that this implementation is legal. This has always been the case
22616   in GNAT.
22618 @noindent
22619   RM References:  9.01 (9.2/2)   9.04 (11.1/2)
22621 @item
22622 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
22623 @cindex AI-0030 (Ada 2012 feature)
22625 @noindent
22626   Requeue is permitted to a protected, synchronized or task interface primitive
22627   providing it is known that the overriding operation is an entry. Otherwise
22628   the requeue statement has the same effect as a procedure call. Use of pragma
22629   @code{Implemented} provides a way to impose a static requirement on the
22630   overriding operation by adhering to one of the implementation kinds: entry,
22631   protected procedure or any of the above.
22633 @noindent
22634   RM References:  9.05 (9)   9.05.04 (2)   9.05.04 (3)   9.05.04 (5)
22635   9.05.04 (6)   9.05.04 (7)   9.05.04 (12)
22638 @item
22639 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
22640 @cindex AI-0201 (Ada 2012 feature)
22642 @noindent
22643   If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
22644   attribute, then individual components may not be addressable by independent
22645   tasks. However, if the representation clause has no effect (is confirming),
22646   then independence is not compromised. Furthermore, in GNAT, specification of
22647   other appropriately addressable component sizes (e.g. 16 for 8-bit
22648   characters) also preserves independence. GNAT now gives very clear warnings
22649   both for the declaration of such a type, and for any assignment to its components.
22651 @noindent
22652   RM References:  9.10 (1/3)   C.06 (22/2)   C.06 (23/2)
22654 @item
22655 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
22656 @cindex AI-0009 (Ada 2012 feature)
22658 @noindent
22659   This AI introduces the new pragmas @code{Independent} and
22660   @code{Independent_Components},
22661   which control guaranteeing independence of access to objects and components.
22662   The AI also requires independence not unaffected by confirming rep clauses.
22664 @noindent
22665   RM References:  9.10 (1)   13.01 (15/1)   13.02 (9)   13.03 (13)   C.06 (2)
22666   C.06 (4)   C.06 (6)   C.06 (9)   C.06 (13)   C.06 (14)
22669 @item
22670 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
22671 @cindex AI-0072 (Ada 2012 feature)
22673 @noindent
22674   This AI clarifies that task signalling for reading @code{'Terminated} only
22675   occurs if the result is True. GNAT semantics has always been consistent with
22676   this notion of task signalling.
22678 @noindent
22679   RM References:  9.10 (6.1/1)
22681 @item
22682 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
22683 @cindex AI-0108 (Ada 2012 feature)
22685 @noindent
22686   This AI confirms that an incomplete type from a limited view does not have
22687   discriminants. This has always been the case in GNAT.
22689 @noindent
22690   RM References:  10.01.01 (12.3/2)
22692 @item
22693 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
22694 @cindex AI-0129 (Ada 2012 feature)
22696 @noindent
22697   This AI clarifies the description of limited views: a limited view of a
22698   package includes only one view of a type that has an incomplete declaration
22699   and a full declaration (there is no possible ambiguity in a client package).
22700   This AI also fixes an omission: a nested package in the private part has no
22701   limited view. GNAT always implemented this correctly.
22703 @noindent
22704   RM References:  10.01.01 (12.2/2)   10.01.01 (12.3/2)
22708 @item
22709 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
22710 @cindex AI-0077 (Ada 2012 feature)
22712 @noindent
22713   This AI clarifies that a declaration does not include a context clause,
22714   and confirms that it is illegal to have a context in which both a limited
22715   and a nonlimited view of a package are accessible. Such double visibility
22716   was always rejected by GNAT.
22718 @noindent
22719   RM References:  10.01.02 (12/2)   10.01.02 (21/2)   10.01.02 (22/2)
22721 @item
22722 @emph{AI-0122 Private with and children of generics (0000-00-00)}
22723 @cindex AI-0122 (Ada 2012 feature)
22725 @noindent
22726   This AI clarifies the visibility of private children of generic units within
22727   instantiations of a parent. GNAT has always handled this correctly.
22729 @noindent
22730   RM References:  10.01.02 (12/2)
22734 @item
22735 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
22736 @cindex AI-0040 (Ada 2012 feature)
22738 @noindent
22739   This AI confirms that a limited with clause in a child unit cannot name
22740   an ancestor of the unit. This has always been checked in GNAT.
22742 @noindent
22743   RM References:  10.01.02 (20/2)
22745 @item
22746 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
22747 @cindex AI-0132 (Ada 2012 feature)
22749 @noindent
22750   This AI fills a gap in the description of library unit pragmas. The pragma
22751   clearly must apply to a library unit, even if it does not carry the name
22752   of the enclosing unit. GNAT has always enforced the required check.
22754 @noindent
22755   RM References:  10.01.05 (7)
22758 @item
22759 @emph{AI-0034 Categorization of limited views (0000-00-00)}
22760 @cindex AI-0034 (Ada 2012 feature)
22762 @noindent
22763   The RM makes certain limited with clauses illegal because of categorization
22764   considerations, when the corresponding normal with would be legal. This is
22765   not intended, and GNAT has always implemented the recommended behavior.
22767 @noindent
22768   RM References:  10.02.01 (11/1)   10.02.01 (17/2)
22771 @item
22772 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
22773 @cindex AI-0035 (Ada 2012 feature)
22775 @noindent
22776   This AI remedies some inconsistencies in the legality rules for Pure units.
22777   Derived access types are legal in a pure unit (on the assumption that the
22778   rule for a zero storage pool size has been enforced on the ancestor type).
22779   The rules are enforced in generic instances and in subunits. GNAT has always
22780   implemented the recommended behavior.
22782 @noindent
22783   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)
22786 @item
22787 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
22788 @cindex AI-0219 (Ada 2012 feature)
22790 @noindent
22791   This AI refines the rules for the cases with limited parameters which do not
22792   allow the implementations to omit ``redundant''. GNAT now properly conforms
22793   to the requirements of this binding interpretation.
22795 @noindent
22796   RM References:  10.02.01 (18/2)
22798 @item
22799 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
22800 @cindex AI-0043 (Ada 2012 feature)
22802 @noindent
22803   This AI covers various omissions in the RM regarding the raising of
22804   exceptions. GNAT has always implemented the intended semantics.
22806 @noindent
22807   RM References:  11.04.01 (10.1/2)   11 (2)
22810 @item
22811 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
22812 @cindex AI-0200 (Ada 2012 feature)
22814 @noindent
22815   This AI plugs a gap in the RM which appeared to allow some obviously intended
22816   illegal instantiations. GNAT has never allowed these instantiations.
22818 @noindent
22819   RM References:  12.07 (16)
22822 @item
22823 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
22824 @cindex AI-0112 (Ada 2012 feature)
22826 @noindent
22827   This AI concerns giving names to various representation aspects, but the
22828   practical effect is simply to make the use of duplicate
22829   @code{Atomic}[@code{_Components}],
22830   @code{Volatile}[@code{_Components}] and
22831   @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
22832   now performs this required check.
22834 @noindent
22835   RM References:  13.01 (8)
22837 @item
22838 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
22839 @cindex AI-0106 (Ada 2012 feature)
22841 @noindent
22842   The RM appeared to allow representation pragmas on generic formal parameters,
22843   but this was not intended, and GNAT has never permitted this usage.
22845 @noindent
22846   RM References:  13.01 (9.1/1)
22849 @item
22850 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
22851 @cindex AI-0012 (Ada 2012 feature)
22853 @noindent
22854   It is now illegal to give an inappropriate component size or a pragma
22855   @code{Pack} that attempts to change the component size in the case of atomic
22856   or aliased components. Previously GNAT ignored such an attempt with a
22857   warning.
22859 @noindent
22860   RM References:  13.02 (6.1/2)   13.02 (7)   C.06 (10)   C.06 (11)   C.06 (21)
22863 @item
22864 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
22865 @cindex AI-0039 (Ada 2012 feature)
22867 @noindent
22868   The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
22869   for stream attributes, but these were never useful and are now illegal. GNAT
22870   has always regarded such expressions as illegal.
22872 @noindent
22873   RM References:  13.03 (4)   13.03 (6)   13.13.02 (38/2)
22876 @item
22877 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
22878 @cindex AI-0095 (Ada 2012 feature)
22880 @noindent
22881   The prefix of @code{'Address} cannot statically denote a subprogram with
22882   convention @code{Intrinsic}. The use of the @code{Address} attribute raises
22883   @code{Program_Error} if the prefix denotes a subprogram with convention
22884   @code{Intrinsic}.
22886 @noindent
22887   RM References:  13.03 (11/1)
22890 @item
22891 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
22892 @cindex AI-0116 (Ada 2012 feature)
22894 @noindent
22895   This AI requires that the alignment of a class-wide object be no greater
22896   than the alignment of any type in the class. GNAT has always followed this
22897   recommendation.
22899 @noindent
22900   RM References:  13.03 (29)   13.11 (16)
22903 @item
22904 @emph{AI-0146 Type invariants (2009-09-21)}
22905 @cindex AI-0146 (Ada 2012 feature)
22907 @noindent
22908   Type invariants may be specified for private types using the aspect notation.
22909   Aspect @code{Type_Invariant} may be specified for any private type,
22910   @code{Type_Invariant'Class} can
22911   only be specified for tagged types, and is inherited by any descendent of the
22912   tagged types. The invariant is a boolean expression that is tested for being
22913   true in the following situations: conversions to the private type, object
22914   declarations for the private type that are default initialized, and
22915   [@b{in}] @b{out}
22916   parameters and returned result on return from any primitive operation for
22917   the type that is visible to a client.
22918   GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
22919   @code{Invariant'Class} for @code{Type_Invariant'Class}.
22921 @noindent
22922   RM References:  13.03.03 (00)
22924 @item
22925 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
22926 @cindex AI-0078 (Ada 2012 feature)
22928 @noindent
22929   In Ada 2012, compilers are required to support unchecked conversion where the
22930   target alignment is a multiple of the source alignment. GNAT always supported
22931   this case (and indeed all cases of differing alignments, doing copies where
22932   required if the alignment was reduced).
22934 @noindent
22935   RM References:  13.09 (7)
22938 @item
22939 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
22940 @cindex AI-0195 (Ada 2012 feature)
22942 @noindent
22943   The handling of invalid values is now designated to be implementation
22944   defined. This is a documentation change only, requiring Annex M in the GNAT
22945   Reference Manual to document this handling.
22946   In GNAT, checks for invalid values are made
22947   only when necessary to avoid erroneous behavior. Operations like assignments
22948   which cannot cause erroneous behavior ignore the possibility of invalid
22949   values and do not do a check. The date given above applies only to the
22950   documentation change, this behavior has always been implemented by GNAT.
22952 @noindent
22953   RM References:  13.09.01 (10)
22955 @item
22956 @emph{AI-0193 Alignment of allocators (2010-09-16)}
22957 @cindex AI-0193 (Ada 2012 feature)
22959 @noindent
22960   This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
22961   analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
22962   of size.
22964 @noindent
22965   RM References:  13.11 (16)   13.11 (21)   13.11.01 (0)   13.11.01 (1)
22966   13.11.01 (2)   13.11.01 (3)
22969 @item
22970 @emph{AI-0177 Parameterized expressions (2010-07-10)}
22971 @cindex AI-0177 (Ada 2012 feature)
22973 @noindent
22974   The new Ada 2012 notion of parameterized expressions is implemented. The form
22975   is:
22976 @smallexample
22977   @i{function specification} @b{is} (@i{expression})
22978 @end smallexample
22980 @noindent
22981   This is exactly equivalent to the
22982   corresponding function body that returns the expression, but it can appear
22983   in a package spec. Note that the expression must be parenthesized.
22985 @noindent
22986   RM References:  13.11.01 (3/2)
22988 @item
22989 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
22990 @cindex AI-0033 (Ada 2012 feature)
22992 @noindent
22993   Neither of these two pragmas may appear within a generic template, because
22994   the generic might be instantiated at other than the library level.
22996 @noindent
22997   RM References:  13.11.02 (16)   C.03.01 (7/2)   C.03.01 (8/2)
23000 @item
23001 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
23002 @cindex AI-0161 (Ada 2012 feature)
23004 @noindent
23005   A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
23006   of the default stream attributes for elementary types. If this restriction is
23007   in force, then it is necessary to provide explicit subprograms for any
23008   stream attributes used.
23010 @noindent
23011   RM References:  13.12.01 (4/2)   13.13.02 (40/2)   13.13.02 (52/2)
23013 @item
23014 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
23015 @cindex AI-0194 (Ada 2012 feature)
23017 @noindent
23018   The @code{Stream_Size} attribute returns the default number of bits in the
23019   stream representation of the given type.
23020   This value is not affected by the presence
23021   of stream subprogram attributes for the type. GNAT has always implemented
23022   this interpretation.
23024 @noindent
23025   RM References:  13.13.02 (1.2/2)
23027 @item
23028 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
23029 @cindex AI-0109 (Ada 2012 feature)
23031 @noindent
23032   This AI is an editorial change only. It removes the need for a tag check
23033   that can never fail.
23035 @noindent
23036   RM References:  13.13.02 (34/2)
23038 @item
23039 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
23040 @cindex AI-0007 (Ada 2012 feature)
23042 @noindent
23043   The RM as written appeared to limit the possibilities of declaring read
23044   attribute procedures for private scalar types. This limitation was not
23045   intended, and has never been enforced by GNAT.
23047 @noindent
23048   RM References:  13.13.02 (50/2)   13.13.02 (51/2)
23051 @item
23052 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
23053 @cindex AI-0065 (Ada 2012 feature)
23055 @noindent
23056   This AI clarifies the fact that all remote access types support external
23057   streaming. This fixes an obvious oversight in the definition of the
23058   language, and GNAT always implemented the intended correct rules.
23060 @noindent
23061   RM References:  13.13.02 (52/2)
23063 @item
23064 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
23065 @cindex AI-0019 (Ada 2012 feature)
23067 @noindent
23068   The RM suggests that primitive subprograms of a specific tagged type are
23069   frozen when the tagged type is frozen. This would be an incompatible change
23070   and is not intended. GNAT has never attempted this kind of freezing and its
23071   behavior is consistent with the recommendation of this AI.
23073 @noindent
23074   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)
23076 @item
23077 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
23078 @cindex AI-0017 (Ada 2012 feature)
23080 @noindent
23081   So-called ``Taft-amendment types'' (i.e., types that are completed in package
23082   bodies) are not frozen by the occurrence of bodies in the
23083   enclosing declarative part. GNAT always implemented this properly.
23085 @noindent
23086   RM References:  13.14 (3/1)
23089 @item
23090 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
23091 @cindex AI-0060 (Ada 2012 feature)
23093 @noindent
23094   This AI extends the definition of remote access types to include access
23095   to limited, synchronized, protected or task class-wide interface types.
23096   GNAT already implemented this extension.
23098 @noindent
23099   RM References:  A (4)   E.02.02 (9/1)   E.02.02 (9.2/1)   E.02.02 (14/2)   E.02.02 (18)
23101 @item
23102 @emph{AI-0114 Classification of letters (0000-00-00)}
23103 @cindex AI-0114 (Ada 2012 feature)
23105 @noindent
23106   The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
23107   181 (@code{MICRO SIGN}), and
23108   186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
23109   lower case letters by Unicode.
23110   However, they are not allowed in identifiers, and they
23111   return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
23112   This behavior is consistent with that defined in Ada 95.
23114 @noindent
23115   RM References:  A.03.02 (59)   A.04.06 (7)
23118 @item
23119 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
23120 @cindex AI-0185 (Ada 2012 feature)
23122 @noindent
23123   Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
23124   classification functions for @code{Wide_Character} and
23125   @code{Wide_Wide_Character}, as well as providing
23126   case folding routines for @code{Wide_[Wide_]Character} and
23127   @code{Wide_[Wide_]String}.
23129 @noindent
23130   RM References:  A.03.05 (0)   A.03.06 (0)
23133 @item
23134 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
23135 @cindex AI-0031 (Ada 2012 feature)
23137 @noindent
23138   A new version of @code{Find_Token} is added to all relevant string packages,
23139   with an extra parameter @code{From}. Instead of starting at the first
23140   character of the string, the search for a matching Token starts at the
23141   character indexed by the value of @code{From}.
23142   These procedures are available in all versions of Ada
23143   but if used in versions earlier than Ada 2012 they will generate a warning
23144   that an Ada 2012 subprogram is being used.
23146 @noindent
23147   RM References:  A.04.03 (16)   A.04.03 (67)   A.04.03 (68/1)   A.04.04 (51)
23148   A.04.05 (46)
23151 @item
23152 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
23153 @cindex AI-0056 (Ada 2012 feature)
23155 @noindent
23156   The wording in the Ada 2005 RM implied an incompatible handling of the
23157   @code{Index} functions, resulting in raising an exception instead of
23158   returning zero in some situations.
23159   This was not intended and has been corrected.
23160   GNAT always returned zero, and is thus consistent with this AI.
23162 @noindent
23163   RM References:  A.04.03 (56.2/2)   A.04.03 (58.5/2)
23166 @item
23167 @emph{AI-0137 String encoding package (2010-03-25)}
23168 @cindex AI-0137 (Ada 2012 feature)
23170 @noindent
23171   The packages @code{Ada.Strings.UTF_Encoding}, together with its child
23172   packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
23173   and @code{Wide_Wide_Strings} have been
23174   implemented. These packages (whose documentation can be found in the spec
23175   files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
23176   @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
23177   @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
23178   values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
23179   UTF-16), as well as conversions between the different UTF encodings. With
23180   the exception of @code{Wide_Wide_Strings}, these packages are available in
23181   Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
23182   The @code{Wide_Wide_Strings package}
23183   is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
23184   mode since it uses @code{Wide_Wide_Character}).
23186 @noindent
23187   RM References:  A.04.11
23189 @item
23190 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
23191 @cindex AI-0038 (Ada 2012 feature)
23193 @noindent
23194   These are minor errors in the description on three points. The intent on
23195   all these points has always been clear, and GNAT has always implemented the
23196   correct intended semantics.
23198 @noindent
23199   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)
23201 @item
23202 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
23203 @cindex AI-0044 (Ada 2012 feature)
23205 @noindent
23206   This AI places restrictions on allowed instantiations of generic containers.
23207   These restrictions are not checked by the compiler, so there is nothing to
23208   change in the implementation. This affects only the RM documentation.
23210 @noindent
23211   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)
23213 @item
23214 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
23215 @cindex AI-0127 (Ada 2012 feature)
23217 @noindent
23218   This package provides an interface for identifying the current locale.
23220 @noindent
23221   RM References:  A.19    A.19.01    A.19.02    A.19.03    A.19.05    A.19.06
23222   A.19.07    A.19.08    A.19.09    A.19.10    A.19.11    A.19.12    A.19.13
23226 @item
23227 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
23228 @cindex AI-0002 (Ada 2012 feature)
23230 @noindent
23231   The compiler is not required to support exporting an Ada subprogram with
23232   convention C if there are parameters or a return type of an unconstrained
23233   array type (such as @code{String}). GNAT allows such declarations but
23234   generates warnings. It is possible, but complicated, to write the
23235   corresponding C code and certainly such code would be specific to GNAT and
23236   non-portable.
23238 @noindent
23239   RM References:  B.01 (17)   B.03 (62)   B.03 (71.1/2)
23242 @item
23243 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
23244 @cindex AI05-0216 (Ada 2012 feature)
23246 @noindent
23247   It is clearly the intention that @code{No_Task_Hierarchy} is intended to
23248   forbid tasks declared locally within subprograms, or functions returning task
23249   objects, and that is the implementation that GNAT has always provided.
23250   However the language in the RM was not sufficiently clear on this point.
23251   Thus this is a documentation change in the RM only.
23253 @noindent
23254   RM References:  D.07 (3/3)
23256 @item
23257 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
23258 @cindex AI-0211 (Ada 2012 feature)
23260 @noindent
23261   The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
23262   @code{Ada.Real_Time.Timing_Events.Set_Handler}.
23264 @noindent
23265   RM References:  D.07 (5)   D.07 (10/2)   D.07 (10.4/2)   D.07 (10.7/2)
23267 @item
23268 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
23269 @cindex AI-0190 (Ada 2012 feature)
23271 @noindent
23272   This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
23273   used to control storage pools globally.
23274   In particular, you can force every access
23275   type that is used for allocation (@b{new}) to have an explicit storage pool,
23276   or you can declare a pool globally to be used for all access types that lack
23277   an explicit one.
23279 @noindent
23280   RM References:  D.07 (8)
23282 @item
23283 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
23284 @cindex AI-0189 (Ada 2012 feature)
23286 @noindent
23287   This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
23288   which says that no dynamic allocation will occur once elaboration is
23289   completed.
23290   In general this requires a run-time check, which is not required, and which
23291   GNAT does not attempt. But the static cases of allocators in a task body or
23292   in the body of the main program are detected and flagged at compile or bind
23293   time.
23295 @noindent
23296   RM References:  D.07 (19.1/2)   H.04 (23.3/2)
23298 @item
23299 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
23300 @cindex AI-0171 (Ada 2012 feature)
23302 @noindent
23303   A new package @code{System.Multiprocessors} is added, together with the
23304   definition of pragma @code{CPU} for controlling task affinity. A new no
23305   dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
23306   is added to the Ravenscar profile.
23308 @noindent
23309   RM References:  D.13.01 (4/2)   D.16
23312 @item
23313 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
23314 @cindex AI-0210 (Ada 2012 feature)
23316 @noindent
23317   This is a documentation only issue regarding wording of metric requirements,
23318   that does not affect the implementation of the compiler.
23320 @noindent
23321   RM References:  D.15 (24/2)
23324 @item
23325 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
23326 @cindex AI-0206 (Ada 2012 feature)
23328 @noindent
23329   Remote types packages are now allowed to depend on preelaborated packages.
23330   This was formerly considered illegal.
23332 @noindent
23333   RM References:  E.02.02 (6)
23337 @item
23338 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
23339 @cindex AI-0152 (Ada 2012 feature)
23341 @noindent
23342   Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
23343   where the type of the returned value is an anonymous access type.
23345 @noindent
23346   RM References:  H.04 (8/1)
23347 @end itemize
23350 @node Obsolescent Features
23351 @chapter Obsolescent Features
23353 @noindent
23354 This chapter describes features that are provided by GNAT, but are
23355 considered obsolescent since there are preferred ways of achieving
23356 the same effect. These features are provided solely for historical
23357 compatibility purposes.
23359 @menu
23360 * pragma No_Run_Time::
23361 * pragma Ravenscar::
23362 * pragma Restricted_Run_Time::
23363 * pragma Task_Info::
23364 * System.Task_Info (s-tasinf.ads)::
23365 @end menu
23367 @node pragma No_Run_Time
23368 @section pragma No_Run_Time
23370 The pragma @code{No_Run_Time} is used to achieve an affect similar
23371 to the use of the "Zero Foot Print" configurable run time, but without
23372 requiring a specially configured run time. The result of using this
23373 pragma, which must be used for all units in a partition, is to restrict
23374 the use of any language features requiring run-time support code. The
23375 preferred usage is to use an appropriately configured run-time that
23376 includes just those features that are to be made accessible.
23378 @node pragma Ravenscar
23379 @section pragma Ravenscar
23381 The pragma @code{Ravenscar} has exactly the same effect as pragma
23382 @code{Profile (Ravenscar)}. The latter usage is preferred since it
23383 is part of the new Ada 2005 standard.
23385 @node pragma Restricted_Run_Time
23386 @section pragma Restricted_Run_Time
23388 The pragma @code{Restricted_Run_Time} has exactly the same effect as
23389 pragma @code{Profile (Restricted)}. The latter usage is
23390 preferred since the Ada 2005 pragma @code{Profile} is intended for
23391 this kind of implementation dependent addition.
23393 @node pragma Task_Info
23394 @section pragma Task_Info
23396 The functionality provided by pragma @code{Task_Info} is now part of the
23397 Ada language. The @code{CPU} aspect and the package
23398 @code{System.Multiprocessors} offer a less system-dependent way to specify
23399 task affinity or to query the number of processsors.
23401 @noindent
23402 Syntax
23404 @smallexample @c ada
23405 pragma Task_Info (EXPRESSION);
23406 @end smallexample
23408 @noindent
23409 This pragma appears within a task definition (like pragma
23410 @code{Priority}) and applies to the task in which it appears.  The
23411 argument must be of type @code{System.Task_Info.Task_Info_Type}.
23412 The @code{Task_Info} pragma provides system dependent control over
23413 aspects of tasking implementation, for example, the ability to map
23414 tasks to specific processors.  For details on the facilities available
23415 for the version of GNAT that you are using, see the documentation
23416 in the spec of package System.Task_Info in the runtime
23417 library.
23419 @node System.Task_Info (s-tasinf.ads)
23420 @section package System.Task_Info (@file{s-tasinf.ads})
23422 @noindent
23423 This package provides target dependent functionality that is used
23424 to support the @code{Task_Info} pragma. The predefined Ada package
23425  @code{System.Multiprocessors} and the @code{CPU} aspect now provide a
23426 standard replacement for GNAT's @code{Task_Info} functionality.
23428 @include fdl.texi
23429 @c GNU Free Documentation License
23431 @node Concept Index
23432 @unnumbered Index
23434 @printindex cp
23436 @contents
23438 @bye