8ad73c59e21a3b8ec37f438214909f1090ec065d
[gcc.git] / gcc / ada / gnat_rm.texi
1 \input texinfo @c -*-texinfo-*-
2
3 @c %**start of header
4
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
14
15 @setfilename gnat_rm.info
16
17 @copying
18 Copyright @copyright{} 1995-2012, Free Software Foundation, Inc.
19
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
27
28 @set EDITION GNAT
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
31
32 @settitle GNAT Reference Manual
33
34 @setchapternewpage odd
35 @syncodeindex fn cp
36
37 @include gcc-common.texi
38
39 @dircategory GNU Ada tools
40 @direntry
41 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
42 @end direntry
43
44 @titlepage
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
47 @versionsubtitle
48 @author AdaCore
49 @page
50 @vskip 0pt plus 1filll
51
52 @insertcopying
53
54 @end titlepage
55
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
59
60 @noindent
61 GNAT Reference Manual
62
63 @noindent
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
66
67 @noindent
68 AdaCore
69
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Aspects::
74 * Implementation Defined Attributes::
75 * Standard and Implementation Defined Restrictions::
76 * Implementation Advice::
77 * Implementation Defined Characteristics::
78 * Intrinsic Subprograms::
79 * Representation Clauses and Pragmas::
80 * Standard Library Routines::
81 * The Implementation of Standard I/O::
82 * The GNAT Library::
83 * Interfacing to Other Languages::
84 * Specialized Needs Annexes::
85 * Implementation of Specific Ada Features::
86 * Implementation of Ada 2012 Features::
87 * Obsolescent Features::
88 * GNU Free Documentation License::
89 * Index::
90
91 --- The Detailed Node Listing ---
92
93 About This Guide
94
95 * What This Reference Manual Contains::
96 * Related Information::
97
98 Implementation Defined Pragmas
99
100 * Pragma Abort_Defer::
101 * Pragma Abstract_State::
102 * Pragma Ada_83::
103 * Pragma Ada_95::
104 * Pragma Ada_05::
105 * Pragma Ada_2005::
106 * Pragma Ada_12::
107 * Pragma Ada_2012::
108 * Pragma Allow_Integer_Address::
109 * Pragma Annotate::
110 * Pragma Assert::
111 * Pragma Assert_And_Cut::
112 * Pragma Assertion_Policy::
113 * Pragma Assume::
114 * Pragma Assume_No_Invalid_Values::
115 * Pragma Attribute_Definition::
116 * Pragma Ast_Entry::
117 * Pragma C_Pass_By_Copy::
118 * Pragma Check::
119 * Pragma Check_Float_Overflow::
120 * Pragma Check_Name::
121 * Pragma Check_Policy::
122 * Pragma CIL_Constructor::
123 * Pragma Comment::
124 * Pragma Common_Object::
125 * Pragma Compile_Time_Error::
126 * Pragma Compile_Time_Warning::
127 * Pragma Compiler_Unit::
128 * Pragma Complete_Representation::
129 * Pragma Complex_Representation::
130 * Pragma Component_Alignment::
131 * Pragma Contract_Cases::
132 * Pragma Convention_Identifier::
133 * Pragma CPP_Class::
134 * Pragma CPP_Constructor::
135 * Pragma CPP_Virtual::
136 * Pragma CPP_Vtable::
137 * Pragma CPU::
138 * Pragma Debug::
139 * Pragma Debug_Policy::
140 * Pragma Default_Storage_Pool::
141 * Pragma Depends::
142 * Pragma Detect_Blocking::
143 * Pragma Disable_Atomic_Synchronization::
144 * Pragma Dispatching_Domain::
145 * Pragma Elaboration_Checks::
146 * Pragma Eliminate::
147 * Pragma Enable_Atomic_Synchronization::
148 * Pragma Export_Exception::
149 * Pragma Export_Function::
150 * Pragma Export_Object::
151 * Pragma Export_Procedure::
152 * Pragma Export_Value::
153 * Pragma Export_Valued_Procedure::
154 * Pragma Extend_System::
155 * Pragma Extensions_Allowed::
156 * Pragma External::
157 * Pragma External_Name_Casing::
158 * Pragma Fast_Math::
159 * Pragma Favor_Top_Level::
160 * Pragma Finalize_Storage_Only::
161 * Pragma Float_Representation::
162 * Pragma Global::
163 * Pragma Ident::
164 * Pragma Implementation_Defined::
165 * Pragma Implemented::
166 * Pragma Implicit_Packing::
167 * Pragma Import_Exception::
168 * Pragma Import_Function::
169 * Pragma Import_Object::
170 * Pragma Import_Procedure::
171 * Pragma Import_Valued_Procedure::
172 * Pragma Independent::
173 * Pragma Independent_Components::
174 * Pragma Initial_Condition::
175 * Pragma Initialize_Scalars::
176 * Pragma Initializes::
177 * Pragma Inline_Always::
178 * Pragma Inline_Generic::
179 * Pragma Interface::
180 * Pragma Interface_Name::
181 * Pragma Interrupt_Handler::
182 * Pragma Interrupt_State::
183 * Pragma Invariant::
184 * Pragma Java_Constructor::
185 * Pragma Java_Interface::
186 * Pragma Keep_Names::
187 * Pragma License::
188 * Pragma Link_With::
189 * Pragma Linker_Alias::
190 * Pragma Linker_Constructor::
191 * Pragma Linker_Destructor::
192 * Pragma Linker_Section::
193 * Pragma Long_Float::
194 * Pragma Loop_Invariant::
195 * Pragma Loop_Optimize::
196 * Pragma Loop_Variant::
197 * Pragma Machine_Attribute::
198 * Pragma Main::
199 * Pragma Main_Storage::
200 * Pragma No_Body::
201 * Pragma No_Inline::
202 * Pragma No_Return::
203 * Pragma No_Run_Time::
204 * Pragma No_Strict_Aliasing ::
205 * Pragma Normalize_Scalars::
206 * Pragma Obsolescent::
207 * Pragma Optimize_Alignment::
208 * Pragma Ordered::
209 * Pragma Overflow_Mode::
210 * Pragma Overriding_Renamings::
211 * Pragma Partition_Elaboration_Policy::
212 * Pragma Passive::
213 * Pragma Persistent_BSS::
214 * Pragma Polling::
215 * Pragma Post::
216 * Pragma Postcondition::
217 * Pragma Post_Class::
218 * Pragma Pre::
219 * Pragma Precondition::
220 * Pragma Predicate::
221 * Pragma Preelaborable_Initialization::
222 * Pragma Preelaborate_05::
223 * Pragma Pre_Class::
224 * Pragma Priority_Specific_Dispatching::
225 * Pragma Profile::
226 * Pragma Profile_Warnings::
227 * Pragma Propagate_Exceptions::
228 * Pragma Psect_Object::
229 * Pragma Pure_05::
230 * Pragma Pure_12::
231 * Pragma Pure_Function::
232 * Pragma Ravenscar::
233 * Pragma Refined_State::
234 * Pragma Relative_Deadline::
235 * Pragma Remote_Access_Type::
236 * Pragma Restricted_Run_Time::
237 * Pragma Restriction_Warnings::
238 * Pragma Share_Generic::
239 * Pragma Shared::
240 * Pragma Short_Circuit_And_Or::
241 * Pragma Short_Descriptors::
242 * Pragma Simple_Storage_Pool_Type::
243 * Pragma Source_File_Name::
244 * Pragma Source_File_Name_Project::
245 * Pragma Source_Reference::
246 * Pragma SPARK_Mode::
247 * Pragma Static_Elaboration_Desired::
248 * Pragma Stream_Convert::
249 * Pragma Style_Checks::
250 * Pragma Subtitle::
251 * Pragma Suppress::
252 * Pragma Suppress_All::
253 * Pragma Suppress_Debug_Info::
254 * Pragma Suppress_Exception_Locations::
255 * Pragma Suppress_Initialization::
256 * Pragma Task_Info::
257 * Pragma Task_Name::
258 * Pragma Task_Storage::
259 * Pragma Test_Case::
260 * Pragma Thread_Local_Storage::
261 * Pragma Time_Slice::
262 * Pragma Title::
263 * Pragma Type_Invariant::
264 * Pragma Type_Invariant_Class::
265 * Pragma Unchecked_Union::
266 * Pragma Unimplemented_Unit::
267 * Pragma Universal_Aliasing ::
268 * Pragma Universal_Data::
269 * Pragma Unmodified::
270 * Pragma Unreferenced::
271 * Pragma Unreferenced_Objects::
272 * Pragma Unreserve_All_Interrupts::
273 * Pragma Unsuppress::
274 * Pragma Use_VADS_Size::
275 * Pragma Validity_Checks::
276 * Pragma Volatile::
277 * Pragma Warnings::
278 * Pragma Weak_External::
279 * Pragma Wide_Character_Encoding::
280
281 Implementation Defined Aspects
282
283 * Aspect Abstract_State::
284 * Aspect Ada_2005::
285 * Aspect Ada_2012::
286 * Aspect Compiler_Unit::
287 * Aspect Contract_Cases::
288 * Aspect Depends::
289 * Aspect Dimension::
290 * Aspect Dimension_System::
291 * Aspect Favor_Top_Level::
292 * Aspect Global::
293 * Aspect Initial_Condition::
294 * Aspect Initializes::
295 * Aspect Inline_Always::
296 * Aspect Invariant::
297 * Aspect Object_Size::
298 * Aspect Persistent_BSS::
299 * Aspect Predicate::
300 * Aspect Preelaborate_05::
301 * Aspect Pure_05::
302 * Aspect Pure_12::
303 * Aspect Pure_Function::
304 * Aspect Refined_State::
305 * Aspect Remote_Access_Type::
306 * Aspect Scalar_Storage_Order::
307 * Aspect Shared::
308 * Aspect Simple_Storage_Pool::
309 * Aspect Simple_Storage_Pool_Type::
310 * Aspect SPARK_Mode::
311 * Aspect Suppress_Debug_Info::
312 * Aspect Test_Case::
313 * Aspect Universal_Aliasing::
314 * Aspect Universal_Data::
315 * Aspect Unmodified::
316 * Aspect Unreferenced::
317 * Aspect Unreferenced_Objects::
318 * Aspect Value_Size::
319 * Aspect Warnings::
320
321 Implementation Defined Attributes
322
323 * Attribute Abort_Signal::
324 * Attribute Address_Size::
325 * Attribute Asm_Input::
326 * Attribute Asm_Output::
327 * Attribute AST_Entry::
328 * Attribute Bit::
329 * Attribute Bit_Position::
330 * Attribute Compiler_Version::
331 * Attribute Code_Address::
332 * Attribute Default_Bit_Order::
333 * Attribute Descriptor_Size::
334 * Attribute Elaborated::
335 * Attribute Elab_Body::
336 * Attribute Elab_Spec::
337 * Attribute Elab_Subp_Body::
338 * Attribute Emax::
339 * Attribute Enabled::
340 * Attribute Enum_Rep::
341 * Attribute Enum_Val::
342 * Attribute Epsilon::
343 * Attribute Fixed_Value::
344 * Attribute Has_Access_Values::
345 * Attribute Has_Discriminants::
346 * Attribute Img::
347 * Attribute Integer_Value::
348 * Attribute Invalid_Value::
349 * Attribute Large::
350 * Attribute Library_Level::
351 * Attribute Loop_Entry::
352 * Attribute Machine_Size::
353 * Attribute Mantissa::
354 * Attribute Max_Interrupt_Priority::
355 * Attribute Max_Priority::
356 * Attribute Maximum_Alignment::
357 * Attribute Mechanism_Code::
358 * Attribute Null_Parameter::
359 * Attribute Object_Size::
360 * Attribute Passed_By_Reference::
361 * Attribute Pool_Address::
362 * Attribute Range_Length::
363 * Attribute Ref::
364 * Attribute Restriction_Set::
365 * Attribute Result::
366 * Attribute Safe_Emax::
367 * Attribute Safe_Large::
368 * Attribute Scalar_Storage_Order::
369 * Attribute Simple_Storage_Pool::
370 * Attribute Small::
371 * Attribute Storage_Unit::
372 * Attribute Stub_Type::
373 * Attribute System_Allocator_Alignment::
374 * Attribute Target_Name::
375 * Attribute Tick::
376 * Attribute To_Address::
377 * Attribute Type_Class::
378 * Attribute UET_Address::
379 * Attribute Unconstrained_Array::
380 * Attribute Universal_Literal_String::
381 * Attribute Unrestricted_Access::
382 * Attribute Update::
383 * Attribute Valid_Scalars::
384 * Attribute VADS_Size::
385 * Attribute Value_Size::
386 * Attribute Wchar_T_Size::
387 * Attribute Word_Size::
388
389 Standard and Implementation Defined Restrictions
390
391 * Partition-Wide Restrictions::
392 * Program Unit Level Restrictions::
393
394 Partition-Wide Restrictions
395
396 * Immediate_Reclamation::
397 * Max_Asynchronous_Select_Nesting::
398 * Max_Entry_Queue_Length::
399 * Max_Protected_Entries::
400 * Max_Select_Alternatives::
401 * Max_Storage_At_Blocking::
402 * Max_Task_Entries::
403 * Max_Tasks::
404 * No_Abort_Statements::
405 * No_Access_Parameter_Allocators::
406 * No_Access_Subprograms::
407 * No_Allocators::
408 * No_Anonymous_Allocators::
409 * No_Calendar::
410 * No_Coextensions::
411 * No_Default_Initialization::
412 * No_Delay::
413 * No_Dependence::
414 * No_Direct_Boolean_Operators::
415 * No_Dispatch::
416 * No_Dispatching_Calls::
417 * No_Dynamic_Attachment::
418 * No_Dynamic_Priorities::
419 * No_Entry_Calls_In_Elaboration_Code::
420 * No_Enumeration_Maps::
421 * No_Exception_Handlers::
422 * No_Exception_Propagation::
423 * No_Exception_Registration::
424 * No_Exceptions::
425 * No_Finalization::
426 * No_Fixed_Point::
427 * No_Floating_Point::
428 * No_Implicit_Conditionals::
429 * No_Implicit_Dynamic_Code::
430 * No_Implicit_Heap_Allocations::
431 * No_Implicit_Loops::
432 * No_Initialize_Scalars::
433 * No_IO::
434 * No_Local_Allocators::
435 * No_Local_Protected_Objects::
436 * No_Local_Timing_Events::
437 * No_Nested_Finalization::
438 * No_Protected_Type_Allocators::
439 * No_Protected_Types::
440 * No_Recursion::
441 * No_Reentrancy::
442 * No_Relative_Delay::
443 * No_Requeue_Statements::
444 * No_Secondary_Stack::
445 * No_Select_Statements::
446 * No_Specific_Termination_Handlers::
447 * No_Specification_of_Aspect::
448 * No_Standard_Allocators_After_Elaboration::
449 * No_Standard_Storage_Pools::
450 * No_Stream_Optimizations::
451 * No_Streams::
452 * No_Task_Allocators::
453 * No_Task_Attributes_Package::
454 * No_Task_Hierarchy::
455 * No_Task_Termination::
456 * No_Tasking::
457 * No_Terminate_Alternatives::
458 * No_Unchecked_Access::
459 * Simple_Barriers::
460 * Static_Priorities::
461 * Static_Storage_Size::
462
463 Program Unit Level Restrictions
464
465 * No_Elaboration_Code::
466 * No_Entry_Queue::
467 * No_Implementation_Aspect_Specifications::
468 * No_Implementation_Attributes::
469 * No_Implementation_Identifiers::
470 * No_Implementation_Pragmas::
471 * No_Implementation_Restrictions::
472 * No_Implementation_Units::
473 * No_Implicit_Aliasing::
474 * No_Obsolescent_Features::
475 * No_Wide_Characters::
476 * SPARK_05::
477
478 The Implementation of Standard I/O
479
480 * Standard I/O Packages::
481 * FORM Strings::
482 * Direct_IO::
483 * Sequential_IO::
484 * Text_IO::
485 * Wide_Text_IO::
486 * Wide_Wide_Text_IO::
487 * Stream_IO::
488 * Text Translation::
489 * Shared Files::
490 * Filenames encoding::
491 * Open Modes::
492 * Operations on C Streams::
493 * Interfacing to C Streams::
494
495 The GNAT Library
496
497 * Ada.Characters.Latin_9 (a-chlat9.ads)::
498 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
499 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
500 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
501 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
502 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
503 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
504 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
505 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
506 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
507 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
508 * Ada.Command_Line.Environment (a-colien.ads)::
509 * Ada.Command_Line.Remove (a-colire.ads)::
510 * Ada.Command_Line.Response_File (a-clrefi.ads)::
511 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
512 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
513 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
514 * Ada.Exceptions.Traceback (a-exctra.ads)::
515 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
516 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
517 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
518 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
519 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
520 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
521 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
522 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
523 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
524 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
525 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
526 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
527 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
528 * GNAT.Altivec (g-altive.ads)::
529 * GNAT.Altivec.Conversions (g-altcon.ads)::
530 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
531 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
532 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
533 * GNAT.Array_Split (g-arrspl.ads)::
534 * GNAT.AWK (g-awk.ads)::
535 * GNAT.Bounded_Buffers (g-boubuf.ads)::
536 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
537 * GNAT.Bubble_Sort (g-bubsor.ads)::
538 * GNAT.Bubble_Sort_A (g-busora.ads)::
539 * GNAT.Bubble_Sort_G (g-busorg.ads)::
540 * GNAT.Byte_Order_Mark (g-byorma.ads)::
541 * GNAT.Byte_Swapping (g-bytswa.ads)::
542 * GNAT.Calendar (g-calend.ads)::
543 * GNAT.Calendar.Time_IO (g-catiio.ads)::
544 * GNAT.Case_Util (g-casuti.ads)::
545 * GNAT.CGI (g-cgi.ads)::
546 * GNAT.CGI.Cookie (g-cgicoo.ads)::
547 * GNAT.CGI.Debug (g-cgideb.ads)::
548 * GNAT.Command_Line (g-comlin.ads)::
549 * GNAT.Compiler_Version (g-comver.ads)::
550 * GNAT.Ctrl_C (g-ctrl_c.ads)::
551 * GNAT.CRC32 (g-crc32.ads)::
552 * GNAT.Current_Exception (g-curexc.ads)::
553 * GNAT.Debug_Pools (g-debpoo.ads)::
554 * GNAT.Debug_Utilities (g-debuti.ads)::
555 * GNAT.Decode_String (g-decstr.ads)::
556 * GNAT.Decode_UTF8_String (g-deutst.ads)::
557 * GNAT.Directory_Operations (g-dirope.ads)::
558 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
559 * GNAT.Dynamic_HTables (g-dynhta.ads)::
560 * GNAT.Dynamic_Tables (g-dyntab.ads)::
561 * GNAT.Encode_String (g-encstr.ads)::
562 * GNAT.Encode_UTF8_String (g-enutst.ads)::
563 * GNAT.Exception_Actions (g-excact.ads)::
564 * GNAT.Exception_Traces (g-exctra.ads)::
565 * GNAT.Exceptions (g-except.ads)::
566 * GNAT.Expect (g-expect.ads)::
567 * GNAT.Expect.TTY (g-exptty.ads)::
568 * GNAT.Float_Control (g-flocon.ads)::
569 * GNAT.Heap_Sort (g-heasor.ads)::
570 * GNAT.Heap_Sort_A (g-hesora.ads)::
571 * GNAT.Heap_Sort_G (g-hesorg.ads)::
572 * GNAT.HTable (g-htable.ads)::
573 * GNAT.IO (g-io.ads)::
574 * GNAT.IO_Aux (g-io_aux.ads)::
575 * GNAT.Lock_Files (g-locfil.ads)::
576 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
577 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
578 * GNAT.MD5 (g-md5.ads)::
579 * GNAT.Memory_Dump (g-memdum.ads)::
580 * GNAT.Most_Recent_Exception (g-moreex.ads)::
581 * GNAT.OS_Lib (g-os_lib.ads)::
582 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
583 * GNAT.Random_Numbers (g-rannum.ads)::
584 * GNAT.Regexp (g-regexp.ads)::
585 * GNAT.Registry (g-regist.ads)::
586 * GNAT.Regpat (g-regpat.ads)::
587 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
588 * GNAT.Semaphores (g-semaph.ads)::
589 * GNAT.Serial_Communications (g-sercom.ads)::
590 * GNAT.SHA1 (g-sha1.ads)::
591 * GNAT.SHA224 (g-sha224.ads)::
592 * GNAT.SHA256 (g-sha256.ads)::
593 * GNAT.SHA384 (g-sha384.ads)::
594 * GNAT.SHA512 (g-sha512.ads)::
595 * GNAT.Signals (g-signal.ads)::
596 * GNAT.Sockets (g-socket.ads)::
597 * GNAT.Source_Info (g-souinf.ads)::
598 * GNAT.Spelling_Checker (g-speche.ads)::
599 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
600 * GNAT.Spitbol.Patterns (g-spipat.ads)::
601 * GNAT.Spitbol (g-spitbo.ads)::
602 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
603 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
604 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
605 * GNAT.SSE (g-sse.ads)::
606 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
607 * GNAT.Strings (g-string.ads)::
608 * GNAT.String_Split (g-strspl.ads)::
609 * GNAT.Table (g-table.ads)::
610 * GNAT.Task_Lock (g-tasloc.ads)::
611 * GNAT.Threads (g-thread.ads)::
612 * GNAT.Time_Stamp (g-timsta.ads)::
613 * GNAT.Traceback (g-traceb.ads)::
614 * GNAT.Traceback.Symbolic (g-trasym.ads)::
615 * GNAT.UTF_32 (g-utf_32.ads)::
616 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
617 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
618 * GNAT.Wide_String_Split (g-wistsp.ads)::
619 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
620 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
621 * Interfaces.C.Extensions (i-cexten.ads)::
622 * Interfaces.C.Streams (i-cstrea.ads)::
623 * Interfaces.CPP (i-cpp.ads)::
624 * Interfaces.Packed_Decimal (i-pacdec.ads)::
625 * Interfaces.VxWorks (i-vxwork.ads)::
626 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
627 * System.Address_Image (s-addima.ads)::
628 * System.Assertions (s-assert.ads)::
629 * System.Memory (s-memory.ads)::
630 * System.Multiprocessors (s-multip.ads)::
631 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
632 * System.Partition_Interface (s-parint.ads)::
633 * System.Pool_Global (s-pooglo.ads)::
634 * System.Pool_Local (s-pooloc.ads)::
635 * System.Restrictions (s-restri.ads)::
636 * System.Rident (s-rident.ads)::
637 * System.Strings.Stream_Ops (s-ststop.ads)::
638 * System.Task_Info (s-tasinf.ads)::
639 * System.Wch_Cnv (s-wchcnv.ads)::
640 * System.Wch_Con (s-wchcon.ads)::
641
642 Text_IO
643
644 * Text_IO Stream Pointer Positioning::
645 * Text_IO Reading and Writing Non-Regular Files::
646 * Get_Immediate::
647 * Treating Text_IO Files as Streams::
648 * Text_IO Extensions::
649 * Text_IO Facilities for Unbounded Strings::
650
651 Wide_Text_IO
652
653 * Wide_Text_IO Stream Pointer Positioning::
654 * Wide_Text_IO Reading and Writing Non-Regular Files::
655
656 Wide_Wide_Text_IO
657
658 * Wide_Wide_Text_IO Stream Pointer Positioning::
659 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
660
661 Interfacing to Other Languages
662
663 * Interfacing to C::
664 * Interfacing to C++::
665 * Interfacing to COBOL::
666 * Interfacing to Fortran::
667 * Interfacing to non-GNAT Ada code::
668
669 Specialized Needs Annexes
670
671 Implementation of Specific Ada Features
672 * Machine Code Insertions::
673 * GNAT Implementation of Tasking::
674 * GNAT Implementation of Shared Passive Packages::
675 * Code Generation for Array Aggregates::
676 * The Size of Discriminated Records with Default Discriminants::
677 * Strict Conformance to the Ada Reference Manual::
678
679 Implementation of Ada 2012 Features
680
681 Obsolescent Features
682
683 GNU Free Documentation License
684
685 Index
686 @end menu
687
688 @end ifnottex
689
690 @node About This Guide
691 @unnumbered About This Guide
692
693 @noindent
694 This manual contains useful information in writing programs using the
695 @value{EDITION} compiler. It includes information on implementation dependent
696 characteristics of @value{EDITION}, including all the information required by
697 Annex M of the Ada language standard.
698
699 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
700 Ada 83 compatibility mode.
701 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
702 but you can override with a compiler switch
703 to explicitly specify the language version.
704 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
705 @value{EDITION} User's Guide}, for details on these switches.)
706 Throughout this manual, references to ``Ada'' without a year suffix
707 apply to both the Ada 95 and Ada 2005 versions of the language.
708
709 Ada is designed to be highly portable.
710 In general, a program will have the same effect even when compiled by
711 different compilers on different platforms.
712 However, since Ada is designed to be used in a
713 wide variety of applications, it also contains a number of system
714 dependent features to be used in interfacing to the external world.
715 @cindex Implementation-dependent features
716 @cindex Portability
717
718 Note: Any program that makes use of implementation-dependent features
719 may be non-portable. You should follow good programming practice and
720 isolate and clearly document any sections of your program that make use
721 of these features in a non-portable manner.
722
723 @ifset PROEDITION
724 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
725 ``GNAT'' in the remainder of this document.
726 @end ifset
727
728 @menu
729 * What This Reference Manual Contains::
730 * Conventions::
731 * Related Information::
732 @end menu
733
734 @node What This Reference Manual Contains
735 @unnumberedsec What This Reference Manual Contains
736
737 @noindent
738 This reference manual contains the following chapters:
739
740 @itemize @bullet
741 @item
742 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
743 pragmas, which can be used to extend and enhance the functionality of the
744 compiler.
745
746 @item
747 @ref{Implementation Defined Attributes}, lists GNAT
748 implementation-dependent attributes, which can be used to extend and
749 enhance the functionality of the compiler.
750
751 @item
752 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
753 implementation-dependent restrictions, which can be used to extend and
754 enhance the functionality of the compiler.
755
756 @item
757 @ref{Implementation Advice}, provides information on generally
758 desirable behavior which are not requirements that all compilers must
759 follow since it cannot be provided on all systems, or which may be
760 undesirable on some systems.
761
762 @item
763 @ref{Implementation Defined Characteristics}, provides a guide to
764 minimizing implementation dependent features.
765
766 @item
767 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
768 implemented by GNAT, and how they can be imported into user
769 application programs.
770
771 @item
772 @ref{Representation Clauses and Pragmas}, describes in detail the
773 way that GNAT represents data, and in particular the exact set
774 of representation clauses and pragmas that is accepted.
775
776 @item
777 @ref{Standard Library Routines}, provides a listing of packages and a
778 brief description of the functionality that is provided by Ada's
779 extensive set of standard library routines as implemented by GNAT@.
780
781 @item
782 @ref{The Implementation of Standard I/O}, details how the GNAT
783 implementation of the input-output facilities.
784
785 @item
786 @ref{The GNAT Library}, is a catalog of packages that complement
787 the Ada predefined library.
788
789 @item
790 @ref{Interfacing to Other Languages}, describes how programs
791 written in Ada using GNAT can be interfaced to other programming
792 languages.
793
794 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
795 of the specialized needs annexes.
796
797 @item
798 @ref{Implementation of Specific Ada Features}, discusses issues related
799 to GNAT's implementation of machine code insertions, tasking, and several
800 other features.
801
802 @item
803 @ref{Implementation of Ada 2012 Features}, describes the status of the
804 GNAT implementation of the Ada 2012 language standard.
805
806 @item
807 @ref{Obsolescent Features} documents implementation dependent features,
808 including pragmas and attributes, which are considered obsolescent, since
809 there are other preferred ways of achieving the same results. These
810 obsolescent forms are retained for backwards compatibility.
811
812 @end itemize
813
814 @cindex Ada 95 Language Reference Manual
815 @cindex Ada 2005 Language Reference Manual
816 @noindent
817 This reference manual assumes a basic familiarity with the Ada 95 language, as
818 described in the International Standard ANSI/ISO/IEC-8652:1995,
819 January 1995.
820 It does not require knowledge of the new features introduced by Ada 2005,
821 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
822 and Amendment 1).
823 Both reference manuals are included in the GNAT documentation
824 package.
825
826 @node Conventions
827 @unnumberedsec Conventions
828 @cindex Conventions, typographical
829 @cindex Typographical conventions
830
831 @noindent
832 Following are examples of the typographical and graphic conventions used
833 in this guide:
834
835 @itemize @bullet
836 @item
837 @code{Functions}, @code{utility program names}, @code{standard names},
838 and @code{classes}.
839
840 @item
841 @code{Option flags}
842
843 @item
844 @file{File names}, @samp{button names}, and @samp{field names}.
845
846 @item
847 @code{Variables}, @env{environment variables}, and @var{metasyntactic
848 variables}.
849
850 @item
851 @emph{Emphasis}.
852
853 @item
854 [optional information or parameters]
855
856 @item
857 Examples are described by text
858 @smallexample
859 and then shown this way.
860 @end smallexample
861 @end itemize
862
863 @noindent
864 Commands that are entered by the user are preceded in this manual by the
865 characters @samp{$ } (dollar sign followed by space). If your system uses this
866 sequence as a prompt, then the commands will appear exactly as you see them
867 in the manual. If your system uses some other prompt, then the command will
868 appear with the @samp{$} replaced by whatever prompt character you are using.
869
870 @node Related Information
871 @unnumberedsec Related Information
872 @noindent
873 See the following documents for further information on GNAT:
874
875 @itemize @bullet
876 @item
877 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
878 @value{EDITION} User's Guide}, which provides information on how to use the
879 GNAT compiler system.
880
881 @item
882 @cite{Ada 95 Reference Manual}, which contains all reference
883 material for the Ada 95 programming language.
884
885 @item
886 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
887 of the Ada 95 standard. The annotations describe
888 detailed aspects of the design decision, and in particular contain useful
889 sections on Ada 83 compatibility.
890
891 @item
892 @cite{Ada 2005 Reference Manual}, which contains all reference
893 material for the Ada 2005 programming language.
894
895 @item
896 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
897 of the Ada 2005 standard. The annotations describe
898 detailed aspects of the design decision, and in particular contain useful
899 sections on Ada 83 and Ada 95 compatibility.
900
901 @item
902 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
903 which contains specific information on compatibility between GNAT and
904 DEC Ada 83 systems.
905
906 @item
907 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
908 describes in detail the pragmas and attributes provided by the DEC Ada 83
909 compiler system.
910
911 @end itemize
912
913 @node Implementation Defined Pragmas
914 @chapter Implementation Defined Pragmas
915
916 @noindent
917 Ada defines a set of pragmas that can be used to supply additional
918 information to the compiler. These language defined pragmas are
919 implemented in GNAT and work as described in the Ada Reference Manual.
920
921 In addition, Ada allows implementations to define additional pragmas
922 whose meaning is defined by the implementation. GNAT provides a number
923 of these implementation-defined pragmas, which can be used to extend
924 and enhance the functionality of the compiler. This section of the GNAT
925 Reference Manual describes these additional pragmas.
926
927 Note that any program using these pragmas might not be portable to other
928 compilers (although GNAT implements this set of pragmas on all
929 platforms). Therefore if portability to other compilers is an important
930 consideration, the use of these pragmas should be minimized.
931
932 @menu
933 * Pragma Abort_Defer::
934 * Pragma Abstract_State::
935 * Pragma Ada_83::
936 * Pragma Ada_95::
937 * Pragma Ada_05::
938 * Pragma Ada_2005::
939 * Pragma Ada_12::
940 * Pragma Ada_2012::
941 * Pragma Allow_Integer_Address::
942 * Pragma Annotate::
943 * Pragma Assert::
944 * Pragma Assert_And_Cut::
945 * Pragma Assertion_Policy::
946 * Pragma Assume::
947 * Pragma Assume_No_Invalid_Values::
948 * Pragma Attribute_Definition::
949 * Pragma Ast_Entry::
950 * Pragma C_Pass_By_Copy::
951 * Pragma Check::
952 * Pragma Check_Float_Overflow::
953 * Pragma Check_Name::
954 * Pragma Check_Policy::
955 * Pragma CIL_Constructor::
956 * Pragma Comment::
957 * Pragma Common_Object::
958 * Pragma Compile_Time_Error::
959 * Pragma Compile_Time_Warning::
960 * Pragma Compiler_Unit::
961 * Pragma Complete_Representation::
962 * Pragma Complex_Representation::
963 * Pragma Component_Alignment::
964 * Pragma Contract_Cases::
965 * Pragma Convention_Identifier::
966 * Pragma CPP_Class::
967 * Pragma CPP_Constructor::
968 * Pragma CPP_Virtual::
969 * Pragma CPP_Vtable::
970 * Pragma CPU::
971 * Pragma Debug::
972 * Pragma Debug_Policy::
973 * Pragma Default_Storage_Pool::
974 * Pragma Depends::
975 * Pragma Detect_Blocking::
976 * Pragma Disable_Atomic_Synchronization::
977 * Pragma Dispatching_Domain::
978 * Pragma Elaboration_Checks::
979 * Pragma Eliminate::
980 * Pragma Enable_Atomic_Synchronization::
981 * Pragma Export_Exception::
982 * Pragma Export_Function::
983 * Pragma Export_Object::
984 * Pragma Export_Procedure::
985 * Pragma Export_Value::
986 * Pragma Export_Valued_Procedure::
987 * Pragma Extend_System::
988 * Pragma Extensions_Allowed::
989 * Pragma External::
990 * Pragma External_Name_Casing::
991 * Pragma Fast_Math::
992 * Pragma Favor_Top_Level::
993 * Pragma Finalize_Storage_Only::
994 * Pragma Float_Representation::
995 * Pragma Global::
996 * Pragma Ident::
997 * Pragma Implementation_Defined::
998 * Pragma Implemented::
999 * Pragma Implicit_Packing::
1000 * Pragma Import_Exception::
1001 * Pragma Import_Function::
1002 * Pragma Import_Object::
1003 * Pragma Import_Procedure::
1004 * Pragma Import_Valued_Procedure::
1005 * Pragma Independent::
1006 * Pragma Independent_Components::
1007 * Pragma Initial_Condition::
1008 * Pragma Initialize_Scalars::
1009 * Pragma Initializes::
1010 * Pragma Inline_Always::
1011 * Pragma Inline_Generic::
1012 * Pragma Interface::
1013 * Pragma Interface_Name::
1014 * Pragma Interrupt_Handler::
1015 * Pragma Interrupt_State::
1016 * Pragma Invariant::
1017 * Pragma Java_Constructor::
1018 * Pragma Java_Interface::
1019 * Pragma Keep_Names::
1020 * Pragma License::
1021 * Pragma Link_With::
1022 * Pragma Linker_Alias::
1023 * Pragma Linker_Constructor::
1024 * Pragma Linker_Destructor::
1025 * Pragma Linker_Section::
1026 * Pragma Long_Float::
1027 * Pragma Loop_Invariant::
1028 * Pragma Loop_Optimize::
1029 * Pragma Loop_Variant::
1030 * Pragma Machine_Attribute::
1031 * Pragma Main::
1032 * Pragma Main_Storage::
1033 * Pragma No_Body::
1034 * Pragma No_Inline::
1035 * Pragma No_Return::
1036 * Pragma No_Run_Time::
1037 * Pragma No_Strict_Aliasing::
1038 * Pragma Normalize_Scalars::
1039 * Pragma Obsolescent::
1040 * Pragma Optimize_Alignment::
1041 * Pragma Ordered::
1042 * Pragma Overflow_Mode::
1043 * Pragma Overriding_Renamings::
1044 * Pragma Partition_Elaboration_Policy::
1045 * Pragma Passive::
1046 * Pragma Persistent_BSS::
1047 * Pragma Polling::
1048 * Pragma Post::
1049 * Pragma Postcondition::
1050 * Pragma Post_Class::
1051 * Pragma Pre::
1052 * Pragma Precondition::
1053 * Pragma Predicate::
1054 * Pragma Preelaborable_Initialization::
1055 * Pragma Preelaborate_05::
1056 * Pragma Pre_Class::
1057 * Pragma Priority_Specific_Dispatching::
1058 * Pragma Profile::
1059 * Pragma Profile_Warnings::
1060 * Pragma Propagate_Exceptions::
1061 * Pragma Psect_Object::
1062 * Pragma Pure_05::
1063 * Pragma Pure_12::
1064 * Pragma Pure_Function::
1065 * Pragma Ravenscar::
1066 * Pragma Refined_State::
1067 * Pragma Relative_Deadline::
1068 * Pragma Remote_Access_Type::
1069 * Pragma Restricted_Run_Time::
1070 * Pragma Restriction_Warnings::
1071 * Pragma Share_Generic::
1072 * Pragma Shared::
1073 * Pragma Short_Circuit_And_Or::
1074 * Pragma Short_Descriptors::
1075 * Pragma Simple_Storage_Pool_Type::
1076 * Pragma Source_File_Name::
1077 * Pragma Source_File_Name_Project::
1078 * Pragma Source_Reference::
1079 * Pragma SPARK_Mode::
1080 * Pragma Static_Elaboration_Desired::
1081 * Pragma Stream_Convert::
1082 * Pragma Style_Checks::
1083 * Pragma Subtitle::
1084 * Pragma Suppress::
1085 * Pragma Suppress_All::
1086 * Pragma Suppress_Debug_Info::
1087 * Pragma Suppress_Exception_Locations::
1088 * Pragma Suppress_Initialization::
1089 * Pragma Task_Info::
1090 * Pragma Task_Name::
1091 * Pragma Task_Storage::
1092 * Pragma Test_Case::
1093 * Pragma Thread_Local_Storage::
1094 * Pragma Time_Slice::
1095 * Pragma Title::
1096 * Pragma Type_Invariant::
1097 * Pragma Type_Invariant_Class::
1098 * Pragma Unchecked_Union::
1099 * Pragma Unimplemented_Unit::
1100 * Pragma Universal_Aliasing ::
1101 * Pragma Universal_Data::
1102 * Pragma Unmodified::
1103 * Pragma Unreferenced::
1104 * Pragma Unreferenced_Objects::
1105 * Pragma Unreserve_All_Interrupts::
1106 * Pragma Unsuppress::
1107 * Pragma Use_VADS_Size::
1108 * Pragma Validity_Checks::
1109 * Pragma Volatile::
1110 * Pragma Warnings::
1111 * Pragma Weak_External::
1112 * Pragma Wide_Character_Encoding::
1113 @end menu
1114
1115 @node Pragma Abort_Defer
1116 @unnumberedsec Pragma Abort_Defer
1117 @findex Abort_Defer
1118 @cindex Deferring aborts
1119 @noindent
1120 Syntax:
1121 @smallexample
1122 pragma Abort_Defer;
1123 @end smallexample
1124
1125 @noindent
1126 This pragma must appear at the start of the statement sequence of a
1127 handled sequence of statements (right after the @code{begin}). It has
1128 the effect of deferring aborts for the sequence of statements (but not
1129 for the declarations or handlers, if any, associated with this statement
1130 sequence).
1131
1132 @node Pragma Abstract_State
1133 @unnumberedsec Pragma Abstract_State
1134 @findex Abstract_State
1135 @noindent
1136 For the description of this pragma, see SPARK 2014 Reference Manual,
1137 section 7.1.4.
1138
1139 @node Pragma Ada_83
1140 @unnumberedsec Pragma Ada_83
1141 @findex Ada_83
1142 @noindent
1143 Syntax:
1144 @smallexample @c ada
1145 pragma Ada_83;
1146 @end smallexample
1147
1148 @noindent
1149 A configuration pragma that establishes Ada 83 mode for the unit to
1150 which it applies, regardless of the mode set by the command line
1151 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1152 the syntax and semantics of Ada 83, as defined in the original Ada
1153 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1154 and Ada 2005 are not recognized, optional package bodies are allowed,
1155 and generics may name types with unknown discriminants without using
1156 the @code{(<>)} notation. In addition, some but not all of the additional
1157 restrictions of Ada 83 are enforced.
1158
1159 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1160 Ada 83 code to be compiled and adapted to GNAT with less effort.
1161 Secondly, it aids in keeping code backwards compatible with Ada 83.
1162 However, there is no guarantee that code that is processed correctly
1163 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1164 83 compiler, since GNAT does not enforce all the additional checks
1165 required by Ada 83.
1166
1167 @node Pragma Ada_95
1168 @unnumberedsec Pragma Ada_95
1169 @findex Ada_95
1170 @noindent
1171 Syntax:
1172 @smallexample @c ada
1173 pragma Ada_95;
1174 @end smallexample
1175
1176 @noindent
1177 A configuration pragma that establishes Ada 95 mode for the unit to which
1178 it applies, regardless of the mode set by the command line switches.
1179 This mode is set automatically for the @code{Ada} and @code{System}
1180 packages and their children, so you need not specify it in these
1181 contexts. This pragma is useful when writing a reusable component that
1182 itself uses Ada 95 features, but which is intended to be usable from
1183 either Ada 83 or Ada 95 programs.
1184
1185 @node Pragma Ada_05
1186 @unnumberedsec Pragma Ada_05
1187 @findex Ada_05
1188 @noindent
1189 Syntax:
1190 @smallexample @c ada
1191 pragma Ada_05;
1192 @end smallexample
1193
1194 @noindent
1195 A configuration pragma that establishes Ada 2005 mode for the unit to which
1196 it applies, regardless of the mode set by the command line switches.
1197 This pragma is useful when writing a reusable component that
1198 itself uses Ada 2005 features, but which is intended to be usable from
1199 either Ada 83 or Ada 95 programs.
1200
1201 @node Pragma Ada_2005
1202 @unnumberedsec Pragma Ada_2005
1203 @findex Ada_2005
1204 @noindent
1205 Syntax:
1206 @smallexample @c ada
1207 pragma Ada_2005;
1208 @end smallexample
1209
1210 @noindent
1211 This configuration pragma is a synonym for pragma Ada_05 and has the
1212 same syntax and effect.
1213
1214 @node Pragma Ada_12
1215 @unnumberedsec Pragma Ada_12
1216 @findex Ada_12
1217 @noindent
1218 Syntax:
1219 @smallexample @c ada
1220 pragma Ada_12;
1221 @end smallexample
1222
1223 @noindent
1224 A configuration pragma that establishes Ada 2012 mode for the unit to which
1225 it applies, regardless of the mode set by the command line switches.
1226 This mode is set automatically for the @code{Ada} and @code{System}
1227 packages and their children, so you need not specify it in these
1228 contexts. This pragma is useful when writing a reusable component that
1229 itself uses Ada 2012 features, but which is intended to be usable from
1230 Ada 83, Ada 95, or Ada 2005 programs.
1231
1232 @node Pragma Ada_2012
1233 @unnumberedsec Pragma Ada_2012
1234 @findex Ada_2005
1235 @noindent
1236 Syntax:
1237 @smallexample @c ada
1238 pragma Ada_2012;
1239 @end smallexample
1240
1241 @noindent
1242 This configuration pragma is a synonym for pragma Ada_12 and has the
1243 same syntax and effect.
1244
1245 @node Pragma Allow_Integer_Address
1246 @unnumberedsec Pragma Allow_Integer_Address
1247 @findex Allow_Integer_Address
1248 @noindent
1249 Syntax:
1250 @smallexample @c ada
1251 pragma Allow_Integer_Address;
1252 @end smallexample
1253
1254 @noindent
1255 In almost all versions of GNAT, @code{System.Address} is a private
1256 type in accordance with the implementation advice in the RM. This
1257 means that integer values,
1258 in particular integer literals, are not allowed as address values.
1259 If the configuration pragma
1260 @code{Allow_Integer_Address} is given, then integer expressions may
1261 be used anywhere a value of type @code{System.Address} is required.
1262 The effect is to introduce an implicit unchecked conversion from the
1263 integer value to type @code{System.Address}. The reverse case of using
1264 an address where an integer type is required is handled analogously.
1265 The following example compiles without errors:
1266
1267 @smallexample @c ada
1268 pragma Allow_Integer_Address;
1269 with System; use System;
1270 package AddrAsInt is
1271 X : Integer;
1272 Y : Integer;
1273 for X'Address use 16#1240#;
1274 for Y use at 16#3230#;
1275 m : Address := 16#4000#;
1276 n : constant Address := 4000;
1277 p : constant Address := Address (X + Y);
1278 v : Integer := y'Address;
1279 w : constant Integer := Integer (Y'Address);
1280 type R is new integer;
1281 RR : R := 1000;
1282 Z : Integer;
1283 for Z'Address use RR;
1284 end AddrAsInt;
1285 @end smallexample
1286
1287 @noindent
1288 Note that pragma @code{Allow_Integer_Address} is ignored if
1289 @code{System.Address}
1290 is not a private type. In implementations of @code{GNAT} where
1291 System.Address is a visible integer type (notably the implementations
1292 for @code{OpenVMS}), this pragma serves no purpose but is ignored
1293 rather than rejected to allow common sets of sources to be used
1294 in the two situations.
1295
1296 @node Pragma Annotate
1297 @unnumberedsec Pragma Annotate
1298 @findex Annotate
1299 @noindent
1300 Syntax:
1301 @smallexample @c ada
1302 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1303
1304 ARG ::= NAME | EXPRESSION
1305 @end smallexample
1306
1307 @noindent
1308 This pragma is used to annotate programs. @var{identifier} identifies
1309 the type of annotation. GNAT verifies that it is an identifier, but does
1310 not otherwise analyze it. The second optional identifier is also left
1311 unanalyzed, and by convention is used to control the action of the tool to
1312 which the annotation is addressed. The remaining @var{arg} arguments
1313 can be either string literals or more generally expressions.
1314 String literals are assumed to be either of type
1315 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1316 depending on the character literals they contain.
1317 All other kinds of arguments are analyzed as expressions, and must be
1318 unambiguous.
1319
1320 The analyzed pragma is retained in the tree, but not otherwise processed
1321 by any part of the GNAT compiler, except to generate corresponding note
1322 lines in the generated ALI file. For the format of these note lines, see
1323 the compiler source file lib-writ.ads. This pragma is intended for use by
1324 external tools, including ASIS@. The use of pragma Annotate does not
1325 affect the compilation process in any way. This pragma may be used as
1326 a configuration pragma.
1327
1328 @node Pragma Assert
1329 @unnumberedsec Pragma Assert
1330 @findex Assert
1331 @noindent
1332 Syntax:
1333 @smallexample @c ada
1334 pragma Assert (
1335 boolean_EXPRESSION
1336 [, string_EXPRESSION]);
1337 @end smallexample
1338
1339 @noindent
1340 The effect of this pragma depends on whether the corresponding command
1341 line switch is set to activate assertions. The pragma expands into code
1342 equivalent to the following:
1343
1344 @smallexample @c ada
1345 if assertions-enabled then
1346 if not boolean_EXPRESSION then
1347 System.Assertions.Raise_Assert_Failure
1348 (string_EXPRESSION);
1349 end if;
1350 end if;
1351 @end smallexample
1352
1353 @noindent
1354 The string argument, if given, is the message that will be associated
1355 with the exception occurrence if the exception is raised. If no second
1356 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1357 where @var{file} is the name of the source file containing the assert,
1358 and @var{nnn} is the line number of the assert. A pragma is not a
1359 statement, so if a statement sequence contains nothing but a pragma
1360 assert, then a null statement is required in addition, as in:
1361
1362 @smallexample @c ada
1363 @dots{}
1364 if J > 3 then
1365 pragma Assert (K > 3, "Bad value for K");
1366 null;
1367 end if;
1368 @end smallexample
1369
1370 @noindent
1371 Note that, as with the @code{if} statement to which it is equivalent, the
1372 type of the expression is either @code{Standard.Boolean}, or any type derived
1373 from this standard type.
1374
1375 Assert checks can be either checked or ignored. By default they are ignored.
1376 They will be checked if either the command line switch @option{-gnata} is
1377 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1378 to enable @code{Assert_Checks}.
1379
1380 If assertions are ignored, then there
1381 is no run-time effect (and in particular, any side effects from the
1382 expression will not occur at run time). (The expression is still
1383 analyzed at compile time, and may cause types to be frozen if they are
1384 mentioned here for the first time).
1385
1386 If assertions are checked, then the given expression is tested, and if
1387 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1388 which results in the raising of @code{Assert_Failure} with the given message.
1389
1390 You should generally avoid side effects in the expression arguments of
1391 this pragma, because these side effects will turn on and off with the
1392 setting of the assertions mode, resulting in assertions that have an
1393 effect on the program. However, the expressions are analyzed for
1394 semantic correctness whether or not assertions are enabled, so turning
1395 assertions on and off cannot affect the legality of a program.
1396
1397 Note that the implementation defined policy @code{DISABLE}, given in a
1398 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1399
1400 Note: this is a standard language-defined pragma in versions
1401 of Ada from 2005 on. In GNAT, it is implemented in all versions
1402 of Ada, and the DISABLE policy is an implementation-defined
1403 addition.
1404
1405 @node Pragma Assert_And_Cut
1406 @unnumberedsec Pragma Assert_And_Cut
1407 @findex Assert_And_Cut
1408 @noindent
1409 Syntax:
1410 @smallexample @c ada
1411 pragma Assert_And_Cut (
1412 boolean_EXPRESSION
1413 [, string_EXPRESSION]);
1414 @end smallexample
1415
1416 @noindent
1417 The effect of this pragma is identical to that of pragma @code{Assert},
1418 except that in an @code{Assertion_Policy} pragma, the identifier
1419 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1420 (or disabled).
1421
1422 The intention is that this be used within a subprogram when the
1423 given test expresion sums up all the work done so far in the
1424 subprogram, so that the rest of the subprogram can be verified
1425 (informally or formally) using only the entry preconditions,
1426 and the expression in this pragma. This allows dividing up
1427 a subprogram into sections for the purposes of testing or
1428 formal verification. The pragma also serves as useful
1429 documentation.
1430
1431 @node Pragma Assertion_Policy
1432 @unnumberedsec Pragma Assertion_Policy
1433 @findex Assertion_Policy
1434 @noindent
1435 Syntax:
1436 @smallexample @c ada
1437 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1438
1439 pragma Assertion_Policy (
1440 ASSERTION_KIND => POLICY_IDENTIFIER
1441 @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1442
1443 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1444
1445 RM_ASSERTION_KIND ::= Assert |
1446 Static_Predicate |
1447 Dynamic_Predicate |
1448 Pre |
1449 Pre'Class |
1450 Post |
1451 Post'Class |
1452 Type_Invariant |
1453 Type_Invariant'Class
1454
1455 ID_ASSERTION_KIND ::= Assertions |
1456 Assert_And_Cut |
1457 Assume |
1458 Contract_Cases |
1459 Debug |
1460 Invariant |
1461 Invariant'Class |
1462 Loop_Invariant |
1463 Loop_Variant |
1464 Postcondition |
1465 Precondition |
1466 Predicate |
1467 Refined_Post |
1468 Statement_Assertions
1469
1470 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1471 @end smallexample
1472
1473 @noindent
1474 This is a standard Ada 2012 pragma that is available as an
1475 implementation-defined pragma in earlier versions of Ada.
1476 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1477 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1478 are implementation defined additions recognized by the GNAT compiler.
1479
1480 The pragma applies in both cases to pragmas and aspects with matching
1481 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1482 applies to both the @code{Precondition} pragma
1483 and the aspect @code{Precondition}. Note that the identifiers for
1484 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
1485 Pre_Class and Post_Class), since these pragmas are intended to be
1486 identical to the corresponding aspects).
1487
1488 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1489 the corresponding pragma or aspect is activated.
1490 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1491 the corresponding pragma or aspect is deactivated.
1492 This pragma overrides the effect of the @option{-gnata} switch on the
1493 command line.
1494
1495 The implementation defined policy @code{DISABLE} is like
1496 @code{IGNORE} except that it completely disables semantic
1497 checking of the corresponding pragma or aspect. This is
1498 useful when the pragma or aspect argument references subprograms
1499 in a with'ed package which is replaced by a dummy package
1500 for the final build.
1501
1502 The implementation defined policy @code{Assertions} applies to all
1503 assertion kinds. The form with no assertion kind given implies this
1504 choice, so it applies to all assertion kinds (RM defined, and
1505 implementation defined).
1506
1507 The implementation defined policy @code{Statement_Assertions}
1508 applies to @code{Assert}, @code{Assert_And_Cut},
1509 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
1510
1511 @node Pragma Assume
1512 @unnumberedsec Pragma Assume
1513 @findex Assume
1514 @noindent
1515 Syntax:
1516 @smallexample @c ada
1517 pragma Assume (
1518 boolean_EXPRESSION
1519 [, string_EXPRESSION]);
1520 @end smallexample
1521
1522 @noindent
1523 The effect of this pragma is identical to that of pragma @code{Assert},
1524 except that in an @code{Assertion_Policy} pragma, the identifier
1525 @code{Assume} is used to control whether it is ignored or checked
1526 (or disabled).
1527
1528 The intention is that this be used for assumptions about the
1529 external environment. So you cannot expect to verify formally
1530 or informally that the condition is met, this must be
1531 established by examining things outside the program itself.
1532 For example, we may have code that depends on the size of
1533 @code{Long_Long_Integer} being at least 64. So we could write:
1534
1535 @smallexample @c ada
1536 pragma Assume (Long_Long_Integer'Size >= 64);
1537 @end smallexample
1538
1539 @noindent
1540 This assumption cannot be proved from the program itself,
1541 but it acts as a useful run-time check that the assumption
1542 is met, and documents the need to ensure that it is met by
1543 reference to information outside the program.
1544
1545 @node Pragma Assume_No_Invalid_Values
1546 @unnumberedsec Pragma Assume_No_Invalid_Values
1547 @findex Assume_No_Invalid_Values
1548 @cindex Invalid representations
1549 @cindex Invalid values
1550 @noindent
1551 Syntax:
1552 @smallexample @c ada
1553 pragma Assume_No_Invalid_Values (On | Off);
1554 @end smallexample
1555
1556 @noindent
1557 This is a configuration pragma that controls the assumptions made by the
1558 compiler about the occurrence of invalid representations (invalid values)
1559 in the code.
1560
1561 The default behavior (corresponding to an Off argument for this pragma), is
1562 to assume that values may in general be invalid unless the compiler can
1563 prove they are valid. Consider the following example:
1564
1565 @smallexample @c ada
1566 V1 : Integer range 1 .. 10;
1567 V2 : Integer range 11 .. 20;
1568 ...
1569 for J in V2 .. V1 loop
1570 ...
1571 end loop;
1572 @end smallexample
1573
1574 @noindent
1575 if V1 and V2 have valid values, then the loop is known at compile
1576 time not to execute since the lower bound must be greater than the
1577 upper bound. However in default mode, no such assumption is made,
1578 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1579 is given, the compiler will assume that any occurrence of a variable
1580 other than in an explicit @code{'Valid} test always has a valid
1581 value, and the loop above will be optimized away.
1582
1583 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1584 you know your code is free of uninitialized variables and other
1585 possible sources of invalid representations, and may result in
1586 more efficient code. A program that accesses an invalid representation
1587 with this pragma in effect is erroneous, so no guarantees can be made
1588 about its behavior.
1589
1590 It is peculiar though permissible to use this pragma in conjunction
1591 with validity checking (-gnatVa). In such cases, accessing invalid
1592 values will generally give an exception, though formally the program
1593 is erroneous so there are no guarantees that this will always be the
1594 case, and it is recommended that these two options not be used together.
1595
1596 @node Pragma Ast_Entry
1597 @unnumberedsec Pragma Ast_Entry
1598 @cindex OpenVMS
1599 @findex Ast_Entry
1600 @noindent
1601 Syntax:
1602 @smallexample @c ada
1603 pragma AST_Entry (entry_IDENTIFIER);
1604 @end smallexample
1605
1606 @noindent
1607 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1608 argument is the simple name of a single entry; at most one @code{AST_Entry}
1609 pragma is allowed for any given entry. This pragma must be used in
1610 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1611 the entry declaration and in the same task type specification or single task
1612 as the entry to which it applies. This pragma specifies that the given entry
1613 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1614 resulting from an OpenVMS system service call. The pragma does not affect
1615 normal use of the entry. For further details on this pragma, see the
1616 DEC Ada Language Reference Manual, section 9.12a.
1617
1618 @node Pragma Attribute_Definition
1619 @unnumberedsec Pragma Attribute_Definition
1620 @findex Attribute_Definition
1621 @noindent
1622 Syntax:
1623 @smallexample @c ada
1624 pragma Attribute_Definition
1625 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1626 [Entity =>] LOCAL_NAME,
1627 [Expression =>] EXPRESSION | NAME);
1628 @end smallexample
1629
1630 @noindent
1631 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1632 the attribute definition clause:
1633
1634 @smallexample @c ada
1635 for Entity'Attribute use Expression;
1636 @end smallexample
1637
1638 If @code{Attribute} is not a recognized attribute name, the pragma is
1639 ignored, and a warning is emitted. This allows source
1640 code to be written that takes advantage of some new attribute, while remaining
1641 compilable with earlier compilers.
1642
1643 @node Pragma C_Pass_By_Copy
1644 @unnumberedsec Pragma C_Pass_By_Copy
1645 @cindex Passing by copy
1646 @findex C_Pass_By_Copy
1647 @noindent
1648 Syntax:
1649 @smallexample @c ada
1650 pragma C_Pass_By_Copy
1651 ([Max_Size =>] static_integer_EXPRESSION);
1652 @end smallexample
1653
1654 @noindent
1655 Normally the default mechanism for passing C convention records to C
1656 convention subprograms is to pass them by reference, as suggested by RM
1657 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1658 this default, by requiring that record formal parameters be passed by
1659 copy if all of the following conditions are met:
1660
1661 @itemize @bullet
1662 @item
1663 The size of the record type does not exceed the value specified for
1664 @code{Max_Size}.
1665 @item
1666 The record type has @code{Convention C}.
1667 @item
1668 The formal parameter has this record type, and the subprogram has a
1669 foreign (non-Ada) convention.
1670 @end itemize
1671
1672 @noindent
1673 If these conditions are met the argument is passed by copy, i.e.@: in a
1674 manner consistent with what C expects if the corresponding formal in the
1675 C prototype is a struct (rather than a pointer to a struct).
1676
1677 You can also pass records by copy by specifying the convention
1678 @code{C_Pass_By_Copy} for the record type, or by using the extended
1679 @code{Import} and @code{Export} pragmas, which allow specification of
1680 passing mechanisms on a parameter by parameter basis.
1681
1682 @node Pragma Check
1683 @unnumberedsec Pragma Check
1684 @cindex Assertions
1685 @cindex Named assertions
1686 @findex Check
1687 @noindent
1688 Syntax:
1689 @smallexample @c ada
1690 pragma Check (
1691 [Name =>] CHECK_KIND,
1692 [Check =>] Boolean_EXPRESSION
1693 [, [Message =>] string_EXPRESSION] );
1694
1695 CHECK_KIND ::= IDENTIFIER |
1696 Pre'Class |
1697 Post'Class |
1698 Type_Invariant'Class |
1699 Invariant'Class
1700 @end smallexample
1701
1702 @noindent
1703 This pragma is similar to the predefined pragma @code{Assert} except that an
1704 extra identifier argument is present. In conjunction with pragma
1705 @code{Check_Policy}, this can be used to define groups of assertions that can
1706 be independently controlled. The identifier @code{Assertion} is special, it
1707 refers to the normal set of pragma @code{Assert} statements.
1708
1709 Checks introduced by this pragma are normally deactivated by default. They can
1710 be activated either by the command line option @option{-gnata}, which turns on
1711 all checks, or individually controlled using pragma @code{Check_Policy}.
1712
1713 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1714 permitted as check kinds, since this would cause confusion with the use
1715 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1716 pragmas, where they are used to refer to sets of assertions.
1717
1718 @node Pragma Check_Float_Overflow
1719 @unnumberedsec Pragma Check_Float_Overflow
1720 @cindex Floating-point overflow
1721 @findex Check_Float_Overflow
1722 @noindent
1723 Syntax:
1724 @smallexample @c ada
1725 pragma Check_Float_Overflow;
1726 @end smallexample
1727
1728 @noindent
1729 In Ada, the predefined floating-point types (@code{Short_Float},
1730 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1731 defined to be @emph{unconstrained}. This means that even though each
1732 has a well-defined base range, an operation that delivers a result
1733 outside this base range is not required to raise an exception.
1734 This implementation permission accommodates the notion
1735 of infinities in IEEE floating-point, and corresponds to the
1736 efficient execution mode on most machines. GNAT will not raise
1737 overflow exceptions on these machines; instead it will generate
1738 infinities and NaN's as defined in the IEEE standard.
1739
1740 Generating infinities, although efficient, is not always desirable.
1741 Often the preferable approach is to check for overflow, even at the
1742 (perhaps considerable) expense of run-time performance.
1743 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1744 range constraints -- and indeed such a subtype
1745 can have the same base range as its base type. For example:
1746
1747 @smallexample @c ada
1748 subtype My_Float is Float range Float'Range;
1749 @end smallexample
1750
1751 @noindent
1752 Here @code{My_Float} has the same range as
1753 @code{Float} but is constrained, so operations on
1754 @code{My_Float} values will be checked for overflow
1755 against this range.
1756
1757 This style will achieve the desired goal, but
1758 it is often more convenient to be able to simply use
1759 the standard predefined floating-point types as long
1760 as overflow checking could be guaranteed.
1761 The @code{Check_Float_Overflow}
1762 configuration pragma achieves this effect. If a unit is compiled
1763 subject to this configuration pragma, then all operations
1764 on predefined floating-point types will be treated as
1765 though those types were constrained, and overflow checks
1766 will be generated. The @code{Constraint_Error}
1767 exception is raised if the result is out of range.
1768
1769 This mode can also be set by use of the compiler
1770 switch @option{-gnateF}.
1771
1772 @node Pragma Check_Name
1773 @unnumberedsec Pragma Check_Name
1774 @cindex Defining check names
1775 @cindex Check names, defining
1776 @findex Check_Name
1777 @noindent
1778 Syntax:
1779 @smallexample @c ada
1780 pragma Check_Name (check_name_IDENTIFIER);
1781 @end smallexample
1782
1783 @noindent
1784 This is a configuration pragma that defines a new implementation
1785 defined check name (unless IDENTIFIER matches one of the predefined
1786 check names, in which case the pragma has no effect). Check names
1787 are global to a partition, so if two or more configuration pragmas
1788 are present in a partition mentioning the same name, only one new
1789 check name is introduced.
1790
1791 An implementation defined check name introduced with this pragma may
1792 be used in only three contexts: @code{pragma Suppress},
1793 @code{pragma Unsuppress},
1794 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1795 any of these three cases, the check name must be visible. A check
1796 name is visible if it is in the configuration pragmas applying to
1797 the current unit, or if it appears at the start of any unit that
1798 is part of the dependency set of the current unit (e.g., units that
1799 are mentioned in @code{with} clauses).
1800
1801 Check names introduced by this pragma are subject to control by compiler
1802 switches (in particular -gnatp) in the usual manner.
1803
1804 @node Pragma Check_Policy
1805 @unnumberedsec Pragma Check_Policy
1806 @cindex Controlling assertions
1807 @cindex Assertions, control
1808 @cindex Check pragma control
1809 @cindex Named assertions
1810 @findex Check
1811 @noindent
1812 Syntax:
1813 @smallexample @c ada
1814 pragma Check_Policy
1815 ([Name =>] CHECK_KIND,
1816 [Policy =>] POLICY_IDENTIFIER);
1817
1818 pragma Check_Policy (
1819 CHECK_KIND => POLICY_IDENTIFIER
1820 @{, CHECK_KIND => POLICY_IDENTIFIER@});
1821
1822 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1823
1824 CHECK_KIND ::= IDENTIFIER |
1825 Pre'Class |
1826 Post'Class |
1827 Type_Invariant'Class |
1828 Invariant'Class
1829
1830 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1831 avoids confusion between the two possible syntax forms for this pragma.
1832
1833 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1834 @end smallexample
1835
1836 @noindent
1837 This pragma is used to set the checking policy for assertions (specified
1838 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1839 to be checked using the @code{Check} pragma. It may appear either as
1840 a configuration pragma, or within a declarative part of package. In the
1841 latter case, it applies from the point where it appears to the end of
1842 the declarative region (like pragma @code{Suppress}).
1843
1844 The @code{Check_Policy} pragma is similar to the
1845 predefined @code{Assertion_Policy} pragma,
1846 and if the check kind corresponds to one of the assertion kinds that
1847 are allowed by @code{Assertion_Policy}, then the effect is identical.
1848
1849 If the first argument is Debug, then the policy applies to Debug pragmas,
1850 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1851 @code{IGNORE}, and allowing them to execute with normal semantics if
1852 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1853 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1854 be totally ignored and not analyzed semantically.
1855
1856 Finally the first argument may be some other identifier than the above
1857 possibilities, in which case it controls a set of named assertions
1858 that can be checked using pragma @code{Check}. For example, if the pragma:
1859
1860 @smallexample @c ada
1861 pragma Check_Policy (Critical_Error, OFF);
1862 @end smallexample
1863
1864 @noindent
1865 is given, then subsequent @code{Check} pragmas whose first argument is also
1866 @code{Critical_Error} will be disabled.
1867
1868 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1869 to turn on corresponding checks. The default for a set of checks for which no
1870 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1871 @option{-gnata} is given, which turns on all checks by default.
1872
1873 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1874 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1875 compatibility with the standard @code{Assertion_Policy} pragma. The check
1876 policy setting @code{DISABLE} causes the second argument of a corresponding
1877 @code{Check} pragma to be completely ignored and not analyzed.
1878
1879 @node Pragma CIL_Constructor
1880 @unnumberedsec Pragma CIL_Constructor
1881 @findex CIL_Constructor
1882 @noindent
1883 Syntax:
1884
1885 @smallexample @c ada
1886 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1887 @end smallexample
1888
1889 @noindent
1890 This pragma is used to assert that the specified Ada function should be
1891 mapped to the .NET constructor for some Ada tagged record type.
1892
1893 See section 4.1 of the
1894 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1895 for related information.
1896
1897 @node Pragma Comment
1898 @unnumberedsec Pragma Comment
1899 @findex Comment
1900 @noindent
1901 Syntax:
1902
1903 @smallexample @c ada
1904 pragma Comment (static_string_EXPRESSION);
1905 @end smallexample
1906
1907 @noindent
1908 This is almost identical in effect to pragma @code{Ident}. It allows the
1909 placement of a comment into the object file and hence into the
1910 executable file if the operating system permits such usage. The
1911 difference is that @code{Comment}, unlike @code{Ident}, has
1912 no limitations on placement of the pragma (it can be placed
1913 anywhere in the main source unit), and if more than one pragma
1914 is used, all comments are retained.
1915
1916 @node Pragma Common_Object
1917 @unnumberedsec Pragma Common_Object
1918 @findex Common_Object
1919 @noindent
1920 Syntax:
1921
1922 @smallexample @c ada
1923 pragma Common_Object (
1924 [Internal =>] LOCAL_NAME
1925 [, [External =>] EXTERNAL_SYMBOL]
1926 [, [Size =>] EXTERNAL_SYMBOL] );
1927
1928 EXTERNAL_SYMBOL ::=
1929 IDENTIFIER
1930 | static_string_EXPRESSION
1931 @end smallexample
1932
1933 @noindent
1934 This pragma enables the shared use of variables stored in overlaid
1935 linker areas corresponding to the use of @code{COMMON}
1936 in Fortran. The single
1937 object @var{LOCAL_NAME} is assigned to the area designated by
1938 the @var{External} argument.
1939 You may define a record to correspond to a series
1940 of fields. The @var{Size} argument
1941 is syntax checked in GNAT, but otherwise ignored.
1942
1943 @code{Common_Object} is not supported on all platforms. If no
1944 support is available, then the code generator will issue a message
1945 indicating that the necessary attribute for implementation of this
1946 pragma is not available.
1947
1948 @node Pragma Compile_Time_Error
1949 @unnumberedsec Pragma Compile_Time_Error
1950 @findex Compile_Time_Error
1951 @noindent
1952 Syntax:
1953
1954 @smallexample @c ada
1955 pragma Compile_Time_Error
1956 (boolean_EXPRESSION, static_string_EXPRESSION);
1957 @end smallexample
1958
1959 @noindent
1960 This pragma can be used to generate additional compile time
1961 error messages. It
1962 is particularly useful in generics, where errors can be issued for
1963 specific problematic instantiations. The first parameter is a boolean
1964 expression. The pragma is effective only if the value of this expression
1965 is known at compile time, and has the value True. The set of expressions
1966 whose values are known at compile time includes all static boolean
1967 expressions, and also other values which the compiler can determine
1968 at compile time (e.g., the size of a record type set by an explicit
1969 size representation clause, or the value of a variable which was
1970 initialized to a constant and is known not to have been modified).
1971 If these conditions are met, an error message is generated using
1972 the value given as the second argument. This string value may contain
1973 embedded ASCII.LF characters to break the message into multiple lines.
1974
1975 @node Pragma Compile_Time_Warning
1976 @unnumberedsec Pragma Compile_Time_Warning
1977 @findex Compile_Time_Warning
1978 @noindent
1979 Syntax:
1980
1981 @smallexample @c ada
1982 pragma Compile_Time_Warning
1983 (boolean_EXPRESSION, static_string_EXPRESSION);
1984 @end smallexample
1985
1986 @noindent
1987 Same as pragma Compile_Time_Error, except a warning is issued instead
1988 of an error message. Note that if this pragma is used in a package that
1989 is with'ed by a client, the client will get the warning even though it
1990 is issued by a with'ed package (normally warnings in with'ed units are
1991 suppressed, but this is a special exception to that rule).
1992
1993 One typical use is within a generic where compile time known characteristics
1994 of formal parameters are tested, and warnings given appropriately. Another use
1995 with a first parameter of True is to warn a client about use of a package,
1996 for example that it is not fully implemented.
1997
1998 @node Pragma Compiler_Unit
1999 @unnumberedsec Pragma Compiler_Unit
2000 @findex Compiler_Unit
2001 @noindent
2002 Syntax:
2003
2004 @smallexample @c ada
2005 pragma Compiler_Unit;
2006 @end smallexample
2007
2008 @noindent
2009 This pragma is intended only for internal use in the GNAT run-time library.
2010 It indicates that the unit is used as part of the compiler build. The effect
2011 is to disallow constructs (raise with message, conditional expressions etc)
2012 that would cause trouble when bootstrapping using an older version of GNAT.
2013 For the exact list of restrictions, see the compiler sources and references
2014 to Is_Compiler_Unit.
2015
2016 @node Pragma Complete_Representation
2017 @unnumberedsec Pragma Complete_Representation
2018 @findex Complete_Representation
2019 @noindent
2020 Syntax:
2021
2022 @smallexample @c ada
2023 pragma Complete_Representation;
2024 @end smallexample
2025
2026 @noindent
2027 This pragma must appear immediately within a record representation
2028 clause. Typical placements are before the first component clause
2029 or after the last component clause. The effect is to give an error
2030 message if any component is missing a component clause. This pragma
2031 may be used to ensure that a record representation clause is
2032 complete, and that this invariant is maintained if fields are
2033 added to the record in the future.
2034
2035 @node Pragma Complex_Representation
2036 @unnumberedsec Pragma Complex_Representation
2037 @findex Complex_Representation
2038 @noindent
2039 Syntax:
2040
2041 @smallexample @c ada
2042 pragma Complex_Representation
2043 ([Entity =>] LOCAL_NAME);
2044 @end smallexample
2045
2046 @noindent
2047 The @var{Entity} argument must be the name of a record type which has
2048 two fields of the same floating-point type. The effect of this pragma is
2049 to force gcc to use the special internal complex representation form for
2050 this record, which may be more efficient. Note that this may result in
2051 the code for this type not conforming to standard ABI (application
2052 binary interface) requirements for the handling of record types. For
2053 example, in some environments, there is a requirement for passing
2054 records by pointer, and the use of this pragma may result in passing
2055 this type in floating-point registers.
2056
2057 @node Pragma Component_Alignment
2058 @unnumberedsec Pragma Component_Alignment
2059 @cindex Alignments of components
2060 @findex Component_Alignment
2061 @noindent
2062 Syntax:
2063
2064 @smallexample @c ada
2065 pragma Component_Alignment (
2066 [Form =>] ALIGNMENT_CHOICE
2067 [, [Name =>] type_LOCAL_NAME]);
2068
2069 ALIGNMENT_CHOICE ::=
2070 Component_Size
2071 | Component_Size_4
2072 | Storage_Unit
2073 | Default
2074 @end smallexample
2075
2076 @noindent
2077 Specifies the alignment of components in array or record types.
2078 The meaning of the @var{Form} argument is as follows:
2079
2080 @table @code
2081 @findex Component_Size
2082 @item Component_Size
2083 Aligns scalar components and subcomponents of the array or record type
2084 on boundaries appropriate to their inherent size (naturally
2085 aligned). For example, 1-byte components are aligned on byte boundaries,
2086 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2087 integer components are aligned on 4-byte boundaries and so on. These
2088 alignment rules correspond to the normal rules for C compilers on all
2089 machines except the VAX@.
2090
2091 @findex Component_Size_4
2092 @item Component_Size_4
2093 Naturally aligns components with a size of four or fewer
2094 bytes. Components that are larger than 4 bytes are placed on the next
2095 4-byte boundary.
2096
2097 @findex Storage_Unit
2098 @item Storage_Unit
2099 Specifies that array or record components are byte aligned, i.e.@:
2100 aligned on boundaries determined by the value of the constant
2101 @code{System.Storage_Unit}.
2102
2103 @cindex OpenVMS
2104 @item Default
2105 Specifies that array or record components are aligned on default
2106 boundaries, appropriate to the underlying hardware or operating system or
2107 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
2108 the @code{Storage_Unit} choice (byte alignment). For all other systems,
2109 the @code{Default} choice is the same as @code{Component_Size} (natural
2110 alignment).
2111 @end table
2112
2113 @noindent
2114 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2115 refer to a local record or array type, and the specified alignment
2116 choice applies to the specified type. The use of
2117 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2118 @code{Component_Alignment} pragma to be ignored. The use of
2119 @code{Component_Alignment} together with a record representation clause
2120 is only effective for fields not specified by the representation clause.
2121
2122 If the @code{Name} parameter is absent, the pragma can be used as either
2123 a configuration pragma, in which case it applies to one or more units in
2124 accordance with the normal rules for configuration pragmas, or it can be
2125 used within a declarative part, in which case it applies to types that
2126 are declared within this declarative part, or within any nested scope
2127 within this declarative part. In either case it specifies the alignment
2128 to be applied to any record or array type which has otherwise standard
2129 representation.
2130
2131 If the alignment for a record or array type is not specified (using
2132 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2133 clause), the GNAT uses the default alignment as described previously.
2134
2135 @node Pragma Contract_Cases
2136 @unnumberedsec Pragma Contract_Cases
2137 @cindex Contract cases
2138 @findex Contract_Cases
2139 @noindent
2140 Syntax:
2141
2142 @smallexample @c ada
2143 pragma Contract_Cases (
2144 Condition => Consequence
2145 @{,Condition => Consequence@});
2146 @end smallexample
2147
2148 @noindent
2149 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2150 that can complement or replace the contract given by a precondition and a
2151 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2152 by testing and formal verification tools. The compiler checks its validity and,
2153 depending on the assertion policy at the point of declaration of the pragma,
2154 it may insert a check in the executable. For code generation, the contract
2155 cases
2156
2157 @smallexample @c ada
2158 pragma Contract_Cases (
2159 Cond1 => Pred1,
2160 Cond2 => Pred2);
2161 @end smallexample
2162
2163 @noindent
2164 are equivalent to
2165
2166 @smallexample @c ada
2167 C1 : constant Boolean := Cond1; -- evaluated at subprogram entry
2168 C2 : constant Boolean := Cond2; -- evaluated at subprogram entry
2169 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2170 pragma Postcondition (if C1 then Pred1);
2171 pragma Postcondition (if C2 then Pred2);
2172 @end smallexample
2173
2174 @noindent
2175 The precondition ensures that one and only one of the conditions is
2176 satisfied on entry to the subprogram.
2177 The postcondition ensures that for the condition that was True on entry,
2178 the corrresponding consequence is True on exit. Other consequence expressions
2179 are not evaluated.
2180
2181 A precondition @code{P} and postcondition @code{Q} can also be
2182 expressed as contract cases:
2183
2184 @smallexample @c ada
2185 pragma Contract_Cases (P => Q);
2186 @end smallexample
2187
2188 The placement and visibility rules for @code{Contract_Cases} pragmas are
2189 identical to those described for preconditions and postconditions.
2190
2191 The compiler checks that boolean expressions given in conditions and
2192 consequences are valid, where the rules for conditions are the same as
2193 the rule for an expression in @code{Precondition} and the rules for
2194 consequences are the same as the rule for an expression in
2195 @code{Postcondition}. In particular, attributes @code{'Old} and
2196 @code{'Result} can only be used within consequence expressions.
2197 The condition for the last contract case may be @code{others}, to denote
2198 any case not captured by the previous cases. The
2199 following is an example of use within a package spec:
2200
2201 @smallexample @c ada
2202 package Math_Functions is
2203 ...
2204 function Sqrt (Arg : Float) return Float;
2205 pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2206 Arg >= 100 => Sqrt'Result >= 10,
2207 others => Sqrt'Result = 0);
2208 ...
2209 end Math_Functions;
2210 @end smallexample
2211
2212 @noindent
2213 The meaning of contract cases is that only one case should apply at each
2214 call, as determined by the corresponding condition evaluating to True,
2215 and that the consequence for this case should hold when the subprogram
2216 returns.
2217
2218 @node Pragma Convention_Identifier
2219 @unnumberedsec Pragma Convention_Identifier
2220 @findex Convention_Identifier
2221 @cindex Conventions, synonyms
2222 @noindent
2223 Syntax:
2224
2225 @smallexample @c ada
2226 pragma Convention_Identifier (
2227 [Name =>] IDENTIFIER,
2228 [Convention =>] convention_IDENTIFIER);
2229 @end smallexample
2230
2231 @noindent
2232 This pragma provides a mechanism for supplying synonyms for existing
2233 convention identifiers. The @code{Name} identifier can subsequently
2234 be used as a synonym for the given convention in other pragmas (including
2235 for example pragma @code{Import} or another @code{Convention_Identifier}
2236 pragma). As an example of the use of this, suppose you had legacy code
2237 which used Fortran77 as the identifier for Fortran. Then the pragma:
2238
2239 @smallexample @c ada
2240 pragma Convention_Identifier (Fortran77, Fortran);
2241 @end smallexample
2242
2243 @noindent
2244 would allow the use of the convention identifier @code{Fortran77} in
2245 subsequent code, avoiding the need to modify the sources. As another
2246 example, you could use this to parameterize convention requirements
2247 according to systems. Suppose you needed to use @code{Stdcall} on
2248 windows systems, and @code{C} on some other system, then you could
2249 define a convention identifier @code{Library} and use a single
2250 @code{Convention_Identifier} pragma to specify which convention
2251 would be used system-wide.
2252
2253 @node Pragma CPP_Class
2254 @unnumberedsec Pragma CPP_Class
2255 @findex CPP_Class
2256 @cindex Interfacing with C++
2257 @noindent
2258 Syntax:
2259
2260 @smallexample @c ada
2261 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2262 @end smallexample
2263
2264 @noindent
2265 The argument denotes an entity in the current declarative region that is
2266 declared as a record type. It indicates that the type corresponds to an
2267 externally declared C++ class type, and is to be laid out the same way
2268 that C++ would lay out the type. If the C++ class has virtual primitives
2269 then the record must be declared as a tagged record type.
2270
2271 Types for which @code{CPP_Class} is specified do not have assignment or
2272 equality operators defined (such operations can be imported or declared
2273 as subprograms as required). Initialization is allowed only by constructor
2274 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2275 limited if not explicitly declared as limited or derived from a limited
2276 type, and an error is issued in that case.
2277
2278 See @ref{Interfacing to C++} for related information.
2279
2280 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2281 for backward compatibility but its functionality is available
2282 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2283
2284 @node Pragma CPP_Constructor
2285 @unnumberedsec Pragma CPP_Constructor
2286 @cindex Interfacing with C++
2287 @findex CPP_Constructor
2288 @noindent
2289 Syntax:
2290
2291 @smallexample @c ada
2292 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2293 [, [External_Name =>] static_string_EXPRESSION ]
2294 [, [Link_Name =>] static_string_EXPRESSION ]);
2295 @end smallexample
2296
2297 @noindent
2298 This pragma identifies an imported function (imported in the usual way
2299 with pragma @code{Import}) as corresponding to a C++ constructor. If
2300 @code{External_Name} and @code{Link_Name} are not specified then the
2301 @code{Entity} argument is a name that must have been previously mentioned
2302 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2303 must be of one of the following forms:
2304
2305 @itemize @bullet
2306 @item
2307 @code{function @var{Fname} return @var{T}}
2308
2309 @itemize @bullet
2310 @item
2311 @code{function @var{Fname} return @var{T}'Class}
2312
2313 @item
2314 @code{function @var{Fname} (@dots{}) return @var{T}}
2315 @end itemize
2316
2317 @item
2318 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2319 @end itemize
2320
2321 @noindent
2322 where @var{T} is a limited record type imported from C++ with pragma
2323 @code{Import} and @code{Convention} = @code{CPP}.
2324
2325 The first two forms import the default constructor, used when an object
2326 of type @var{T} is created on the Ada side with no explicit constructor.
2327 The latter two forms cover all the non-default constructors of the type.
2328 See the @value{EDITION} User's Guide for details.
2329
2330 If no constructors are imported, it is impossible to create any objects
2331 on the Ada side and the type is implicitly declared abstract.
2332
2333 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2334 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2335 GCC switch).
2336 See @ref{Interfacing to C++} for more related information.
2337
2338 Note: The use of functions returning class-wide types for constructors is
2339 currently obsolete. They are supported for backward compatibility. The
2340 use of functions returning the type T leave the Ada sources more clear
2341 because the imported C++ constructors always return an object of type T;
2342 that is, they never return an object whose type is a descendant of type T.
2343
2344 @node Pragma CPP_Virtual
2345 @unnumberedsec Pragma CPP_Virtual
2346 @cindex Interfacing to C++
2347 @findex CPP_Virtual
2348 @noindent
2349 This pragma is now obsolete and, other than generating a warning if warnings
2350 on obsolescent features are enabled, is completely ignored.
2351 It is retained for compatibility
2352 purposes. It used to be required to ensure compoatibility with C++, but
2353 is no longer required for that purpose because GNAT generates
2354 the same object layout as the G++ compiler by default.
2355
2356 See @ref{Interfacing to C++} for related information.
2357
2358 @node Pragma CPP_Vtable
2359 @unnumberedsec Pragma CPP_Vtable
2360 @cindex Interfacing with C++
2361 @findex CPP_Vtable
2362 @noindent
2363 This pragma is now obsolete and, other than generating a warning if warnings
2364 on obsolescent features are enabled, is completely ignored.
2365 It used to be required to ensure compatibility with C++, but
2366 is no longer required for that purpose because GNAT generates
2367 the same object layout than the G++ compiler by default.
2368
2369 See @ref{Interfacing to C++} for related information.
2370
2371 @node Pragma CPU
2372 @unnumberedsec Pragma CPU
2373 @findex CPU
2374 @noindent
2375 Syntax:
2376
2377 @smallexample @c ada
2378 pragma CPU (EXPRESSION);
2379 @end smallexample
2380
2381 @noindent
2382 This pragma is standard in Ada 2012, but is available in all earlier
2383 versions of Ada as an implementation-defined pragma.
2384 See Ada 2012 Reference Manual for details.
2385
2386 @node Pragma Debug
2387 @unnumberedsec Pragma Debug
2388 @findex Debug
2389 @noindent
2390 Syntax:
2391
2392 @smallexample @c ada
2393 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2394
2395 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2396 PROCEDURE_NAME
2397 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2398 @end smallexample
2399
2400 @noindent
2401 The procedure call argument has the syntactic form of an expression, meeting
2402 the syntactic requirements for pragmas.
2403
2404 If debug pragmas are not enabled or if the condition is present and evaluates
2405 to False, this pragma has no effect. If debug pragmas are enabled, the
2406 semantics of the pragma is exactly equivalent to the procedure call statement
2407 corresponding to the argument with a terminating semicolon. Pragmas are
2408 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2409 intersperse calls to debug procedures in the middle of declarations. Debug
2410 pragmas can be enabled either by use of the command line switch @option{-gnata}
2411 or by use of the pragma @code{Check_Policy} with a first argument of
2412 @code{Debug}.
2413
2414 @node Pragma Debug_Policy
2415 @unnumberedsec Pragma Debug_Policy
2416 @findex Debug_Policy
2417 @noindent
2418 Syntax:
2419
2420 @smallexample @c ada
2421 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2422 @end smallexample
2423
2424 @noindent
2425 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2426 with a first argument of @code{Debug}. It is retained for historical
2427 compatibility reasons.
2428
2429 @node Pragma Default_Storage_Pool
2430 @unnumberedsec Pragma Default_Storage_Pool
2431 @findex Default_Storage_Pool
2432 @noindent
2433 Syntax:
2434
2435 @smallexample @c ada
2436 pragma Default_Storage_Pool (storage_pool_NAME | null);
2437 @end smallexample
2438
2439 @noindent
2440 This pragma is standard in Ada 2012, but is available in all earlier
2441 versions of Ada as an implementation-defined pragma.
2442 See Ada 2012 Reference Manual for details.
2443
2444 @node Pragma Depends
2445 @unnumberedsec Pragma Depends
2446 @findex Depends
2447 @noindent
2448 For the description of this pragma, see SPARK 2014 Reference Manual,
2449 section 6.1.5.
2450
2451 @node Pragma Detect_Blocking
2452 @unnumberedsec Pragma Detect_Blocking
2453 @findex Detect_Blocking
2454 @noindent
2455 Syntax:
2456
2457 @smallexample @c ada
2458 pragma Detect_Blocking;
2459 @end smallexample
2460
2461 @noindent
2462 This is a standard pragma in Ada 2005, that is available in all earlier
2463 versions of Ada as an implementation-defined pragma.
2464
2465 This is a configuration pragma that forces the detection of potentially
2466 blocking operations within a protected operation, and to raise Program_Error
2467 if that happens.
2468
2469 @node Pragma Disable_Atomic_Synchronization
2470 @unnumberedsec Pragma Disable_Atomic_Synchronization
2471 @cindex Atomic Synchronization
2472 @findex Disable_Atomic_Synchronization
2473 @noindent
2474 Syntax:
2475
2476 @smallexample @c ada
2477 pragma Disable_Atomic_Synchronization [(Entity)];
2478 @end smallexample
2479
2480 @noindent
2481 Ada requires that accesses (reads or writes) of an atomic variable be
2482 regarded as synchronization points in the case of multiple tasks.
2483 Particularly in the case of multi-processors this may require special
2484 handling, e.g. the generation of memory barriers. This capability may
2485 be turned off using this pragma in cases where it is known not to be
2486 required.
2487
2488 The placement and scope rules for this pragma are the same as those
2489 for @code{pragma Suppress}. In particular it can be used as a
2490 configuration pragma, or in a declaration sequence where it applies
2491 till the end of the scope. If an @code{Entity} argument is present,
2492 the action applies only to that entity.
2493
2494 @node Pragma Dispatching_Domain
2495 @unnumberedsec Pragma Dispatching_Domain
2496 @findex Dispatching_Domain
2497 @noindent
2498 Syntax:
2499
2500 @smallexample @c ada
2501 pragma Dispatching_Domain (EXPRESSION);
2502 @end smallexample
2503
2504 @noindent
2505 This pragma is standard in Ada 2012, but is available in all earlier
2506 versions of Ada as an implementation-defined pragma.
2507 See Ada 2012 Reference Manual for details.
2508
2509 @node Pragma Elaboration_Checks
2510 @unnumberedsec Pragma Elaboration_Checks
2511 @cindex Elaboration control
2512 @findex Elaboration_Checks
2513 @noindent
2514 Syntax:
2515
2516 @smallexample @c ada
2517 pragma Elaboration_Checks (Dynamic | Static);
2518 @end smallexample
2519
2520 @noindent
2521 This is a configuration pragma that provides control over the
2522 elaboration model used by the compilation affected by the
2523 pragma. If the parameter is @code{Dynamic},
2524 then the dynamic elaboration
2525 model described in the Ada Reference Manual is used, as though
2526 the @option{-gnatE} switch had been specified on the command
2527 line. If the parameter is @code{Static}, then the default GNAT static
2528 model is used. This configuration pragma overrides the setting
2529 of the command line. For full details on the elaboration models
2530 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2531 gnat_ugn, @value{EDITION} User's Guide}.
2532
2533 @node Pragma Eliminate
2534 @unnumberedsec Pragma Eliminate
2535 @cindex Elimination of unused subprograms
2536 @findex Eliminate
2537 @noindent
2538 Syntax:
2539
2540 @smallexample @c ada
2541 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2542 [Source_Location =>] STRING_LITERAL);
2543 @end smallexample
2544
2545 @noindent
2546 The string literal given for the source location is a string which
2547 specifies the line number of the occurrence of the entity, using
2548 the syntax for SOURCE_TRACE given below:
2549
2550 @smallexample @c ada
2551 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2552
2553 LBRACKET ::= [
2554 RBRACKET ::= ]
2555
2556 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2557
2558 LINE_NUMBER ::= DIGIT @{DIGIT@}
2559 @end smallexample
2560
2561 @noindent
2562 Spaces around the colon in a @code{Source_Reference} are optional.
2563
2564 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2565 explicit subprogram declaration, where the @code{entity} name in this
2566 designator appears on the source line specified by the source location.
2567
2568 The source trace that is given as the @code{Source_Location} shall obey the
2569 following rules. The @code{FILE_NAME} is the short name (with no directory
2570 information) of an Ada source file, given using exactly the required syntax
2571 for the underlying file system (e.g. case is important if the underlying
2572 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2573 number of the occurrence of the @code{entity}
2574 as a decimal literal without an exponent or point. If an @code{entity} is not
2575 declared in a generic instantiation (this includes generic subprogram
2576 instances), the source trace includes only one source reference. If an entity
2577 is declared inside a generic instantiation, its source trace (when parsing
2578 from left to right) starts with the source location of the declaration of the
2579 entity in the generic unit and ends with the source location of the
2580 instantiation (it is given in square brackets). This approach is recursively
2581 used in case of nested instantiations: the rightmost (nested most deeply in
2582 square brackets) element of the source trace is the location of the outermost
2583 instantiation, the next to left element is the location of the next (first
2584 nested) instantiation in the code of the corresponding generic unit, and so
2585 on, and the leftmost element (that is out of any square brackets) is the
2586 location of the declaration of the entity to eliminate in a generic unit.
2587
2588 Note that the @code{Source_Location} argument specifies which of a set of
2589 similarly named entities is being eliminated, dealing both with overloading,
2590 and also appearance of the same entity name in different scopes.
2591
2592 This pragma indicates that the given entity is not used in the program to be
2593 compiled and built. The effect of the pragma is to allow the compiler to
2594 eliminate the code or data associated with the named entity. Any reference to
2595 an eliminated entity causes a compile-time or link-time error.
2596
2597 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2598 in a system-independent manner, with unused entities eliminated, without
2599 needing to modify the source text. Normally the required set of
2600 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2601
2602 Any source file change that removes, splits, or
2603 adds lines may make the set of Eliminate pragmas invalid because their
2604 @code{Source_Location} argument values may get out of date.
2605
2606 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2607 operation. In this case all the subprograms to which the given operation can
2608 dispatch are considered to be unused (are never called as a result of a direct
2609 or a dispatching call).
2610
2611 @node Pragma Enable_Atomic_Synchronization
2612 @unnumberedsec Pragma Enable_Atomic_Synchronization
2613 @cindex Atomic Synchronization
2614 @findex Enable_Atomic_Synchronization
2615 @noindent
2616 Syntax:
2617
2618 @smallexample @c ada
2619 pragma Enable_Atomic_Synchronization [(Entity)];
2620 @end smallexample
2621
2622 @noindent
2623 Ada requires that accesses (reads or writes) of an atomic variable be
2624 regarded as synchronization points in the case of multiple tasks.
2625 Particularly in the case of multi-processors this may require special
2626 handling, e.g. the generation of memory barriers. This synchronization
2627 is performed by default, but can be turned off using
2628 @code{pragma Disable_Atomic_Synchronization}. The
2629 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2630 it back on.
2631
2632 The placement and scope rules for this pragma are the same as those
2633 for @code{pragma Unsuppress}. In particular it can be used as a
2634 configuration pragma, or in a declaration sequence where it applies
2635 till the end of the scope. If an @code{Entity} argument is present,
2636 the action applies only to that entity.
2637
2638 @node Pragma Export_Exception
2639 @unnumberedsec Pragma Export_Exception
2640 @cindex OpenVMS
2641 @findex Export_Exception
2642 @noindent
2643 Syntax:
2644
2645 @smallexample @c ada
2646 pragma Export_Exception (
2647 [Internal =>] LOCAL_NAME
2648 [, [External =>] EXTERNAL_SYMBOL]
2649 [, [Form =>] Ada | VMS]
2650 [, [Code =>] static_integer_EXPRESSION]);
2651
2652 EXTERNAL_SYMBOL ::=
2653 IDENTIFIER
2654 | static_string_EXPRESSION
2655 @end smallexample
2656
2657 @noindent
2658 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2659 causes the specified exception to be propagated outside of the Ada program,
2660 so that it can be handled by programs written in other OpenVMS languages.
2661 This pragma establishes an external name for an Ada exception and makes the
2662 name available to the OpenVMS Linker as a global symbol. For further details
2663 on this pragma, see the
2664 DEC Ada Language Reference Manual, section 13.9a3.2.
2665
2666 @node Pragma Export_Function
2667 @unnumberedsec Pragma Export_Function
2668 @cindex Argument passing mechanisms
2669 @findex Export_Function
2670
2671 @noindent
2672 Syntax:
2673
2674 @smallexample @c ada
2675 pragma Export_Function (
2676 [Internal =>] LOCAL_NAME
2677 [, [External =>] EXTERNAL_SYMBOL]
2678 [, [Parameter_Types =>] PARAMETER_TYPES]
2679 [, [Result_Type =>] result_SUBTYPE_MARK]
2680 [, [Mechanism =>] MECHANISM]
2681 [, [Result_Mechanism =>] MECHANISM_NAME]);
2682
2683 EXTERNAL_SYMBOL ::=
2684 IDENTIFIER
2685 | static_string_EXPRESSION
2686 | ""
2687
2688 PARAMETER_TYPES ::=
2689 null
2690 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2691
2692 TYPE_DESIGNATOR ::=
2693 subtype_NAME
2694 | subtype_Name ' Access
2695
2696 MECHANISM ::=
2697 MECHANISM_NAME
2698 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2699
2700 MECHANISM_ASSOCIATION ::=
2701 [formal_parameter_NAME =>] MECHANISM_NAME
2702
2703 MECHANISM_NAME ::=
2704 Value
2705 | Reference
2706 | Descriptor [([Class =>] CLASS_NAME)]
2707 | Short_Descriptor [([Class =>] CLASS_NAME)]
2708
2709 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2710 @end smallexample
2711
2712 @noindent
2713 Use this pragma to make a function externally callable and optionally
2714 provide information on mechanisms to be used for passing parameter and
2715 result values. We recommend, for the purposes of improving portability,
2716 this pragma always be used in conjunction with a separate pragma
2717 @code{Export}, which must precede the pragma @code{Export_Function}.
2718 GNAT does not require a separate pragma @code{Export}, but if none is
2719 present, @code{Convention Ada} is assumed, which is usually
2720 not what is wanted, so it is usually appropriate to use this
2721 pragma in conjunction with a @code{Export} or @code{Convention}
2722 pragma that specifies the desired foreign convention.
2723 Pragma @code{Export_Function}
2724 (and @code{Export}, if present) must appear in the same declarative
2725 region as the function to which they apply.
2726
2727 @var{internal_name} must uniquely designate the function to which the
2728 pragma applies. If more than one function name exists of this name in
2729 the declarative part you must use the @code{Parameter_Types} and
2730 @code{Result_Type} parameters is mandatory to achieve the required
2731 unique designation. @var{subtype_mark}s in these parameters must
2732 exactly match the subtypes in the corresponding function specification,
2733 using positional notation to match parameters with subtype marks.
2734 The form with an @code{'Access} attribute can be used to match an
2735 anonymous access parameter.
2736
2737 @cindex OpenVMS
2738 @cindex Passing by descriptor
2739 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2740 The default behavior for Export_Function is to accept either 64bit or
2741 32bit descriptors unless short_descriptor is specified, then only 32bit
2742 descriptors are accepted.
2743
2744 @cindex Suppressing external name
2745 Special treatment is given if the EXTERNAL is an explicit null
2746 string or a static string expressions that evaluates to the null
2747 string. In this case, no external name is generated. This form
2748 still allows the specification of parameter mechanisms.
2749
2750 @node Pragma Export_Object
2751 @unnumberedsec Pragma Export_Object
2752 @findex Export_Object
2753 @noindent
2754 Syntax:
2755
2756 @smallexample @c ada
2757 pragma Export_Object
2758 [Internal =>] LOCAL_NAME
2759 [, [External =>] EXTERNAL_SYMBOL]
2760 [, [Size =>] EXTERNAL_SYMBOL]
2761
2762 EXTERNAL_SYMBOL ::=
2763 IDENTIFIER
2764 | static_string_EXPRESSION
2765 @end smallexample
2766
2767 @noindent
2768 This pragma designates an object as exported, and apart from the
2769 extended rules for external symbols, is identical in effect to the use of
2770 the normal @code{Export} pragma applied to an object. You may use a
2771 separate Export pragma (and you probably should from the point of view
2772 of portability), but it is not required. @var{Size} is syntax checked,
2773 but otherwise ignored by GNAT@.
2774
2775 @node Pragma Export_Procedure
2776 @unnumberedsec Pragma Export_Procedure
2777 @findex Export_Procedure
2778 @noindent
2779 Syntax:
2780
2781 @smallexample @c ada
2782 pragma Export_Procedure (
2783 [Internal =>] LOCAL_NAME
2784 [, [External =>] EXTERNAL_SYMBOL]
2785 [, [Parameter_Types =>] PARAMETER_TYPES]
2786 [, [Mechanism =>] MECHANISM]);
2787
2788 EXTERNAL_SYMBOL ::=
2789 IDENTIFIER
2790 | static_string_EXPRESSION
2791 | ""
2792
2793 PARAMETER_TYPES ::=
2794 null
2795 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2796
2797 TYPE_DESIGNATOR ::=
2798 subtype_NAME
2799 | subtype_Name ' Access
2800
2801 MECHANISM ::=
2802 MECHANISM_NAME
2803 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2804
2805 MECHANISM_ASSOCIATION ::=
2806 [formal_parameter_NAME =>] MECHANISM_NAME
2807
2808 MECHANISM_NAME ::=
2809 Value
2810 | Reference
2811 | Descriptor [([Class =>] CLASS_NAME)]
2812 | Short_Descriptor [([Class =>] CLASS_NAME)]
2813
2814 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2815 @end smallexample
2816
2817 @noindent
2818 This pragma is identical to @code{Export_Function} except that it
2819 applies to a procedure rather than a function and the parameters
2820 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2821 GNAT does not require a separate pragma @code{Export}, but if none is
2822 present, @code{Convention Ada} is assumed, which is usually
2823 not what is wanted, so it is usually appropriate to use this
2824 pragma in conjunction with a @code{Export} or @code{Convention}
2825 pragma that specifies the desired foreign convention.
2826
2827 @cindex OpenVMS
2828 @cindex Passing by descriptor
2829 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2830 The default behavior for Export_Procedure is to accept either 64bit or
2831 32bit descriptors unless short_descriptor is specified, then only 32bit
2832 descriptors are accepted.
2833
2834 @cindex Suppressing external name
2835 Special treatment is given if the EXTERNAL is an explicit null
2836 string or a static string expressions that evaluates to the null
2837 string. In this case, no external name is generated. This form
2838 still allows the specification of parameter mechanisms.
2839
2840 @node Pragma Export_Value
2841 @unnumberedsec Pragma Export_Value
2842 @findex Export_Value
2843 @noindent
2844 Syntax:
2845
2846 @smallexample @c ada
2847 pragma Export_Value (
2848 [Value =>] static_integer_EXPRESSION,
2849 [Link_Name =>] static_string_EXPRESSION);
2850 @end smallexample
2851
2852 @noindent
2853 This pragma serves to export a static integer value for external use.
2854 The first argument specifies the value to be exported. The Link_Name
2855 argument specifies the symbolic name to be associated with the integer
2856 value. This pragma is useful for defining a named static value in Ada
2857 that can be referenced in assembly language units to be linked with
2858 the application. This pragma is currently supported only for the
2859 AAMP target and is ignored for other targets.
2860
2861 @node Pragma Export_Valued_Procedure
2862 @unnumberedsec Pragma Export_Valued_Procedure
2863 @findex Export_Valued_Procedure
2864 @noindent
2865 Syntax:
2866
2867 @smallexample @c ada
2868 pragma Export_Valued_Procedure (
2869 [Internal =>] LOCAL_NAME
2870 [, [External =>] EXTERNAL_SYMBOL]
2871 [, [Parameter_Types =>] PARAMETER_TYPES]
2872 [, [Mechanism =>] MECHANISM]);
2873
2874 EXTERNAL_SYMBOL ::=
2875 IDENTIFIER
2876 | static_string_EXPRESSION
2877 | ""
2878
2879 PARAMETER_TYPES ::=
2880 null
2881 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2882
2883 TYPE_DESIGNATOR ::=
2884 subtype_NAME
2885 | subtype_Name ' Access
2886
2887 MECHANISM ::=
2888 MECHANISM_NAME
2889 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2890
2891 MECHANISM_ASSOCIATION ::=
2892 [formal_parameter_NAME =>] MECHANISM_NAME
2893
2894 MECHANISM_NAME ::=
2895 Value
2896 | Reference
2897 | Descriptor [([Class =>] CLASS_NAME)]
2898 | Short_Descriptor [([Class =>] CLASS_NAME)]
2899
2900 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2901 @end smallexample
2902
2903 @noindent
2904 This pragma is identical to @code{Export_Procedure} except that the
2905 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2906 mode @code{OUT}, and externally the subprogram is treated as a function
2907 with this parameter as the result of the function. GNAT provides for
2908 this capability to allow the use of @code{OUT} and @code{IN OUT}
2909 parameters in interfacing to external functions (which are not permitted
2910 in Ada functions).
2911 GNAT does not require a separate pragma @code{Export}, but if none is
2912 present, @code{Convention Ada} is assumed, which is almost certainly
2913 not what is wanted since the whole point of this pragma is to interface
2914 with foreign language functions, so it is usually appropriate to use this
2915 pragma in conjunction with a @code{Export} or @code{Convention}
2916 pragma that specifies the desired foreign convention.
2917
2918 @cindex OpenVMS
2919 @cindex Passing by descriptor
2920 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2921 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2922 32bit descriptors unless short_descriptor is specified, then only 32bit
2923 descriptors are accepted.
2924
2925 @cindex Suppressing external name
2926 Special treatment is given if the EXTERNAL is an explicit null
2927 string or a static string expressions that evaluates to the null
2928 string. In this case, no external name is generated. This form
2929 still allows the specification of parameter mechanisms.
2930
2931 @node Pragma Extend_System
2932 @unnumberedsec Pragma Extend_System
2933 @cindex @code{system}, extending
2934 @cindex Dec Ada 83
2935 @findex Extend_System
2936 @noindent
2937 Syntax:
2938
2939 @smallexample @c ada
2940 pragma Extend_System ([Name =>] IDENTIFIER);
2941 @end smallexample
2942
2943 @noindent
2944 This pragma is used to provide backwards compatibility with other
2945 implementations that extend the facilities of package @code{System}. In
2946 GNAT, @code{System} contains only the definitions that are present in
2947 the Ada RM@. However, other implementations, notably the DEC Ada 83
2948 implementation, provide many extensions to package @code{System}.
2949
2950 For each such implementation accommodated by this pragma, GNAT provides a
2951 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2952 implementation, which provides the required additional definitions. You
2953 can use this package in two ways. You can @code{with} it in the normal
2954 way and access entities either by selection or using a @code{use}
2955 clause. In this case no special processing is required.
2956
2957 However, if existing code contains references such as
2958 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2959 definitions provided in package @code{System}, you may use this pragma
2960 to extend visibility in @code{System} in a non-standard way that
2961 provides greater compatibility with the existing code. Pragma
2962 @code{Extend_System} is a configuration pragma whose single argument is
2963 the name of the package containing the extended definition
2964 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2965 control of this pragma will be processed using special visibility
2966 processing that looks in package @code{System.Aux_@var{xxx}} where
2967 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2968 package @code{System}, but not found in package @code{System}.
2969
2970 You can use this pragma either to access a predefined @code{System}
2971 extension supplied with the compiler, for example @code{Aux_DEC} or
2972 you can construct your own extension unit following the above
2973 definition. Note that such a package is a child of @code{System}
2974 and thus is considered part of the implementation. To compile
2975 it you will have to use the appropriate switch for compiling
2976 system units.
2977 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2978 for details.
2979
2980 @node Pragma Extensions_Allowed
2981 @unnumberedsec Pragma Extensions_Allowed
2982 @cindex Ada Extensions
2983 @cindex GNAT Extensions
2984 @findex Extensions_Allowed
2985 @noindent
2986 Syntax:
2987
2988 @smallexample @c ada
2989 pragma Extensions_Allowed (On | Off);
2990 @end smallexample
2991
2992 @noindent
2993 This configuration pragma enables or disables the implementation
2994 extension mode (the use of Off as a parameter cancels the effect
2995 of the @option{-gnatX} command switch).
2996
2997 In extension mode, the latest version of the Ada language is
2998 implemented (currently Ada 2012), and in addition a small number
2999 of GNAT specific extensions are recognized as follows:
3000
3001 @table @asis
3002 @item Constrained attribute for generic objects
3003 The @code{Constrained} attribute is permitted for objects of
3004 generic types. The result indicates if the corresponding actual
3005 is constrained.
3006
3007 @end table
3008
3009 @node Pragma External
3010 @unnumberedsec Pragma External
3011 @findex External
3012 @noindent
3013 Syntax:
3014
3015 @smallexample @c ada
3016 pragma External (
3017 [ Convention =>] convention_IDENTIFIER,
3018 [ Entity =>] LOCAL_NAME
3019 [, [External_Name =>] static_string_EXPRESSION ]
3020 [, [Link_Name =>] static_string_EXPRESSION ]);
3021 @end smallexample
3022
3023 @noindent
3024 This pragma is identical in syntax and semantics to pragma
3025 @code{Export} as defined in the Ada Reference Manual. It is
3026 provided for compatibility with some Ada 83 compilers that
3027 used this pragma for exactly the same purposes as pragma
3028 @code{Export} before the latter was standardized.
3029
3030 @node Pragma External_Name_Casing
3031 @unnumberedsec Pragma External_Name_Casing
3032 @cindex Dec Ada 83 casing compatibility
3033 @cindex External Names, casing
3034 @cindex Casing of External names
3035 @findex External_Name_Casing
3036 @noindent
3037 Syntax:
3038
3039 @smallexample @c ada
3040 pragma External_Name_Casing (
3041 Uppercase | Lowercase
3042 [, Uppercase | Lowercase | As_Is]);
3043 @end smallexample
3044
3045 @noindent
3046 This pragma provides control over the casing of external names associated
3047 with Import and Export pragmas. There are two cases to consider:
3048
3049 @table @asis
3050 @item Implicit external names
3051 Implicit external names are derived from identifiers. The most common case
3052 arises when a standard Ada Import or Export pragma is used with only two
3053 arguments, as in:
3054
3055 @smallexample @c ada
3056 pragma Import (C, C_Routine);
3057 @end smallexample
3058
3059 @noindent
3060 Since Ada is a case-insensitive language, the spelling of the identifier in
3061 the Ada source program does not provide any information on the desired
3062 casing of the external name, and so a convention is needed. In GNAT the
3063 default treatment is that such names are converted to all lower case
3064 letters. This corresponds to the normal C style in many environments.
3065 The first argument of pragma @code{External_Name_Casing} can be used to
3066 control this treatment. If @code{Uppercase} is specified, then the name
3067 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3068 then the normal default of all lower case letters will be used.
3069
3070 This same implicit treatment is also used in the case of extended DEC Ada 83
3071 compatible Import and Export pragmas where an external name is explicitly
3072 specified using an identifier rather than a string.
3073
3074 @item Explicit external names
3075 Explicit external names are given as string literals. The most common case
3076 arises when a standard Ada Import or Export pragma is used with three
3077 arguments, as in:
3078
3079 @smallexample @c ada
3080 pragma Import (C, C_Routine, "C_routine");
3081 @end smallexample
3082
3083 @noindent
3084 In this case, the string literal normally provides the exact casing required
3085 for the external name. The second argument of pragma
3086 @code{External_Name_Casing} may be used to modify this behavior.
3087 If @code{Uppercase} is specified, then the name
3088 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3089 then the name will be forced to all lowercase letters. A specification of
3090 @code{As_Is} provides the normal default behavior in which the casing is
3091 taken from the string provided.
3092 @end table
3093
3094 @noindent
3095 This pragma may appear anywhere that a pragma is valid. In particular, it
3096 can be used as a configuration pragma in the @file{gnat.adc} file, in which
3097 case it applies to all subsequent compilations, or it can be used as a program
3098 unit pragma, in which case it only applies to the current unit, or it can
3099 be used more locally to control individual Import/Export pragmas.
3100
3101 It is primarily intended for use with OpenVMS systems, where many
3102 compilers convert all symbols to upper case by default. For interfacing to
3103 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3104 the pragma:
3105
3106 @smallexample @c ada
3107 pragma External_Name_Casing (Uppercase, Uppercase);
3108 @end smallexample
3109
3110 @noindent
3111 to enforce the upper casing of all external symbols.
3112
3113 @node Pragma Fast_Math
3114 @unnumberedsec Pragma Fast_Math
3115 @findex Fast_Math
3116 @noindent
3117 Syntax:
3118
3119 @smallexample @c ada
3120 pragma Fast_Math;
3121 @end smallexample
3122
3123 @noindent
3124 This is a configuration pragma which activates a mode in which speed is
3125 considered more important for floating-point operations than absolutely
3126 accurate adherence to the requirements of the standard. Currently the
3127 following operations are affected:
3128
3129 @table @asis
3130 @item Complex Multiplication
3131 The normal simple formula for complex multiplication can result in intermediate
3132 overflows for numbers near the end of the range. The Ada standard requires that
3133 this situation be detected and corrected by scaling, but in Fast_Math mode such
3134 cases will simply result in overflow. Note that to take advantage of this you
3135 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3136 under control of the pragma, rather than use the preinstantiated versions.
3137 @end table
3138
3139 @node Pragma Favor_Top_Level
3140 @unnumberedsec Pragma Favor_Top_Level
3141 @findex Favor_Top_Level
3142 @noindent
3143 Syntax:
3144
3145 @smallexample @c ada
3146 pragma Favor_Top_Level (type_NAME);
3147 @end smallexample
3148
3149 @noindent
3150 The named type must be an access-to-subprogram type. This pragma is an
3151 efficiency hint to the compiler, regarding the use of 'Access or
3152 'Unrestricted_Access on nested (non-library-level) subprograms. The
3153 pragma means that nested subprograms are not used with this type, or
3154 are rare, so that the generated code should be efficient in the
3155 top-level case. When this pragma is used, dynamically generated
3156 trampolines may be used on some targets for nested subprograms.
3157 See also the No_Implicit_Dynamic_Code restriction.
3158
3159 @node Pragma Finalize_Storage_Only
3160 @unnumberedsec Pragma Finalize_Storage_Only
3161 @findex Finalize_Storage_Only
3162 @noindent
3163 Syntax:
3164
3165 @smallexample @c ada
3166 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3167 @end smallexample
3168
3169 @noindent
3170 This pragma allows the compiler not to emit a Finalize call for objects
3171 defined at the library level. This is mostly useful for types where
3172 finalization is only used to deal with storage reclamation since in most
3173 environments it is not necessary to reclaim memory just before terminating
3174 execution, hence the name.
3175
3176 @node Pragma Float_Representation
3177 @unnumberedsec Pragma Float_Representation
3178 @cindex OpenVMS
3179 @findex Float_Representation
3180 @noindent
3181 Syntax:
3182
3183 @smallexample @c ada
3184 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3185
3186 FLOAT_REP ::= VAX_Float | IEEE_Float
3187 @end smallexample
3188
3189 @noindent
3190 In the one argument form, this pragma is a configuration pragma which
3191 allows control over the internal representation chosen for the predefined
3192 floating point types declared in the packages @code{Standard} and
3193 @code{System}. On all systems other than OpenVMS, the argument must
3194 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3195 argument may be @code{VAX_Float} to specify the use of the VAX float
3196 format for the floating-point types in Standard. This requires that
3197 the standard runtime libraries be recompiled.
3198
3199 The two argument form specifies the representation to be used for
3200 the specified floating-point type. On all systems other than OpenVMS,
3201 the argument must
3202 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3203
3204 @itemize @bullet
3205 @item
3206 For a digits value of 6, 32-bit IEEE short format will be used.
3207 @item
3208 For a digits value of 15, 64-bit IEEE long format will be used.
3209 @item
3210 No other value of digits is permitted.
3211 @end itemize
3212
3213 On OpenVMS, the
3214 argument may be @code{VAX_Float} to specify the use of the VAX float
3215 format, as follows:
3216
3217 @itemize @bullet
3218 @item
3219 For digits values up to 6, F float format will be used.
3220 @item
3221 For digits values from 7 to 9, D float format will be used.
3222 @item
3223 For digits values from 10 to 15, G float format will be used.
3224 @item
3225 Digits values above 15 are not allowed.
3226 @end itemize
3227
3228 @node Pragma Global
3229 @unnumberedsec Pragma Global
3230 @findex Global
3231 @noindent
3232 For the description of this pragma, see SPARK 2014 Reference Manual,
3233 section 6.1.4.
3234
3235 @node Pragma Ident
3236 @unnumberedsec Pragma Ident
3237 @findex Ident
3238 @noindent
3239 Syntax:
3240
3241 @smallexample @c ada
3242 pragma Ident (static_string_EXPRESSION);
3243 @end smallexample
3244
3245 @noindent
3246 This pragma provides a string identification in the generated object file,
3247 if the system supports the concept of this kind of identification string.
3248 This pragma is allowed only in the outermost declarative part or
3249 declarative items of a compilation unit. If more than one @code{Ident}
3250 pragma is given, only the last one processed is effective.
3251 @cindex OpenVMS
3252 On OpenVMS systems, the effect of the pragma is identical to the effect of
3253 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
3254 maximum allowed length is 31 characters, so if it is important to
3255 maintain compatibility with this compiler, you should obey this length
3256 limit.
3257
3258 @node Pragma Implementation_Defined
3259 @unnumberedsec Pragma Implementation_Defined
3260 @findex Implementation_Defined
3261 @noindent
3262 Syntax:
3263
3264 @smallexample @c ada
3265 pragma Implementation_Defined (local_NAME);
3266 @end smallexample
3267
3268 @noindent
3269 This pragma marks a previously declared entioty as implementation-defined.
3270 For an overloaded entity, applies to the most recent homonym.
3271
3272 @smallexample @c ada
3273 pragma Implementation_Defined;
3274 @end smallexample
3275
3276 @noindent
3277 The form with no arguments appears anywhere within a scope, most
3278 typically a package spec, and indicates that all entities that are
3279 defined within the package spec are Implementation_Defined.
3280
3281 This pragma is used within the GNAT runtime library to identify
3282 implementation-defined entities introduced in language-defined units,
3283 for the purpose of implementing the No_Implementation_Identifiers
3284 restriction.
3285
3286 @node Pragma Implemented
3287 @unnumberedsec Pragma Implemented
3288 @findex Implemented
3289 @noindent
3290 Syntax:
3291
3292 @smallexample @c ada
3293 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3294
3295 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3296 @end smallexample
3297
3298 @noindent
3299 This is an Ada 2012 representation pragma which applies to protected, task
3300 and synchronized interface primitives. The use of pragma Implemented provides
3301 a way to impose a static requirement on the overriding operation by adhering
3302 to one of the three implementation kinds: entry, protected procedure or any of
3303 the above. This pragma is available in all earlier versions of Ada as an
3304 implementation-defined pragma.
3305
3306 @smallexample @c ada
3307 type Synch_Iface is synchronized interface;
3308 procedure Prim_Op (Obj : in out Iface) is abstract;
3309 pragma Implemented (Prim_Op, By_Protected_Procedure);
3310
3311 protected type Prot_1 is new Synch_Iface with
3312 procedure Prim_Op; -- Legal
3313 end Prot_1;
3314
3315 protected type Prot_2 is new Synch_Iface with
3316 entry Prim_Op; -- Illegal
3317 end Prot_2;
3318
3319 task type Task_Typ is new Synch_Iface with
3320 entry Prim_Op; -- Illegal
3321 end Task_Typ;
3322 @end smallexample
3323
3324 @noindent
3325 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3326 Implemented determines the runtime behavior of the requeue. Implementation kind
3327 By_Entry guarantees that the action of requeueing will proceed from an entry to
3328 another entry. Implementation kind By_Protected_Procedure transforms the
3329 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3330 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3331 the target's overriding subprogram kind.
3332
3333 @node Pragma Implicit_Packing
3334 @unnumberedsec Pragma Implicit_Packing
3335 @findex Implicit_Packing
3336 @cindex Rational Profile
3337 @noindent
3338 Syntax:
3339
3340 @smallexample @c ada
3341 pragma Implicit_Packing;
3342 @end smallexample
3343
3344 @noindent
3345 This is a configuration pragma that requests implicit packing for packed
3346 arrays for which a size clause is given but no explicit pragma Pack or
3347 specification of Component_Size is present. It also applies to records
3348 where no record representation clause is present. Consider this example:
3349
3350 @smallexample @c ada
3351 type R is array (0 .. 7) of Boolean;
3352 for R'Size use 8;
3353 @end smallexample
3354
3355 @noindent
3356 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3357 does not change the layout of a composite object. So the Size clause in the
3358 above example is normally rejected, since the default layout of the array uses
3359 8-bit components, and thus the array requires a minimum of 64 bits.
3360
3361 If this declaration is compiled in a region of code covered by an occurrence
3362 of the configuration pragma Implicit_Packing, then the Size clause in this
3363 and similar examples will cause implicit packing and thus be accepted. For
3364 this implicit packing to occur, the type in question must be an array of small
3365 components whose size is known at compile time, and the Size clause must
3366 specify the exact size that corresponds to the number of elements in the array
3367 multiplied by the size in bits of the component type (both single and
3368 multi-dimensioned arrays can be controlled with this pragma).
3369
3370 @cindex Array packing
3371
3372 Similarly, the following example shows the use in the record case
3373
3374 @smallexample @c ada
3375 type r is record
3376 a, b, c, d, e, f, g, h : boolean;
3377 chr : character;
3378 end record;
3379 for r'size use 16;
3380 @end smallexample
3381
3382 @noindent
3383 Without a pragma Pack, each Boolean field requires 8 bits, so the
3384 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3385 sufficient. The use of pragma Implicit_Packing allows this record
3386 declaration to compile without an explicit pragma Pack.
3387 @node Pragma Import_Exception
3388 @unnumberedsec Pragma Import_Exception
3389 @cindex OpenVMS
3390 @findex Import_Exception
3391 @noindent
3392 Syntax:
3393
3394 @smallexample @c ada
3395 pragma Import_Exception (
3396 [Internal =>] LOCAL_NAME
3397 [, [External =>] EXTERNAL_SYMBOL]
3398 [, [Form =>] Ada | VMS]
3399 [, [Code =>] static_integer_EXPRESSION]);
3400
3401 EXTERNAL_SYMBOL ::=
3402 IDENTIFIER
3403 | static_string_EXPRESSION
3404 @end smallexample
3405
3406 @noindent
3407 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3408 It allows OpenVMS conditions (for example, from OpenVMS system services or
3409 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3410 The pragma specifies that the exception associated with an exception
3411 declaration in an Ada program be defined externally (in non-Ada code).
3412 For further details on this pragma, see the
3413 DEC Ada Language Reference Manual, section 13.9a.3.1.
3414
3415 @node Pragma Import_Function
3416 @unnumberedsec Pragma Import_Function
3417 @findex Import_Function
3418 @noindent
3419 Syntax:
3420
3421 @smallexample @c ada
3422 pragma Import_Function (
3423 [Internal =>] LOCAL_NAME,
3424 [, [External =>] EXTERNAL_SYMBOL]
3425 [, [Parameter_Types =>] PARAMETER_TYPES]
3426 [, [Result_Type =>] SUBTYPE_MARK]
3427 [, [Mechanism =>] MECHANISM]
3428 [, [Result_Mechanism =>] MECHANISM_NAME]
3429 [, [First_Optional_Parameter =>] IDENTIFIER]);
3430
3431 EXTERNAL_SYMBOL ::=
3432 IDENTIFIER
3433 | static_string_EXPRESSION
3434
3435 PARAMETER_TYPES ::=
3436 null
3437 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3438
3439 TYPE_DESIGNATOR ::=
3440 subtype_NAME
3441 | subtype_Name ' Access
3442
3443 MECHANISM ::=
3444 MECHANISM_NAME
3445 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3446
3447 MECHANISM_ASSOCIATION ::=
3448 [formal_parameter_NAME =>] MECHANISM_NAME
3449
3450 MECHANISM_NAME ::=
3451 Value
3452 | Reference
3453 | Descriptor [([Class =>] CLASS_NAME)]
3454 | Short_Descriptor [([Class =>] CLASS_NAME)]
3455
3456 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3457 @end smallexample
3458
3459 @noindent
3460 This pragma is used in conjunction with a pragma @code{Import} to
3461 specify additional information for an imported function. The pragma
3462 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3463 @code{Import_Function} pragma and both must appear in the same
3464 declarative part as the function specification.
3465
3466 The @var{Internal} argument must uniquely designate
3467 the function to which the
3468 pragma applies. If more than one function name exists of this name in
3469 the declarative part you must use the @code{Parameter_Types} and
3470 @var{Result_Type} parameters to achieve the required unique
3471 designation. Subtype marks in these parameters must exactly match the
3472 subtypes in the corresponding function specification, using positional
3473 notation to match parameters with subtype marks.
3474 The form with an @code{'Access} attribute can be used to match an
3475 anonymous access parameter.
3476
3477 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3478 parameters to specify passing mechanisms for the
3479 parameters and result. If you specify a single mechanism name, it
3480 applies to all parameters. Otherwise you may specify a mechanism on a
3481 parameter by parameter basis using either positional or named
3482 notation. If the mechanism is not specified, the default mechanism
3483 is used.
3484
3485 @cindex OpenVMS
3486 @cindex Passing by descriptor
3487 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3488 The default behavior for Import_Function is to pass a 64bit descriptor
3489 unless short_descriptor is specified, then a 32bit descriptor is passed.
3490
3491 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3492 It specifies that the designated parameter and all following parameters
3493 are optional, meaning that they are not passed at the generated code
3494 level (this is distinct from the notion of optional parameters in Ada
3495 where the parameters are passed anyway with the designated optional
3496 parameters). All optional parameters must be of mode @code{IN} and have
3497 default parameter values that are either known at compile time
3498 expressions, or uses of the @code{'Null_Parameter} attribute.
3499
3500 @node Pragma Import_Object
3501 @unnumberedsec Pragma Import_Object
3502 @findex Import_Object
3503 @noindent
3504 Syntax:
3505
3506 @smallexample @c ada
3507 pragma Import_Object
3508 [Internal =>] LOCAL_NAME
3509 [, [External =>] EXTERNAL_SYMBOL]
3510 [, [Size =>] EXTERNAL_SYMBOL]);
3511
3512 EXTERNAL_SYMBOL ::=
3513 IDENTIFIER
3514 | static_string_EXPRESSION
3515 @end smallexample
3516
3517 @noindent
3518 This pragma designates an object as imported, and apart from the
3519 extended rules for external symbols, is identical in effect to the use of
3520 the normal @code{Import} pragma applied to an object. Unlike the
3521 subprogram case, you need not use a separate @code{Import} pragma,
3522 although you may do so (and probably should do so from a portability
3523 point of view). @var{size} is syntax checked, but otherwise ignored by
3524 GNAT@.
3525
3526 @node Pragma Import_Procedure
3527 @unnumberedsec Pragma Import_Procedure
3528 @findex Import_Procedure
3529 @noindent
3530 Syntax:
3531
3532 @smallexample @c ada
3533 pragma Import_Procedure (
3534 [Internal =>] LOCAL_NAME
3535 [, [External =>] EXTERNAL_SYMBOL]
3536 [, [Parameter_Types =>] PARAMETER_TYPES]
3537 [, [Mechanism =>] MECHANISM]
3538 [, [First_Optional_Parameter =>] IDENTIFIER]);
3539
3540 EXTERNAL_SYMBOL ::=
3541 IDENTIFIER
3542 | static_string_EXPRESSION
3543
3544 PARAMETER_TYPES ::=
3545 null
3546 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3547
3548 TYPE_DESIGNATOR ::=
3549 subtype_NAME
3550 | subtype_Name ' Access
3551
3552 MECHANISM ::=
3553 MECHANISM_NAME
3554 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3555
3556 MECHANISM_ASSOCIATION ::=
3557 [formal_parameter_NAME =>] MECHANISM_NAME
3558
3559 MECHANISM_NAME ::=
3560 Value
3561 | Reference
3562 | Descriptor [([Class =>] CLASS_NAME)]
3563 | Short_Descriptor [([Class =>] CLASS_NAME)]
3564
3565 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3566 @end smallexample
3567
3568 @noindent
3569 This pragma is identical to @code{Import_Function} except that it
3570 applies to a procedure rather than a function and the parameters
3571 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3572
3573 @node Pragma Import_Valued_Procedure
3574 @unnumberedsec Pragma Import_Valued_Procedure
3575 @findex Import_Valued_Procedure
3576 @noindent
3577 Syntax:
3578
3579 @smallexample @c ada
3580 pragma Import_Valued_Procedure (
3581 [Internal =>] LOCAL_NAME
3582 [, [External =>] EXTERNAL_SYMBOL]
3583 [, [Parameter_Types =>] PARAMETER_TYPES]
3584 [, [Mechanism =>] MECHANISM]
3585 [, [First_Optional_Parameter =>] IDENTIFIER]);
3586
3587 EXTERNAL_SYMBOL ::=
3588 IDENTIFIER
3589 | static_string_EXPRESSION
3590
3591 PARAMETER_TYPES ::=
3592 null
3593 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3594
3595 TYPE_DESIGNATOR ::=
3596 subtype_NAME
3597 | subtype_Name ' Access
3598
3599 MECHANISM ::=
3600 MECHANISM_NAME
3601 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3602
3603 MECHANISM_ASSOCIATION ::=
3604 [formal_parameter_NAME =>] MECHANISM_NAME
3605
3606 MECHANISM_NAME ::=
3607 Value
3608 | Reference
3609 | Descriptor [([Class =>] CLASS_NAME)]
3610 | Short_Descriptor [([Class =>] CLASS_NAME)]
3611
3612 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3613 @end smallexample
3614
3615 @noindent
3616 This pragma is identical to @code{Import_Procedure} except that the
3617 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3618 mode @code{OUT}, and externally the subprogram is treated as a function
3619 with this parameter as the result of the function. The purpose of this
3620 capability is to allow the use of @code{OUT} and @code{IN OUT}
3621 parameters in interfacing to external functions (which are not permitted
3622 in Ada functions). You may optionally use the @code{Mechanism}
3623 parameters to specify passing mechanisms for the parameters.
3624 If you specify a single mechanism name, it applies to all parameters.
3625 Otherwise you may specify a mechanism on a parameter by parameter
3626 basis using either positional or named notation. If the mechanism is not
3627 specified, the default mechanism is used.
3628
3629 Note that it is important to use this pragma in conjunction with a separate
3630 pragma Import that specifies the desired convention, since otherwise the
3631 default convention is Ada, which is almost certainly not what is required.
3632
3633 @node Pragma Independent
3634 @unnumberedsec Pragma Independent
3635 @findex Independent
3636 @noindent
3637 Syntax:
3638
3639 @smallexample @c ada
3640 pragma Independent (Local_NAME);
3641 @end smallexample
3642
3643 @noindent
3644 This pragma is standard in Ada 2012 mode (which also provides an aspect
3645 of the same name). It is also available as an implementation-defined
3646 pragma in all earlier versions. It specifies that the
3647 designated object or all objects of the designated type must be
3648 independently addressable. This means that separate tasks can safely
3649 manipulate such objects. For example, if two components of a record are
3650 independent, then two separate tasks may access these two components.
3651 This may place
3652 constraints on the representation of the object (for instance prohibiting
3653 tight packing).
3654
3655 @node Pragma Independent_Components
3656 @unnumberedsec Pragma Independent_Components
3657 @findex Independent_Components
3658 @noindent
3659 Syntax:
3660
3661 @smallexample @c ada
3662 pragma Independent_Components (Local_NAME);
3663 @end smallexample
3664
3665 @noindent
3666 This pragma is standard in Ada 2012 mode (which also provides an aspect
3667 of the same name). It is also available as an implementation-defined
3668 pragma in all earlier versions. It specifies that the components of the
3669 designated object, or the components of each object of the designated
3670 type, must be
3671 independently addressable. This means that separate tasks can safely
3672 manipulate separate components in the composite object. This may place
3673 constraints on the representation of the object (for instance prohibiting
3674 tight packing).
3675
3676 @node Pragma Initial_Condition
3677 @unnumberedsec Pragma Initial_Condition
3678 @findex Initial_Condition
3679 @noindent
3680 For the description of this pragma, see SPARK 2014 Reference Manual,
3681 section 7.1.6.
3682
3683 @node Pragma Initialize_Scalars
3684 @unnumberedsec Pragma Initialize_Scalars
3685 @findex Initialize_Scalars
3686 @cindex debugging with Initialize_Scalars
3687 @noindent
3688 Syntax:
3689
3690 @smallexample @c ada
3691 pragma Initialize_Scalars;
3692 @end smallexample
3693
3694 @noindent
3695 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3696 two important differences. First, there is no requirement for the pragma
3697 to be used uniformly in all units of a partition, in particular, it is fine
3698 to use this just for some or all of the application units of a partition,
3699 without needing to recompile the run-time library.
3700
3701 In the case where some units are compiled with the pragma, and some without,
3702 then a declaration of a variable where the type is defined in package
3703 Standard or is locally declared will always be subject to initialization,
3704 as will any declaration of a scalar variable. For composite variables,
3705 whether the variable is initialized may also depend on whether the package
3706 in which the type of the variable is declared is compiled with the pragma.
3707
3708 The other important difference is that you can control the value used
3709 for initializing scalar objects. At bind time, you can select several
3710 options for initialization. You can
3711 initialize with invalid values (similar to Normalize_Scalars, though for
3712 Initialize_Scalars it is not always possible to determine the invalid
3713 values in complex cases like signed component fields with non-standard
3714 sizes). You can also initialize with high or
3715 low values, or with a specified bit pattern. See the @value{EDITION}
3716 User's Guide for binder options for specifying these cases.
3717
3718 This means that you can compile a program, and then without having to
3719 recompile the program, you can run it with different values being used
3720 for initializing otherwise uninitialized values, to test if your program
3721 behavior depends on the choice. Of course the behavior should not change,
3722 and if it does, then most likely you have an erroneous reference to an
3723 uninitialized value.
3724
3725 It is even possible to change the value at execution time eliminating even
3726 the need to rebind with a different switch using an environment variable.
3727 See the @value{EDITION} User's Guide for details.
3728
3729 Note that pragma @code{Initialize_Scalars} is particularly useful in
3730 conjunction with the enhanced validity checking that is now provided
3731 in GNAT, which checks for invalid values under more conditions.
3732 Using this feature (see description of the @option{-gnatV} flag in the
3733 @value{EDITION} User's Guide) in conjunction with
3734 pragma @code{Initialize_Scalars}
3735 provides a powerful new tool to assist in the detection of problems
3736 caused by uninitialized variables.
3737
3738 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3739 effect on the generated code. This may cause your code to be
3740 substantially larger. It may also cause an increase in the amount
3741 of stack required, so it is probably a good idea to turn on stack
3742 checking (see description of stack checking in the @value{EDITION}
3743 User's Guide) when using this pragma.
3744
3745 @node Pragma Initializes
3746 @unnumberedsec Pragma Initializes
3747 @findex Initializes
3748 @noindent
3749 For the description of this pragma, see SPARK 2014 Reference Manual,
3750 section 7.1.5.
3751
3752 @node Pragma Inline_Always
3753 @unnumberedsec Pragma Inline_Always
3754 @findex Inline_Always
3755 @noindent
3756 Syntax:
3757
3758 @smallexample @c ada
3759 pragma Inline_Always (NAME [, NAME]);
3760 @end smallexample
3761
3762 @noindent
3763 Similar to pragma @code{Inline} except that inlining is not subject to
3764 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3765 happens regardless of whether these options are used.
3766
3767 @node Pragma Inline_Generic
3768 @unnumberedsec Pragma Inline_Generic
3769 @findex Inline_Generic
3770 @noindent
3771 Syntax:
3772
3773 @smallexample @c ada
3774 pragma Inline_Generic (GNAME @{, GNAME@});
3775
3776 GNAME ::= generic_unit_NAME | generic_instance_NAME
3777 @end smallexample
3778
3779 @noindent
3780 This pragma is provided for compatibility with Dec Ada 83. It has
3781 no effect in @code{GNAT} (which always inlines generics), other
3782 than to check that the given names are all names of generic units or
3783 generic instances.
3784
3785 @node Pragma Interface
3786 @unnumberedsec Pragma Interface
3787 @findex Interface
3788 @noindent
3789 Syntax:
3790
3791 @smallexample @c ada
3792 pragma Interface (
3793 [Convention =>] convention_identifier,
3794 [Entity =>] local_NAME
3795 [, [External_Name =>] static_string_expression]
3796 [, [Link_Name =>] static_string_expression]);
3797 @end smallexample
3798
3799 @noindent
3800 This pragma is identical in syntax and semantics to
3801 the standard Ada pragma @code{Import}. It is provided for compatibility
3802 with Ada 83. The definition is upwards compatible both with pragma
3803 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3804 with some extended implementations of this pragma in certain Ada 83
3805 implementations. The only difference between pragma @code{Interface}
3806 and pragma @code{Import} is that there is special circuitry to allow
3807 both pragmas to appear for the same subprogram entity (normally it
3808 is illegal to have multiple @code{Import} pragmas. This is useful in
3809 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3810 Ada 83 compilers.
3811
3812 @node Pragma Interface_Name
3813 @unnumberedsec Pragma Interface_Name
3814 @findex Interface_Name
3815 @noindent
3816 Syntax:
3817
3818 @smallexample @c ada
3819 pragma Interface_Name (
3820 [Entity =>] LOCAL_NAME
3821 [, [External_Name =>] static_string_EXPRESSION]
3822 [, [Link_Name =>] static_string_EXPRESSION]);
3823 @end smallexample
3824
3825 @noindent
3826 This pragma provides an alternative way of specifying the interface name
3827 for an interfaced subprogram, and is provided for compatibility with Ada
3828 83 compilers that use the pragma for this purpose. You must provide at
3829 least one of @var{External_Name} or @var{Link_Name}.
3830
3831 @node Pragma Interrupt_Handler
3832 @unnumberedsec Pragma Interrupt_Handler
3833 @findex Interrupt_Handler
3834 @noindent
3835 Syntax:
3836
3837 @smallexample @c ada
3838 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3839 @end smallexample
3840
3841 @noindent
3842 This program unit pragma is supported for parameterless protected procedures
3843 as described in Annex C of the Ada Reference Manual. On the AAMP target
3844 the pragma can also be specified for nonprotected parameterless procedures
3845 that are declared at the library level (which includes procedures
3846 declared at the top level of a library package). In the case of AAMP,
3847 when this pragma is applied to a nonprotected procedure, the instruction
3848 @code{IERET} is generated for returns from the procedure, enabling
3849 maskable interrupts, in place of the normal return instruction.
3850
3851 @node Pragma Interrupt_State
3852 @unnumberedsec Pragma Interrupt_State
3853 @findex Interrupt_State
3854 @noindent
3855 Syntax:
3856
3857 @smallexample @c ada
3858 pragma Interrupt_State
3859 ([Name =>] value,
3860 [State =>] SYSTEM | RUNTIME | USER);
3861 @end smallexample
3862
3863 @noindent
3864 Normally certain interrupts are reserved to the implementation. Any attempt
3865 to attach an interrupt causes Program_Error to be raised, as described in
3866 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3867 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3868 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3869 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3870 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3871 Ada exceptions, or used to implement run-time functions such as the
3872 @code{abort} statement and stack overflow checking.
3873
3874 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3875 such uses of interrupts. It subsumes the functionality of pragma
3876 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3877 available on Windows or VMS. On all other platforms than VxWorks,
3878 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3879 and may be used to mark interrupts required by the board support package
3880 as reserved.
3881
3882 Interrupts can be in one of three states:
3883 @itemize @bullet
3884 @item System
3885
3886 The interrupt is reserved (no Ada handler can be installed), and the
3887 Ada run-time may not install a handler. As a result you are guaranteed
3888 standard system default action if this interrupt is raised.
3889
3890 @item Runtime
3891
3892 The interrupt is reserved (no Ada handler can be installed). The run time
3893 is allowed to install a handler for internal control purposes, but is
3894 not required to do so.
3895
3896 @item User
3897
3898 The interrupt is unreserved. The user may install a handler to provide
3899 some other action.
3900 @end itemize
3901
3902 @noindent
3903 These states are the allowed values of the @code{State} parameter of the
3904 pragma. The @code{Name} parameter is a value of the type
3905 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3906 @code{Ada.Interrupts.Names}.
3907
3908 This is a configuration pragma, and the binder will check that there
3909 are no inconsistencies between different units in a partition in how a
3910 given interrupt is specified. It may appear anywhere a pragma is legal.
3911
3912 The effect is to move the interrupt to the specified state.
3913
3914 By declaring interrupts to be SYSTEM, you guarantee the standard system
3915 action, such as a core dump.
3916
3917 By declaring interrupts to be USER, you guarantee that you can install
3918 a handler.
3919
3920 Note that certain signals on many operating systems cannot be caught and
3921 handled by applications. In such cases, the pragma is ignored. See the
3922 operating system documentation, or the value of the array @code{Reserved}
3923 declared in the spec of package @code{System.OS_Interface}.
3924
3925 Overriding the default state of signals used by the Ada runtime may interfere
3926 with an application's runtime behavior in the cases of the synchronous signals,
3927 and in the case of the signal used to implement the @code{abort} statement.
3928
3929 @node Pragma Invariant
3930 @unnumberedsec Pragma Invariant
3931 @findex Invariant
3932 @noindent
3933 Syntax:
3934
3935 @smallexample @c ada
3936 pragma Invariant
3937 ([Entity =>] private_type_LOCAL_NAME,
3938 [Check =>] EXPRESSION
3939 [,[Message =>] String_Expression]);
3940 @end smallexample
3941
3942 @noindent
3943 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3944 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3945 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3946 requires the use of the aspect syntax, which is not available except in 2012
3947 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3948 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3949 note that the aspect Invariant is a synonym in GNAT for the aspect
3950 Type_Invariant, but there is no pragma Type_Invariant.
3951
3952 The pragma must appear within the visible part of the package specification,
3953 after the type to which its Entity argument appears. As with the Invariant
3954 aspect, the Check expression is not analyzed until the end of the visible
3955 part of the package, so it may contain forward references. The Message
3956 argument, if present, provides the exception message used if the invariant
3957 is violated. If no Message parameter is provided, a default message that
3958 identifies the line on which the pragma appears is used.
3959
3960 It is permissible to have multiple Invariants for the same type entity, in
3961 which case they are and'ed together. It is permissible to use this pragma
3962 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3963 invariant pragma for the same entity.
3964
3965 For further details on the use of this pragma, see the Ada 2012 documentation
3966 of the Type_Invariant aspect.
3967
3968 @node Pragma Java_Constructor
3969 @unnumberedsec Pragma Java_Constructor
3970 @findex Java_Constructor
3971 @noindent
3972 Syntax:
3973
3974 @smallexample @c ada
3975 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
3976 @end smallexample
3977
3978 @noindent
3979 This pragma is used to assert that the specified Ada function should be
3980 mapped to the Java constructor for some Ada tagged record type.
3981
3982 See section 7.3.2 of the
3983 @code{GNAT User's Guide: Supplement for the JVM Platform.}
3984 for related information.
3985
3986 @node Pragma Java_Interface
3987 @unnumberedsec Pragma Java_Interface
3988 @findex Java_Interface
3989 @noindent
3990 Syntax:
3991
3992 @smallexample @c ada
3993 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
3994 @end smallexample
3995
3996 @noindent
3997 This pragma is used to assert that the specified Ada abstract tagged type
3998 is to be mapped to a Java interface name.
3999
4000 See sections 7.1 and 7.2 of the
4001 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4002 for related information.
4003
4004 @node Pragma Keep_Names
4005 @unnumberedsec Pragma Keep_Names
4006 @findex Keep_Names
4007 @noindent
4008 Syntax:
4009
4010 @smallexample @c ada
4011 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4012 @end smallexample
4013
4014 @noindent
4015 The @var{LOCAL_NAME} argument
4016 must refer to an enumeration first subtype
4017 in the current declarative part. The effect is to retain the enumeration
4018 literal names for use by @code{Image} and @code{Value} even if a global
4019 @code{Discard_Names} pragma applies. This is useful when you want to
4020 generally suppress enumeration literal names and for example you therefore
4021 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
4022 want to retain the names for specific enumeration types.
4023
4024 @node Pragma License
4025 @unnumberedsec Pragma License
4026 @findex License
4027 @cindex License checking
4028 @noindent
4029 Syntax:
4030
4031 @smallexample @c ada
4032 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4033 @end smallexample
4034
4035 @noindent
4036 This pragma is provided to allow automated checking for appropriate license
4037 conditions with respect to the standard and modified GPL@. A pragma
4038 @code{License}, which is a configuration pragma that typically appears at
4039 the start of a source file or in a separate @file{gnat.adc} file, specifies
4040 the licensing conditions of a unit as follows:
4041
4042 @itemize @bullet
4043 @item Unrestricted
4044 This is used for a unit that can be freely used with no license restrictions.
4045 Examples of such units are public domain units, and units from the Ada
4046 Reference Manual.
4047
4048 @item GPL
4049 This is used for a unit that is licensed under the unmodified GPL, and which
4050 therefore cannot be @code{with}'ed by a restricted unit.
4051
4052 @item Modified_GPL
4053 This is used for a unit licensed under the GNAT modified GPL that includes
4054 a special exception paragraph that specifically permits the inclusion of
4055 the unit in programs without requiring the entire program to be released
4056 under the GPL@.
4057
4058 @item Restricted
4059 This is used for a unit that is restricted in that it is not permitted to
4060 depend on units that are licensed under the GPL@. Typical examples are
4061 proprietary code that is to be released under more restrictive license
4062 conditions. Note that restricted units are permitted to @code{with} units
4063 which are licensed under the modified GPL (this is the whole point of the
4064 modified GPL).
4065
4066 @end itemize
4067
4068 @noindent
4069 Normally a unit with no @code{License} pragma is considered to have an
4070 unknown license, and no checking is done. However, standard GNAT headers
4071 are recognized, and license information is derived from them as follows.
4072
4073 @itemize @bullet
4074
4075 A GNAT license header starts with a line containing 78 hyphens. The following
4076 comment text is searched for the appearance of any of the following strings.
4077
4078 If the string ``GNU General Public License'' is found, then the unit is assumed
4079 to have GPL license, unless the string ``As a special exception'' follows, in
4080 which case the license is assumed to be modified GPL@.
4081
4082 If one of the strings
4083 ``This specification is adapted from the Ada Semantic Interface'' or
4084 ``This specification is derived from the Ada Reference Manual'' is found
4085 then the unit is assumed to be unrestricted.
4086 @end itemize
4087
4088 @noindent
4089 These default actions means that a program with a restricted license pragma
4090 will automatically get warnings if a GPL unit is inappropriately
4091 @code{with}'ed. For example, the program:
4092
4093 @smallexample @c ada
4094 with Sem_Ch3;
4095 with GNAT.Sockets;
4096 procedure Secret_Stuff is
4097 @dots{}
4098 end Secret_Stuff
4099 @end smallexample
4100
4101 @noindent
4102 if compiled with pragma @code{License} (@code{Restricted}) in a
4103 @file{gnat.adc} file will generate the warning:
4104
4105 @smallexample
4106 1. with Sem_Ch3;
4107 |
4108 >>> license of withed unit "Sem_Ch3" is incompatible
4109
4110 2. with GNAT.Sockets;
4111 3. procedure Secret_Stuff is
4112 @end smallexample
4113
4114 @noindent
4115 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4116 compiler and is licensed under the
4117 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4118 run time, and is therefore licensed under the modified GPL@.
4119
4120 @node Pragma Link_With
4121 @unnumberedsec Pragma Link_With
4122 @findex Link_With
4123 @noindent
4124 Syntax:
4125
4126 @smallexample @c ada
4127 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4128 @end smallexample
4129
4130 @noindent
4131 This pragma is provided for compatibility with certain Ada 83 compilers.
4132 It has exactly the same effect as pragma @code{Linker_Options} except
4133 that spaces occurring within one of the string expressions are treated
4134 as separators. For example, in the following case:
4135
4136 @smallexample @c ada
4137 pragma Link_With ("-labc -ldef");
4138 @end smallexample
4139
4140 @noindent
4141 results in passing the strings @code{-labc} and @code{-ldef} as two
4142 separate arguments to the linker. In addition pragma Link_With allows
4143 multiple arguments, with the same effect as successive pragmas.
4144
4145 @node Pragma Linker_Alias
4146 @unnumberedsec Pragma Linker_Alias
4147 @findex Linker_Alias
4148 @noindent
4149 Syntax:
4150
4151 @smallexample @c ada
4152 pragma Linker_Alias (
4153 [Entity =>] LOCAL_NAME,
4154 [Target =>] static_string_EXPRESSION);
4155 @end smallexample
4156
4157 @noindent
4158 @var{LOCAL_NAME} must refer to an object that is declared at the library
4159 level. This pragma establishes the given entity as a linker alias for the
4160 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4161 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4162 @var{static_string_EXPRESSION} in the object file, that is to say no space
4163 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4164 to the same address as @var{static_string_EXPRESSION} by the linker.
4165
4166 The actual linker name for the target must be used (e.g.@: the fully
4167 encoded name with qualification in Ada, or the mangled name in C++),
4168 or it must be declared using the C convention with @code{pragma Import}
4169 or @code{pragma Export}.
4170
4171 Not all target machines support this pragma. On some of them it is accepted
4172 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4173
4174 @smallexample @c ada
4175 -- Example of the use of pragma Linker_Alias
4176
4177 package p is
4178 i : Integer := 1;
4179 pragma Export (C, i);
4180
4181 new_name_for_i : Integer;
4182 pragma Linker_Alias (new_name_for_i, "i");
4183 end p;
4184 @end smallexample
4185
4186 @node Pragma Linker_Constructor
4187 @unnumberedsec Pragma Linker_Constructor
4188 @findex Linker_Constructor
4189 @noindent
4190 Syntax:
4191
4192 @smallexample @c ada
4193 pragma Linker_Constructor (procedure_LOCAL_NAME);
4194 @end smallexample
4195
4196 @noindent
4197 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4198 is declared at the library level. A procedure to which this pragma is
4199 applied will be treated as an initialization routine by the linker.
4200 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4201 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4202 of the executable is called (or immediately after the shared library is
4203 loaded if the procedure is linked in a shared library), in particular
4204 before the Ada run-time environment is set up.
4205
4206 Because of these specific contexts, the set of operations such a procedure
4207 can perform is very limited and the type of objects it can manipulate is
4208 essentially restricted to the elementary types. In particular, it must only
4209 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4210
4211 This pragma is used by GNAT to implement auto-initialization of shared Stand
4212 Alone Libraries, which provides a related capability without the restrictions
4213 listed above. Where possible, the use of Stand Alone Libraries is preferable
4214 to the use of this pragma.
4215
4216 @node Pragma Linker_Destructor
4217 @unnumberedsec Pragma Linker_Destructor
4218 @findex Linker_Destructor
4219 @noindent
4220 Syntax:
4221
4222 @smallexample @c ada
4223 pragma Linker_Destructor (procedure_LOCAL_NAME);
4224 @end smallexample
4225
4226 @noindent
4227 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4228 is declared at the library level. A procedure to which this pragma is
4229 applied will be treated as a finalization routine by the linker.
4230 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4231 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4232 of the executable has exited (or immediately before the shared library
4233 is unloaded if the procedure is linked in a shared library), in particular
4234 after the Ada run-time environment is shut down.
4235
4236 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4237 because of these specific contexts.
4238
4239 @node Pragma Linker_Section
4240 @unnumberedsec Pragma Linker_Section
4241 @findex Linker_Section
4242 @noindent
4243 Syntax:
4244
4245 @smallexample @c ada
4246 pragma Linker_Section (
4247 [Entity =>] LOCAL_NAME,
4248 [Section =>] static_string_EXPRESSION);
4249 @end smallexample
4250
4251 @noindent
4252 @var{LOCAL_NAME} must refer to an object that is
4253 declared at the library level. This pragma specifies the name of the
4254 linker section for the given entity. It is equivalent to
4255 @code{__attribute__((section))} in GNU C and causes @var{LOCAL_NAME} to
4256 be placed in the @var{static_string_EXPRESSION} section of the
4257 executable (assuming the linker doesn't rename the section).
4258
4259 The compiler normally places library-level entities in standard sections
4260 depending on the class: procedures and functions generally go in the
4261 @code{.text} section, initialized variables in the @code{.data} section
4262 and uninitialized variables in the @code{.bss} section.
4263
4264 Other, special sections may exist on given target machines to map special
4265 hardware, for example I/O ports or flash memory. This pragma is a means to
4266 defer the final layout of the executable to the linker, thus fully working
4267 at the symbolic level with the compiler.
4268
4269 Some file formats do not support arbitrary sections so not all target
4270 machines support this pragma. The use of this pragma may cause a program
4271 execution to be erroneous if it is used to place an entity into an
4272 inappropriate section (e.g.@: a modified variable into the @code{.text}
4273 section). See also @code{pragma Persistent_BSS}.
4274
4275 @smallexample @c ada
4276 -- Example of the use of pragma Linker_Section
4277
4278 package IO_Card is
4279 Port_A : Integer;
4280 pragma Volatile (Port_A);
4281 pragma Linker_Section (Port_A, ".bss.port_a");
4282
4283 Port_B : Integer;
4284 pragma Volatile (Port_B);
4285 pragma Linker_Section (Port_B, ".bss.port_b");
4286 end IO_Card;
4287 @end smallexample
4288
4289 @node Pragma Long_Float
4290 @unnumberedsec Pragma Long_Float
4291 @cindex OpenVMS
4292 @findex Long_Float
4293 @noindent
4294 Syntax:
4295
4296 @smallexample @c ada
4297 pragma Long_Float (FLOAT_FORMAT);
4298
4299 FLOAT_FORMAT ::= D_Float | G_Float
4300 @end smallexample
4301
4302 @noindent
4303 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4304 It allows control over the internal representation chosen for the predefined
4305 type @code{Long_Float} and for floating point type representations with
4306 @code{digits} specified in the range 7 through 15.
4307 For further details on this pragma, see the
4308 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
4309 this pragma, the standard runtime libraries must be recompiled.
4310
4311 @node Pragma Loop_Invariant
4312 @unnumberedsec Pragma Loop_Invariant
4313 @findex Loop_Invariant
4314 @noindent
4315 Syntax:
4316
4317 @smallexample @c ada
4318 pragma Loop_Invariant ( boolean_EXPRESSION );
4319 @end smallexample
4320
4321 @noindent
4322 The effect of this pragma is similar to that of pragma @code{Assert},
4323 except that in an @code{Assertion_Policy} pragma, the identifier
4324 @code{Loop_Invariant} is used to control whether it is ignored or checked
4325 (or disabled).
4326
4327 @code{Loop_Invariant} can only appear as one of the items in the sequence
4328 of statements of a loop body. The intention is that it be used to
4329 represent a "loop invariant" assertion, i.e. something that is true each
4330 time through the loop, and which can be used to show that the loop is
4331 achieving its purpose.
4332
4333 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4334 may be used to refer to the value of an expression on entry to the loop. This
4335 attribute can only be used within the expression of a @code{Loop_Invariant}
4336 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4337
4338 @node Pragma Loop_Optimize
4339 @unnumberedsec Pragma Loop_Optimize
4340 @findex Loop_Optimize
4341 @noindent
4342 Syntax:
4343
4344 @smallexample @c ada
4345 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4346
4347 OPTIMIZATION_HINT ::= No_Unroll | Unroll | No_Vector | Vector
4348 @end smallexample
4349
4350 @noindent
4351 This pragma must appear immediately within a loop statement. It allows the
4352 programmer to specify optimization hints for the enclosing loop. The hints
4353 are not mutually exclusive and can be freely mixed, but not all combinations
4354 will yield a sensible outcome.
4355
4356 There are four supported optimization hints for a loop:
4357 @itemize @bullet
4358 @item No_Unroll
4359
4360 The loop must not be unrolled. This is a strong hint: the compiler will not
4361 unroll a loop marked with this hint.
4362
4363 @item Unroll
4364
4365 The loop should be unrolled. This is a weak hint: the compiler will try to
4366 apply unrolling to this loop preferably to other optimizations, notably
4367 vectorization, but there is no guarantee that the loop will be unrolled.
4368
4369 @item No_Vector
4370
4371 The loop must not be vectorized. This is a strong hint: the compiler will not
4372 vectorize a loop marked with this hint.
4373
4374 @item Vector
4375
4376 The loop should be vectorized. This is a weak hint: the compiler will try to
4377 apply vectorization to this loop preferably to other optimizations, notably
4378 unrolling, but there is no guarantee that the loop will be vectorized.
4379
4380 @end itemize
4381
4382 These hints do not void the need to pass the appropriate switches to the
4383 compiler in order to enable the relevant optimizations, that is to say
4384 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4385 vectorization.
4386
4387 @node Pragma Loop_Variant
4388 @unnumberedsec Pragma Loop_Variant
4389 @findex Loop_Variant
4390 @noindent
4391 Syntax:
4392
4393 @smallexample @c ada
4394 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4395 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4396 CHANGE_DIRECTION ::= Increases | Decreases
4397 @end smallexample
4398
4399 @noindent
4400 This pragma must appear immediately within the sequence of statements of a
4401 loop statement. It allows the specification of quantities which must always
4402 decrease or increase in successive iterations of the loop. In its simplest
4403 form, just one expression is specified, whose value must increase or decrease
4404 on each iteration of the loop.
4405
4406 In a more complex form, multiple arguments can be given which are intepreted
4407 in a nesting lexicographic manner. For example:
4408
4409 @smallexample @c ada
4410 pragma Loop_Variant (Increases => X, Decreases => Y);
4411 @end smallexample
4412
4413 @noindent
4414 specifies that each time through the loop either X increases, or X stays
4415 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4416 loop is making progress. It can be useful in helping to show informally
4417 or prove formally that the loop always terminates.
4418
4419 @code{Loop_Variant} is an assertion whose effect can be controlled using
4420 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4421 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4422 to ignore the check (in which case the pragma has no effect on the program),
4423 or @code{Disable} in which case the pragma is not even checked for correct
4424 syntax.
4425
4426 The @code{Loop_Entry} attribute may be used within the expressions of the
4427 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4428
4429 @node Pragma Machine_Attribute
4430 @unnumberedsec Pragma Machine_Attribute
4431 @findex Machine_Attribute
4432 @noindent
4433 Syntax:
4434
4435 @smallexample @c ada
4436 pragma Machine_Attribute (
4437 [Entity =>] LOCAL_NAME,
4438 [Attribute_Name =>] static_string_EXPRESSION
4439 [, [Info =>] static_EXPRESSION] );
4440 @end smallexample
4441
4442 @noindent
4443 Machine-dependent attributes can be specified for types and/or
4444 declarations. This pragma is semantically equivalent to
4445 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4446 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4447 in GNU C, where @code{@var{attribute_name}} is recognized by the
4448 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4449 specific macro. A string literal for the optional parameter @var{info}
4450 is transformed into an identifier, which may make this pragma unusable
4451 for some attributes. @xref{Target Attributes,, Defining target-specific
4452 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4453 Internals}, further information.
4454
4455 @node Pragma Main
4456 @unnumberedsec Pragma Main
4457 @cindex OpenVMS
4458 @findex Main
4459 @noindent
4460 Syntax:
4461
4462 @smallexample @c ada
4463 pragma Main
4464 (MAIN_OPTION [, MAIN_OPTION]);
4465
4466 MAIN_OPTION ::=
4467 [Stack_Size =>] static_integer_EXPRESSION
4468 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4469 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
4470 @end smallexample
4471
4472 @noindent
4473 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4474 no effect in GNAT, other than being syntax checked.
4475
4476 @node Pragma Main_Storage
4477 @unnumberedsec Pragma Main_Storage
4478 @cindex OpenVMS
4479 @findex Main_Storage
4480 @noindent
4481 Syntax:
4482
4483 @smallexample @c ada
4484 pragma Main_Storage
4485 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4486
4487 MAIN_STORAGE_OPTION ::=
4488 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4489 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
4490 @end smallexample
4491
4492 @noindent
4493 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4494 no effect in GNAT, other than being syntax checked. Note that the pragma
4495 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4496
4497 @node Pragma No_Body
4498 @unnumberedsec Pragma No_Body
4499 @findex No_Body
4500 @noindent
4501 Syntax:
4502
4503 @smallexample @c ada
4504 pragma No_Body;
4505 @end smallexample
4506
4507 @noindent
4508 There are a number of cases in which a package spec does not require a body,
4509 and in fact a body is not permitted. GNAT will not permit the spec to be
4510 compiled if there is a body around. The pragma No_Body allows you to provide
4511 a body file, even in a case where no body is allowed. The body file must
4512 contain only comments and a single No_Body pragma. This is recognized by
4513 the compiler as indicating that no body is logically present.
4514
4515 This is particularly useful during maintenance when a package is modified in
4516 such a way that a body needed before is no longer needed. The provision of a
4517 dummy body with a No_Body pragma ensures that there is no interference from
4518 earlier versions of the package body.
4519
4520 @node Pragma No_Inline
4521 @unnumberedsec Pragma No_Inline
4522 @findex No_Inline
4523 @noindent
4524 Syntax:
4525
4526 @smallexample @c ada
4527 pragma No_Inline (NAME @{, NAME@});
4528 @end smallexample
4529
4530 @noindent
4531 This pragma suppresses inlining for the callable entity or the instances of
4532 the generic subprogram designated by @var{NAME}, including inlining that
4533 results from the use of pragma @code{Inline}. This pragma is always active,
4534 in particular it is not subject to the use of option @option{-gnatn} or
4535 @option{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
4536 pragma @code{Inline_Always} for the same @var{NAME}.
4537
4538 @node Pragma No_Return
4539 @unnumberedsec Pragma No_Return
4540 @findex No_Return
4541 @noindent
4542 Syntax:
4543
4544 @smallexample @c ada
4545 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4546 @end smallexample
4547
4548 @noindent
4549 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4550 declarations in the current declarative part. A procedure to which this
4551 pragma is applied may not contain any explicit @code{return} statements.
4552 In addition, if the procedure contains any implicit returns from falling
4553 off the end of a statement sequence, then execution of that implicit
4554 return will cause Program_Error to be raised.
4555
4556 One use of this pragma is to identify procedures whose only purpose is to raise
4557 an exception. Another use of this pragma is to suppress incorrect warnings
4558 about missing returns in functions, where the last statement of a function
4559 statement sequence is a call to such a procedure.
4560
4561 Note that in Ada 2005 mode, this pragma is part of the language. It is
4562 available in all earlier versions of Ada as an implementation-defined
4563 pragma.
4564
4565 @node Pragma No_Run_Time
4566 @unnumberedsec Pragma No_Run_Time
4567 @findex No_Run_Time
4568 @noindent
4569 Syntax:
4570
4571 @smallexample @c ada
4572 pragma No_Run_Time;
4573 @end smallexample
4574
4575 @noindent
4576 This is an obsolete configuration pragma that historically was used to
4577 setup what is now called the "zero footprint" library. It causes any
4578 library units outside this basic library to be ignored. The use of
4579 this pragma has been superseded by the general configurable run-time
4580 capability of @code{GNAT} where the compiler takes into account whatever
4581 units happen to be accessible in the library.
4582
4583 @node Pragma No_Strict_Aliasing
4584 @unnumberedsec Pragma No_Strict_Aliasing
4585 @findex No_Strict_Aliasing
4586 @noindent
4587 Syntax:
4588
4589 @smallexample @c ada
4590 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4591 @end smallexample
4592
4593 @noindent
4594 @var{type_LOCAL_NAME} must refer to an access type
4595 declaration in the current declarative part. The effect is to inhibit
4596 strict aliasing optimization for the given type. The form with no
4597 arguments is a configuration pragma which applies to all access types
4598 declared in units to which the pragma applies. For a detailed
4599 description of the strict aliasing optimization, and the situations
4600 in which it must be suppressed, see @ref{Optimization and Strict
4601 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4602
4603 This pragma currently has no effects on access to unconstrained array types.
4604
4605 @node Pragma Normalize_Scalars
4606 @unnumberedsec Pragma Normalize_Scalars
4607 @findex Normalize_Scalars
4608 @noindent
4609 Syntax:
4610
4611 @smallexample @c ada
4612 pragma Normalize_Scalars;
4613 @end smallexample
4614
4615 @noindent
4616 This is a language defined pragma which is fully implemented in GNAT@. The
4617 effect is to cause all scalar objects that are not otherwise initialized
4618 to be initialized. The initial values are implementation dependent and
4619 are as follows:
4620
4621 @table @code
4622 @item Standard.Character
4623 @noindent
4624 Objects whose root type is Standard.Character are initialized to
4625 Character'Last unless the subtype range excludes NUL (in which case
4626 NUL is used). This choice will always generate an invalid value if
4627 one exists.
4628
4629 @item Standard.Wide_Character
4630 @noindent
4631 Objects whose root type is Standard.Wide_Character are initialized to
4632 Wide_Character'Last unless the subtype range excludes NUL (in which case
4633 NUL is used). This choice will always generate an invalid value if
4634 one exists.
4635
4636 @item Standard.Wide_Wide_Character
4637 @noindent
4638 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4639 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4640 which case NUL is used). This choice will always generate an invalid value if
4641 one exists.
4642
4643 @item Integer types
4644 @noindent
4645 Objects of an integer type are treated differently depending on whether
4646 negative values are present in the subtype. If no negative values are
4647 present, then all one bits is used as the initial value except in the
4648 special case where zero is excluded from the subtype, in which case
4649 all zero bits are used. This choice will always generate an invalid
4650 value if one exists.
4651
4652 For subtypes with negative values present, the largest negative number
4653 is used, except in the unusual case where this largest negative number
4654 is in the subtype, and the largest positive number is not, in which case
4655 the largest positive value is used. This choice will always generate
4656 an invalid value if one exists.
4657
4658 @item Floating-Point Types
4659 Objects of all floating-point types are initialized to all 1-bits. For
4660 standard IEEE format, this corresponds to a NaN (not a number) which is
4661 indeed an invalid value.
4662
4663 @item Fixed-Point Types
4664 Objects of all fixed-point types are treated as described above for integers,
4665 with the rules applying to the underlying integer value used to represent
4666 the fixed-point value.
4667
4668 @item Modular types
4669 Objects of a modular type are initialized to all one bits, except in
4670 the special case where zero is excluded from the subtype, in which
4671 case all zero bits are used. This choice will always generate an
4672 invalid value if one exists.
4673
4674 @item Enumeration types
4675 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4676 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4677 whose Pos value is zero, in which case a code of zero is used. This choice
4678 will always generate an invalid value if one exists.
4679
4680 @end table
4681
4682 @node Pragma Obsolescent
4683 @unnumberedsec Pragma Obsolescent
4684 @findex Obsolescent
4685 @noindent
4686 Syntax:
4687
4688 @smallexample @c ada
4689 pragma Obsolescent;
4690
4691 pragma Obsolescent (
4692 [Message =>] static_string_EXPRESSION
4693 [,[Version =>] Ada_05]]);
4694
4695 pragma Obsolescent (
4696 [Entity =>] NAME
4697 [,[Message =>] static_string_EXPRESSION
4698 [,[Version =>] Ada_05]] );
4699 @end smallexample
4700
4701 @noindent
4702 This pragma can occur immediately following a declaration of an entity,
4703 including the case of a record component. If no Entity argument is present,
4704 then this declaration is the one to which the pragma applies. If an Entity
4705 parameter is present, it must either match the name of the entity in this
4706 declaration, or alternatively, the pragma can immediately follow an enumeration
4707 type declaration, where the Entity argument names one of the enumeration
4708 literals.
4709
4710 This pragma is used to indicate that the named entity
4711 is considered obsolescent and should not be used. Typically this is
4712 used when an API must be modified by eventually removing or modifying
4713 existing subprograms or other entities. The pragma can be used at an
4714 intermediate stage when the entity is still present, but will be
4715 removed later.
4716
4717 The effect of this pragma is to output a warning message on a reference to
4718 an entity thus marked that the subprogram is obsolescent if the appropriate
4719 warning option in the compiler is activated. If the Message parameter is
4720 present, then a second warning message is given containing this text. In
4721 addition, a reference to the entity is considered to be a violation of pragma
4722 Restrictions (No_Obsolescent_Features).
4723
4724 This pragma can also be used as a program unit pragma for a package,
4725 in which case the entity name is the name of the package, and the
4726 pragma indicates that the entire package is considered
4727 obsolescent. In this case a client @code{with}'ing such a package
4728 violates the restriction, and the @code{with} statement is
4729 flagged with warnings if the warning option is set.
4730
4731 If the Version parameter is present (which must be exactly
4732 the identifier Ada_05, no other argument is allowed), then the
4733 indication of obsolescence applies only when compiling in Ada 2005
4734 mode. This is primarily intended for dealing with the situations
4735 in the predefined library where subprograms or packages
4736 have become defined as obsolescent in Ada 2005
4737 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4738
4739 The following examples show typical uses of this pragma:
4740
4741 @smallexample @c ada
4742 package p is
4743 pragma Obsolescent (p, Message => "use pp instead of p");
4744 end p;
4745
4746 package q is
4747 procedure q2;
4748 pragma Obsolescent ("use q2new instead");
4749
4750 type R is new integer;
4751 pragma Obsolescent
4752 (Entity => R,
4753 Message => "use RR in Ada 2005",
4754 Version => Ada_05);
4755
4756 type M is record
4757 F1 : Integer;
4758 F2 : Integer;
4759 pragma Obsolescent;
4760 F3 : Integer;
4761 end record;
4762
4763 type E is (a, bc, 'd', quack);
4764 pragma Obsolescent (Entity => bc)
4765 pragma Obsolescent (Entity => 'd')
4766
4767 function "+"
4768 (a, b : character) return character;
4769 pragma Obsolescent (Entity => "+");
4770 end;
4771 @end smallexample
4772
4773 @noindent
4774 Note that, as for all pragmas, if you use a pragma argument identifier,
4775 then all subsequent parameters must also use a pragma argument identifier.
4776 So if you specify "Entity =>" for the Entity argument, and a Message
4777 argument is present, it must be preceded by "Message =>".
4778
4779 @node Pragma Optimize_Alignment
4780 @unnumberedsec Pragma Optimize_Alignment
4781 @findex Optimize_Alignment
4782 @cindex Alignment, default settings
4783 @noindent
4784 Syntax:
4785
4786 @smallexample @c ada
4787 pragma Optimize_Alignment (TIME | SPACE | OFF);
4788 @end smallexample
4789
4790 @noindent
4791 This is a configuration pragma which affects the choice of default alignments
4792 for types where no alignment is explicitly specified. There is a time/space
4793 trade-off in the selection of these values. Large alignments result in more
4794 efficient code, at the expense of larger data space, since sizes have to be
4795 increased to match these alignments. Smaller alignments save space, but the
4796 access code is slower. The normal choice of default alignments (which is what
4797 you get if you do not use this pragma, or if you use an argument of OFF),
4798 tries to balance these two requirements.
4799
4800 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4801 First any packed record is given an alignment of 1. Second, if a size is given
4802 for the type, then the alignment is chosen to avoid increasing this size. For
4803 example, consider:
4804
4805 @smallexample @c ada
4806 type R is record
4807 X : Integer;
4808 Y : Character;
4809 end record;
4810
4811 for R'Size use 5*8;
4812 @end smallexample
4813
4814 @noindent
4815 In the default mode, this type gets an alignment of 4, so that access to the
4816 Integer field X are efficient. But this means that objects of the type end up
4817 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4818 allowed to be bigger than the size of the type, but it can waste space if for
4819 example fields of type R appear in an enclosing record. If the above type is
4820 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4821
4822 However, there is one case in which SPACE is ignored. If a variable length
4823 record (that is a discriminated record with a component which is an array
4824 whose length depends on a discriminant), has a pragma Pack, then it is not
4825 in general possible to set the alignment of such a record to one, so the
4826 pragma is ignored in this case (with a warning).
4827
4828 Specifying TIME causes larger default alignments to be chosen in the case of
4829 small types with sizes that are not a power of 2. For example, consider:
4830
4831 @smallexample @c ada
4832 type R is record
4833 A : Character;
4834 B : Character;
4835 C : Boolean;
4836 end record;
4837
4838 pragma Pack (R);
4839 for R'Size use 17;
4840 @end smallexample
4841
4842 @noindent
4843 The default alignment for this record is normally 1, but if this type is
4844 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4845 to 4, which wastes space for objects of the type, since they are now 4 bytes
4846 long, but results in more efficient access when the whole record is referenced.
4847
4848 As noted above, this is a configuration pragma, and there is a requirement
4849 that all units in a partition be compiled with a consistent setting of the
4850 optimization setting. This would normally be achieved by use of a configuration
4851 pragma file containing the appropriate setting. The exception to this rule is
4852 that units with an explicit configuration pragma in the same file as the source
4853 unit are excluded from the consistency check, as are all predefined units. The
4854 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4855 pragma appears at the start of the file.
4856
4857 @node Pragma Ordered
4858 @unnumberedsec Pragma Ordered
4859 @findex Ordered
4860 @findex pragma @code{Ordered}
4861 @noindent
4862 Syntax:
4863
4864 @smallexample @c ada
4865 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4866 @end smallexample
4867
4868 @noindent
4869 Most enumeration types are from a conceptual point of view unordered.
4870 For example, consider:
4871
4872 @smallexample @c ada
4873 type Color is (Red, Blue, Green, Yellow);
4874 @end smallexample
4875
4876 @noindent
4877 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4878 but really these relations make no sense; the enumeration type merely
4879 specifies a set of possible colors, and the order is unimportant.
4880
4881 For unordered enumeration types, it is generally a good idea if
4882 clients avoid comparisons (other than equality or inequality) and
4883 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4884 other than the unit where the type is declared, its body, and its subunits.)
4885 For example, if code buried in some client says:
4886
4887 @smallexample @c ada
4888 if Current_Color < Yellow then ...
4889 if Current_Color in Blue .. Green then ...
4890 @end smallexample
4891
4892 @noindent
4893 then the client code is relying on the order, which is undesirable.
4894 It makes the code hard to read and creates maintenance difficulties if
4895 entries have to be added to the enumeration type. Instead,
4896 the code in the client should list the possibilities, or an
4897 appropriate subtype should be declared in the unit that declares
4898 the original enumeration type. E.g., the following subtype could
4899 be declared along with the type @code{Color}:
4900
4901 @smallexample @c ada
4902 subtype RBG is Color range Red .. Green;
4903 @end smallexample
4904
4905 @noindent
4906 and then the client could write:
4907
4908 @smallexample @c ada
4909 if Current_Color in RBG then ...
4910 if Current_Color = Blue or Current_Color = Green then ...
4911 @end smallexample
4912
4913 @noindent
4914 However, some enumeration types are legitimately ordered from a conceptual
4915 point of view. For example, if you declare:
4916
4917 @smallexample @c ada
4918 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4919 @end smallexample
4920
4921 @noindent
4922 then the ordering imposed by the language is reasonable, and
4923 clients can depend on it, writing for example:
4924
4925 @smallexample @c ada
4926 if D in Mon .. Fri then ...
4927 if D < Wed then ...
4928 @end smallexample
4929
4930 @noindent
4931 The pragma @option{Ordered} is provided to mark enumeration types that
4932 are conceptually ordered, alerting the reader that clients may depend
4933 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4934 rather than one to mark them as unordered, since in our experience,
4935 the great majority of enumeration types are conceptually unordered.
4936
4937 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4938 and @code{Wide_Wide_Character}
4939 are considered to be ordered types, so each is declared with a
4940 pragma @code{Ordered} in package @code{Standard}.
4941
4942 Normally pragma @code{Ordered} serves only as documentation and a guide for
4943 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4944 requests warnings for inappropriate uses (comparisons and explicit
4945 subranges) for unordered types. If this switch is used, then any
4946 enumeration type not marked with pragma @code{Ordered} will be considered
4947 as unordered, and will generate warnings for inappropriate uses.
4948
4949 For additional information please refer to the description of the
4950 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4951
4952 @node Pragma Overflow_Mode
4953 @unnumberedsec Pragma Overflow_Mode
4954 @findex Overflow checks
4955 @findex Overflow mode
4956 @findex pragma @code{Overflow_Mode}
4957 @noindent
4958 Syntax:
4959
4960 @smallexample @c ada
4961 pragma Overflow_Mode
4962 ( [General =>] MODE
4963 [,[Assertions =>] MODE]);
4964
4965 MODE ::= STRICT | MINIMIZED | ELIMINATED
4966 @end smallexample
4967
4968 @noindent
4969 This pragma sets the current overflow mode to the given setting. For details
4970 of the meaning of these modes, please refer to the
4971 ``Overflow Check Handling in GNAT'' appendix in the
4972 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
4973 the given mode applies to all expressions. If both parameters are present,
4974 the @code{General} mode applies to expressions outside assertions, and
4975 the @code{Eliminated} mode applies to expressions within assertions.
4976
4977 The case of the @code{MODE} parameter is ignored,
4978 so @code{MINIMIZED}, @code{Minimized} and
4979 @code{minimized} all have the same effect.
4980
4981 The @code{Overflow_Mode} pragma has the same scoping and placement
4982 rules as pragma @code{Suppress}, so it can occur either as a
4983 configuration pragma, specifying a default for the whole
4984 program, or in a declarative scope, where it applies to the
4985 remaining declarations and statements in that scope.
4986
4987 The pragma @code{Suppress (Overflow_Check)} suppresses
4988 overflow checking, but does not affect the overflow mode.
4989
4990 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
4991 overflow checking, but does not affect the overflow mode.
4992
4993 @node Pragma Overriding_Renamings
4994 @unnumberedsec Pragma Overriding_Renamings
4995 @findex Overriding_Renamings
4996 @cindex Rational profile
4997 @cindex Rational compatibility
4998 @noindent
4999 Syntax:
5000
5001 @smallexample @c ada
5002 pragma Overriding_Renamings;
5003 @end smallexample
5004
5005 @noindent
5006 This is a GNAT configuration pragma to simplify porting
5007 legacy code accepted by the Rational
5008 Ada compiler. In the presence of this pragma, a renaming declaration that
5009 renames an inherited operation declared in the same scope is legal if selected
5010 notation is used as in:
5011
5012 @smallexample @c ada
5013 pragma Overriding_Renamings;
5014 ...
5015 package R is
5016 function F (..);
5017 ...
5018 function F (..) renames R.F;
5019 end R;
5020 @end smallexample
5021
5022 even though
5023 RM 8.3 (15) stipulates that an overridden operation is not visible within the
5024 declaration of the overriding operation.
5025
5026 @node Pragma Partition_Elaboration_Policy
5027 @unnumberedsec Pragma Partition_Elaboration_Policy
5028 @findex Partition_Elaboration_Policy
5029 @noindent
5030 Syntax:
5031
5032 @smallexample @c ada
5033 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
5034
5035 POLICY_IDENTIFIER ::= Concurrent | Sequential
5036 @end smallexample
5037
5038 @noindent
5039 This pragma is standard in Ada 2005, but is available in all earlier
5040 versions of Ada as an implementation-defined pragma.
5041 See Ada 2012 Reference Manual for details.
5042
5043 @node Pragma Passive
5044 @unnumberedsec Pragma Passive
5045 @findex Passive
5046 @noindent
5047 Syntax:
5048
5049 @smallexample @c ada
5050 pragma Passive [(Semaphore | No)];
5051 @end smallexample
5052
5053 @noindent
5054 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
5055 compatibility with DEC Ada 83 implementations, where it is used within a
5056 task definition to request that a task be made passive. If the argument
5057 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
5058 treats the pragma as an assertion that the containing task is passive
5059 and that optimization of context switch with this task is permitted and
5060 desired. If the argument @code{No} is present, the task must not be
5061 optimized. GNAT does not attempt to optimize any tasks in this manner
5062 (since protected objects are available in place of passive tasks).
5063
5064 For more information on the subject of passive tasks, see the section
5065 ``Passive Task Optimization'' in the GNAT Users Guide.
5066
5067 @node Pragma Persistent_BSS
5068 @unnumberedsec Pragma Persistent_BSS
5069 @findex Persistent_BSS
5070 @noindent
5071 Syntax:
5072
5073 @smallexample @c ada
5074 pragma Persistent_BSS [(LOCAL_NAME)]
5075 @end smallexample
5076
5077 @noindent
5078 This pragma allows selected objects to be placed in the @code{.persistent_bss}
5079 section. On some targets the linker and loader provide for special
5080 treatment of this section, allowing a program to be reloaded without
5081 affecting the contents of this data (hence the name persistent).
5082
5083 There are two forms of usage. If an argument is given, it must be the
5084 local name of a library level object, with no explicit initialization
5085 and whose type is potentially persistent. If no argument is given, then
5086 the pragma is a configuration pragma, and applies to all library level
5087 objects with no explicit initialization of potentially persistent types.
5088
5089 A potentially persistent type is a scalar type, or a non-tagged,
5090 non-discriminated record, all of whose components have no explicit
5091 initialization and are themselves of a potentially persistent type,
5092 or an array, all of whose constraints are static, and whose component
5093 type is potentially persistent.
5094
5095 If this pragma is used on a target where this feature is not supported,
5096 then the pragma will be ignored. See also @code{pragma Linker_Section}.
5097
5098 @node Pragma Polling
5099 @unnumberedsec Pragma Polling
5100 @findex Polling
5101 @noindent
5102 Syntax:
5103
5104 @smallexample @c ada
5105 pragma Polling (ON | OFF);
5106 @end smallexample
5107
5108 @noindent
5109 This pragma controls the generation of polling code. This is normally off.
5110 If @code{pragma Polling (ON)} is used then periodic calls are generated to
5111 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
5112 runtime library, and can be found in file @file{a-excpol.adb}.
5113
5114 Pragma @code{Polling} can appear as a configuration pragma (for example it
5115 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
5116 can be used in the statement or declaration sequence to control polling
5117 more locally.
5118
5119 A call to the polling routine is generated at the start of every loop and
5120 at the start of every subprogram call. This guarantees that the @code{Poll}
5121 routine is called frequently, and places an upper bound (determined by
5122 the complexity of the code) on the period between two @code{Poll} calls.
5123
5124 The primary purpose of the polling interface is to enable asynchronous
5125 aborts on targets that cannot otherwise support it (for example Windows
5126 NT), but it may be used for any other purpose requiring periodic polling.
5127 The standard version is null, and can be replaced by a user program. This
5128 will require re-compilation of the @code{Ada.Exceptions} package that can
5129 be found in files @file{a-except.ads} and @file{a-except.adb}.
5130
5131 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
5132 distribution) is used to enable the asynchronous abort capability on
5133 targets that do not normally support the capability. The version of
5134 @code{Poll} in this file makes a call to the appropriate runtime routine
5135 to test for an abort condition.
5136
5137 Note that polling can also be enabled by use of the @option{-gnatP} switch.
5138 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
5139 details.
5140
5141 @node Pragma Post
5142 @unnumberedsec Pragma Post
5143 @cindex Post
5144 @cindex Checks, postconditions
5145 @findex Postconditions
5146 @noindent
5147 Syntax:
5148
5149 @smallexample @c ada
5150 pragma Post (Boolean_Expression);
5151 @end smallexample
5152
5153 @noindent
5154 The @code{Post} pragma is intended to be an exact replacement for
5155 the language-defined
5156 @code{Post} aspect, and shares its restrictions and semantics.
5157 It must appear either immediately following the corresponding
5158 subprogram declaration (only other pragmas may intervene), or
5159 if there is no separate subprogram declaration, then it can
5160 appear at the start of the declarations in a subprogram body
5161 (preceded only by other pragmas).
5162
5163 @node Pragma Postcondition
5164 @unnumberedsec Pragma Postcondition
5165 @cindex Postcondition
5166 @cindex Checks, postconditions
5167 @findex Postconditions
5168 @noindent
5169 Syntax:
5170
5171 @smallexample @c ada
5172 pragma Postcondition (
5173 [Check =>] Boolean_Expression
5174 [,[Message =>] String_Expression]);
5175 @end smallexample
5176
5177 @noindent
5178 The @code{Postcondition} pragma allows specification of automatic
5179 postcondition checks for subprograms. These checks are similar to
5180 assertions, but are automatically inserted just prior to the return
5181 statements of the subprogram with which they are associated (including
5182 implicit returns at the end of procedure bodies and associated
5183 exception handlers).
5184
5185 In addition, the boolean expression which is the condition which
5186 must be true may contain references to function'Result in the case
5187 of a function to refer to the returned value.
5188
5189 @code{Postcondition} pragmas may appear either immediately following the
5190 (separate) declaration of a subprogram, or at the start of the
5191 declarations of a subprogram body. Only other pragmas may intervene
5192 (that is appear between the subprogram declaration and its
5193 postconditions, or appear before the postcondition in the
5194 declaration sequence in a subprogram body). In the case of a
5195 postcondition appearing after a subprogram declaration, the
5196 formal arguments of the subprogram are visible, and can be
5197 referenced in the postcondition expressions.
5198
5199 The postconditions are collected and automatically tested just
5200 before any return (implicit or explicit) in the subprogram body.
5201 A postcondition is only recognized if postconditions are active
5202 at the time the pragma is encountered. The compiler switch @option{gnata}
5203 turns on all postconditions by default, and pragma @code{Check_Policy}
5204 with an identifier of @code{Postcondition} can also be used to
5205 control whether postconditions are active.
5206
5207 The general approach is that postconditions are placed in the spec
5208 if they represent functional aspects which make sense to the client.
5209 For example we might have:
5210
5211 @smallexample @c ada
5212 function Direction return Integer;
5213 pragma Postcondition
5214 (Direction'Result = +1
5215 or else
5216 Direction'Result = -1);
5217 @end smallexample
5218
5219 @noindent
5220 which serves to document that the result must be +1 or -1, and
5221 will test that this is the case at run time if postcondition
5222 checking is active.
5223
5224 Postconditions within the subprogram body can be used to
5225 check that some internal aspect of the implementation,
5226 not visible to the client, is operating as expected.
5227 For instance if a square root routine keeps an internal
5228 counter of the number of times it is called, then we
5229 might have the following postcondition:
5230
5231 @smallexample @c ada
5232 Sqrt_Calls : Natural := 0;
5233
5234 function Sqrt (Arg : Float) return Float is
5235 pragma Postcondition
5236 (Sqrt_Calls = Sqrt_Calls'Old + 1);
5237 ...
5238 end Sqrt
5239 @end smallexample
5240
5241 @noindent
5242 As this example, shows, the use of the @code{Old} attribute
5243 is often useful in postconditions to refer to the state on
5244 entry to the subprogram.
5245
5246 Note that postconditions are only checked on normal returns
5247 from the subprogram. If an abnormal return results from
5248 raising an exception, then the postconditions are not checked.
5249
5250 If a postcondition fails, then the exception
5251 @code{System.Assertions.Assert_Failure} is raised. If
5252 a message argument was supplied, then the given string
5253 will be used as the exception message. If no message
5254 argument was supplied, then the default message has
5255 the form "Postcondition failed at file:line". The
5256 exception is raised in the context of the subprogram
5257 body, so it is possible to catch postcondition failures
5258 within the subprogram body itself.
5259
5260 Within a package spec, normal visibility rules
5261 in Ada would prevent forward references within a
5262 postcondition pragma to functions defined later in
5263 the same package. This would introduce undesirable
5264 ordering constraints. To avoid this problem, all
5265 postcondition pragmas are analyzed at the end of
5266 the package spec, allowing forward references.
5267
5268 The following example shows that this even allows
5269 mutually recursive postconditions as in:
5270
5271 @smallexample @c ada
5272 package Parity_Functions is
5273 function Odd (X : Natural) return Boolean;
5274 pragma Postcondition
5275 (Odd'Result =
5276 (x = 1
5277 or else
5278 (x /= 0 and then Even (X - 1))));
5279
5280 function Even (X : Natural) return Boolean;
5281 pragma Postcondition
5282 (Even'Result =
5283 (x = 0
5284 or else
5285 (x /= 1 and then Odd (X - 1))));
5286
5287 end Parity_Functions;
5288 @end smallexample
5289
5290 @noindent
5291 There are no restrictions on the complexity or form of
5292 conditions used within @code{Postcondition} pragmas.
5293 The following example shows that it is even possible
5294 to verify performance behavior.
5295
5296 @smallexample @c ada
5297 package Sort is
5298
5299 Performance : constant Float;
5300 -- Performance constant set by implementation
5301 -- to match target architecture behavior.
5302
5303 procedure Treesort (Arg : String);
5304 -- Sorts characters of argument using N*logN sort
5305 pragma Postcondition
5306 (Float (Clock - Clock'Old) <=
5307 Float (Arg'Length) *
5308 log (Float (Arg'Length)) *
5309 Performance);
5310 end Sort;
5311 @end smallexample
5312
5313 @noindent
5314 Note: postcondition pragmas associated with subprograms that are
5315 marked as Inline_Always, or those marked as Inline with front-end
5316 inlining (-gnatN option set) are accepted and legality-checked
5317 by the compiler, but are ignored at run-time even if postcondition
5318 checking is enabled.
5319
5320 Note that pragma @code{Postcondition} differs from the language-defined
5321 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
5322 multiple occurrences, allowing occurences in the body even if there
5323 is a separate spec, and allowing a second string parameter, and the
5324 use of the pragma identifier @code{Check}. Historically, pragma
5325 @code{Postcondition} was implemented prior to the development of
5326 Ada 2012, and has been retained in its original form for
5327 compatibility purposes.
5328
5329 @node Pragma Post_Class
5330 @unnumberedsec Pragma Post_Class
5331 @cindex Post
5332 @cindex Checks, postconditions
5333 @findex Postconditions
5334 @noindent
5335 Syntax:
5336
5337 @smallexample @c ada
5338 pragma Post_Class (Boolean_Expression);
5339 @end smallexample
5340
5341 @noindent
5342 The @code{Post_Class} pragma is intended to be an exact replacement for
5343 the language-defined
5344 @code{Post'Class} aspect, and shares its restrictions and semantics.
5345 It must appear either immediately following the corresponding
5346 subprogram declaration (only other pragmas may intervene), or
5347 if there is no separate subprogram declaration, then it can
5348 appear at the start of the declarations in a subprogram body
5349 (preceded only by other pragmas).
5350
5351 Note: This pragma is called @code{Post_Class} rather than
5352 @code{Post'Class} because the latter would not be strictly
5353 conforming to the allowed syntax for pragmas. The motivation
5354 for provinding pragmas equivalent to the aspects is to allow a program
5355 to be written using the pragmas, and then compiled if necessary
5356 using an Ada compiler that does not recognize the pragmas or
5357 aspects, but is prepared to ignore the pragmas. The assertion
5358 policy that controls this pragma is @code{Post'Class}, not
5359 @code{Post_Class}.
5360
5361 @node Pragma Pre
5362 @unnumberedsec Pragma Pre
5363 @cindex Pre
5364 @cindex Checks, preconditions
5365 @findex Preconditions
5366 @noindent
5367 Syntax:
5368
5369 @smallexample @c ada
5370 pragma Pre (Boolean_Expression);
5371 @end smallexample
5372
5373 @noindent
5374 The @code{Pre} pragma is intended to be an exact replacement for
5375 the language-defined
5376 @code{Pre} aspect, and shares its restrictions and semantics.
5377 It must appear either immediately following the corresponding
5378 subprogram declaration (only other pragmas may intervene), or
5379 if there is no separate subprogram declaration, then it can
5380 appear at the start of the declarations in a subprogram body
5381 (preceded only by other pragmas).
5382
5383 @node Pragma Precondition
5384 @unnumberedsec Pragma Precondition
5385 @cindex Preconditions
5386 @cindex Checks, preconditions
5387 @findex Preconditions
5388 @noindent
5389 Syntax:
5390
5391 @smallexample @c ada
5392 pragma Precondition (
5393 [Check =>] Boolean_Expression
5394 [,[Message =>] String_Expression]);
5395 @end smallexample
5396
5397 @noindent
5398 The @code{Precondition} pragma is similar to @code{Postcondition}
5399 except that the corresponding checks take place immediately upon
5400 entry to the subprogram, and if a precondition fails, the exception
5401 is raised in the context of the caller, and the attribute 'Result
5402 cannot be used within the precondition expression.
5403
5404 Otherwise, the placement and visibility rules are identical to those
5405 described for postconditions. The following is an example of use
5406 within a package spec:
5407
5408 @smallexample @c ada
5409 package Math_Functions is
5410 ...
5411 function Sqrt (Arg : Float) return Float;
5412 pragma Precondition (Arg >= 0.0)
5413 ...
5414 end Math_Functions;
5415 @end smallexample
5416
5417 @noindent
5418 @code{Precondition} pragmas may appear either immediately following the
5419 (separate) declaration of a subprogram, or at the start of the
5420 declarations of a subprogram body. Only other pragmas may intervene
5421 (that is appear between the subprogram declaration and its
5422 postconditions, or appear before the postcondition in the
5423 declaration sequence in a subprogram body).
5424
5425 Note: precondition pragmas associated with subprograms that are
5426 marked as Inline_Always, or those marked as Inline with front-end
5427 inlining (-gnatN option set) are accepted and legality-checked
5428 by the compiler, but are ignored at run-time even if precondition
5429 checking is enabled.
5430
5431 Note that pragma @code{Precondition} differs from the language-defined
5432 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
5433 multiple occurrences, allowing occurences in the body even if there
5434 is a separate spec, and allowing a second string parameter, and the
5435 use of the pragma identifier @code{Check}. Historically, pragma
5436 @code{Precondition} was implemented prior to the development of
5437 Ada 2012, and has been retained in its original form for
5438 compatibility purposes.
5439
5440 @node Pragma Predicate
5441 @unnumberedsec Pragma Predicate
5442 @findex Predicate
5443 @findex Predicate pragma
5444 @noindent
5445 Syntax:
5446
5447 @smallexample @c ada
5448 pragma Predicate
5449 ([Entity =>] type_LOCAL_NAME,
5450 [Check =>] EXPRESSION);
5451 @end smallexample
5452
5453 @noindent
5454 This pragma (available in all versions of Ada in GNAT) encompasses both
5455 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
5456 Ada 2012. A predicate is regarded as static if it has an allowed form
5457 for @code{Static_Predicate} and is otherwise treated as a
5458 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
5459 pragma behave exactly as described in the Ada 2012 reference manual.
5460 For example, if we have
5461
5462 @smallexample @c ada
5463 type R is range 1 .. 10;
5464 subtype S is R;
5465 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5466 subtype Q is R
5467 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5468 @end smallexample
5469
5470 @noindent
5471 the effect is identical to the following Ada 2012 code:
5472
5473 @smallexample @c ada
5474 type R is range 1 .. 10;
5475 subtype S is R with
5476 Static_Predicate => S not in 4 .. 6;
5477 subtype Q is R with
5478 Dynamic_Predicate => F(Q) or G(Q);
5479 @end smallexample
5480
5481 Note that there is are no pragmas @code{Dynamic_Predicate}
5482 or @code{Static_Predicate}. That is
5483 because these pragmas would affect legality and semantics of
5484 the program and thus do not have a neutral effect if ignored.
5485 The motivation behind providing pragmas equivalent to
5486 corresponding aspects is to allow a program to be written
5487 using the pragmas, and then compiled with a compiler that
5488 will ignore the pragmas. That doesn't work in the case of
5489 static and dynamic predicates, since if the corresponding
5490 pragmas are ignored, then the behavior of the program is
5491 fundamentally changed (for example a membership test
5492 @code{A in B} would not take into account a predicate
5493 defined for subtype B). When following this approach, the
5494 use of predicates should be avoided.
5495
5496 @node Pragma Preelaborable_Initialization
5497 @unnumberedsec Pragma Preelaborable_Initialization
5498 @findex Preelaborable_Initialization
5499 @noindent
5500 Syntax:
5501
5502 @smallexample @c ada
5503 pragma Preelaborable_Initialization (DIRECT_NAME);
5504 @end smallexample
5505
5506 @noindent
5507 This pragma is standard in Ada 2005, but is available in all earlier
5508 versions of Ada as an implementation-defined pragma.
5509 See Ada 2012 Reference Manual for details.
5510
5511 @node Pragma Preelaborate_05
5512 @unnumberedsec Pragma Preelaborate_05
5513 @findex Preelaborate_05
5514 @noindent
5515 Syntax:
5516
5517 @smallexample @c ada
5518 pragma Preelaborate_05 [(library_unit_NAME)];
5519 @end smallexample
5520
5521 @noindent
5522 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5523 and is intended for use in the standard run-time library only. It has
5524 no effect in Ada 83 or Ada 95 mode, but is
5525 equivalent to @code{pragma Prelaborate} when operating in later
5526 Ada versions. This is used to handle some cases where packages
5527 not previously preelaborable became so in Ada 2005.
5528
5529 @node Pragma Pre_Class
5530 @unnumberedsec Pragma Pre_Class
5531 @cindex Pre_Class
5532 @cindex Checks, preconditions
5533 @findex Preconditions
5534 @noindent
5535 Syntax:
5536
5537 @smallexample @c ada
5538 pragma Pre_Class (Boolean_Expression);
5539 @end smallexample
5540
5541 @noindent
5542 The @code{Pre_Class} pragma is intended to be an exact replacement for
5543 the language-defined
5544 @code{Pre'Class} aspect, and shares its restrictions and semantics.
5545 It must appear either immediately following the corresponding
5546 subprogram declaration (only other pragmas may intervene), or
5547 if there is no separate subprogram declaration, then it can
5548 appear at the start of the declarations in a subprogram body
5549 (preceded only by other pragmas).
5550
5551 Note: This pragma is called @code{Pre_Class} rather than
5552 @code{Pre'Class} because the latter would not be strictly
5553 conforming to the allowed syntax for pragmas. The motivation
5554 for providing pragmas equivalent to the aspects is to allow a program
5555 to be written using the pragmas, and then compiled if necessary
5556 using an Ada compiler that does not recognize the pragmas or
5557 aspects, but is prepared to ignore the pragmas. The assertion
5558 policy that controls this pragma is @code{Pre'Class}, not
5559 @code{Pre_Class}.
5560
5561 @node Pragma Priority_Specific_Dispatching
5562 @unnumberedsec Pragma Priority_Specific_Dispatching
5563 @findex Priority_Specific_Dispatching
5564 @noindent
5565 Syntax:
5566
5567 @smallexample @c ada
5568 pragma Priority_Specific_Dispatching (
5569 POLICY_IDENTIFIER,
5570 first_priority_EXPRESSION,
5571 last_priority_EXPRESSION)
5572
5573 POLICY_IDENTIFIER ::=
5574 EDF_Across_Priorities |
5575 FIFO_Within_Priorities |
5576 Non_Preemptive_Within_Priorities |
5577 Round_Robin_Within_Priorities
5578 @end smallexample
5579
5580 @noindent
5581 This pragma is standard in Ada 2005, but is available in all earlier
5582 versions of Ada as an implementation-defined pragma.
5583 See Ada 2012 Reference Manual for details.
5584
5585 @node Pragma Profile
5586 @unnumberedsec Pragma Profile
5587 @findex Profile
5588 @noindent
5589 Syntax:
5590
5591 @smallexample @c ada
5592 pragma Profile (Ravenscar | Restricted | Rational);
5593 @end smallexample
5594
5595 @noindent
5596 This pragma is standard in Ada 2005, but is available in all earlier
5597 versions of Ada as an implementation-defined pragma. This is a
5598 configuration pragma that establishes a set of configiuration pragmas
5599 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5600 The other two possibilities (@code{Restricted} or @code{Rational})
5601 are implementation-defined. The set of configuration pragmas
5602 is defined in the following sections.
5603
5604 @itemize
5605
5606 @item Pragma Profile (Ravenscar)
5607 @findex Ravenscar
5608 @noindent
5609
5610 The @code{Ravenscar} profile is standard in Ada 2005,
5611 but is available in all earlier
5612 versions of Ada as an implementation-defined pragma. This profile
5613 establishes the following set of configuration pragmas:
5614
5615 @table @code
5616 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5617 [RM D.2.2] Tasks are dispatched following a preemptive
5618 priority-ordered scheduling policy.
5619
5620 @item Locking_Policy (Ceiling_Locking)
5621 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5622 the ceiling priority of the corresponding protected object.
5623
5624 @item Detect_Blocking
5625 This pragma forces the detection of potentially blocking operations within a
5626 protected operation, and to raise Program_Error if that happens.
5627 @end table
5628 @noindent
5629
5630 plus the following set of restrictions:
5631
5632 @table @code
5633 @item Max_Entry_Queue_Length => 1
5634 No task can be queued on a protected entry.
5635 @item Max_Protected_Entries => 1
5636 @item Max_Task_Entries => 0
5637 No rendezvous statements are allowed.
5638 @item No_Abort_Statements
5639 @item No_Dynamic_Attachment
5640 @item No_Dynamic_Priorities
5641 @item No_Implicit_Heap_Allocations
5642 @item No_Local_Protected_Objects
5643 @item No_Local_Timing_Events
5644 @item No_Protected_Type_Allocators
5645 @item No_Relative_Delay
5646 @item No_Requeue_Statements
5647 @item No_Select_Statements
5648 @item No_Specific_Termination_Handlers
5649 @item No_Task_Allocators
5650 @item No_Task_Hierarchy
5651 @item No_Task_Termination
5652 @item Simple_Barriers
5653 @end table
5654 @noindent
5655
5656 The Ravenscar profile also includes the following restrictions that specify
5657 that there are no semantic dependences on the corresponding predefined
5658 packages:
5659
5660 @table @code
5661 @item No_Dependence => Ada.Asynchronous_Task_Control
5662 @item No_Dependence => Ada.Calendar
5663 @item No_Dependence => Ada.Execution_Time.Group_Budget
5664 @item No_Dependence => Ada.Execution_Time.Timers
5665 @item No_Dependence => Ada.Task_Attributes
5666 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5667 @end table
5668
5669 @noindent
5670
5671 This set of configuration pragmas and restrictions correspond to the
5672 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5673 published by the @cite{International Real-Time Ada Workshop}, 1997,
5674 and whose most recent description is available at
5675 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5676
5677 The original definition of the profile was revised at subsequent IRTAW
5678 meetings. It has been included in the ISO
5679 @cite{Guide for the Use of the Ada Programming Language in High
5680 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5681 the next revision of the standard. The formal definition given by
5682 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5683 AI-305) available at
5684 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5685 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5686
5687 The above set is a superset of the restrictions provided by pragma
5688 @code{Profile (Restricted)}, it includes six additional restrictions
5689 (@code{Simple_Barriers}, @code{No_Select_Statements},
5690 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5691 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
5692 that pragma @code{Profile (Ravenscar)}, like the pragma
5693 @code{Profile (Restricted)},
5694 automatically causes the use of a simplified,
5695 more efficient version of the tasking run-time system.
5696
5697 @item Pragma Profile (Restricted)
5698 @findex Restricted Run Time
5699 @noindent
5700 This profile corresponds to the GNAT restricted run time. It
5701 establishes the following set of restrictions:
5702
5703 @itemize @bullet
5704 @item No_Abort_Statements
5705 @item No_Entry_Queue
5706 @item No_Task_Hierarchy
5707 @item No_Task_Allocators
5708 @item No_Dynamic_Priorities
5709 @item No_Terminate_Alternatives
5710 @item No_Dynamic_Attachment
5711 @item No_Protected_Type_Allocators
5712 @item No_Local_Protected_Objects
5713 @item No_Requeue_Statements
5714 @item No_Task_Attributes_Package
5715 @item Max_Asynchronous_Select_Nesting = 0
5716 @item Max_Task_Entries = 0
5717 @item Max_Protected_Entries = 1
5718 @item Max_Select_Alternatives = 0
5719 @end itemize
5720
5721 @noindent
5722 This set of restrictions causes the automatic selection of a simplified
5723 version of the run time that provides improved performance for the
5724 limited set of tasking functionality permitted by this set of restrictions.
5725
5726 @item Pragma Profile (Rational)
5727 @findex Rational compatibility mode
5728 @noindent
5729 The Rational profile is intended to facilitate porting legacy code that
5730 compiles with the Rational APEX compiler, even when the code includes non-
5731 conforming Ada constructs. The profile enables the following three pragmas:
5732
5733 @itemize @bullet
5734 @item pragma Implicit_Packing
5735 @item pragma Overriding_Renamings
5736 @item pragma Use_VADS_Size
5737 @end itemize
5738
5739 @end itemize
5740
5741 @node Pragma Profile_Warnings
5742 @unnumberedsec Pragma Profile_Warnings
5743 @findex Profile_Warnings
5744 @noindent
5745 Syntax:
5746
5747 @smallexample @c ada
5748 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5749 @end smallexample
5750
5751 @noindent
5752 This is an implementation-defined pragma that is similar in
5753 effect to @code{pragma Profile} except that instead of
5754 generating @code{Restrictions} pragmas, it generates
5755 @code{Restriction_Warnings} pragmas. The result is that
5756 violations of the profile generate warning messages instead
5757 of error messages.
5758
5759 @node Pragma Propagate_Exceptions
5760 @unnumberedsec Pragma Propagate_Exceptions
5761 @cindex Interfacing to C++
5762 @findex Propagate_Exceptions
5763 @noindent
5764 Syntax:
5765
5766 @smallexample @c ada
5767 pragma Propagate_Exceptions;
5768 @end smallexample
5769
5770 @noindent
5771 This pragma is now obsolete and, other than generating a warning if warnings
5772 on obsolescent features are enabled, is ignored.
5773 It is retained for compatibility
5774 purposes. It used to be used in connection with optimization of
5775 a now-obsolete mechanism for implementation of exceptions.
5776
5777 @node Pragma Psect_Object
5778 @unnumberedsec Pragma Psect_Object
5779 @findex Psect_Object
5780 @noindent
5781 Syntax:
5782
5783 @smallexample @c ada
5784 pragma Psect_Object (
5785 [Internal =>] LOCAL_NAME,
5786 [, [External =>] EXTERNAL_SYMBOL]
5787 [, [Size =>] EXTERNAL_SYMBOL]);
5788
5789 EXTERNAL_SYMBOL ::=
5790 IDENTIFIER
5791 | static_string_EXPRESSION
5792 @end smallexample
5793
5794 @noindent
5795 This pragma is identical in effect to pragma @code{Common_Object}.
5796
5797 @node Pragma Pure_05
5798 @unnumberedsec Pragma Pure_05
5799 @findex Pure_05
5800 @noindent
5801 Syntax:
5802
5803 @smallexample @c ada
5804 pragma Pure_05 [(library_unit_NAME)];
5805 @end smallexample
5806
5807 @noindent
5808 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5809 and is intended for use in the standard run-time library only. It has
5810 no effect in Ada 83 or Ada 95 mode, but is
5811 equivalent to @code{pragma Pure} when operating in later
5812 Ada versions. This is used to handle some cases where packages
5813 not previously pure became so in Ada 2005.
5814
5815 @node Pragma Pure_12
5816 @unnumberedsec Pragma Pure_12
5817 @findex Pure_12
5818 @noindent
5819 Syntax:
5820
5821 @smallexample @c ada
5822 pragma Pure_12 [(library_unit_NAME)];
5823 @end smallexample
5824
5825 @noindent
5826 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5827 and is intended for use in the standard run-time library only. It has
5828 no effect in Ada 83, Ada 95, or Ada 2005 modes, but is
5829 equivalent to @code{pragma Pure} when operating in later
5830 Ada versions. This is used to handle some cases where packages
5831 not previously pure became so in Ada 2012.
5832
5833 @node Pragma Pure_Function
5834 @unnumberedsec Pragma Pure_Function
5835 @findex Pure_Function
5836 @noindent
5837 Syntax:
5838
5839 @smallexample @c ada
5840 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5841 @end smallexample
5842
5843 @noindent
5844 This pragma appears in the same declarative part as a function
5845 declaration (or a set of function declarations if more than one
5846 overloaded declaration exists, in which case the pragma applies
5847 to all entities). It specifies that the function @code{Entity} is
5848 to be considered pure for the purposes of code generation. This means
5849 that the compiler can assume that there are no side effects, and
5850 in particular that two calls with identical arguments produce the
5851 same result. It also means that the function can be used in an
5852 address clause.
5853
5854 Note that, quite deliberately, there are no static checks to try
5855 to ensure that this promise is met, so @code{Pure_Function} can be used
5856 with functions that are conceptually pure, even if they do modify
5857 global variables. For example, a square root function that is
5858 instrumented to count the number of times it is called is still
5859 conceptually pure, and can still be optimized, even though it
5860 modifies a global variable (the count). Memo functions are another
5861 example (where a table of previous calls is kept and consulted to
5862 avoid re-computation).
5863
5864 Note also that the normal rules excluding optimization of subprograms
5865 in pure units (when parameter types are descended from System.Address,
5866 or when the full view of a parameter type is limited), do not apply
5867 for the Pure_Function case. If you explicitly specify Pure_Function,
5868 the compiler may optimize away calls with identical arguments, and
5869 if that results in unexpected behavior, the proper action is not to
5870 use the pragma for subprograms that are not (conceptually) pure.
5871
5872 @findex Pure
5873 Note: Most functions in a @code{Pure} package are automatically pure, and
5874 there is no need to use pragma @code{Pure_Function} for such functions. One
5875 exception is any function that has at least one formal of type
5876 @code{System.Address} or a type derived from it. Such functions are not
5877 considered pure by default, since the compiler assumes that the
5878 @code{Address} parameter may be functioning as a pointer and that the
5879 referenced data may change even if the address value does not.
5880 Similarly, imported functions are not considered to be pure by default,
5881 since there is no way of checking that they are in fact pure. The use
5882 of pragma @code{Pure_Function} for such a function will override these default
5883 assumption, and cause the compiler to treat a designated subprogram as pure
5884 in these cases.
5885
5886 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5887 applies to the underlying renamed function. This can be used to
5888 disambiguate cases of overloading where some but not all functions
5889 in a set of overloaded functions are to be designated as pure.
5890
5891 If pragma @code{Pure_Function} is applied to a library level function, the
5892 function is also considered pure from an optimization point of view, but the
5893 unit is not a Pure unit in the categorization sense. So for example, a function
5894 thus marked is free to @code{with} non-pure units.
5895
5896 @node Pragma Ravenscar
5897 @unnumberedsec Pragma Ravenscar
5898 @findex Pragma Ravenscar
5899 @noindent
5900 Syntax:
5901
5902 @smallexample @c ada
5903 pragma Ravenscar;
5904 @end smallexample
5905
5906 @noindent
5907 This pragma is considered obsolescent, but is retained for
5908 compatibility purposes. It is equivalent to:
5909
5910 @smallexample @c ada
5911 pragma Profile (Ravenscar);
5912 @end smallexample
5913
5914 @noindent
5915 which is the preferred method of setting the @code{Ravenscar} profile.
5916
5917 @node Pragma Refined_State
5918 @unnumberedsec Pragma Refined_State
5919 @findex Refined_State
5920 @noindent
5921 For the description of this pragma, see SPARK 2014 Reference Manual,
5922 section 7.2.2.
5923
5924 @node Pragma Relative_Deadline
5925 @unnumberedsec Pragma Relative_Deadline
5926 @findex Relative_Deadline
5927 @noindent
5928 Syntax:
5929
5930 @smallexample @c ada
5931 pragma Relative_Deadline (time_span_EXPRESSION);
5932 @end smallexample
5933
5934 @noindent
5935 This pragma is standard in Ada 2005, but is available in all earlier
5936 versions of Ada as an implementation-defined pragma.
5937 See Ada 2012 Reference Manual for details.
5938
5939 @node Pragma Remote_Access_Type
5940 @unnumberedsec Pragma Remote_Access_Type
5941 @findex Remote_Access_Type
5942 @noindent
5943 Syntax:
5944
5945 @smallexample @c ada
5946 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
5947 @end smallexample
5948
5949 @noindent
5950 This pragma appears in the formal part of a generic declaration.
5951 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
5952 the use of a remote access to class-wide type as actual for a formal
5953 access type.
5954
5955 When this pragma applies to a formal access type @code{Entity}, that
5956 type is treated as a remote access to class-wide type in the generic.
5957 It must be a formal general access type, and its designated type must
5958 be the class-wide type of a formal tagged limited private type from the
5959 same generic declaration.
5960
5961 In the generic unit, the formal type is subject to all restrictions
5962 pertaining to remote access to class-wide types. At instantiation, the
5963 actual type must be a remote access to class-wide type.
5964
5965 @node Pragma Restricted_Run_Time
5966 @unnumberedsec Pragma Restricted_Run_Time
5967 @findex Pragma Restricted_Run_Time
5968 @noindent
5969 Syntax:
5970
5971 @smallexample @c ada
5972 pragma Restricted_Run_Time;
5973 @end smallexample
5974
5975 @noindent
5976 This pragma is considered obsolescent, but is retained for
5977 compatibility purposes. It is equivalent to:
5978
5979 @smallexample @c ada
5980 pragma Profile (Restricted);
5981 @end smallexample
5982
5983 @noindent
5984 which is the preferred method of setting the restricted run time
5985 profile.
5986
5987 @node Pragma Restriction_Warnings
5988 @unnumberedsec Pragma Restriction_Warnings
5989 @findex Restriction_Warnings
5990 @noindent
5991 Syntax:
5992
5993 @smallexample @c ada
5994 pragma Restriction_Warnings
5995 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
5996 @end smallexample
5997
5998 @noindent
5999 This pragma allows a series of restriction identifiers to be
6000 specified (the list of allowed identifiers is the same as for
6001 pragma @code{Restrictions}). For each of these identifiers
6002 the compiler checks for violations of the restriction, but
6003 generates a warning message rather than an error message
6004 if the restriction is violated.
6005
6006 @node Pragma Share_Generic
6007 @unnumberedsec Pragma Share_Generic
6008 @findex Share_Generic
6009 @noindent
6010 Syntax:
6011
6012 @smallexample @c ada
6013 pragma Share_Generic (GNAME @{, GNAME@});
6014
6015 GNAME ::= generic_unit_NAME | generic_instance_NAME
6016 @end smallexample
6017
6018 @noindent
6019 This pragma is provided for compatibility with Dec Ada 83. It has
6020 no effect in @code{GNAT} (which does not implement shared generics), other
6021 than to check that the given names are all names of generic units or
6022 generic instances.
6023
6024 @node Pragma Shared
6025 @unnumberedsec Pragma Shared
6026 @findex Shared
6027
6028 @noindent
6029 This pragma is provided for compatibility with Ada 83. The syntax and
6030 semantics are identical to pragma Atomic.
6031
6032 @node Pragma Short_Circuit_And_Or
6033 @unnumberedsec Pragma Short_Circuit_And_Or
6034 @findex Short_Circuit_And_Or
6035 @noindent
6036 Syntax:
6037
6038 @smallexample @c ada
6039 pragma Short_Circuit_And_Or;
6040 @end smallexample
6041
6042 @noindent
6043 This configuration pragma causes any occurrence of the AND operator applied to
6044 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
6045 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
6046 may be useful in the context of certification protocols requiring the use of
6047 short-circuited logical operators. If this configuration pragma occurs locally
6048 within the file being compiled, it applies only to the file being compiled.
6049 There is no requirement that all units in a partition use this option.
6050
6051 @node Pragma Short_Descriptors
6052 @unnumberedsec Pragma Short_Descriptors
6053 @findex Short_Descriptors
6054 @noindent
6055 Syntax:
6056
6057 @smallexample @c ada
6058 pragma Short_Descriptors
6059 @end smallexample
6060
6061 @noindent
6062 In VMS versions of the compiler, this configuration pragma causes all
6063 occurrences of the mechanism types Descriptor[_xxx] to be treated as
6064 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
6065 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
6066 versions.
6067
6068 @node Pragma Simple_Storage_Pool_Type
6069 @unnumberedsec Pragma Simple_Storage_Pool_Type
6070 @findex Simple_Storage_Pool_Type
6071 @cindex Storage pool, simple
6072 @cindex Simple storage pool
6073 @noindent
6074 Syntax:
6075
6076 @smallexample @c ada
6077 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
6078 @end smallexample
6079
6080 @noindent
6081 A type can be established as a ``simple storage pool type'' by applying
6082 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
6083 A type named in the pragma must be a library-level immutably limited record
6084 type or limited tagged type declared immediately within a package declaration.
6085 The type can also be a limited private type whose full type is allowed as
6086 a simple storage pool type.
6087
6088 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
6089 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
6090 are subtype conformant with the following subprogram declarations:
6091
6092 @smallexample @c ada
6093 procedure Allocate
6094 (Pool : in out SSP;
6095 Storage_Address : out System.Address;
6096 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6097 Alignment : System.Storage_Elements.Storage_Count);
6098
6099 procedure Deallocate
6100 (Pool : in out SSP;
6101 Storage_Address : System.Address;
6102 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6103 Alignment : System.Storage_Elements.Storage_Count);
6104
6105 function Storage_Size (Pool : SSP)
6106 return System.Storage_Elements.Storage_Count;
6107 @end smallexample
6108
6109 @noindent
6110 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
6111 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
6112 applying an unchecked deallocation has no effect other than to set its actual
6113 parameter to null. If @code{Storage_Size} is not declared, then the
6114 @code{Storage_Size} attribute applied to an access type associated with
6115 a pool object of type SSP returns zero. Additional operations can be declared
6116 for a simple storage pool type (such as for supporting a mark/release
6117 storage-management discipline).
6118
6119 An object of a simple storage pool type can be associated with an access
6120 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
6121
6122 @smallexample @c ada
6123
6124 My_Pool : My_Simple_Storage_Pool_Type;
6125
6126 type Acc is access My_Data_Type;
6127
6128 for Acc'Simple_Storage_Pool use My_Pool;
6129
6130 @end smallexample
6131
6132 @noindent
6133 See attribute @code{Simple_Storage_Pool} for further details.
6134
6135 @node Pragma Source_File_Name
6136 @unnumberedsec Pragma Source_File_Name
6137 @findex Source_File_Name
6138 @noindent
6139 Syntax:
6140
6141 @smallexample @c ada
6142 pragma Source_File_Name (
6143 [Unit_Name =>] unit_NAME,
6144 Spec_File_Name => STRING_LITERAL,
6145 [Index => INTEGER_LITERAL]);
6146
6147 pragma Source_File_Name (
6148 [Unit_Name =>] unit_NAME,
6149 Body_File_Name => STRING_LITERAL,
6150 [Index => INTEGER_LITERAL]);
6151 @end smallexample
6152
6153 @noindent
6154 Use this to override the normal naming convention. It is a configuration
6155 pragma, and so has the usual applicability of configuration pragmas
6156 (i.e.@: it applies to either an entire partition, or to all units in a
6157 compilation, or to a single unit, depending on how it is used.
6158 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
6159 the second argument is required, and indicates whether this is the file
6160 name for the spec or for the body.
6161
6162 The optional Index argument should be used when a file contains multiple
6163 units, and when you do not want to use @code{gnatchop} to separate then
6164 into multiple files (which is the recommended procedure to limit the
6165 number of recompilations that are needed when some sources change).
6166 For instance, if the source file @file{source.ada} contains
6167
6168 @smallexample @c ada
6169 package B is
6170 ...
6171 end B;
6172
6173 with B;
6174 procedure A is
6175 begin
6176 ..
6177 end A;
6178 @end smallexample
6179
6180 you could use the following configuration pragmas:
6181
6182 @smallexample @c ada
6183 pragma Source_File_Name
6184 (B, Spec_File_Name => "source.ada", Index => 1);
6185 pragma Source_File_Name
6186 (A, Body_File_Name => "source.ada", Index => 2);
6187 @end smallexample
6188
6189 Note that the @code{gnatname} utility can also be used to generate those
6190 configuration pragmas.
6191
6192 Another form of the @code{Source_File_Name} pragma allows
6193 the specification of patterns defining alternative file naming schemes
6194 to apply to all files.
6195
6196 @smallexample @c ada
6197 pragma Source_File_Name
6198 ( [Spec_File_Name =>] STRING_LITERAL
6199 [,[Casing =>] CASING_SPEC]
6200 [,[Dot_Replacement =>] STRING_LITERAL]);
6201
6202 pragma Source_File_Name
6203 ( [Body_File_Name =>] STRING_LITERAL
6204 [,[Casing =>] CASING_SPEC]
6205 [,[Dot_Replacement =>] STRING_LITERAL]);
6206
6207 pragma Source_File_Name
6208 ( [Subunit_File_Name =>] STRING_LITERAL
6209 [,[Casing =>] CASING_SPEC]
6210 [,[Dot_Replacement =>] STRING_LITERAL]);
6211
6212 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
6213 @end smallexample
6214
6215 @noindent
6216 The first argument is a pattern that contains a single asterisk indicating
6217 the point at which the unit name is to be inserted in the pattern string
6218 to form the file name. The second argument is optional. If present it
6219 specifies the casing of the unit name in the resulting file name string.
6220 The default is lower case. Finally the third argument allows for systematic
6221 replacement of any dots in the unit name by the specified string literal.
6222
6223 Note that Source_File_Name pragmas should not be used if you are using
6224 project files. The reason for this rule is that the project manager is not
6225 aware of these pragmas, and so other tools that use the projet file would not
6226 be aware of the intended naming conventions. If you are using project files,
6227 file naming is controlled by Source_File_Name_Project pragmas, which are
6228 usually supplied automatically by the project manager. A pragma
6229 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
6230
6231 For more details on the use of the @code{Source_File_Name} pragma,
6232 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
6233 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
6234 User's Guide}.
6235
6236 @node Pragma Source_File_Name_Project
6237 @unnumberedsec Pragma Source_File_Name_Project
6238 @findex Source_File_Name_Project
6239 @noindent
6240
6241 This pragma has the same syntax and semantics as pragma Source_File_Name.
6242 It is only allowed as a stand alone configuration pragma.
6243 It cannot appear after a @ref{Pragma Source_File_Name}, and
6244 most importantly, once pragma Source_File_Name_Project appears,
6245 no further Source_File_Name pragmas are allowed.
6246
6247 The intention is that Source_File_Name_Project pragmas are always
6248 generated by the Project Manager in a manner consistent with the naming
6249 specified in a project file, and when naming is controlled in this manner,
6250 it is not permissible to attempt to modify this naming scheme using
6251 Source_File_Name or Source_File_Name_Project pragmas (which would not be
6252 known to the project manager).
6253
6254 @node Pragma Source_Reference
6255 @unnumberedsec Pragma Source_Reference
6256 @findex Source_Reference
6257 @noindent
6258 Syntax:
6259
6260 @smallexample @c ada
6261 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
6262 @end smallexample
6263
6264 @noindent
6265 This pragma must appear as the first line of a source file.
6266 @var{integer_literal} is the logical line number of the line following
6267 the pragma line (for use in error messages and debugging
6268 information). @var{string_literal} is a static string constant that
6269 specifies the file name to be used in error messages and debugging
6270 information. This is most notably used for the output of @code{gnatchop}
6271 with the @option{-r} switch, to make sure that the original unchopped
6272 source file is the one referred to.
6273
6274 The second argument must be a string literal, it cannot be a static
6275 string expression other than a string literal. This is because its value
6276 is needed for error messages issued by all phases of the compiler.
6277
6278 @node Pragma SPARK_Mode
6279 @unnumberedsec Pragma SPARK_Mode
6280 @findex SPARK_Mode
6281 @noindent
6282 Syntax:
6283
6284 @smallexample @c ada
6285 pragma SPARK_Mode [ (On | Off | Auto) ] ;
6286 @end smallexample
6287
6288 @noindent
6289 This pragma is used to specify whether a construct must
6290 satisfy the syntactic and semantic rules of the SPARK 2014 programming
6291 language. The pragma is intended for use with formal verification tools
6292 and has no effect on the generated code.
6293
6294 The SPARK_Mode pragma is used to specify the value of the SPARK_Mode aspect
6295 (a three-valued aspect having values of On, Off, or Auto) of an entity.
6296 More precisely, it is used to specify the aspect value of a ``section''
6297 of an entity (the term ``section'' is defined below).
6298 If a Spark_Mode pragma's (optional) argument is omitted,
6299 an implicit argument of On is assumed.
6300
6301 A SPARK_Mode pragma may be used as a configuration pragma and then has the
6302 semantics described below. A SPARK_Mode pragma which is not used as a
6303 configuration pragma (or an equivalent SPARK_Mode aspect_specification)
6304 shall not have an argument of Auto.
6305
6306 A SPARK_Mode pragma can be used as a local pragma only
6307 in the following contexts:
6308
6309 @itemize @bullet
6310
6311 @item
6312 When the pragma is at the start of the visible declarations (preceded only
6313 by other pragmas) of a package declaration, it marks the visible part
6314 of the package as being in or out of SPARK 2014.
6315
6316 @item
6317 When the pragma appears at the start of the private declarations of a
6318 package (preceded only by other pragmas), it marks the private part
6319 of the package as being in or out of SPARK 2014.
6320
6321 @item
6322 When the pragma appears at the start of the declarations of a
6323 package body (preceded only by other pragmas),
6324 it marks the declaration list of the package body body as being
6325 in or out of SPARK 2014.
6326
6327 @item
6328 When the pragma appears at the start of the elaboration statements of
6329 a package body (preceded only by other pragmas),
6330 it marks the handled_sequence_of_statements of the package body
6331 as being in or out of SPARK 2014.
6332
6333 @item
6334 When the pragma appears after a subprogram declaration (with only other
6335 pragmas intervening), it marks the subprogram's specification as
6336 being in or out of SPARK 2014.
6337
6338 @item
6339 When the pragma appears at the start of the declarations of a subprogram
6340 body (preceded only by other pragmas), it marks the subprogram body
6341 as being in or out of SPARK 2014. For a subprogram body which is
6342 not a completion of another declaration, it also applies to the
6343 specification of the subprogram.
6344
6345 @end itemize
6346
6347 A package is defined to have 4 ``sections'': its visible part, its private
6348 part, its body's declaration list, and its body's
6349 handled_sequence_of_statements. Any other construct which requires a
6350 completion is defined to have 2 ``sections'': its declaration and its
6351 completion. Any other construct is defined to have 1 section.
6352
6353 The SPARK_Mode aspect value of an arbitrary section of an arbitrary Ada entity
6354 or construct is then defined to be the following value (except if this yields
6355 a result of Auto for a non-package; see below):
6356
6357 @itemize
6358
6359 @item
6360 If SPARK_Mode has been specified for the given section of the given entity or
6361 construct, then the specified value;
6362
6363 @item
6364 else if SPARK_Mode has been specified for at least one preceding section of
6365 the same entity, then the SPARK_Mode of the immediately preceding section;
6366
6367 @item
6368 else for any of the visible part or body declarations of a library unit package
6369 or either section of a library unit subprogram, if there is an applicable
6370 SPARK_Mode configuration pragma then the value specified by the
6371 pragma; if no such configuration pragma applies, then an implicit
6372 specification of Auto is assumed;
6373
6374 @item
6375 else for any subsequent (i.e., not the first) section of a library unit
6376 package, the SPARK_Mode of the preceding section;
6377
6378 @item
6379 else the SPARK_Mode of the enclosing section of the nearest enclosing package
6380 or subprogram;
6381
6382 @end itemize
6383
6384 If the above computation yields a result of Auto for any construct other than
6385 one of the four sections of a package, then a result of On or Off is
6386 determined instead based on the legality (with respect to the rules of
6387 SPARK 2014) of the construct. The construct's SPARK_Mode is On if and only
6388 if the construct is in SPARK 2014. [A SPARK_Mode of
6389 Auto is therefore only possible for sections of a package.]
6390
6391 If an earlier section of an entity has a Spark_Mode of Off, then the
6392 Spark_Mode aspect of any later section of that entity shall not be
6393 specified to be On. For example,
6394 if the specification of a subprogram has a Spark_Mode of Off, then the
6395 body of the subprogram shall not have a Spark_Mode of On.
6396
6397 The following rules apply to SPARK code (i.e., constructs which
6398 have a SPARK_Mode aspect value of On):
6399
6400 @itemize
6401
6402 @item
6403 SPARK code shall only reference SPARK declarations, but a SPARK declaration
6404 which requires a completion may have a non-SPARK completion.
6405
6406 @item
6407 SPARK code shall only enclose SPARK code, except that SPARK code may enclose
6408 a non-SPARK completion of an enclosed SPARK declaration.
6409
6410 @end itemize
6411
6412 @node Pragma Static_Elaboration_Desired
6413 @unnumberedsec Pragma Static_Elaboration_Desired
6414 @findex Static_Elaboration_Desired
6415 @noindent
6416 Syntax:
6417
6418 @smallexample @c ada
6419 pragma Static_Elaboration_Desired;
6420 @end smallexample
6421
6422 @noindent
6423 This pragma is used to indicate that the compiler should attempt to initialize
6424 statically the objects declared in the library unit to which the pragma applies,
6425 when these objects are initialized (explicitly or implicitly) by an aggregate.
6426 In the absence of this pragma, aggregates in object declarations are expanded
6427 into assignments and loops, even when the aggregate components are static
6428 constants. When the aggregate is present the compiler builds a static expression
6429 that requires no run-time code, so that the initialized object can be placed in
6430 read-only data space. If the components are not static, or the aggregate has
6431 more that 100 components, the compiler emits a warning that the pragma cannot
6432 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6433 construction of larger aggregates with static components that include an others
6434 choice.)
6435
6436 @node Pragma Stream_Convert
6437 @unnumberedsec Pragma Stream_Convert
6438 @findex Stream_Convert
6439 @noindent
6440 Syntax:
6441
6442 @smallexample @c ada
6443 pragma Stream_Convert (
6444 [Entity =>] type_LOCAL_NAME,
6445 [Read =>] function_NAME,
6446 [Write =>] function_NAME);
6447 @end smallexample
6448
6449 @noindent
6450 This pragma provides an efficient way of providing stream functions for
6451 types defined in packages. Not only is it simpler to use than declaring
6452 the necessary functions with attribute representation clauses, but more
6453 significantly, it allows the declaration to made in such a way that the
6454 stream packages are not loaded unless they are needed. The use of
6455 the Stream_Convert pragma adds no overhead at all, unless the stream
6456 attributes are actually used on the designated type.
6457
6458 The first argument specifies the type for which stream functions are
6459 provided. The second parameter provides a function used to read values
6460 of this type. It must name a function whose argument type may be any
6461 subtype, and whose returned type must be the type given as the first
6462 argument to the pragma.
6463
6464 The meaning of the @var{Read} parameter is that if a stream attribute directly
6465 or indirectly specifies reading of the type given as the first parameter,
6466 then a value of the type given as the argument to the Read function is
6467 read from the stream, and then the Read function is used to convert this
6468 to the required target type.
6469
6470 Similarly the @var{Write} parameter specifies how to treat write attributes
6471 that directly or indirectly apply to the type given as the first parameter.
6472 It must have an input parameter of the type specified by the first parameter,
6473 and the return type must be the same as the input type of the Read function.
6474 The effect is to first call the Write function to convert to the given stream
6475 type, and then write the result type to the stream.
6476
6477 The Read and Write functions must not be overloaded subprograms. If necessary
6478 renamings can be supplied to meet this requirement.
6479 The usage of this attribute is best illustrated by a simple example, taken
6480 from the GNAT implementation of package Ada.Strings.Unbounded:
6481
6482 @smallexample @c ada
6483 function To_Unbounded (S : String)
6484 return Unbounded_String
6485 renames To_Unbounded_String;
6486
6487 pragma Stream_Convert
6488 (Unbounded_String, To_Unbounded, To_String);
6489 @end smallexample
6490
6491 @noindent
6492 The specifications of the referenced functions, as given in the Ada
6493 Reference Manual are:
6494
6495 @smallexample @c ada
6496 function To_Unbounded_String (Source : String)
6497 return Unbounded_String;
6498
6499 function To_String (Source : Unbounded_String)
6500 return String;
6501 @end smallexample
6502
6503 @noindent
6504 The effect is that if the value of an unbounded string is written to a stream,
6505 then the representation of the item in the stream is in the same format that
6506 would be used for @code{Standard.String'Output}, and this same representation
6507 is expected when a value of this type is read from the stream. Note that the
6508 value written always includes the bounds, even for Unbounded_String'Write,
6509 since Unbounded_String is not an array type.
6510
6511 @node Pragma Style_Checks
6512 @unnumberedsec Pragma Style_Checks
6513 @findex Style_Checks
6514 @noindent
6515 Syntax:
6516
6517 @smallexample @c ada
6518 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6519 On | Off [, LOCAL_NAME]);
6520 @end smallexample
6521
6522 @noindent
6523 This pragma is used in conjunction with compiler switches to control the
6524 built in style checking provided by GNAT@. The compiler switches, if set,
6525 provide an initial setting for the switches, and this pragma may be used
6526 to modify these settings, or the settings may be provided entirely by
6527 the use of the pragma. This pragma can be used anywhere that a pragma
6528 is legal, including use as a configuration pragma (including use in
6529 the @file{gnat.adc} file).
6530
6531 The form with a string literal specifies which style options are to be
6532 activated. These are additive, so they apply in addition to any previously
6533 set style check options. The codes for the options are the same as those
6534 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6535 For example the following two methods can be used to enable
6536 layout checking:
6537
6538 @itemize @bullet
6539 @item
6540 @smallexample @c ada
6541 pragma Style_Checks ("l");
6542 @end smallexample
6543
6544 @item
6545 @smallexample
6546 gcc -c -gnatyl @dots{}
6547 @end smallexample
6548 @end itemize
6549
6550 @noindent
6551 The form ALL_CHECKS activates all standard checks (its use is equivalent
6552 to the use of the @code{gnaty} switch with no options. @xref{Top,
6553 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6554 @value{EDITION} User's Guide}, for details.)
6555
6556 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6557 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6558 options (i.e. equivalent to -gnatyg).
6559
6560 The forms with @code{Off} and @code{On}
6561 can be used to temporarily disable style checks
6562 as shown in the following example:
6563
6564 @smallexample @c ada
6565 @iftex
6566 @leftskip=0cm
6567 @end iftex
6568 pragma Style_Checks ("k"); -- requires keywords in lower case
6569 pragma Style_Checks (Off); -- turn off style checks
6570 NULL; -- this will not generate an error message
6571 pragma Style_Checks (On); -- turn style checks back on
6572 NULL; -- this will generate an error message
6573 @end smallexample
6574
6575 @noindent
6576 Finally the two argument form is allowed only if the first argument is
6577 @code{On} or @code{Off}. The effect is to turn of semantic style checks
6578 for the specified entity, as shown in the following example:
6579
6580 @smallexample @c ada
6581 @iftex
6582 @leftskip=0cm
6583 @end iftex
6584 pragma Style_Checks ("r"); -- require consistency of identifier casing
6585 Arg : Integer;
6586 Rf1 : Integer := ARG; -- incorrect, wrong case
6587 pragma Style_Checks (Off, Arg);
6588 Rf2 : Integer := ARG; -- OK, no error
6589 @end smallexample
6590
6591 @node Pragma Subtitle
6592 @unnumberedsec Pragma Subtitle
6593 @findex Subtitle
6594 @noindent
6595 Syntax:
6596
6597 @smallexample @c ada
6598 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6599 @end smallexample
6600
6601 @noindent
6602 This pragma is recognized for compatibility with other Ada compilers
6603 but is ignored by GNAT@.
6604
6605 @node Pragma Suppress
6606 @unnumberedsec Pragma Suppress
6607 @findex Suppress
6608 @noindent
6609 Syntax:
6610
6611 @smallexample @c ada
6612 pragma Suppress (Identifier [, [On =>] Name]);
6613 @end smallexample
6614
6615 @noindent
6616 This is a standard pragma, and supports all the check names required in
6617 the RM. It is included here because GNAT recognizes some additional check
6618 names that are implementation defined (as permitted by the RM):
6619
6620 @itemize @bullet
6621
6622 @item
6623 @code{Alignment_Check} can be used to suppress alignment checks
6624 on addresses used in address clauses. Such checks can also be suppressed
6625 by suppressing range checks, but the specific use of @code{Alignment_Check}
6626 allows suppression of alignment checks without suppressing other range checks.
6627
6628 @item
6629 @code{Predicate_Check} can be used to control whether predicate checks are
6630 active. It is applicable only to predicates for which the policy is
6631 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6632 predicate is ignored or checked for the whole program, the use of
6633 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6634 predicate to be turned on and off at specific points in the program.
6635
6636 @item
6637 @code{Validity_Check} can be used specifically to control validity checks.
6638 If @code{Suppress} is used to suppress validity checks, then no validity
6639 checks are performed, including those specified by the appropriate compiler
6640 switch or the @code{Validity_Checks} pragma.
6641
6642 @item
6643 Additional check names previously introduced by use of the @code{Check_Name}
6644 pragma are also allowed.
6645
6646 @end itemize
6647
6648 @noindent
6649 Note that pragma Suppress gives the compiler permission to omit
6650 checks, but does not require the compiler to omit checks. The compiler
6651 will generate checks if they are essentially free, even when they are
6652 suppressed. In particular, if the compiler can prove that a certain
6653 check will necessarily fail, it will generate code to do an
6654 unconditional ``raise'', even if checks are suppressed. The compiler
6655 warns in this case.
6656
6657 Of course, run-time checks are omitted whenever the compiler can prove
6658 that they will not fail, whether or not checks are suppressed.
6659
6660 @node Pragma Suppress_All
6661 @unnumberedsec Pragma Suppress_All
6662 @findex Suppress_All
6663 @noindent
6664 Syntax:
6665
6666 @smallexample @c ada
6667 pragma Suppress_All;
6668 @end smallexample
6669
6670 @noindent
6671 This pragma can appear anywhere within a unit.
6672 The effect is to apply @code{Suppress (All_Checks)} to the unit
6673 in which it appears. This pragma is implemented for compatibility with DEC
6674 Ada 83 usage where it appears at the end of a unit, and for compatibility
6675 with Rational Ada, where it appears as a program unit pragma.
6676 The use of the standard Ada pragma @code{Suppress (All_Checks)}
6677 as a normal configuration pragma is the preferred usage in GNAT@.
6678
6679 @node Pragma Suppress_Debug_Info
6680 @unnumberedsec Pragma Suppress_Debug_Info
6681 @findex Suppress_Debug_Info
6682 @noindent
6683 Syntax:
6684
6685 @smallexample @c ada
6686 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
6687 @end smallexample
6688
6689 @noindent
6690 This pragma can be used to suppress generation of debug information
6691 for the specified entity. It is intended primarily for use in debugging
6692 the debugger, and navigating around debugger problems.
6693
6694 @node Pragma Suppress_Exception_Locations
6695 @unnumberedsec Pragma Suppress_Exception_Locations
6696 @findex Suppress_Exception_Locations
6697 @noindent
6698 Syntax:
6699
6700 @smallexample @c ada
6701 pragma Suppress_Exception_Locations;
6702 @end smallexample
6703
6704 @noindent
6705 In normal mode, a raise statement for an exception by default generates
6706 an exception message giving the file name and line number for the location
6707 of the raise. This is useful for debugging and logging purposes, but this
6708 entails extra space for the strings for the messages. The configuration
6709 pragma @code{Suppress_Exception_Locations} can be used to suppress the
6710 generation of these strings, with the result that space is saved, but the
6711 exception message for such raises is null. This configuration pragma may
6712 appear in a global configuration pragma file, or in a specific unit as
6713 usual. It is not required that this pragma be used consistently within
6714 a partition, so it is fine to have some units within a partition compiled
6715 with this pragma and others compiled in normal mode without it.
6716
6717 @node Pragma Suppress_Initialization
6718 @unnumberedsec Pragma Suppress_Initialization
6719 @findex Suppress_Initialization
6720 @cindex Suppressing initialization
6721 @cindex Initialization, suppression of
6722 @noindent
6723 Syntax:
6724
6725 @smallexample @c ada
6726 pragma Suppress_Initialization ([Entity =>] subtype_Name);
6727 @end smallexample
6728
6729 @noindent
6730 Here subtype_Name is the name introduced by a type declaration
6731 or subtype declaration.
6732 This pragma suppresses any implicit or explicit initialization
6733 for all variables of the given type or subtype,
6734 including initialization resulting from the use of pragmas
6735 Normalize_Scalars or Initialize_Scalars.
6736
6737 This is considered a representation item, so it cannot be given after
6738 the type is frozen. It applies to all subsequent object declarations,
6739 and also any allocator that creates objects of the type.
6740
6741 If the pragma is given for the first subtype, then it is considered
6742 to apply to the base type and all its subtypes. If the pragma is given
6743 for other than a first subtype, then it applies only to the given subtype.
6744 The pragma may not be given after the type is frozen.
6745
6746 @node Pragma Task_Info
6747 @unnumberedsec Pragma Task_Info
6748 @findex Task_Info
6749 @noindent
6750 Syntax
6751
6752 @smallexample @c ada
6753 pragma Task_Info (EXPRESSION);
6754 @end smallexample
6755
6756 @noindent
6757 This pragma appears within a task definition (like pragma
6758 @code{Priority}) and applies to the task in which it appears. The
6759 argument must be of type @code{System.Task_Info.Task_Info_Type}.
6760 The @code{Task_Info} pragma provides system dependent control over
6761 aspects of tasking implementation, for example, the ability to map
6762 tasks to specific processors. For details on the facilities available
6763 for the version of GNAT that you are using, see the documentation
6764 in the spec of package System.Task_Info in the runtime
6765 library.
6766
6767 @node Pragma Task_Name
6768 @unnumberedsec Pragma Task_Name
6769 @findex Task_Name
6770 @noindent
6771 Syntax
6772
6773 @smallexample @c ada
6774 pragma Task_Name (string_EXPRESSION);
6775 @end smallexample
6776
6777 @noindent
6778 This pragma appears within a task definition (like pragma
6779 @code{Priority}) and applies to the task in which it appears. The
6780 argument must be of type String, and provides a name to be used for
6781 the task instance when the task is created. Note that this expression
6782 is not required to be static, and in particular, it can contain
6783 references to task discriminants. This facility can be used to
6784 provide different names for different tasks as they are created,
6785 as illustrated in the example below.
6786
6787 The task name is recorded internally in the run-time structures
6788 and is accessible to tools like the debugger. In addition the
6789 routine @code{Ada.Task_Identification.Image} will return this
6790 string, with a unique task address appended.
6791
6792 @smallexample @c ada
6793 -- Example of the use of pragma Task_Name
6794
6795 with Ada.Task_Identification;
6796 use Ada.Task_Identification;
6797 with Text_IO; use Text_IO;
6798 procedure t3 is
6799
6800 type Astring is access String;
6801
6802 task type Task_Typ (Name : access String) is
6803 pragma Task_Name (Name.all);
6804 end Task_Typ;
6805
6806 task body Task_Typ is
6807 Nam : constant String := Image (Current_Task);
6808 begin
6809 Put_Line ("-->" & Nam (1 .. 14) & "<--");
6810 end Task_Typ;
6811
6812 type Ptr_Task is access Task_Typ;
6813 Task_Var : Ptr_Task;
6814
6815 begin
6816 Task_Var :=
6817 new Task_Typ (new String'("This is task 1"));
6818 Task_Var :=
6819 new Task_Typ (new String'("This is task 2"));
6820 end;
6821 @end smallexample
6822
6823 @node Pragma Task_Storage
6824 @unnumberedsec Pragma Task_Storage
6825 @findex Task_Storage
6826 Syntax:
6827
6828 @smallexample @c ada
6829 pragma Task_Storage (
6830 [Task_Type =>] LOCAL_NAME,
6831 [Top_Guard =>] static_integer_EXPRESSION);
6832 @end smallexample
6833
6834 @noindent
6835 This pragma specifies the length of the guard area for tasks. The guard
6836 area is an additional storage area allocated to a task. A value of zero
6837 means that either no guard area is created or a minimal guard area is
6838 created, depending on the target. This pragma can appear anywhere a
6839 @code{Storage_Size} attribute definition clause is allowed for a task
6840 type.
6841
6842 @node Pragma Test_Case
6843 @unnumberedsec Pragma Test_Case
6844 @cindex Test cases
6845 @findex Test_Case
6846 @noindent
6847 Syntax:
6848
6849 @smallexample @c ada
6850 pragma Test_Case (
6851 [Name =>] static_string_Expression
6852 ,[Mode =>] (Nominal | Robustness)
6853 [, Requires => Boolean_Expression]
6854 [, Ensures => Boolean_Expression]);
6855 @end smallexample
6856
6857 @noindent
6858 The @code{Test_Case} pragma allows defining fine-grain specifications
6859 for use by testing tools.
6860 The compiler checks the validity of the @code{Test_Case} pragma, but its
6861 presence does not lead to any modification of the code generated by the
6862 compiler.
6863
6864 @code{Test_Case} pragmas may only appear immediately following the
6865 (separate) declaration of a subprogram in a package declaration, inside
6866 a package spec unit. Only other pragmas may intervene (that is appear
6867 between the subprogram declaration and a test case).
6868
6869 The compiler checks that boolean expressions given in @code{Requires} and
6870 @code{Ensures} are valid, where the rules for @code{Requires} are the
6871 same as the rule for an expression in @code{Precondition} and the rules
6872 for @code{Ensures} are the same as the rule for an expression in
6873 @code{Postcondition}. In particular, attributes @code{'Old} and
6874 @code{'Result} can only be used within the @code{Ensures}
6875 expression. The following is an example of use within a package spec:
6876
6877 @smallexample @c ada
6878 package Math_Functions is
6879 ...
6880 function Sqrt (Arg : Float) return Float;
6881 pragma Test_Case (Name => "Test 1",
6882 Mode => Nominal,
6883 Requires => Arg < 10000,
6884 Ensures => Sqrt'Result < 10);
6885 ...
6886 end Math_Functions;
6887 @end smallexample
6888
6889 @noindent
6890 The meaning of a test case is that there is at least one context where
6891 @code{Requires} holds such that, if the associated subprogram is executed in
6892 that context, then @code{Ensures} holds when the subprogram returns.
6893 Mode @code{Nominal} indicates that the input context should also satisfy the
6894 precondition of the subprogram, and the output context should also satisfy its
6895 postcondition. More @code{Robustness} indicates that the precondition and
6896 postcondition of the subprogram should be ignored for this test case.
6897
6898 @node Pragma Thread_Local_Storage
6899 @unnumberedsec Pragma Thread_Local_Storage
6900 @findex Thread_Local_Storage
6901 @cindex Task specific storage
6902 @cindex TLS (Thread Local Storage)
6903 @cindex Task_Attributes
6904 Syntax:
6905
6906 @smallexample @c ada
6907 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
6908 @end smallexample
6909
6910 @noindent
6911 This pragma specifies that the specified entity, which must be
6912 a variable declared in a library level package, is to be marked as
6913 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
6914 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
6915 (and hence each Ada task) to see a distinct copy of the variable.
6916
6917 The variable may not have default initialization, and if there is
6918 an explicit initialization, it must be either @code{null} for an
6919 access variable, or a static expression for a scalar variable.
6920 This provides a low level mechanism similar to that provided by
6921 the @code{Ada.Task_Attributes} package, but much more efficient
6922 and is also useful in writing interface code that will interact
6923 with foreign threads.
6924
6925 If this pragma is used on a system where @code{TLS} is not supported,
6926 then an error message will be generated and the program will be rejected.
6927
6928 @node Pragma Time_Slice
6929 @unnumberedsec Pragma Time_Slice
6930 @findex Time_Slice
6931 @noindent
6932 Syntax:
6933
6934 @smallexample @c ada
6935 pragma Time_Slice (static_duration_EXPRESSION);
6936 @end smallexample
6937
6938 @noindent
6939 For implementations of GNAT on operating systems where it is possible
6940 to supply a time slice value, this pragma may be used for this purpose.
6941 It is ignored if it is used in a system that does not allow this control,
6942 or if it appears in other than the main program unit.
6943 @cindex OpenVMS
6944 Note that the effect of this pragma is identical to the effect of the
6945 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
6946
6947 @node Pragma Title
6948 @unnumberedsec Pragma Title
6949 @findex Title
6950 @noindent
6951 Syntax:
6952
6953 @smallexample @c ada
6954 pragma Title (TITLING_OPTION [, TITLING OPTION]);
6955
6956 TITLING_OPTION ::=
6957 [Title =>] STRING_LITERAL,
6958 | [Subtitle =>] STRING_LITERAL
6959 @end smallexample
6960
6961 @noindent
6962 Syntax checked but otherwise ignored by GNAT@. This is a listing control
6963 pragma used in DEC Ada 83 implementations to provide a title and/or
6964 subtitle for the program listing. The program listing generated by GNAT
6965 does not have titles or subtitles.
6966
6967 Unlike other pragmas, the full flexibility of named notation is allowed
6968 for this pragma, i.e.@: the parameters may be given in any order if named
6969 notation is used, and named and positional notation can be mixed
6970 following the normal rules for procedure calls in Ada.
6971
6972 @node Pragma Type_Invariant
6973 @unnumberedsec Pragma Type_Invariant
6974 @findex Invariant
6975 @findex Type_Invariant pragma
6976 @noindent
6977 Syntax:
6978
6979 @smallexample @c ada
6980 pragma Type_Invariant
6981 ([Entity =>] type_LOCAL_NAME,
6982 [Check =>] EXPRESSION);
6983 @end smallexample
6984
6985 @noindent
6986 The @code{Type_Invariant} pragma is intended to be an exact
6987 replacement for the language-defined @code{Type_Invariant}
6988 aspect, and shares its restrictions and semantics. It differs
6989 from the language defined @code{Invariant} pragma in that it
6990 does not permit a string parameter, and it is
6991 controlled by the assertion identifier @code{Type_Invariant}
6992 rather than @code{Invariant}.
6993
6994 @node Pragma Type_Invariant_Class
6995 @unnumberedsec Pragma Type_Invariant_Class
6996 @findex Invariant
6997 @findex Type_Invariant_Class pragma
6998 @noindent
6999 Syntax:
7000
7001 @smallexample @c ada
7002 pragma Type_Invariant_Class
7003 ([Entity =>] type_LOCAL_NAME,
7004 [Check =>] EXPRESSION);
7005 @end smallexample
7006
7007 @noindent
7008 The @code{Type_Invariant_Class} pragma is intended to be an exact
7009 replacement for the language-defined @code{Type_Invariant'Class}
7010 aspect, and shares its restrictions and semantics.
7011
7012 Note: This pragma is called @code{Type_Invariant_Class} rather than
7013 @code{Type_Invariant'Class} because the latter would not be strictly
7014 conforming to the allowed syntax for pragmas. The motivation
7015 for providing pragmas equivalent to the aspects is to allow a program
7016 to be written using the pragmas, and then compiled if necessary
7017 using an Ada compiler that does not recognize the pragmas or
7018 aspects, but is prepared to ignore the pragmas. The assertion
7019 policy that controls this pragma is @code{Type_Invariant'Class},
7020 not @code{Type_Invariant_Class}.
7021
7022 @node Pragma Unchecked_Union
7023 @unnumberedsec Pragma Unchecked_Union
7024 @cindex Unions in C
7025 @findex Unchecked_Union
7026 @noindent
7027 Syntax:
7028
7029 @smallexample @c ada
7030 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
7031 @end smallexample
7032
7033 @noindent
7034 This pragma is used to specify a representation of a record type that is
7035 equivalent to a C union. It was introduced as a GNAT implementation defined
7036 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
7037 pragma, making it language defined, and GNAT fully implements this extended
7038 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
7039 details, consult the Ada 2012 Reference Manual, section B.3.3.
7040
7041 @node Pragma Unimplemented_Unit
7042 @unnumberedsec Pragma Unimplemented_Unit
7043 @findex Unimplemented_Unit
7044 @noindent
7045 Syntax:
7046
7047 @smallexample @c ada
7048 pragma Unimplemented_Unit;
7049 @end smallexample
7050
7051 @noindent
7052 If this pragma occurs in a unit that is processed by the compiler, GNAT
7053 aborts with the message @samp{@var{xxx} not implemented}, where
7054 @var{xxx} is the name of the current compilation unit. This pragma is
7055 intended to allow the compiler to handle unimplemented library units in
7056 a clean manner.
7057
7058 The abort only happens if code is being generated. Thus you can use
7059 specs of unimplemented packages in syntax or semantic checking mode.
7060
7061 @node Pragma Universal_Aliasing
7062 @unnumberedsec Pragma Universal_Aliasing
7063 @findex Universal_Aliasing
7064 @noindent
7065 Syntax:
7066
7067 @smallexample @c ada
7068 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
7069 @end smallexample
7070
7071 @noindent
7072 @var{type_LOCAL_NAME} must refer to a type declaration in the current
7073 declarative part. The effect is to inhibit strict type-based aliasing
7074 optimization for the given type. In other words, the effect is as though
7075 access types designating this type were subject to pragma No_Strict_Aliasing.
7076 For a detailed description of the strict aliasing optimization, and the
7077 situations in which it must be suppressed, @xref{Optimization and Strict
7078 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
7079
7080 @node Pragma Universal_Data
7081 @unnumberedsec Pragma Universal_Data
7082 @findex Universal_Data
7083 @noindent
7084 Syntax:
7085
7086 @smallexample @c ada
7087 pragma Universal_Data [(library_unit_Name)];
7088 @end smallexample
7089
7090 @noindent
7091 This pragma is supported only for the AAMP target and is ignored for
7092 other targets. The pragma specifies that all library-level objects
7093 (Counter 0 data) associated with the library unit are to be accessed
7094 and updated using universal addressing (24-bit addresses for AAMP5)
7095 rather than the default of 16-bit Data Environment (DENV) addressing.
7096 Use of this pragma will generally result in less efficient code for
7097 references to global data associated with the library unit, but
7098 allows such data to be located anywhere in memory. This pragma is
7099 a library unit pragma, but can also be used as a configuration pragma
7100 (including use in the @file{gnat.adc} file). The functionality
7101 of this pragma is also available by applying the -univ switch on the
7102 compilations of units where universal addressing of the data is desired.
7103
7104 @node Pragma Unmodified
7105 @unnumberedsec Pragma Unmodified
7106 @findex Unmodified
7107 @cindex Warnings, unmodified
7108 @noindent
7109 Syntax:
7110
7111 @smallexample @c ada
7112 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
7113 @end smallexample
7114
7115 @noindent
7116 This pragma signals that the assignable entities (variables,
7117 @code{out} parameters, @code{in out} parameters) whose names are listed are
7118 deliberately not assigned in the current source unit. This
7119 suppresses warnings about the
7120 entities being referenced but not assigned, and in addition a warning will be
7121 generated if one of these entities is in fact assigned in the
7122 same unit as the pragma (or in the corresponding body, or one
7123 of its subunits).
7124
7125 This is particularly useful for clearly signaling that a particular
7126 parameter is not modified, even though the spec suggests that it might
7127 be.
7128
7129 @node Pragma Unreferenced
7130 @unnumberedsec Pragma Unreferenced
7131 @findex Unreferenced
7132 @cindex Warnings, unreferenced
7133 @noindent
7134 Syntax:
7135
7136 @smallexample @c ada
7137 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
7138 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
7139 @end smallexample
7140
7141 @noindent
7142 This pragma signals that the entities whose names are listed are
7143 deliberately not referenced in the current source unit. This
7144 suppresses warnings about the
7145 entities being unreferenced, and in addition a warning will be
7146 generated if one of these entities is in fact subsequently referenced in the
7147 same unit as the pragma (or in the corresponding body, or one
7148 of its subunits).
7149
7150 This is particularly useful for clearly signaling that a particular
7151 parameter is not referenced in some particular subprogram implementation
7152 and that this is deliberate. It can also be useful in the case of
7153 objects declared only for their initialization or finalization side
7154 effects.
7155
7156 If @code{LOCAL_NAME} identifies more than one matching homonym in the
7157 current scope, then the entity most recently declared is the one to which
7158 the pragma applies. Note that in the case of accept formals, the pragma
7159 Unreferenced may appear immediately after the keyword @code{do} which
7160 allows the indication of whether or not accept formals are referenced
7161 or not to be given individually for each accept statement.
7162
7163 The left hand side of an assignment does not count as a reference for the
7164 purpose of this pragma. Thus it is fine to assign to an entity for which
7165 pragma Unreferenced is given.
7166
7167 Note that if a warning is desired for all calls to a given subprogram,
7168 regardless of whether they occur in the same unit as the subprogram
7169 declaration, then this pragma should not be used (calls from another
7170 unit would not be flagged); pragma Obsolescent can be used instead
7171 for this purpose, see @xref{Pragma Obsolescent}.
7172
7173 The second form of pragma @code{Unreferenced} is used within a context
7174 clause. In this case the arguments must be unit names of units previously
7175 mentioned in @code{with} clauses (similar to the usage of pragma
7176 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
7177 units and unreferenced entities within these units.
7178
7179 @node Pragma Unreferenced_Objects
7180 @unnumberedsec Pragma Unreferenced_Objects
7181 @findex Unreferenced_Objects
7182 @cindex Warnings, unreferenced
7183 @noindent
7184 Syntax:
7185
7186 @smallexample @c ada
7187 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
7188 @end smallexample
7189
7190 @noindent
7191 This pragma signals that for the types or subtypes whose names are
7192 listed, objects which are declared with one of these types or subtypes may
7193 not be referenced, and if no references appear, no warnings are given.
7194
7195 This is particularly useful for objects which are declared solely for their
7196 initialization and finalization effect. Such variables are sometimes referred
7197 to as RAII variables (Resource Acquisition Is Initialization). Using this
7198 pragma on the relevant type (most typically a limited controlled type), the
7199 compiler will automatically suppress unwanted warnings about these variables
7200 not being referenced.
7201
7202 @node Pragma Unreserve_All_Interrupts
7203 @unnumberedsec Pragma Unreserve_All_Interrupts
7204 @findex Unreserve_All_Interrupts
7205 @noindent
7206 Syntax:
7207
7208 @smallexample @c ada
7209 pragma Unreserve_All_Interrupts;
7210 @end smallexample
7211
7212 @noindent
7213 Normally certain interrupts are reserved to the implementation. Any attempt
7214 to attach an interrupt causes Program_Error to be raised, as described in
7215 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
7216 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
7217 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
7218 interrupt execution.
7219
7220 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
7221 a program, then all such interrupts are unreserved. This allows the
7222 program to handle these interrupts, but disables their standard
7223 functions. For example, if this pragma is used, then pressing
7224 @kbd{Ctrl-C} will not automatically interrupt execution. However,
7225 a program can then handle the @code{SIGINT} interrupt as it chooses.
7226
7227 For a full list of the interrupts handled in a specific implementation,
7228 see the source code for the spec of @code{Ada.Interrupts.Names} in
7229 file @file{a-intnam.ads}. This is a target dependent file that contains the
7230 list of interrupts recognized for a given target. The documentation in
7231 this file also specifies what interrupts are affected by the use of
7232 the @code{Unreserve_All_Interrupts} pragma.
7233
7234 For a more general facility for controlling what interrupts can be
7235 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
7236 of the @code{Unreserve_All_Interrupts} pragma.
7237
7238 @node Pragma Unsuppress
7239 @unnumberedsec Pragma Unsuppress
7240 @findex Unsuppress
7241 @noindent
7242 Syntax:
7243
7244 @smallexample @c ada
7245 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
7246 @end smallexample
7247
7248 @noindent
7249 This pragma undoes the effect of a previous pragma @code{Suppress}. If
7250 there is no corresponding pragma @code{Suppress} in effect, it has no
7251 effect. The range of the effect is the same as for pragma
7252 @code{Suppress}. The meaning of the arguments is identical to that used
7253 in pragma @code{Suppress}.
7254
7255 One important application is to ensure that checks are on in cases where
7256 code depends on the checks for its correct functioning, so that the code
7257 will compile correctly even if the compiler switches are set to suppress
7258 checks.
7259
7260 This pragma is standard in Ada 2005. It is available in all earlier versions
7261 of Ada as an implementation-defined pragma.
7262
7263 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
7264 a number of implementation-defined check names. See description of pragma
7265 @code{Suppress} for full details.
7266
7267 @node Pragma Use_VADS_Size
7268 @unnumberedsec Pragma Use_VADS_Size
7269 @cindex @code{Size}, VADS compatibility
7270 @cindex Rational profile
7271 @findex Use_VADS_Size
7272 @noindent
7273 Syntax:
7274
7275 @smallexample @c ada
7276 pragma Use_VADS_Size;
7277 @end smallexample
7278
7279 @noindent
7280 This is a configuration pragma. In a unit to which it applies, any use
7281 of the 'Size attribute is automatically interpreted as a use of the
7282 'VADS_Size attribute. Note that this may result in incorrect semantic
7283 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
7284 the handling of existing code which depends on the interpretation of Size
7285 as implemented in the VADS compiler. See description of the VADS_Size
7286 attribute for further details.
7287
7288 @node Pragma Validity_Checks
7289 @unnumberedsec Pragma Validity_Checks
7290 @findex Validity_Checks
7291 @noindent
7292 Syntax:
7293
7294 @smallexample @c ada
7295 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
7296 @end smallexample
7297
7298 @noindent
7299 This pragma is used in conjunction with compiler switches to control the
7300 built-in validity checking provided by GNAT@. The compiler switches, if set
7301 provide an initial setting for the switches, and this pragma may be used
7302 to modify these settings, or the settings may be provided entirely by
7303 the use of the pragma. This pragma can be used anywhere that a pragma
7304 is legal, including use as a configuration pragma (including use in
7305 the @file{gnat.adc} file).
7306
7307 The form with a string literal specifies which validity options are to be
7308 activated. The validity checks are first set to include only the default
7309 reference manual settings, and then a string of letters in the string
7310 specifies the exact set of options required. The form of this string
7311 is exactly as described for the @option{-gnatVx} compiler switch (see the
7312 @value{EDITION} User's Guide for details). For example the following two
7313 methods can be used to enable validity checking for mode @code{in} and
7314 @code{in out} subprogram parameters:
7315
7316 @itemize @bullet
7317 @item
7318 @smallexample @c ada
7319 pragma Validity_Checks ("im");
7320 @end smallexample
7321
7322 @item
7323 @smallexample
7324 gcc -c -gnatVim @dots{}
7325 @end smallexample
7326 @end itemize
7327
7328 @noindent
7329 The form ALL_CHECKS activates all standard checks (its use is equivalent
7330 to the use of the @code{gnatva} switch.
7331
7332 The forms with @code{Off} and @code{On}
7333 can be used to temporarily disable validity checks
7334 as shown in the following example:
7335
7336 @smallexample @c ada
7337 @iftex
7338 @leftskip=0cm
7339 @end iftex
7340 pragma Validity_Checks ("c"); -- validity checks for copies
7341 pragma Validity_Checks (Off); -- turn off validity checks
7342 A := B; -- B will not be validity checked
7343 pragma Validity_Checks (On); -- turn validity checks back on
7344 A := C; -- C will be validity checked
7345 @end smallexample
7346
7347 @node Pragma Volatile
7348 @unnumberedsec Pragma Volatile
7349 @findex Volatile
7350 @noindent
7351 Syntax:
7352
7353 @smallexample @c ada
7354 pragma Volatile (LOCAL_NAME);
7355 @end smallexample
7356
7357 @noindent
7358 This pragma is defined by the Ada Reference Manual, and the GNAT
7359 implementation is fully conformant with this definition. The reason it
7360 is mentioned in this section is that a pragma of the same name was supplied
7361 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
7362 implementation of pragma Volatile is upwards compatible with the
7363 implementation in DEC Ada 83.
7364
7365 @node Pragma Warnings
7366 @unnumberedsec Pragma Warnings
7367 @findex Warnings
7368 @noindent
7369 Syntax:
7370
7371 @smallexample @c ada
7372 pragma Warnings (On | Off [,REASON]);
7373 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
7374 pragma Warnings (static_string_EXPRESSION [,REASON]);
7375 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
7376
7377 REASON ::= Reason => static_string_EXPRESSION
7378 @end smallexample
7379
7380 @noindent
7381 Normally warnings are enabled, with the output being controlled by
7382 the command line switch. Warnings (@code{Off}) turns off generation of
7383 warnings until a Warnings (@code{On}) is encountered or the end of the
7384 current unit. If generation of warnings is turned off using this
7385 pragma, then some or all of the warning messages are suppressed,
7386 regardless of the setting of the command line switches.
7387
7388 The @code{Reason} parameter may optionally appear as the last argument
7389 in any of the forms of this pragma. It is intended purely for the
7390 purposes of documenting the reason for the @code{Warnings} pragma.
7391 The compiler will check that the argument is a static string but
7392 otherwise ignore this argument. Other tools may provide specialized
7393 processing for this string.
7394
7395 The form with a single argument (or two arguments if Reason present),
7396 where the first argument is @code{ON} or @code{OFF}
7397 may be used as a configuration pragma.
7398
7399 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
7400 the specified entity. This suppression is effective from the point where
7401 it occurs till the end of the extended scope of the variable (similar to
7402 the scope of @code{Suppress}). This form cannot be used as a configuration
7403 pragma.
7404
7405 The form with a single static_string_EXPRESSION argument (and possible
7406 reason) provides more precise
7407 control over which warnings are active. The string is a list of letters
7408 specifying which warnings are to be activated and which deactivated. The
7409 code for these letters is the same as the string used in the command
7410 line switch controlling warnings. For a brief summary, use the gnatmake
7411 command with no arguments, which will generate usage information containing
7412 the list of warnings switches supported. For
7413 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
7414 User's Guide}. This form can also be used as a configuration pragma.
7415
7416 @noindent
7417 The warnings controlled by the `-gnatw' switch are generated by the front end
7418 of the compiler. The `GCC' back end can provide additional warnings and they
7419 are controlled by the `-W' switch.
7420 The form with a single static_string_EXPRESSION argument also works for the
7421 latters, but the string must be a single full `-W' switch in this case.
7422 The above reference lists a few examples of these additional warnings.
7423
7424 @noindent
7425 The specified warnings will be in effect until the end of the program
7426 or another pragma Warnings is encountered. The effect of the pragma is
7427 cumulative. Initially the set of warnings is the standard default set
7428 as possibly modified by compiler switches. Then each pragma Warning
7429 modifies this set of warnings as specified. This form of the pragma may
7430 also be used as a configuration pragma.
7431
7432 The fourth form, with an @code{On|Off} parameter and a string, is used to
7433 control individual messages, based on their text. The string argument
7434 is a pattern that is used to match against the text of individual
7435 warning messages (not including the initial "warning: " tag).
7436
7437 The pattern may contain asterisks, which match zero or more characters in
7438 the message. For example, you can use
7439 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
7440 message @code{warning: 960 bits of "a" unused}. No other regular
7441 expression notations are permitted. All characters other than asterisk in
7442 these three specific cases are treated as literal characters in the match.
7443
7444 The above use of patterns to match the message applies only to warning
7445 messages generated by the front end. This form of the pragma with a
7446 string argument can also be used to control back end warnings controlled
7447 by a "-Wxxx" switch. Such warnings can be identified by the appearance
7448 of a string of the form "[-Wxxx]" in the message which identifies the
7449 "-W" switch that controls the message. By using the text of the
7450 "-W" switch in the pragma, such back end warnings can be turned on and off.
7451
7452 There are two ways to use the pragma in this form. The OFF form can be used as a
7453 configuration pragma. The effect is to suppress all warnings (if any)
7454 that match the pattern string throughout the compilation (or match the
7455 -W switch in the back end case).
7456
7457 The second usage is to suppress a warning locally, and in this case, two
7458 pragmas must appear in sequence:
7459
7460 @smallexample @c ada
7461 pragma Warnings (Off, Pattern);
7462 @dots{} code where given warning is to be suppressed
7463 pragma Warnings (On, Pattern);
7464 @end smallexample
7465
7466 @noindent
7467 In this usage, the pattern string must match in the Off and On pragmas,
7468 and at least one matching warning must be suppressed.
7469
7470 Note: to write a string that will match any warning, use the string
7471 @code{"***"}. It will not work to use a single asterisk or two asterisks
7472 since this looks like an operator name. This form with three asterisks
7473 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
7474 matching @code{pragma Warnings (On, "***")} will be required. This can be
7475 helpful in avoiding forgetting to turn warnings back on.
7476
7477 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7478 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7479 be useful in checking whether obsolete pragmas in existing programs are hiding
7480 real problems.
7481
7482 Note: pragma Warnings does not affect the processing of style messages. See
7483 separate entry for pragma Style_Checks for control of style messages.
7484
7485 @node Pragma Weak_External
7486 @unnumberedsec Pragma Weak_External
7487 @findex Weak_External
7488 @noindent
7489 Syntax:
7490
7491 @smallexample @c ada
7492 pragma Weak_External ([Entity =>] LOCAL_NAME);
7493 @end smallexample
7494
7495 @noindent
7496 @var{LOCAL_NAME} must refer to an object that is declared at the library
7497 level. This pragma specifies that the given entity should be marked as a
7498 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
7499 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
7500 of a regular symbol, that is to say a symbol that does not have to be
7501 resolved by the linker if used in conjunction with a pragma Import.
7502
7503 When a weak symbol is not resolved by the linker, its address is set to
7504 zero. This is useful in writing interfaces to external modules that may
7505 or may not be linked in the final executable, for example depending on
7506 configuration settings.
7507
7508 If a program references at run time an entity to which this pragma has been
7509 applied, and the corresponding symbol was not resolved at link time, then
7510 the execution of the program is erroneous. It is not erroneous to take the
7511 Address of such an entity, for example to guard potential references,
7512 as shown in the example below.
7513
7514 Some file formats do not support weak symbols so not all target machines
7515 support this pragma.
7516
7517 @smallexample @c ada
7518 -- Example of the use of pragma Weak_External
7519
7520 package External_Module is
7521 key : Integer;
7522 pragma Import (C, key);
7523 pragma Weak_External (key);
7524 function Present return boolean;
7525 end External_Module;
7526
7527 with System; use System;
7528 package body External_Module is
7529 function Present return boolean is
7530 begin
7531 return key'Address /= System.Null_Address;
7532 end Present;
7533 end External_Module;
7534 @end smallexample
7535
7536 @node Pragma Wide_Character_Encoding
7537 @unnumberedsec Pragma Wide_Character_Encoding
7538 @findex Wide_Character_Encoding
7539 @noindent
7540 Syntax:
7541
7542 @smallexample @c ada
7543 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
7544 @end smallexample
7545
7546 @noindent
7547 This pragma specifies the wide character encoding to be used in program
7548 source text appearing subsequently. It is a configuration pragma, but may
7549 also be used at any point that a pragma is allowed, and it is permissible
7550 to have more than one such pragma in a file, allowing multiple encodings
7551 to appear within the same file.
7552
7553 The argument can be an identifier or a character literal. In the identifier
7554 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
7555 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
7556 case it is correspondingly one of the characters @samp{h}, @samp{u},
7557 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
7558
7559 Note that when the pragma is used within a file, it affects only the
7560 encoding within that file, and does not affect withed units, specs,
7561 or subunits.
7562
7563 @node Implementation Defined Aspects
7564 @chapter Implementation Defined Aspects
7565 Ada defines (throughout the Ada 2012 reference manual, summarized
7566 in annex K) a set of aspects that can be specified for certain entities.
7567 These language defined aspects are implemented in GNAT in Ada 2012 mode
7568 and work as described in the Ada 2012 Reference Manual.
7569
7570 In addition, Ada 2012 allows implementations to define additional aspects
7571 whose meaning is defined by the implementation. GNAT provides
7572 a number of these implementation-dependent aspects which can be used
7573 to extend and enhance the functionality of the compiler. This section of
7574 the GNAT reference manual describes these additional attributes.
7575
7576 Note that any program using these aspects may not be portable to
7577 other compilers (although GNAT implements this set of aspects on all
7578 platforms). Therefore if portability to other compilers is an important
7579 consideration, you should minimize the use of these aspects.
7580
7581 Note that for many of these aspects, the effect is essentially similar
7582 to the use of a pragma or attribute specification with the same name
7583 applied to the entity. For example, if we write:
7584
7585 @smallexample @c ada
7586 type R is range 1 .. 100
7587 with Value_Size => 10;
7588 @end smallexample
7589
7590 @noindent
7591 then the effect is the same as:
7592
7593 @smallexample @c ada
7594 type R is range 1 .. 100;
7595 for R'Value_Size use 10;
7596 @end smallexample
7597
7598 @noindent
7599 and if we write:
7600
7601 @smallexample @c ada
7602 type R is new Integer
7603 with Shared => True;
7604 @end smallexample
7605
7606 @noindent
7607 then the effect is the same as:
7608
7609 @smallexample @c ada
7610 type R is new Integer;
7611 pragma Shared (R);
7612 @end smallexample
7613
7614 @noindent
7615 In the documentation sections that follow, such cases are simply marked
7616 as being equivalent to the corresponding pragma or attribute definition
7617 clause.
7618
7619 @menu
7620 * Aspect Abstract_State::
7621 * Aspect Ada_2005::
7622 * Aspect Ada_2012::
7623 * Aspect Compiler_Unit::
7624 * Aspect Contract_Cases::
7625 * Aspect Depends::
7626 * Aspect Dimension::
7627 * Aspect Dimension_System::
7628 * Aspect Favor_Top_Level::
7629 * Aspect Global::
7630 * Aspect Initial_Condition::
7631 * Aspect Initializes::
7632 * Aspect Inline_Always::
7633 * Aspect Invariant::
7634 * Aspect Lock_Free::
7635 * Aspect Object_Size::
7636 * Aspect Persistent_BSS::
7637 * Aspect Predicate::
7638 * Aspect Preelaborate_05::
7639 * Aspect Pure_05::
7640 * Aspect Pure_12::
7641 * Aspect Pure_Function::
7642 * Aspect Refined_State::
7643 * Aspect Remote_Access_Type::
7644 * Aspect Scalar_Storage_Order::
7645 * Aspect Shared::
7646 * Aspect Simple_Storage_Pool::
7647 * Aspect Simple_Storage_Pool_Type::
7648 * Aspect SPARK_Mode::
7649 * Aspect Suppress_Debug_Info::
7650 * Aspect Test_Case::
7651 * Aspect Universal_Aliasing::
7652 * Aspect Universal_Data::
7653 * Aspect Unmodified::
7654 * Aspect Unreferenced::
7655 * Aspect Unreferenced_Objects::
7656 * Aspect Value_Size::
7657 * Aspect Warnings::
7658 @end menu
7659
7660 @node Aspect Abstract_State
7661 @unnumberedsec Aspect Abstract_State
7662 @findex Abstract_State
7663 @noindent
7664 This aspect is equivalent to pragma @code{Abstract_State}.
7665
7666 @node Aspect Ada_2005
7667 @unnumberedsec Aspect Ada_2005
7668 @findex Ada_2005
7669 @noindent
7670 This aspect is equivalent to the one argument form of pragma @code{Ada_2005}.
7671
7672 @node Aspect Ada_2012
7673 @unnumberedsec Aspect Ada_2012
7674 @findex Ada_2012
7675 @noindent
7676 This aspect is equivalent to the one argument form of pragma @code{Ada_2012}.
7677
7678 @node Aspect Compiler_Unit
7679 @unnumberedsec Aspect Compiler_Unit
7680 @findex Compiler_Unit
7681 @noindent
7682 This aspect is equivalent to pragma @code{Compiler_Unit}.
7683
7684 @node Aspect Contract_Cases
7685 @unnumberedsec Aspect Contract_Cases
7686 @findex Contract_Cases
7687 @noindent
7688 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
7689 of clauses being enclosed in parentheses so that syntactically it is an
7690 aggregate.
7691
7692 @node Aspect Depends
7693 @unnumberedsec Aspect Depends
7694 @findex Depends
7695 @noindent
7696 This aspect is equivalent to pragma @code{Depends}.
7697
7698 * Dimension::
7699
7700 @node Aspect Dimension
7701 @unnumberedsec Aspect Dimension
7702 @findex Dimension
7703 @noindent
7704 The @code{Dimension} aspect is used to specify the dimensions of a given
7705 subtype of a dimensioned numeric type. The aspect also specifies a symbol
7706 used when doing formatted output of dimensioned quantities. The syntax is:
7707
7708 @smallexample @c ada
7709 with Dimension =>
7710 ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
7711
7712 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
7713
7714 DIMENSION_VALUE ::=
7715 RATIONAL
7716 | others => RATIONAL
7717 | DISCRETE_CHOICE_LIST => RATIONAL
7718
7719 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
7720 @end smallexample
7721
7722 @noindent
7723 This aspect can only be applied to a subtype whose parent type has
7724 a @code{Dimension_Systen} aspect. The aspect must specify values for
7725 all dimensions of the system. The rational values are the powers of the
7726 corresponding dimensions that are used by the compiler to verify that
7727 physical (numeric) computations are dimensionally consistent. For example,
7728 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
7729 For further examples of the usage
7730 of this aspect, see package @code{System.Dim.Mks}.
7731 Note that when the dimensioned type is an integer type, then any
7732 dimension value must be an integer literal.
7733
7734 @node Aspect Dimension_System
7735 @unnumberedsec Aspect Dimension_System
7736 @findex Dimension_System
7737 @noindent
7738 The @code{Dimension_System} aspect is used to define a system of
7739 dimensions that will be used in subsequent subtype declarations with
7740 @code{Dimension} aspects that reference this system. The syntax is:
7741
7742 @smallexample @c ada
7743 with Dimension_System => (DIMENSION @{, DIMENSION@});
7744
7745 DIMENSION ::= ([Unit_Name =>] IDENTIFIER,
7746 [Unit_Symbol =>] SYMBOL,
7747 [Dim_Symbol =>] SYMBOL)
7748
7749 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
7750 @end smallexample
7751
7752 @noindent
7753 This aspect is applied to a type, which must be a numeric derived type
7754 (typically a floating-point type), that
7755 will represent values within the dimension system. Each @code{DIMENSION}
7756 corresponds to one particular dimension. A maximum of 7 dimensions may
7757 be specified. @code{Unit_Name} is the name of the dimension (for example
7758 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
7759 of this dimension (for example 'm' for Meter). @code{Dim_Symbol} gives
7760 the identification within the dimension system (typically this is a
7761 single letter, e.g. 'L' standing for length for unit name Meter). The
7762 Unit_Smbol is used in formatted output of dimensioned quantities. The
7763 Dim_Symbol is used in error messages when numeric operations have
7764 inconsistent dimensions.
7765
7766 GNAT provides the standard definition of the International MKS system in
7767 the run-time package @code{System.Dim.Mks}. You can easily define
7768 similar packages for cgs units or British units, and define conversion factors
7769 between values in different systems. The MKS system is characterized by the
7770 following aspect:
7771
7772 @smallexample @c ada
7773 type Mks_Type is new Long_Long_Float
7774 with
7775 Dimension_System => (
7776 (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
7777 (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
7778 (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
7779 (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
7780 (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
7781 (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
7782 (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
7783 @end smallexample
7784
7785 @noindent
7786 See section "Performing Dimensionality Analysis in GNAT" in the GNAT Users
7787 Guide for detailed examples of use of the dimension system.
7788
7789 @node Aspect Favor_Top_Level
7790 @unnumberedsec Aspect Favor_Top_Level
7791 @findex Favor_Top_Level
7792 @noindent
7793 This aspect is equivalent to pragma @code{Favor_Top_Level}.
7794
7795 @node Aspect Global
7796 @unnumberedsec Aspect Global
7797 @findex Global
7798 @noindent
7799 This aspect is equivalent to pragma @code{Global}.
7800
7801 @node Aspect Initial_Condition
7802 @unnumberedsec Aspect Initial_Condition
7803 @findex Initial_Condition
7804 @noindent
7805 This aspect is equivalent to pragma @code{Initial_Condition}.
7806
7807 @node Aspect Initializes
7808 @unnumberedsec Aspect Initializes
7809 @findex Initializes
7810 @noindent
7811 This aspect is equivalent to pragma @code{Initializes}.
7812
7813 @node Aspect Inline_Always
7814 @unnumberedsec Aspect Inline_Always
7815 @findex Inline_Always
7816 @noindent
7817 This aspect is equivalent to pragma @code{Inline_Always}.
7818
7819 @node Aspect Invariant
7820 @unnumberedsec Aspect Invariant
7821 @findex Invariant
7822 @noindent
7823 This aspect is equivalent to pragma @code{Invariant}. It is a
7824 synonym for the language defined aspect @code{Type_Invariant} except
7825 that it is separately controllable using pragma @code{Assertion_Policy}.
7826
7827 @node Aspect Lock_Free
7828 @unnumberedsec Aspect Lock_Free
7829 @findex Lock_Free
7830 @noindent
7831 This aspect is equivalent to pragma @code{Lock_Free}.
7832
7833 @node Aspect Object_Size
7834 @unnumberedsec Aspect Object_Size
7835 @findex Object_Size
7836 @noindent
7837 This aspect is equivalent to an @code{Object_Size} attribute definition
7838 clause.
7839
7840 @node Aspect Persistent_BSS
7841 @unnumberedsec Aspect Persistent_BSS
7842 @findex Persistent_BSS
7843 @noindent
7844 This aspect is equivalent to pragma @code{Persistent_BSS}.
7845
7846 @node Aspect Predicate
7847 @unnumberedsec Aspect Predicate
7848 @findex Predicate
7849 @noindent
7850 This aspect is equivalent to pragma @code{Predicate}. It is thus
7851 similar to the language defined aspects @code{Dynamic_Predicate}
7852 and @code{Static_Predicate} except that whether the resulting
7853 predicate is static or dynamic is controlled by the form of the
7854 expression. It is also separately controllable using pragma
7855 @code{Assertion_Policy}.
7856
7857 @node Aspect Preelaborate_05
7858 @unnumberedsec Aspect Preelaborate_05
7859 @findex Preelaborate_05
7860 @noindent
7861 This aspect is equivalent to pragma @code{Preelaborate_05}.
7862
7863 @node Aspect Pure_05
7864 @unnumberedsec Aspect Pure_05
7865 @findex Pure_05
7866 @noindent
7867 This aspect is equivalent to pragma @code{Pure_05}.
7868
7869 @node Aspect Pure_12
7870 @unnumberedsec Aspect Pure_12
7871 @findex Pure_12
7872 @noindent
7873 This aspect is equivalent to pragma @code{Pure_12}.
7874
7875 @node Aspect Pure_Function
7876 @unnumberedsec Aspect Pure_Function
7877 @findex Pure_Function
7878 @noindent
7879 This aspect is equivalent to pragma @code{Pure_Function}.
7880
7881 @node Aspect Refined_State
7882 @unnumberedsec Aspect Refined_State
7883 @findex Refined_State
7884 @noindent
7885 This aspect is equivalent to pragma @code{Refined_State}.
7886
7887 @node Aspect Remote_Access_Type
7888 @unnumberedsec Aspect Remote_Access_Type
7889 @findex Remote_Access_Type
7890 @noindent
7891 This aspect is equivalent to pragma @code{Remote_Access_Type}.
7892
7893 @node Aspect Scalar_Storage_Order
7894 @unnumberedsec Aspect Scalar_Storage_Order
7895 @findex Scalar_Storage_Order
7896 @noindent
7897 This aspect is equivalent to a @code{Scalar_Storage_Order}
7898 attribute definition clause.
7899
7900 @node Aspect Shared
7901 @unnumberedsec Aspect Shared
7902 @findex Shared
7903 @noindent
7904 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
7905 for aspect @code{Atomic}.
7906
7907 @node Aspect Simple_Storage_Pool
7908 @unnumberedsec Aspect Simple_Storage_Pool
7909 @findex Simple_Storage_Pool
7910 @noindent
7911 This aspect is equivalent to a @code{Simple_Storage_Pool}
7912 attribute definition clause.
7913
7914 @node Aspect Simple_Storage_Pool_Type
7915 @unnumberedsec Aspect Simple_Storage_Pool_Type
7916 @findex Simple_Storage_Pool_Type
7917 @noindent
7918 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
7919
7920 @node Aspect SPARK_Mode
7921 @unnumberedsec Aspect SPARK_Mode
7922 @findex SPARK_Mode
7923 @noindent
7924 This aspect is equivalent to pragma @code{SPARK_Mode} and
7925 may be specified for either or both of the specification and body
7926 of a subprogram or package.
7927
7928 @node Aspect Suppress_Debug_Info
7929 @unnumberedsec Aspect Suppress_Debug_Info
7930 @findex Suppress_Debug_Info
7931 @noindent
7932 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
7933
7934 @node Aspect Test_Case
7935 @unnumberedsec Aspect Test_Case
7936 @findex Test_Case
7937 @noindent
7938 This aspect is equivalent to pragma @code{Test_Case}.
7939
7940 @node Aspect Universal_Aliasing
7941 @unnumberedsec Aspect Universal_Aliasing
7942 @findex Universal_Aliasing
7943 @noindent
7944 This aspect is equivalent to pragma @code{Universal_Aliasing}.
7945
7946 @node Aspect Universal_Data
7947 @unnumberedsec Aspect Universal_Data
7948 @findex Universal_Data
7949 @noindent
7950 This aspect is equivalent to pragma @code{Universal_Data}.
7951
7952 @node Aspect Unmodified
7953 @unnumberedsec Aspect Unmodified
7954 @findex Unmodified
7955 @noindent
7956 This aspect is equivalent to pragma @code{Unmodified}.
7957
7958 @node Aspect Unreferenced
7959 @unnumberedsec Aspect Unreferenced
7960 @findex Unreferenced
7961 @noindent
7962 This aspect is equivalent to pragma @code{Unreferenced}.
7963
7964 @node Aspect Unreferenced_Objects
7965 @unnumberedsec Aspect Unreferenced_Objects
7966 @findex Unreferenced_Objects
7967 @noindent
7968 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
7969
7970 @node Aspect Value_Size
7971 @unnumberedsec Aspect Value_Size
7972 @findex Value_Size
7973 @noindent
7974 This aspect is equivalent to a @code{Value_Size}
7975 attribute definition clause.
7976
7977 @node Aspect Warnings
7978 @unnumberedsec Aspect Warnings
7979 @findex Warnings
7980 @noindent
7981 This aspect is equivalent to the two argument form of pragma @code{Warnings},
7982 where the first argument is @code{ON} or @code{OFF} and the second argument
7983 is the entity.
7984
7985 @node Implementation Defined Attributes
7986 @chapter Implementation Defined Attributes
7987 Ada defines (throughout the Ada reference manual,
7988 summarized in Annex K),
7989 a set of attributes that provide useful additional functionality in all
7990 areas of the language. These language defined attributes are implemented
7991 in GNAT and work as described in the Ada Reference Manual.
7992
7993 In addition, Ada allows implementations to define additional
7994 attributes whose meaning is defined by the implementation. GNAT provides
7995 a number of these implementation-dependent attributes which can be used
7996 to extend and enhance the functionality of the compiler. This section of
7997 the GNAT reference manual describes these additional attributes.
7998
7999 Note that any program using these attributes may not be portable to
8000 other compilers (although GNAT implements this set of attributes on all
8001 platforms). Therefore if portability to other compilers is an important
8002 consideration, you should minimize the use of these attributes.
8003
8004 @menu
8005 * Attribute Abort_Signal::
8006 * Attribute Address_Size::
8007 * Attribute Asm_Input::
8008 * Attribute Asm_Output::
8009 * Attribute AST_Entry::
8010 * Attribute Bit::
8011 * Attribute Bit_Position::
8012 * Attribute Compiler_Version::
8013 * Attribute Code_Address::
8014 * Attribute Default_Bit_Order::
8015 * Attribute Descriptor_Size::
8016 * Attribute Elaborated::
8017 * Attribute Elab_Body::
8018 * Attribute Elab_Spec::
8019 * Attribute Elab_Subp_Body::
8020 * Attribute Emax::
8021 * Attribute Enabled::
8022 * Attribute Enum_Rep::
8023 * Attribute Enum_Val::
8024 * Attribute Epsilon::
8025 * Attribute Fixed_Value::
8026 * Attribute Has_Access_Values::
8027 * Attribute Has_Discriminants::
8028 * Attribute Img::
8029 * Attribute Integer_Value::
8030 * Attribute Invalid_Value::
8031 * Attribute Large::
8032 * Attribute Library_Level::
8033 * Attribute Loop_Entry::
8034 * Attribute Machine_Size::
8035 * Attribute Mantissa::
8036 * Attribute Max_Interrupt_Priority::
8037 * Attribute Max_Priority::
8038 * Attribute Maximum_Alignment::
8039 * Attribute Mechanism_Code::
8040 * Attribute Null_Parameter::
8041 * Attribute Object_Size::
8042 * Attribute Passed_By_Reference::
8043 * Attribute Pool_Address::
8044 * Attribute Range_Length::
8045 * Attribute Ref::
8046 * Attribute Restriction_Set::
8047 * Attribute Result::
8048 * Attribute Safe_Emax::
8049 * Attribute Safe_Large::
8050 * Attribute Scalar_Storage_Order::
8051 * Attribute Simple_Storage_Pool::
8052 * Attribute Small::
8053 * Attribute Storage_Unit::
8054 * Attribute Stub_Type::
8055 * Attribute System_Allocator_Alignment::
8056 * Attribute Target_Name::
8057 * Attribute Tick::
8058 * Attribute To_Address::
8059 * Attribute Type_Class::
8060 * Attribute UET_Address::
8061 * Attribute Unconstrained_Array::
8062 * Attribute Universal_Literal_String::
8063 * Attribute Unrestricted_Access::
8064 * Attribute Update::
8065 * Attribute Valid_Scalars::
8066 * Attribute VADS_Size::
8067 * Attribute Value_Size::
8068 * Attribute Wchar_T_Size::
8069 * Attribute Word_Size::
8070 @end menu
8071
8072 @node Attribute Abort_Signal
8073 @unnumberedsec Attribute Abort_Signal
8074 @findex Abort_Signal
8075 @noindent
8076 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
8077 prefix) provides the entity for the special exception used to signal
8078 task abort or asynchronous transfer of control. Normally this attribute
8079 should only be used in the tasking runtime (it is highly peculiar, and
8080 completely outside the normal semantics of Ada, for a user program to
8081 intercept the abort exception).
8082
8083 @node Attribute Address_Size
8084 @unnumberedsec Attribute Address_Size
8085 @cindex Size of @code{Address}
8086 @findex Address_Size
8087 @noindent
8088 @code{Standard'Address_Size} (@code{Standard} is the only allowed
8089 prefix) is a static constant giving the number of bits in an
8090 @code{Address}. It is the same value as System.Address'Size,
8091 but has the advantage of being static, while a direct
8092 reference to System.Address'Size is non-static because Address
8093 is a private type.
8094
8095 @node Attribute Asm_Input
8096 @unnumberedsec Attribute Asm_Input
8097 @findex Asm_Input
8098 @noindent
8099 The @code{Asm_Input} attribute denotes a function that takes two
8100 parameters. The first is a string, the second is an expression of the
8101 type designated by the prefix. The first (string) argument is required
8102 to be a static expression, and is the constraint for the parameter,
8103 (e.g.@: what kind of register is required). The second argument is the
8104 value to be used as the input argument. The possible values for the
8105 constant are the same as those used in the RTL, and are dependent on
8106 the configuration file used to built the GCC back end.
8107 @ref{Machine Code Insertions}
8108
8109 @node Attribute Asm_Output
8110 @unnumberedsec Attribute Asm_Output
8111 @findex Asm_Output
8112 @noindent
8113 The @code{Asm_Output} attribute denotes a function that takes two
8114 parameters. The first is a string, the second is the name of a variable
8115 of the type designated by the attribute prefix. The first (string)
8116 argument is required to be a static expression and designates the
8117 constraint for the parameter (e.g.@: what kind of register is
8118 required). The second argument is the variable to be updated with the
8119 result. The possible values for constraint are the same as those used in
8120 the RTL, and are dependent on the configuration file used to build the
8121 GCC back end. If there are no output operands, then this argument may
8122 either be omitted, or explicitly given as @code{No_Output_Operands}.
8123 @ref{Machine Code Insertions}
8124
8125 @node Attribute AST_Entry
8126 @unnumberedsec Attribute AST_Entry
8127 @cindex OpenVMS
8128 @findex AST_Entry
8129 @noindent
8130 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
8131 the name of an entry, it yields a value of the predefined type AST_Handler
8132 (declared in the predefined package System, as extended by the use of
8133 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
8134 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
8135 Language Reference Manual}, section 9.12a.
8136
8137 @node Attribute Bit
8138 @unnumberedsec Attribute Bit
8139 @findex Bit
8140 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
8141 offset within the storage unit (byte) that contains the first bit of
8142 storage allocated for the object. The value of this attribute is of the
8143 type @code{Universal_Integer}, and is always a non-negative number not
8144 exceeding the value of @code{System.Storage_Unit}.
8145
8146 For an object that is a variable or a constant allocated in a register,
8147 the value is zero. (The use of this attribute does not force the
8148 allocation of a variable to memory).
8149
8150 For an object that is a formal parameter, this attribute applies
8151 to either the matching actual parameter or to a copy of the
8152 matching actual parameter.
8153
8154 For an access object the value is zero. Note that
8155 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
8156 designated object. Similarly for a record component
8157 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
8158 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
8159 are subject to index checks.
8160
8161 This attribute is designed to be compatible with the DEC Ada 83 definition
8162 and implementation of the @code{Bit} attribute.
8163
8164 @node Attribute Bit_Position
8165 @unnumberedsec Attribute Bit_Position
8166 @findex Bit_Position
8167 @noindent
8168 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
8169 of the fields of the record type, yields the bit
8170 offset within the record contains the first bit of
8171 storage allocated for the object. The value of this attribute is of the
8172 type @code{Universal_Integer}. The value depends only on the field
8173 @var{C} and is independent of the alignment of
8174 the containing record @var{R}.
8175
8176 @node Attribute Compiler_Version
8177 @unnumberedsec Attribute Compiler_Version
8178 @findex Compiler_Version
8179 @noindent
8180 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
8181 prefix) yields a static string identifying the version of the compiler
8182 being used to compile the unit containing the attribute reference. A
8183 typical result would be something like "@value{EDITION} @i{version} (20090221)".
8184
8185 @node Attribute Code_Address
8186 @unnumberedsec Attribute Code_Address
8187 @findex Code_Address
8188 @cindex Subprogram address
8189 @cindex Address of subprogram code
8190 @noindent
8191 The @code{'Address}
8192 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
8193 intended effect seems to be to provide
8194 an address value which can be used to call the subprogram by means of
8195 an address clause as in the following example:
8196
8197 @smallexample @c ada
8198 procedure K is @dots{}
8199
8200 procedure L;
8201 for L'Address use K'Address;
8202 pragma Import (Ada, L);
8203 @end smallexample
8204
8205 @noindent
8206 A call to @code{L} is then expected to result in a call to @code{K}@.
8207 In Ada 83, where there were no access-to-subprogram values, this was
8208 a common work-around for getting the effect of an indirect call.
8209 GNAT implements the above use of @code{Address} and the technique
8210 illustrated by the example code works correctly.
8211
8212 However, for some purposes, it is useful to have the address of the start
8213 of the generated code for the subprogram. On some architectures, this is
8214 not necessarily the same as the @code{Address} value described above.
8215 For example, the @code{Address} value may reference a subprogram
8216 descriptor rather than the subprogram itself.
8217
8218 The @code{'Code_Address} attribute, which can only be applied to
8219 subprogram entities, always returns the address of the start of the
8220 generated code of the specified subprogram, which may or may not be
8221 the same value as is returned by the corresponding @code{'Address}
8222 attribute.
8223
8224 @node Attribute Default_Bit_Order
8225 @unnumberedsec Attribute Default_Bit_Order
8226 @cindex Big endian
8227 @cindex Little endian
8228 @findex Default_Bit_Order
8229 @noindent
8230 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
8231 permissible prefix), provides the value @code{System.Default_Bit_Order}
8232 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
8233 @code{Low_Order_First}). This is used to construct the definition of
8234 @code{Default_Bit_Order} in package @code{System}.
8235
8236 @node Attribute Descriptor_Size
8237 @unnumberedsec Attribute Descriptor_Size
8238 @cindex Descriptor
8239 @cindex Dope vector
8240 @findex Descriptor_Size
8241 @noindent
8242 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
8243 descriptor allocated for a type. The result is non-zero only for unconstrained
8244 array types and the returned value is of type universal integer. In GNAT, an
8245 array descriptor contains bounds information and is located immediately before
8246 the first element of the array.
8247
8248 @smallexample @c ada
8249 type Unconstr_Array is array (Positive range <>) of Boolean;
8250 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
8251 @end smallexample
8252
8253 @noindent
8254 The attribute takes into account any additional padding due to type alignment.
8255 In the example above, the descriptor contains two values of type
8256 @code{Positive} representing the low and high bound. Since @code{Positive} has
8257 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
8258 Positive'Size + 2} or 64 bits.
8259
8260 @node Attribute Elaborated
8261 @unnumberedsec Attribute Elaborated
8262 @findex Elaborated
8263 @noindent
8264 The prefix of the @code{'Elaborated} attribute must be a unit name. The
8265 value is a Boolean which indicates whether or not the given unit has been
8266 elaborated. This attribute is primarily intended for internal use by the
8267 generated code for dynamic elaboration checking, but it can also be used
8268 in user programs. The value will always be True once elaboration of all
8269 units has been completed. An exception is for units which need no
8270 elaboration, the value is always False for such units.
8271
8272 @node Attribute Elab_Body
8273 @unnumberedsec Attribute Elab_Body
8274 @findex Elab_Body
8275 @noindent
8276 This attribute can only be applied to a program unit name. It returns
8277 the entity for the corresponding elaboration procedure for elaborating
8278 the body of the referenced unit. This is used in the main generated
8279 elaboration procedure by the binder and is not normally used in any
8280 other context. However, there may be specialized situations in which it
8281 is useful to be able to call this elaboration procedure from Ada code,
8282 e.g.@: if it is necessary to do selective re-elaboration to fix some
8283 error.
8284
8285 @node Attribute Elab_Spec
8286 @unnumberedsec Attribute Elab_Spec
8287 @findex Elab_Spec
8288 @noindent
8289 This attribute can only be applied to a program unit name. It returns
8290 the entity for the corresponding elaboration procedure for elaborating
8291 the spec of the referenced unit. This is used in the main
8292 generated elaboration procedure by the binder and is not normally used
8293 in any other context. However, there may be specialized situations in
8294 which it is useful to be able to call this elaboration procedure from
8295 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
8296 some error.
8297
8298 @node Attribute Elab_Subp_Body
8299 @unnumberedsec Attribute Elab_Subp_Body
8300 @findex Elab_Subp_Body
8301 @noindent
8302 This attribute can only be applied to a library level subprogram
8303 name and is only allowed in CodePeer mode. It returns the entity
8304 for the corresponding elaboration procedure for elaborating the body
8305 of the referenced subprogram unit. This is used in the main generated
8306 elaboration procedure by the binder in CodePeer mode only and is unrecognized
8307 otherwise.
8308
8309 @node Attribute Emax
8310 @unnumberedsec Attribute Emax
8311 @cindex Ada 83 attributes
8312 @findex Emax
8313 @noindent
8314 The @code{Emax} attribute is provided for compatibility with Ada 83. See
8315 the Ada 83 reference manual for an exact description of the semantics of
8316 this attribute.
8317
8318 @node Attribute Enabled
8319 @unnumberedsec Attribute Enabled
8320 @findex Enabled
8321 @noindent
8322 The @code{Enabled} attribute allows an application program to check at compile
8323 time to see if the designated check is currently enabled. The prefix is a
8324 simple identifier, referencing any predefined check name (other than
8325 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
8326 no argument is given for the attribute, the check is for the general state
8327 of the check, if an argument is given, then it is an entity name, and the
8328 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
8329 given naming the entity (if not, then the argument is ignored).
8330
8331 Note that instantiations inherit the check status at the point of the
8332 instantiation, so a useful idiom is to have a library package that
8333 introduces a check name with @code{pragma Check_Name}, and then contains
8334 generic packages or subprograms which use the @code{Enabled} attribute
8335 to see if the check is enabled. A user of this package can then issue
8336 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
8337 the package or subprogram, controlling whether the check will be present.
8338
8339 @node Attribute Enum_Rep
8340 @unnumberedsec Attribute Enum_Rep
8341 @cindex Representation of enums
8342 @findex Enum_Rep
8343 @noindent
8344 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
8345 function with the following spec:
8346
8347 @smallexample @c ada
8348 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
8349 return @i{Universal_Integer};
8350 @end smallexample
8351
8352 @noindent
8353 It is also allowable to apply @code{Enum_Rep} directly to an object of an
8354 enumeration type or to a non-overloaded enumeration
8355 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
8356 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
8357 enumeration literal or object.
8358
8359 The function returns the representation value for the given enumeration
8360 value. This will be equal to value of the @code{Pos} attribute in the
8361 absence of an enumeration representation clause. This is a static
8362 attribute (i.e.@: the result is static if the argument is static).
8363
8364 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
8365 in which case it simply returns the integer value. The reason for this
8366 is to allow it to be used for @code{(<>)} discrete formal arguments in
8367 a generic unit that can be instantiated with either enumeration types
8368 or integer types. Note that if @code{Enum_Rep} is used on a modular
8369 type whose upper bound exceeds the upper bound of the largest signed
8370 integer type, and the argument is a variable, so that the universal
8371 integer calculation is done at run time, then the call to @code{Enum_Rep}
8372 may raise @code{Constraint_Error}.
8373
8374 @node Attribute Enum_Val
8375 @unnumberedsec Attribute Enum_Val
8376 @cindex Representation of enums
8377 @findex Enum_Val
8378 @noindent
8379 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
8380 function with the following spec:
8381
8382 @smallexample @c ada
8383 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
8384 return @var{S}'Base};
8385 @end smallexample
8386
8387 @noindent
8388 The function returns the enumeration value whose representation matches the
8389 argument, or raises Constraint_Error if no enumeration literal of the type
8390 has the matching value.
8391 This will be equal to value of the @code{Val} attribute in the
8392 absence of an enumeration representation clause. This is a static
8393 attribute (i.e.@: the result is static if the argument is static).
8394
8395 @node Attribute Epsilon
8396 @unnumberedsec Attribute Epsilon
8397 @cindex Ada 83 attributes
8398 @findex Epsilon
8399 @noindent
8400 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
8401 the Ada 83 reference manual for an exact description of the semantics of
8402 this attribute.
8403
8404 @node Attribute Fixed_Value
8405 @unnumberedsec Attribute Fixed_Value
8406 @findex Fixed_Value
8407 @noindent
8408 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
8409 function with the following specification:
8410
8411 @smallexample @c ada
8412 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
8413 return @var{S};
8414 @end smallexample
8415
8416 @noindent
8417 The value returned is the fixed-point value @var{V} such that
8418
8419 @smallexample @c ada
8420 @var{V} = Arg * @var{S}'Small
8421 @end smallexample
8422
8423 @noindent
8424 The effect is thus similar to first converting the argument to the
8425 integer type used to represent @var{S}, and then doing an unchecked
8426 conversion to the fixed-point type. The difference is
8427 that there are full range checks, to ensure that the result is in range.
8428 This attribute is primarily intended for use in implementation of the
8429 input-output functions for fixed-point values.
8430
8431 @node Attribute Has_Access_Values
8432 @unnumberedsec Attribute Has_Access_Values
8433 @cindex Access values, testing for
8434 @findex Has_Access_Values
8435 @noindent
8436 The prefix of the @code{Has_Access_Values} attribute is a type. The result
8437 is a Boolean value which is True if the is an access type, or is a composite
8438 type with a component (at any nesting depth) that is an access type, and is
8439 False otherwise.
8440 The intended use of this attribute is in conjunction with generic
8441 definitions. If the attribute is applied to a generic private type, it
8442 indicates whether or not the corresponding actual type has access values.
8443
8444 @node Attribute Has_Discriminants
8445 @unnumberedsec Attribute Has_Discriminants
8446 @cindex Discriminants, testing for
8447 @findex Has_Discriminants
8448 @noindent
8449 The prefix of the @code{Has_Discriminants} attribute is a type. The result
8450 is a Boolean value which is True if the type has discriminants, and False
8451 otherwise. The intended use of this attribute is in conjunction with generic
8452 definitions. If the attribute is applied to a generic private type, it
8453 indicates whether or not the corresponding actual type has discriminants.
8454
8455 @node Attribute Img
8456 @unnumberedsec Attribute Img
8457 @findex Img
8458 @noindent
8459 The @code{Img} attribute differs from @code{Image} in that it is applied
8460 directly to an object, and yields the same result as
8461 @code{Image} for the subtype of the object. This is convenient for
8462 debugging:
8463
8464 @smallexample @c ada
8465 Put_Line ("X = " & X'Img);
8466 @end smallexample
8467
8468 @noindent
8469 has the same meaning as the more verbose:
8470
8471 @smallexample @c ada
8472 Put_Line ("X = " & @var{T}'Image (X));
8473 @end smallexample
8474
8475 @noindent
8476 where @var{T} is the (sub)type of the object @code{X}.
8477
8478 Note that technically, in analogy to @code{Image},
8479 @code{X'Img} returns a parameterless function
8480 that returns the appropriate string when called. This means that
8481 @code{X'Img} can be renamed as a function-returning-string, or used
8482 in an instantiation as a function parameter.
8483
8484 @node Attribute Integer_Value
8485 @unnumberedsec Attribute Integer_Value
8486 @findex Integer_Value
8487 @noindent
8488 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
8489 function with the following spec:
8490
8491 @smallexample @c ada
8492 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
8493 return @var{S};
8494 @end smallexample
8495
8496 @noindent
8497 The value returned is the integer value @var{V}, such that
8498
8499 @smallexample @c ada
8500 Arg = @var{V} * @var{T}'Small
8501 @end smallexample
8502
8503 @noindent
8504 where @var{T} is the type of @code{Arg}.
8505 The effect is thus similar to first doing an unchecked conversion from
8506 the fixed-point type to its corresponding implementation type, and then
8507 converting the result to the target integer type. The difference is
8508 that there are full range checks, to ensure that the result is in range.
8509 This attribute is primarily intended for use in implementation of the
8510 standard input-output functions for fixed-point values.
8511
8512 @node Attribute Invalid_Value
8513 @unnumberedsec Attribute Invalid_Value
8514 @findex Invalid_Value
8515 @noindent
8516 For every scalar type S, S'Invalid_Value returns an undefined value of the
8517 type. If possible this value is an invalid representation for the type. The
8518 value returned is identical to the value used to initialize an otherwise
8519 uninitialized value of the type if pragma Initialize_Scalars is used,
8520 including the ability to modify the value with the binder -Sxx flag and
8521 relevant environment variables at run time.
8522
8523 @node Attribute Large
8524 @unnumberedsec Attribute Large
8525 @cindex Ada 83 attributes
8526 @findex Large
8527 @noindent
8528 The @code{Large} attribute is provided for compatibility with Ada 83. See
8529 the Ada 83 reference manual for an exact description of the semantics of
8530 this attribute.
8531
8532 @node Attribute Library_Level
8533 @unnumberedsec Attribute Library_Level
8534 @findex Library_Level
8535 @noindent
8536 @noindent
8537 @code{P'Library_Level}, where P is an entity name,
8538 returns a Boolean value which is True if the entity is declared
8539 at the library level, and False otherwise. Note that within a
8540 generic instantition, the name of the generic unit denotes the
8541 instance, which means that this attribute can be used to test
8542 if a generic is instantiated at the library level, as shown
8543 in this example:
8544
8545 @smallexample @c ada
8546 generic
8547 ...
8548 package Gen is
8549 pragma Compile_Time_Error
8550 (not Gen'Library_Level,
8551 "Gen can only be instantiated at library level");
8552 ...
8553 end Gen;
8554 @end smallexample
8555
8556 @node Attribute Loop_Entry
8557 @unnumberedsec Attribute Loop_Entry
8558 @findex Loop_Entry
8559 @noindent
8560 Syntax:
8561
8562 @smallexample @c ada
8563 X'Loop_Entry [(loop_name)]
8564 @end smallexample
8565
8566 @noindent
8567 The @code{Loop_Entry} attribute is used to refer to the value that an
8568 expression had upon entry to a given loop in much the same way that the
8569 @code{Old} attribute in a subprogram postcondition can be used to refer
8570 to the value an expression had upon entry to the subprogram. The
8571 relevant loop is either identified by the given loop name, or it is the
8572 innermost enclosing loop when no loop name is given.
8573
8574 @noindent
8575 A @code{Loop_Entry} attribute can only occur within a
8576 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
8577 @code{Loop_Entry} is to compare the current value of objects with their
8578 initial value at loop entry, in a @code{Loop_Invariant} pragma.
8579
8580 @noindent
8581 The effect of using @code{X'Loop_Entry} is the same as declaring
8582 a constant initialized with the initial value of @code{X} at loop
8583 entry. This copy is not performed if the loop is not entered, or if the
8584 corresponding pragmas are ignored or disabled.
8585
8586 @node Attribute Machine_Size
8587 @unnumberedsec Attribute Machine_Size
8588 @findex Machine_Size
8589 @noindent
8590 This attribute is identical to the @code{Object_Size} attribute. It is
8591 provided for compatibility with the DEC Ada 83 attribute of this name.
8592
8593 @node Attribute Mantissa
8594 @unnumberedsec Attribute Mantissa
8595 @cindex Ada 83 attributes
8596 @findex Mantissa
8597 @noindent
8598 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
8599 the Ada 83 reference manual for an exact description of the semantics of
8600 this attribute.
8601
8602 @node Attribute Max_Interrupt_Priority
8603 @unnumberedsec Attribute Max_Interrupt_Priority
8604 @cindex Interrupt priority, maximum
8605 @findex Max_Interrupt_Priority
8606 @noindent
8607 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
8608 permissible prefix), provides the same value as
8609 @code{System.Max_Interrupt_Priority}.
8610
8611 @node Attribute Max_Priority
8612 @unnumberedsec Attribute Max_Priority
8613 @cindex Priority, maximum
8614 @findex Max_Priority
8615 @noindent
8616 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
8617 prefix) provides the same value as @code{System.Max_Priority}.
8618
8619 @node Attribute Maximum_Alignment
8620 @unnumberedsec Attribute Maximum_Alignment
8621 @cindex Alignment, maximum
8622 @findex Maximum_Alignment
8623 @noindent
8624 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
8625 permissible prefix) provides the maximum useful alignment value for the
8626 target. This is a static value that can be used to specify the alignment
8627 for an object, guaranteeing that it is properly aligned in all
8628 cases.
8629
8630 @node Attribute Mechanism_Code
8631 @unnumberedsec Attribute Mechanism_Code
8632 @cindex Return values, passing mechanism
8633 @cindex Parameters, passing mechanism
8634 @findex Mechanism_Code
8635 @noindent
8636 @code{@var{function}'Mechanism_Code} yields an integer code for the
8637 mechanism used for the result of function, and
8638 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
8639 used for formal parameter number @var{n} (a static integer value with 1
8640 meaning the first parameter) of @var{subprogram}. The code returned is:
8641
8642 @table @asis
8643 @item 1
8644 by copy (value)
8645 @item 2
8646 by reference
8647 @item 3
8648 by descriptor (default descriptor class)
8649 @item 4
8650 by descriptor (UBS: unaligned bit string)
8651 @item 5
8652 by descriptor (UBSB: aligned bit string with arbitrary bounds)
8653 @item 6
8654 by descriptor (UBA: unaligned bit array)
8655 @item 7
8656 by descriptor (S: string, also scalar access type parameter)
8657 @item 8
8658 by descriptor (SB: string with arbitrary bounds)
8659 @item 9
8660 by descriptor (A: contiguous array)
8661 @item 10
8662 by descriptor (NCA: non-contiguous array)
8663 @end table
8664
8665 @noindent
8666 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
8667 @cindex OpenVMS
8668
8669 @node Attribute Null_Parameter
8670 @unnumberedsec Attribute Null_Parameter
8671 @cindex Zero address, passing
8672 @findex Null_Parameter
8673 @noindent
8674 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
8675 type or subtype @var{T} allocated at machine address zero. The attribute
8676 is allowed only as the default expression of a formal parameter, or as
8677 an actual expression of a subprogram call. In either case, the
8678 subprogram must be imported.
8679
8680 The identity of the object is represented by the address zero in the
8681 argument list, independent of the passing mechanism (explicit or
8682 default).
8683
8684 This capability is needed to specify that a zero address should be
8685 passed for a record or other composite object passed by reference.
8686 There is no way of indicating this without the @code{Null_Parameter}
8687 attribute.
8688
8689 @node Attribute Object_Size
8690 @unnumberedsec Attribute Object_Size
8691 @cindex Size, used for objects
8692 @findex Object_Size
8693 @noindent
8694 The size of an object is not necessarily the same as the size of the type
8695 of an object. This is because by default object sizes are increased to be
8696 a multiple of the alignment of the object. For example,
8697 @code{Natural'Size} is
8698 31, but by default objects of type @code{Natural} will have a size of 32 bits.
8699 Similarly, a record containing an integer and a character:
8700
8701 @smallexample @c ada
8702 type Rec is record
8703 I : Integer;
8704 C : Character;
8705 end record;
8706 @end smallexample
8707
8708 @noindent
8709 will have a size of 40 (that is @code{Rec'Size} will be 40). The
8710 alignment will be 4, because of the
8711 integer field, and so the default size of record objects for this type
8712 will be 64 (8 bytes).
8713
8714 @node Attribute Passed_By_Reference
8715 @unnumberedsec Attribute Passed_By_Reference
8716 @cindex Parameters, when passed by reference
8717 @findex Passed_By_Reference
8718 @noindent
8719 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
8720 a value of type @code{Boolean} value that is @code{True} if the type is
8721 normally passed by reference and @code{False} if the type is normally
8722 passed by copy in calls. For scalar types, the result is always @code{False}
8723 and is static. For non-scalar types, the result is non-static.
8724
8725 @node Attribute Pool_Address
8726 @unnumberedsec Attribute Pool_Address
8727 @cindex Parameters, when passed by reference
8728 @findex Pool_Address
8729 @noindent
8730 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
8731 of X within its storage pool. This is the same as
8732 @code{@var{X}'Address}, except that for an unconstrained array whose
8733 bounds are allocated just before the first component,
8734 @code{@var{X}'Pool_Address} returns the address of those bounds,
8735 whereas @code{@var{X}'Address} returns the address of the first
8736 component.
8737
8738 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
8739 the object is allocated'', which could be a user-defined storage pool,
8740 the global heap, on the stack, or in a static memory area. For an
8741 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
8742 what is passed to @code{Allocate} and returned from @code{Deallocate}.
8743
8744 @node Attribute Range_Length
8745 @unnumberedsec Attribute Range_Length
8746 @findex Range_Length
8747 @noindent
8748 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
8749 the number of values represented by the subtype (zero for a null
8750 range). The result is static for static subtypes. @code{Range_Length}
8751 applied to the index subtype of a one dimensional array always gives the
8752 same result as @code{Length} applied to the array itself.
8753
8754 @node Attribute Ref
8755 @unnumberedsec Attribute Ref
8756 @findex Ref
8757 @noindent
8758
8759
8760 @node Attribute Restriction_Set
8761 @unnumberedsec Attribute Restriction_Set
8762 @findex Restriction_Set
8763 @cindex Restrictions
8764 @noindent
8765 This attribute allows compile time testing of restrictions that
8766 are currently in effect. It is primarily intended for specializing
8767 code in the run-time based on restrictions that are active (e.g.
8768 don't need to save fpt registers if restriction No_Floating_Point
8769 is known to be in effect), but can be used anywhere.
8770
8771 There are two forms:
8772
8773 @smallexample @c ada
8774 System'Restriction_Set (partition_boolean_restriction_NAME)
8775 System'Restriction_Set (No_Dependence => library_unit_NAME);
8776 @end smallexample
8777
8778 @noindent
8779 In the case of the first form, the only restriction names
8780 allowed are parameterless restrictions that are checked
8781 for consistency at bind time. For a complete list see the
8782 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
8783
8784 The result returned is True if the restriction is known to
8785 be in effect, and False if the restriction is known not to
8786 be in effect. An important guarantee is that the value of
8787 a Restriction_Set attribute is known to be consistent throughout
8788 all the code of a partition.
8789
8790 This is trivially achieved if the entire partition is compiled
8791 with a consistent set of restriction pragmas. However, the
8792 compilation model does not require this. It is possible to
8793 compile one set of units with one set of pragmas, and another
8794 set of units with another set of pragmas. It is even possible
8795 to compile a spec with one set of pragmas, and then WITH the
8796 same spec with a different set of pragmas. Inconsistencies
8797 in the actual use of the restriction are checked at bind time.
8798
8799 In order to achieve the guarantee of consistency for the
8800 Restriction_Set pragma, we consider that a use of the pragma
8801 that yields False is equivalent to a violation of the
8802 restriction.
8803
8804 So for example if you write
8805
8806 @smallexample @c ada
8807 if System'Restriction_Set (No_Floating_Point) then
8808 ...
8809 else
8810 ...
8811 end if;
8812 @end smallexample
8813
8814 @noindent
8815 And the result is False, so that the else branch is executed,
8816 you can assume that this restriction is not set for any unit
8817 in the partition. This is checked by considering this use of
8818 the restriction pragma to be a violation of the restriction
8819 No_Floating_Point. This means that no other unit can attempt
8820 to set this restriction (if some unit does attempt to set it,
8821 the binder will refuse to bind the partition).
8822
8823 Technical note: The restriction name and the unit name are
8824 intepreted entirely syntactically, as in the corresponding
8825 Restrictions pragma, they are not analyzed semantically,
8826 so they do not have a type.
8827
8828 @node Attribute Result
8829 @unnumberedsec Attribute Result
8830 @findex Result
8831 @noindent
8832 @code{@var{function}'Result} can only be used with in a Postcondition pragma
8833 for a function. The prefix must be the name of the corresponding function. This
8834 is used to refer to the result of the function in the postcondition expression.
8835 For a further discussion of the use of this attribute and examples of its use,
8836 see the description of pragma Postcondition.
8837
8838 @node Attribute Safe_Emax
8839 @unnumberedsec Attribute Safe_Emax
8840 @cindex Ada 83 attributes
8841 @findex Safe_Emax
8842 @noindent
8843 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
8844 the Ada 83 reference manual for an exact description of the semantics of
8845 this attribute.
8846
8847 @node Attribute Safe_Large
8848 @unnumberedsec Attribute Safe_Large
8849 @cindex Ada 83 attributes
8850 @findex Safe_Large
8851 @noindent
8852 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
8853 the Ada 83 reference manual for an exact description of the semantics of
8854 this attribute.
8855
8856 @node Attribute Scalar_Storage_Order
8857 @unnumberedsec Attribute Scalar_Storage_Order
8858 @cindex Endianness
8859 @cindex Scalar storage order
8860 @findex Scalar_Storage_Order
8861 @noindent
8862 For every array or record type @var{S}, the representation attribute
8863 @code{Scalar_Storage_Order} denotes the order in which storage elements
8864 that make up scalar components are ordered within S:
8865
8866 @smallexample @c ada
8867 -- Component type definitions
8868
8869 subtype Yr_Type is Natural range 0 .. 127;
8870 subtype Mo_Type is Natural range 1 .. 12;
8871 subtype Da_Type is Natural range 1 .. 31;
8872
8873 -- Record declaration
8874
8875 type Date is record
8876 Years_Since_1980 : Yr_Type;
8877 Month : Mo_Type;
8878 Day_Of_Month : Da_Type;
8879 end record;
8880
8881 -- Record representation clause
8882
8883 for Date use record
8884 Years_Since_1980 at 0 range 0 .. 6;
8885 Month at 0 range 7 .. 10;
8886 Day_Of_Month at 0 range 11 .. 15;
8887 end record;
8888
8889 -- Attribute definition clauses
8890
8891 for Date'Bit_Order use System.High_Order_First;
8892 for Date'Scalar_Storage_Order use System.High_Order_First;
8893 -- If Scalar_Storage_Order is specified, it must be consistent with
8894 -- Bit_Order, so it's best to always define the latter explicitly if
8895 -- the former is used.
8896 @end smallexample
8897
8898 Other properties are
8899 as for standard representation attribute @code{Bit_Order}, as defined by
8900 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
8901
8902 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
8903 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
8904 this means that if a @code{Scalar_Storage_Order} attribute definition
8905 clause is not confirming, then the type's @code{Bit_Order} shall be
8906 specified explicitly and set to the same value.
8907
8908 For a record extension, the derived type shall have the same scalar storage
8909 order as the parent type.
8910
8911 If a component of @var{S} has itself a record or array type, then it shall also
8912 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
8913 if the component is a packed array, or does not start on a byte boundary, then
8914 the scalar storage order specified for S and for the nested component type shall
8915 be identical.
8916
8917 If @var{S} appears as the type of a record or array component, the enclosing
8918 record or array shall also have a @code{Scalar_Storage_Order} attribute
8919 definition clause.
8920
8921 No component of a type that has a @code{Scalar_Storage_Order} attribute
8922 definition may be aliased.
8923
8924 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
8925 with a value equal to @code{System.Default_Bit_Order}) has no effect.
8926
8927 If the opposite storage order is specified, then whenever the value of
8928 a scalar component of an object of type @var{S} is read, the storage
8929 elements of the enclosing machine scalar are first reversed (before
8930 retrieving the component value, possibly applying some shift and mask
8931 operatings on the enclosing machine scalar), and the opposite operation
8932 is done for writes.
8933
8934 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
8935 are relaxed. Instead, the following rules apply:
8936
8937 @itemize @bullet
8938 @item the underlying storage elements are those at positions
8939 @code{(position + first_bit / storage_element_size) ..
8940 (position + (last_bit + storage_element_size - 1) /
8941 storage_element_size)}
8942 @item the sequence of underlying storage elements shall have
8943 a size no greater than the largest machine scalar
8944 @item the enclosing machine scalar is defined as the smallest machine
8945 scalar starting at a position no greater than
8946 @code{position + first_bit / storage_element_size} and covering
8947 storage elements at least up to @code{position + (last_bit +
8948 storage_element_size - 1) / storage_element_size}
8949 @item the position of the component is interpreted relative to that machine
8950 scalar.
8951
8952 @end itemize
8953
8954 @node Attribute Simple_Storage_Pool
8955 @unnumberedsec Attribute Simple_Storage_Pool
8956 @cindex Storage pool, simple
8957 @cindex Simple storage pool
8958 @findex Simple_Storage_Pool
8959 @noindent
8960 For every nonformal, nonderived access-to-object type @var{Acc}, the
8961 representation attribute @code{Simple_Storage_Pool} may be specified
8962 via an attribute_definition_clause (or by specifying the equivalent aspect):
8963
8964 @smallexample @c ada
8965
8966 My_Pool : My_Simple_Storage_Pool_Type;
8967
8968 type Acc is access My_Data_Type;
8969
8970 for Acc'Simple_Storage_Pool use My_Pool;
8971
8972 @end smallexample
8973
8974 @noindent
8975 The name given in an attribute_definition_clause for the
8976 @code{Simple_Storage_Pool} attribute shall denote a variable of
8977 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
8978
8979 The use of this attribute is only allowed for a prefix denoting a type
8980 for which it has been specified. The type of the attribute is the type
8981 of the variable specified as the simple storage pool of the access type,
8982 and the attribute denotes that variable.
8983
8984 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
8985 for the same access type.
8986
8987 If the @code{Simple_Storage_Pool} attribute has been specified for an access
8988 type, then applying the @code{Storage_Pool} attribute to the type is flagged
8989 with a warning and its evaluation raises the exception @code{Program_Error}.
8990
8991 If the Simple_Storage_Pool attribute has been specified for an access
8992 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
8993 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
8994 which is intended to indicate the number of storage elements reserved for
8995 the simple storage pool. If the Storage_Size function has not been defined
8996 for the simple storage pool type, then this attribute returns zero.
8997
8998 If an access type @var{S} has a specified simple storage pool of type
8999 @var{SSP}, then the evaluation of an allocator for that access type calls
9000 the primitive @code{Allocate} procedure for type @var{SSP}, passing
9001 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
9002 semantics of such allocators is the same as those defined for allocators
9003 in section 13.11 of the Ada Reference Manual, with the term
9004 ``simple storage pool'' substituted for ``storage pool''.
9005
9006 If an access type @var{S} has a specified simple storage pool of type
9007 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
9008 for that access type invokes the primitive @code{Deallocate} procedure
9009 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
9010 parameter. The detailed semantics of such unchecked deallocations is the same
9011 as defined in section 13.11.2 of the Ada Reference Manual, except that the
9012 term ``simple storage pool'' is substituted for ``storage pool''.
9013
9014 @node Attribute Small
9015 @unnumberedsec Attribute Small
9016 @cindex Ada 83 attributes
9017 @findex Small
9018 @noindent
9019 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
9020 fixed-point types.
9021 GNAT also allows this attribute to be applied to floating-point types
9022 for compatibility with Ada 83. See
9023 the Ada 83 reference manual for an exact description of the semantics of
9024 this attribute when applied to floating-point types.
9025
9026 @node Attribute Storage_Unit
9027 @unnumberedsec Attribute Storage_Unit
9028 @findex Storage_Unit
9029 @noindent
9030 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
9031 prefix) provides the same value as @code{System.Storage_Unit}.
9032
9033 @node Attribute Stub_Type
9034 @unnumberedsec Attribute Stub_Type
9035 @findex Stub_Type
9036 @noindent
9037 The GNAT implementation of remote access-to-classwide types is
9038 organized as described in AARM section E.4 (20.t): a value of an RACW type
9039 (designating a remote object) is represented as a normal access
9040 value, pointing to a "stub" object which in turn contains the
9041 necessary information to contact the designated remote object. A
9042 call on any dispatching operation of such a stub object does the
9043 remote call, if necessary, using the information in the stub object
9044 to locate the target partition, etc.
9045
9046 For a prefix @code{T} that denotes a remote access-to-classwide type,
9047 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
9048
9049 By construction, the layout of @code{T'Stub_Type} is identical to that of
9050 type @code{RACW_Stub_Type} declared in the internal implementation-defined
9051 unit @code{System.Partition_Interface}. Use of this attribute will create
9052 an implicit dependency on this unit.
9053
9054 @node Attribute System_Allocator_Alignment
9055 @unnumberedsec Attribute System_Allocator_Alignment
9056 @cindex Alignment, allocator
9057 @findex System_Allocator_Alignment
9058 @noindent
9059 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
9060 permissible prefix) provides the observable guaranted to be honored by
9061 the system allocator (malloc). This is a static value that can be used
9062 in user storage pools based on malloc either to reject allocation
9063 with alignment too large or to enable a realignment circuitry if the
9064 alignment request is larger than this value.
9065
9066 @node Attribute Target_Name
9067 @unnumberedsec Attribute Target_Name
9068 @findex Target_Name
9069 @noindent
9070 @code{Standard'Target_Name} (@code{Standard} is the only permissible
9071 prefix) provides a static string value that identifies the target
9072 for the current compilation. For GCC implementations, this is the
9073 standard gcc target name without the terminating slash (for
9074 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
9075
9076 @node Attribute Tick
9077 @unnumberedsec Attribute Tick
9078 @findex Tick
9079 @noindent
9080 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
9081 provides the same value as @code{System.Tick},
9082
9083 @node Attribute To_Address
9084 @unnumberedsec Attribute To_Address
9085 @findex To_Address
9086 @noindent
9087 The @code{System'To_Address}
9088 (@code{System} is the only permissible prefix)
9089 denotes a function identical to
9090 @code{System.Storage_Elements.To_Address} except that
9091 it is a static attribute. This means that if its argument is
9092 a static expression, then the result of the attribute is a
9093 static expression. This means that such an expression can be
9094 used in contexts (e.g.@: preelaborable packages) which require a
9095 static expression and where the function call could not be used
9096 (since the function call is always non-static, even if its
9097 argument is static). The argument must be in the range
9098 -(2**(m-1) .. 2**m-1, where m is the memory size
9099 (typically 32 or 64). Negative values are intepreted in a
9100 modular manner (e.g. -1 means the same as 16#FFFF_FFFF# on
9101 a 32 bits machine).
9102
9103 @node Attribute Type_Class
9104 @unnumberedsec Attribute Type_Class
9105 @findex Type_Class
9106 @noindent
9107 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
9108 the value of the type class for the full type of @var{type}. If
9109 @var{type} is a generic formal type, the value is the value for the
9110 corresponding actual subtype. The value of this attribute is of type
9111 @code{System.Aux_DEC.Type_Class}, which has the following definition:
9112
9113 @smallexample @c ada
9114 type Type_Class is
9115 (Type_Class_Enumeration,
9116 Type_Class_Integer,
9117 Type_Class_Fixed_Point,
9118 Type_Class_Floating_Point,
9119 Type_Class_Array,
9120 Type_Class_Record,
9121 Type_Class_Access,
9122 Type_Class_Task,
9123 Type_Class_Address);
9124 @end smallexample
9125
9126 @noindent
9127 Protected types yield the value @code{Type_Class_Task}, which thus
9128 applies to all concurrent types. This attribute is designed to
9129 be compatible with the DEC Ada 83 attribute of the same name.
9130
9131 @node Attribute UET_Address
9132 @unnumberedsec Attribute UET_Address
9133 @findex UET_Address
9134 @noindent
9135 The @code{UET_Address} attribute can only be used for a prefix which
9136 denotes a library package. It yields the address of the unit exception
9137 table when zero cost exception handling is used. This attribute is
9138 intended only for use within the GNAT implementation. See the unit
9139 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
9140 for details on how this attribute is used in the implementation.
9141
9142 @node Attribute Unconstrained_Array
9143 @unnumberedsec Attribute Unconstrained_Array
9144 @findex Unconstrained_Array
9145 @noindent
9146 The @code{Unconstrained_Array} attribute can be used with a prefix that
9147 denotes any type or subtype. It is a static attribute that yields
9148 @code{True} if the prefix designates an unconstrained array,
9149 and @code{False} otherwise. In a generic instance, the result is
9150 still static, and yields the result of applying this test to the
9151 generic actual.
9152
9153 @node Attribute Universal_Literal_String
9154 @unnumberedsec Attribute Universal_Literal_String
9155 @cindex Named numbers, representation of
9156 @findex Universal_Literal_String
9157 @noindent
9158 The prefix of @code{Universal_Literal_String} must be a named
9159 number. The static result is the string consisting of the characters of
9160 the number as defined in the original source. This allows the user
9161 program to access the actual text of named numbers without intermediate
9162 conversions and without the need to enclose the strings in quotes (which
9163 would preclude their use as numbers).
9164
9165 For example, the following program prints the first 50 digits of pi:
9166
9167 @smallexample @c ada
9168 with Text_IO; use Text_IO;
9169 with Ada.Numerics;
9170 procedure Pi is
9171 begin
9172 Put (Ada.Numerics.Pi'Universal_Literal_String);
9173 end;
9174 @end smallexample
9175
9176 @node Attribute Unrestricted_Access
9177 @unnumberedsec Attribute Unrestricted_Access
9178 @cindex @code{Access}, unrestricted
9179 @findex Unrestricted_Access
9180 @noindent
9181 The @code{Unrestricted_Access} attribute is similar to @code{Access}
9182 except that all accessibility and aliased view checks are omitted. This
9183 is a user-beware attribute. It is similar to
9184 @code{Address}, for which it is a desirable replacement where the value
9185 desired is an access type. In other words, its effect is identical to
9186 first applying the @code{Address} attribute and then doing an unchecked
9187 conversion to a desired access type. In GNAT, but not necessarily in
9188 other implementations, the use of static chains for inner level
9189 subprograms means that @code{Unrestricted_Access} applied to a
9190 subprogram yields a value that can be called as long as the subprogram
9191 is in scope (normal Ada accessibility rules restrict this usage).
9192
9193 It is possible to use @code{Unrestricted_Access} for any type, but care
9194 must be exercised if it is used to create pointers to unconstrained
9195 objects. In this case, the resulting pointer has the same scope as the
9196 context of the attribute, and may not be returned to some enclosing
9197 scope. For instance, a function cannot use @code{Unrestricted_Access}
9198 to create a unconstrained pointer and then return that value to the
9199 caller.
9200
9201 @node Attribute Update
9202 @unnumberedsec Attribute Update
9203 @findex Update
9204 @noindent
9205 The @code{Update} attribute creates a copy of an array or record value
9206 with one or more modified components. The syntax is:
9207
9208 @smallexample @c ada
9209 PREFIX'Update (AGGREGATE)
9210 @end smallexample
9211
9212 @noindent
9213 where @code{PREFIX} is the name of an array or record object, and
9214 @code{AGGREGATE} is a named aggregate that does not contain an @code{others}
9215 choice. The effect is to yield a copy of the array or record value which
9216 is unchanged apart from the components mentioned in the aggregate, which
9217 are changed to the indicated value. The original value of the array or
9218 record value is not affected. For example:
9219
9220 @smallexample @c ada
9221 type Arr is Array (1 .. 5) of Integer;
9222 ...
9223 Avar1 : Arr := (1,2,3,4,5);
9224 Avar2 : Arr := Avar1'Update ((2 => 10, 3 .. 4 => 20));
9225 @end smallexample
9226
9227 @noindent
9228 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
9229 begin unmodified. Similarly:
9230
9231 @smallexample @c ada
9232 type Rec is A, B, C : Integer;
9233 ...
9234 Rvar1 : Rec := (A => 1, B => 2, C => 3);
9235 Rvar2 : Rec := Rvar1'Update ((B => 20));
9236 @end smallexample
9237
9238 @noindent
9239 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
9240 with @code{Rvar1} being unmodifed.
9241 Note that the value of the attribute reference is computed
9242 completely before it is used. This means that if you write:
9243
9244 @smallexample @c ada
9245 Avar1 := Avar1'Update ((1 => 10, 2 => Function_Call));
9246 @end smallexample
9247
9248 @noindent
9249 then the value of @code{Avar1} is not modified if @code{Function_Call}
9250 raises an exception, unlike the effect of a series of direct assignments
9251 to elements of @code{Avar1}. In general this requires that
9252 two extra complete copies of the object are required, which should be
9253 kept in mind when considering efficiency.
9254
9255 The @code{Update} attribute cannot be applied to prefixes of a limited
9256 type, and cannot reference discriminants in the case of a record type.
9257 The accessibility level of an Update attribute result object is defined
9258 as for an aggregate.
9259
9260 In the record case, no component can be mentioned more than once. In
9261 the array case, two overlapping ranges can appear in the aggregate,
9262 in which case the modifications are processed left to right.
9263
9264 Multi-dimensional arrays can be modified, as shown by this example:
9265
9266 @smallexample @c ada
9267 A : array (1 .. 10, 1 .. 10) of Integer;
9268 ..
9269 A := A'Update (1 => (2 => 20), 3 => (4 => 30));
9270 @end smallexample
9271
9272 @noindent
9273 which changes element (1,2) to 20 and (3,4) to 30.
9274
9275 @node Attribute Valid_Scalars
9276 @unnumberedsec Attribute Valid_Scalars
9277 @findex Valid_Scalars
9278 @noindent
9279 The @code{'Valid_Scalars} attribute is intended to make it easier to
9280 check the validity of scalar subcomponents of composite objects. It
9281 is defined for any prefix @code{X} that denotes an object.
9282 The value of this attribute is of the predefined type Boolean.
9283 @code{X'Valid_Scalars} yields True if and only if evaluation of
9284 @code{P'Valid} yields True for every scalar part P of X or if X has
9285 no scalar parts. It is not specified in what order the scalar parts
9286 are checked, nor whether any more are checked after any one of them
9287 is determined to be invalid. If the prefix @code{X} is of a class-wide
9288 type @code{T'Class} (where @code{T} is the associated specific type),
9289 or if the prefix @code{X} is of a specific tagged type @code{T}, then
9290 only the scalar parts of components of @code{T} are traversed; in other
9291 words, components of extensions of @code{T} are not traversed even if
9292 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
9293 be determined at compile time that the prefix of the attribute has no
9294 scalar parts (e.g., if the prefix is of an access type, an interface type,
9295 an undiscriminated task type, or an undiscriminated protected type).
9296
9297 @node Attribute VADS_Size
9298 @unnumberedsec Attribute VADS_Size
9299 @cindex @code{Size}, VADS compatibility
9300 @findex VADS_Size
9301 @noindent
9302 The @code{'VADS_Size} attribute is intended to make it easier to port
9303 legacy code which relies on the semantics of @code{'Size} as implemented
9304 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
9305 same semantic interpretation. In particular, @code{'VADS_Size} applied
9306 to a predefined or other primitive type with no Size clause yields the
9307 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
9308 typical machines). In addition @code{'VADS_Size} applied to an object
9309 gives the result that would be obtained by applying the attribute to
9310 the corresponding type.
9311
9312 @node Attribute Value_Size
9313 @unnumberedsec Attribute Value_Size
9314 @cindex @code{Size}, setting for not-first subtype
9315 @findex Value_Size
9316 @code{@var{type}'Value_Size} is the number of bits required to represent
9317 a value of the given subtype. It is the same as @code{@var{type}'Size},
9318 but, unlike @code{Size}, may be set for non-first subtypes.
9319
9320 @node Attribute Wchar_T_Size
9321 @unnumberedsec Attribute Wchar_T_Size
9322 @findex Wchar_T_Size
9323 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
9324 prefix) provides the size in bits of the C @code{wchar_t} type
9325 primarily for constructing the definition of this type in
9326 package @code{Interfaces.C}.
9327
9328 @node Attribute Word_Size
9329 @unnumberedsec Attribute Word_Size
9330 @findex Word_Size
9331 @code{Standard'Word_Size} (@code{Standard} is the only permissible
9332 prefix) provides the value @code{System.Word_Size}.
9333
9334 @node Standard and Implementation Defined Restrictions
9335 @chapter Standard and Implementation Defined Restrictions
9336
9337 @noindent
9338 All RM defined Restriction identifiers are implemented:
9339
9340 @itemize @bullet
9341 @item language-defined restrictions (see 13.12.1)
9342 @item tasking restrictions (see D.7)
9343 @item high integrity restrictions (see H.4)
9344 @end itemize
9345
9346 @noindent
9347 GNAT implements additional restriction identifiers. All restrictions, whether
9348 language defined or GNAT-specific, are listed in the following.
9349
9350 @menu
9351 * Partition-Wide Restrictions::
9352 * Program Unit Level Restrictions::
9353 @end menu
9354
9355 @node Partition-Wide Restrictions
9356 @section Partition-Wide Restrictions
9357
9358 There are two separate lists of restriction identifiers. The first
9359 set requires consistency throughout a partition (in other words, if the
9360 restriction identifier is used for any compilation unit in the partition,
9361 then all compilation units in the partition must obey the restriction).
9362
9363 @menu
9364 * Immediate_Reclamation::
9365 * Max_Asynchronous_Select_Nesting::
9366 * Max_Entry_Queue_Length::
9367 * Max_Protected_Entries::
9368 * Max_Select_Alternatives::
9369 * Max_Storage_At_Blocking::
9370 * Max_Task_Entries::
9371 * Max_Tasks::
9372 * No_Abort_Statements::
9373 * No_Access_Parameter_Allocators::
9374 * No_Access_Subprograms::
9375 * No_Allocators::
9376 * No_Anonymous_Allocators::
9377 * No_Calendar::
9378 * No_Coextensions::
9379 * No_Default_Initialization::
9380 * No_Delay::
9381 * No_Dependence::
9382 * No_Direct_Boolean_Operators::
9383 * No_Dispatch::
9384 * No_Dispatching_Calls::
9385 * No_Dynamic_Attachment::
9386 * No_Dynamic_Priorities::
9387 * No_Entry_Calls_In_Elaboration_Code::
9388 * No_Enumeration_Maps::
9389 * No_Exception_Handlers::
9390 * No_Exception_Propagation::
9391 * No_Exception_Registration::
9392 * No_Exceptions::
9393 * No_Finalization::
9394 * No_Fixed_Point::
9395 * No_Floating_Point::
9396 * No_Implicit_Conditionals::
9397 * No_Implicit_Dynamic_Code::
9398 * No_Implicit_Heap_Allocations::
9399 * No_Implicit_Loops::
9400 * No_Initialize_Scalars::
9401 * No_IO::
9402 * No_Local_Allocators::
9403 * No_Local_Protected_Objects::
9404 * No_Local_Timing_Events::
9405 * No_Nested_Finalization::
9406 * No_Protected_Type_Allocators::
9407 * No_Protected_Types::
9408 * No_Recursion::
9409 * No_Reentrancy::
9410 * No_Relative_Delay::
9411 * No_Requeue_Statements::
9412 * No_Secondary_Stack::
9413 * No_Select_Statements::
9414 * No_Specific_Termination_Handlers::
9415 * No_Specification_of_Aspect::
9416 * No_Standard_Allocators_After_Elaboration::
9417 * No_Standard_Storage_Pools::
9418 * No_Stream_Optimizations::
9419 * No_Streams::
9420 * No_Task_Allocators::
9421 * No_Task_Attributes_Package::
9422 * No_Task_Hierarchy::
9423 * No_Task_Termination::
9424 * No_Tasking::
9425 * No_Terminate_Alternatives::
9426 * No_Unchecked_Access::
9427 * Simple_Barriers::
9428 * Static_Priorities::
9429 * Static_Storage_Size::
9430 @end menu
9431
9432 @node Immediate_Reclamation
9433 @unnumberedsubsec Immediate_Reclamation
9434 @findex Immediate_Reclamation
9435 [RM H.4] This restriction ensures that, except for storage occupied by
9436 objects created by allocators and not deallocated via unchecked
9437 deallocation, any storage reserved at run time for an object is
9438 immediately reclaimed when the object no longer exists.
9439
9440 @node Max_Asynchronous_Select_Nesting
9441 @unnumberedsubsec Max_Asynchronous_Select_Nesting
9442 @findex Max_Asynchronous_Select_Nesting
9443 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
9444 selects. Violations of this restriction with a value of zero are
9445 detected at compile time. Violations of this restriction with values
9446 other than zero cause Storage_Error to be raised.
9447
9448 @node Max_Entry_Queue_Length
9449 @unnumberedsubsec Max_Entry_Queue_Length
9450 @findex Max_Entry_Queue_Length
9451 [RM D.7] This restriction is a declaration that any protected entry compiled in
9452 the scope of the restriction has at most the specified number of
9453 tasks waiting on the entry at any one time, and so no queue is required.
9454 Note that this restriction is checked at run time. Violation of this
9455 restriction results in the raising of Program_Error exception at the point of
9456 the call.
9457
9458 @findex Max_Entry_Queue_Depth
9459 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
9460 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
9461 compatibility purposes (and a warning will be generated for its use if
9462 warnings on obsolescent features are activated).
9463
9464 @node Max_Protected_Entries
9465 @unnumberedsubsec Max_Protected_Entries
9466 @findex Max_Protected_Entries
9467 [RM D.7] Specifies the maximum number of entries per protected type. The
9468 bounds of every entry family of a protected unit shall be static, or shall be
9469 defined by a discriminant of a subtype whose corresponding bound is static.
9470
9471 @node Max_Select_Alternatives
9472 @unnumberedsubsec Max_Select_Alternatives
9473 @findex Max_Select_Alternatives
9474 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
9475
9476 @node Max_Storage_At_Blocking
9477 @unnumberedsubsec Max_Storage_At_Blocking
9478 @findex Max_Storage_At_Blocking
9479 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
9480 Storage_Size that can be retained by a blocked task. A violation of this
9481 restriction causes Storage_Error to be raised.
9482
9483 @node Max_Task_Entries
9484 @unnumberedsubsec Max_Task_Entries
9485 @findex Max_Task_Entries
9486 [RM D.7] Specifies the maximum number of entries
9487 per task. The bounds of every entry family
9488 of a task unit shall be static, or shall be
9489 defined by a discriminant of a subtype whose
9490 corresponding bound is static.
9491
9492 @node Max_Tasks
9493 @unnumberedsubsec Max_Tasks
9494 @findex Max_Tasks
9495 [RM D.7] Specifies the maximum number of task that may be created, not
9496 counting the creation of the environment task. Violations of this
9497 restriction with a value of zero are detected at compile
9498 time. Violations of this restriction with values other than zero cause
9499 Storage_Error to be raised.
9500
9501 @node No_Abort_Statements
9502 @unnumberedsubsec No_Abort_Statements
9503 @findex No_Abort_Statements
9504 [RM D.7] There are no abort_statements, and there are
9505 no calls to Task_Identification.Abort_Task.
9506
9507 @node No_Access_Parameter_Allocators
9508 @unnumberedsubsec No_Access_Parameter_Allocators
9509 @findex No_Access_Parameter_Allocators
9510 [RM H.4] This restriction ensures at compile time that there are no
9511 occurrences of an allocator as the actual parameter to an access
9512 parameter.
9513
9514 @node No_Access_Subprograms
9515 @unnumberedsubsec No_Access_Subprograms
9516 @findex No_Access_Subprograms
9517 [RM H.4] This restriction ensures at compile time that there are no
9518 declarations of access-to-subprogram types.
9519
9520 @node No_Allocators
9521 @unnumberedsubsec No_Allocators
9522 @findex No_Allocators
9523 [RM H.4] This restriction ensures at compile time that there are no
9524 occurrences of an allocator.
9525
9526 @node No_Anonymous_Allocators
9527 @unnumberedsubsec No_Anonymous_Allocators
9528 @findex No_Anonymous_Allocators
9529 [RM H.4] This restriction ensures at compile time that there are no
9530 occurrences of an allocator of anonymous access type.
9531
9532 @node No_Calendar
9533 @unnumberedsubsec No_Calendar
9534 @findex No_Calendar
9535 [GNAT] This restriction ensures at compile time that there is no implicit or
9536 explicit dependence on the package @code{Ada.Calendar}.
9537
9538 @node No_Coextensions
9539 @unnumberedsubsec No_Coextensions
9540 @findex No_Coextensions
9541 [RM H.4] This restriction ensures at compile time that there are no
9542 coextensions. See 3.10.2.
9543
9544 @node No_Default_Initialization
9545 @unnumberedsubsec No_Default_Initialization
9546 @findex No_Default_Initialization
9547
9548 [GNAT] This restriction prohibits any instance of default initialization
9549 of variables. The binder implements a consistency rule which prevents
9550 any unit compiled without the restriction from with'ing a unit with the
9551 restriction (this allows the generation of initialization procedures to
9552 be skipped, since you can be sure that no call is ever generated to an
9553 initialization procedure in a unit with the restriction active). If used
9554 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
9555 is to prohibit all cases of variables declared without a specific
9556 initializer (including the case of OUT scalar parameters).
9557
9558 @node No_Delay
9559 @unnumberedsubsec No_Delay
9560 @findex No_Delay
9561 [RM H.4] This restriction ensures at compile time that there are no
9562 delay statements and no dependences on package Calendar.
9563
9564 @node No_Dependence
9565 @unnumberedsubsec No_Dependence
9566 @findex No_Dependence
9567 [RM 13.12.1] This restriction checks at compile time that there are no
9568 dependence on a library unit.
9569
9570 @node No_Direct_Boolean_Operators
9571 @unnumberedsubsec No_Direct_Boolean_Operators
9572 @findex No_Direct_Boolean_Operators
9573 [GNAT] This restriction ensures that no logical operators (and/or/xor)
9574 are used on operands of type Boolean (or any type derived from Boolean).
9575 This is intended for use in safety critical programs where the certification
9576 protocol requires the use of short-circuit (and then, or else) forms for all
9577 composite boolean operations.
9578
9579 @node No_Dispatch
9580 @unnumberedsubsec No_Dispatch
9581 @findex No_Dispatch
9582 [RM H.4] This restriction ensures at compile time that there are no
9583 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
9584
9585 @node No_Dispatching_Calls
9586 @unnumberedsubsec No_Dispatching_Calls
9587 @findex No_Dispatching_Calls
9588 [GNAT] This restriction ensures at compile time that the code generated by the
9589 compiler involves no dispatching calls. The use of this restriction allows the
9590 safe use of record extensions, classwide membership tests and other classwide
9591 features not involving implicit dispatching. This restriction ensures that
9592 the code contains no indirect calls through a dispatching mechanism. Note that
9593 this includes internally-generated calls created by the compiler, for example
9594 in the implementation of class-wide objects assignments. The
9595 membership test is allowed in the presence of this restriction, because its
9596 implementation requires no dispatching.
9597 This restriction is comparable to the official Ada restriction
9598 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
9599 all classwide constructs that do not imply dispatching.
9600 The following example indicates constructs that violate this restriction.
9601
9602 @smallexample
9603 package Pkg is
9604 type T is tagged record
9605 Data : Natural;
9606 end record;
9607 procedure P (X : T);
9608
9609 type DT is new T with record
9610 More_Data : Natural;
9611 end record;
9612 procedure Q (X : DT);
9613 end Pkg;
9614
9615 with Pkg; use Pkg;
9616 procedure Example is
9617 procedure Test (O : T'Class) is
9618 N : Natural := O'Size;-- Error: Dispatching call
9619 C : T'Class := O; -- Error: implicit Dispatching Call
9620 begin
9621 if O in DT'Class then -- OK : Membership test
9622 Q (DT (O)); -- OK : Type conversion plus direct call
9623 else
9624 P (O); -- Error: Dispatching call
9625 end if;
9626 end Test;
9627
9628 Obj : DT;
9629 begin
9630 P (Obj); -- OK : Direct call
9631 P (T (Obj)); -- OK : Type conversion plus direct call
9632 P (T'Class (Obj)); -- Error: Dispatching call
9633
9634 Test (Obj); -- OK : Type conversion
9635
9636 if Obj in T'Class then -- OK : Membership test
9637 null;
9638 end if;
9639 end Example;
9640 @end smallexample
9641
9642 @node No_Dynamic_Attachment
9643 @unnumberedsubsec No_Dynamic_Attachment
9644 @findex No_Dynamic_Attachment
9645 [RM D.7] This restriction ensures that there is no call to any of the
9646 operations defined in package Ada.Interrupts
9647 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
9648 Detach_Handler, and Reference).
9649
9650 @findex No_Dynamic_Interrupts
9651 The restriction @code{No_Dynamic_Interrupts} is recognized as a
9652 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
9653 compatibility purposes (and a warning will be generated for its use if
9654 warnings on obsolescent features are activated).
9655
9656 @node No_Dynamic_Priorities
9657 @unnumberedsubsec No_Dynamic_Priorities
9658 @findex No_Dynamic_Priorities
9659 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
9660
9661 @node No_Entry_Calls_In_Elaboration_Code
9662 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
9663 @findex No_Entry_Calls_In_Elaboration_Code
9664 [GNAT] This restriction ensures at compile time that no task or protected entry
9665 calls are made during elaboration code. As a result of the use of this
9666 restriction, the compiler can assume that no code past an accept statement
9667 in a task can be executed at elaboration time.
9668
9669 @node No_Enumeration_Maps
9670 @unnumberedsubsec No_Enumeration_Maps
9671 @findex No_Enumeration_Maps
9672 [GNAT] This restriction ensures at compile time that no operations requiring
9673 enumeration maps are used (that is Image and Value attributes applied
9674 to enumeration types).
9675
9676 @node No_Exception_Handlers
9677 @unnumberedsubsec No_Exception_Handlers
9678 @findex No_Exception_Handlers
9679 [GNAT] This restriction ensures at compile time that there are no explicit
9680 exception handlers. It also indicates that no exception propagation will
9681 be provided. In this mode, exceptions may be raised but will result in
9682 an immediate call to the last chance handler, a routine that the user
9683 must define with the following profile:
9684
9685 @smallexample @c ada
9686 procedure Last_Chance_Handler
9687 (Source_Location : System.Address; Line : Integer);
9688 pragma Export (C, Last_Chance_Handler,
9689 "__gnat_last_chance_handler");
9690 @end smallexample
9691
9692 The parameter is a C null-terminated string representing a message to be
9693 associated with the exception (typically the source location of the raise
9694 statement generated by the compiler). The Line parameter when nonzero
9695 represents the line number in the source program where the raise occurs.
9696
9697 @node No_Exception_Propagation
9698 @unnumberedsubsec No_Exception_Propagation
9699 @findex No_Exception_Propagation
9700 [GNAT] This restriction guarantees that exceptions are never propagated
9701 to an outer subprogram scope. The only case in which an exception may
9702 be raised is when the handler is statically in the same subprogram, so
9703 that the effect of a raise is essentially like a goto statement. Any
9704 other raise statement (implicit or explicit) will be considered
9705 unhandled. Exception handlers are allowed, but may not contain an
9706 exception occurrence identifier (exception choice). In addition, use of
9707 the package GNAT.Current_Exception is not permitted, and reraise
9708 statements (raise with no operand) are not permitted.
9709
9710 @node No_Exception_Registration
9711 @unnumberedsubsec No_Exception_Registration
9712 @findex No_Exception_Registration
9713 [GNAT] This restriction ensures at compile time that no stream operations for
9714 types Exception_Id or Exception_Occurrence are used. This also makes it
9715 impossible to pass exceptions to or from a partition with this restriction
9716 in a distributed environment. If this exception is active, then the generated
9717 code is simplified by omitting the otherwise-required global registration
9718 of exceptions when they are declared.
9719
9720 @node No_Exceptions
9721 @unnumberedsubsec No_Exceptions
9722 @findex No_Exceptions
9723 [RM H.4] This restriction ensures at compile time that there are no
9724 raise statements and no exception handlers.
9725
9726 @node No_Finalization
9727 @unnumberedsubsec No_Finalization
9728 @findex No_Finalization
9729 [GNAT] This restriction disables the language features described in
9730 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
9731 performed by the compiler to support these features. The following types
9732 are no longer considered controlled when this restriction is in effect:
9733 @itemize @bullet
9734 @item
9735 @code{Ada.Finalization.Controlled}
9736 @item
9737 @code{Ada.Finalization.Limited_Controlled}
9738 @item
9739 Derivations from @code{Controlled} or @code{Limited_Controlled}
9740 @item
9741 Class-wide types
9742 @item
9743 Protected types
9744 @item
9745 Task types
9746 @item
9747 Array and record types with controlled components
9748 @end itemize
9749 The compiler no longer generates code to initialize, finalize or adjust an
9750 object or a nested component, either declared on the stack or on the heap. The
9751 deallocation of a controlled object no longer finalizes its contents.
9752
9753 @node No_Fixed_Point
9754 @unnumberedsubsec No_Fixed_Point
9755 @findex No_Fixed_Point
9756 [RM H.4] This restriction ensures at compile time that there are no
9757 occurrences of fixed point types and operations.
9758
9759 @node No_Floating_Point
9760 @unnumberedsubsec No_Floating_Point
9761 @findex No_Floating_Point
9762 [RM H.4] This restriction ensures at compile time that there are no
9763 occurrences of floating point types and operations.
9764
9765 @node No_Implicit_Conditionals
9766 @unnumberedsubsec No_Implicit_Conditionals
9767 @findex No_Implicit_Conditionals
9768 [GNAT] This restriction ensures that the generated code does not contain any
9769 implicit conditionals, either by modifying the generated code where possible,
9770 or by rejecting any construct that would otherwise generate an implicit
9771 conditional. Note that this check does not include run time constraint
9772 checks, which on some targets may generate implicit conditionals as
9773 well. To control the latter, constraint checks can be suppressed in the
9774 normal manner. Constructs generating implicit conditionals include comparisons
9775 of composite objects and the Max/Min attributes.
9776
9777 @node No_Implicit_Dynamic_Code
9778 @unnumberedsubsec No_Implicit_Dynamic_Code
9779 @findex No_Implicit_Dynamic_Code
9780 @cindex trampoline
9781 [GNAT] This restriction prevents the compiler from building ``trampolines''.
9782 This is a structure that is built on the stack and contains dynamic
9783 code to be executed at run time. On some targets, a trampoline is
9784 built for the following features: @code{Access},
9785 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
9786 nested task bodies; primitive operations of nested tagged types.
9787 Trampolines do not work on machines that prevent execution of stack
9788 data. For example, on windows systems, enabling DEP (data execution
9789 protection) will cause trampolines to raise an exception.
9790 Trampolines are also quite slow at run time.
9791
9792 On many targets, trampolines have been largely eliminated. Look at the
9793 version of system.ads for your target --- if it has
9794 Always_Compatible_Rep equal to False, then trampolines are largely
9795 eliminated. In particular, a trampoline is built for the following
9796 features: @code{Address} of a nested subprogram;
9797 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
9798 but only if pragma Favor_Top_Level applies, or the access type has a
9799 foreign-language convention; primitive operations of nested tagged
9800 types.
9801
9802 @node No_Implicit_Heap_Allocations
9803 @unnumberedsubsec No_Implicit_Heap_Allocations
9804 @findex No_Implicit_Heap_Allocations
9805 [RM D.7] No constructs are allowed to cause implicit heap allocation.
9806
9807 @node No_Implicit_Loops
9808 @unnumberedsubsec No_Implicit_Loops
9809 @findex No_Implicit_Loops
9810 [GNAT] This restriction ensures that the generated code does not contain any
9811 implicit @code{for} loops, either by modifying
9812 the generated code where possible,
9813 or by rejecting any construct that would otherwise generate an implicit
9814 @code{for} loop. If this restriction is active, it is possible to build
9815 large array aggregates with all static components without generating an
9816 intermediate temporary, and without generating a loop to initialize individual
9817 components. Otherwise, a loop is created for arrays larger than about 5000
9818 scalar components.
9819
9820 @node No_Initialize_Scalars
9821 @unnumberedsubsec No_Initialize_Scalars
9822 @findex No_Initialize_Scalars
9823 [GNAT] This restriction ensures that no unit in the partition is compiled with
9824 pragma Initialize_Scalars. This allows the generation of more efficient
9825 code, and in particular eliminates dummy null initialization routines that
9826 are otherwise generated for some record and array types.
9827
9828 @node No_IO
9829 @unnumberedsubsec No_IO
9830 @findex No_IO
9831 [RM H.4] This restriction ensures at compile time that there are no
9832 dependences on any of the library units Sequential_IO, Direct_IO,
9833 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
9834
9835 @node No_Local_Allocators
9836 @unnumberedsubsec No_Local_Allocators
9837 @findex No_Local_Allocators
9838 [RM H.4] This restriction ensures at compile time that there are no
9839 occurrences of an allocator in subprograms, generic subprograms, tasks,
9840 and entry bodies.
9841
9842 @node No_Local_Protected_Objects
9843 @unnumberedsubsec No_Local_Protected_Objects
9844 @findex No_Local_Protected_Objects
9845 [RM D.7] This restriction ensures at compile time that protected objects are
9846 only declared at the library level.
9847
9848 @node No_Local_Timing_Events
9849 @unnumberedsubsec No_Local_Timing_Events
9850 @findex No_Local_Timing_Events
9851 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
9852 declared at the library level.
9853
9854 @node No_Nested_Finalization
9855 @unnumberedsubsec No_Nested_Finalization
9856 @findex No_Nested_Finalization
9857 [RM D.7] All objects requiring finalization are declared at the library level.
9858
9859 @node No_Protected_Type_Allocators
9860 @unnumberedsubsec No_Protected_Type_Allocators
9861 @findex No_Protected_Type_Allocators
9862 [RM D.7] This restriction ensures at compile time that there are no allocator
9863 expressions that attempt to allocate protected objects.
9864
9865 @node No_Protected_Types
9866 @unnumberedsubsec No_Protected_Types
9867 @findex No_Protected_Types
9868 [RM H.4] This restriction ensures at compile time that there are no
9869 declarations of protected types or protected objects.
9870
9871 @node No_Recursion
9872 @unnumberedsubsec No_Recursion
9873 @findex No_Recursion
9874 [RM H.4] A program execution is erroneous if a subprogram is invoked as
9875 part of its execution.
9876
9877 @node No_Reentrancy
9878 @unnumberedsubsec No_Reentrancy
9879 @findex No_Reentrancy
9880 [RM H.4] A program execution is erroneous if a subprogram is executed by
9881 two tasks at the same time.
9882
9883 @node No_Relative_Delay
9884 @unnumberedsubsec No_Relative_Delay
9885 @findex No_Relative_Delay
9886 [RM D.7] This restriction ensures at compile time that there are no delay
9887 relative statements and prevents expressions such as @code{delay 1.23;} from
9888 appearing in source code.
9889
9890 @node No_Requeue_Statements
9891 @unnumberedsubsec No_Requeue_Statements
9892 @findex No_Requeue_Statements
9893 [RM D.7] This restriction ensures at compile time that no requeue statements
9894 are permitted and prevents keyword @code{requeue} from being used in source
9895 code.
9896
9897 @findex No_Requeue
9898 The restriction @code{No_Requeue} is recognized as a
9899 synonym for @code{No_Requeue_Statements}. This is retained for historical
9900 compatibility purposes (and a warning will be generated for its use if
9901 warnings on oNobsolescent features are activated).
9902
9903 @node No_Secondary_Stack
9904 @unnumberedsubsec No_Secondary_Stack
9905 @findex No_Secondary_Stack
9906 [GNAT] This restriction ensures at compile time that the generated code
9907 does not contain any reference to the secondary stack. The secondary
9908 stack is used to implement functions returning unconstrained objects
9909 (arrays or records) on some targets.
9910
9911 @node No_Select_Statements
9912 @unnumberedsubsec No_Select_Statements
9913 @findex No_Select_Statements
9914 [RM D.7] This restriction ensures at compile time no select statements of any
9915 kind are permitted, that is the keyword @code{select} may not appear.
9916
9917 @node No_Specific_Termination_Handlers
9918 @unnumberedsubsec No_Specific_Termination_Handlers
9919 @findex No_Specific_Termination_Handlers
9920 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
9921 or to Ada.Task_Termination.Specific_Handler.
9922
9923 @node No_Specification_of_Aspect
9924 @unnumberedsubsec No_Specification_of_Aspect
9925 @findex No_Specification_of_Aspect
9926 [RM 13.12.1] This restriction checks at compile time that no aspect
9927 specification, attribute definition clause, or pragma is given for a
9928 given aspect.
9929
9930 @node No_Standard_Allocators_After_Elaboration
9931 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
9932 @findex No_Standard_Allocators_After_Elaboration
9933 [RM D.7] Specifies that an allocator using a standard storage pool
9934 should never be evaluated at run time after the elaboration of the
9935 library items of the partition has completed. Otherwise, Storage_Error
9936 is raised.
9937
9938 @node No_Standard_Storage_Pools
9939 @unnumberedsubsec No_Standard_Storage_Pools
9940 @findex No_Standard_Storage_Pools
9941 [GNAT] This restriction ensures at compile time that no access types
9942 use the standard default storage pool. Any access type declared must
9943 have an explicit Storage_Pool attribute defined specifying a
9944 user-defined storage pool.
9945
9946 @node No_Stream_Optimizations
9947 @unnumberedsubsec No_Stream_Optimizations
9948 @findex No_Stream_Optimizations
9949 [GNAT] This restriction affects the performance of stream operations on types
9950 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
9951 compiler uses block reads and writes when manipulating @code{String} objects
9952 due to their supperior performance. When this restriction is in effect, the
9953 compiler performs all IO operations on a per-character basis.
9954
9955 @node No_Streams
9956 @unnumberedsubsec No_Streams
9957 @findex No_Streams
9958 [GNAT] This restriction ensures at compile/bind time that there are no
9959 stream objects created and no use of stream attributes.
9960 This restriction does not forbid dependences on the package
9961 @code{Ada.Streams}. So it is permissible to with
9962 @code{Ada.Streams} (or another package that does so itself)
9963 as long as no actual stream objects are created and no
9964 stream attributes are used.
9965
9966 Note that the use of restriction allows optimization of tagged types,
9967 since they do not need to worry about dispatching stream operations.
9968 To take maximum advantage of this space-saving optimization, any
9969 unit declaring a tagged type should be compiled with the restriction,
9970 though this is not required.
9971
9972 @node No_Task_Allocators
9973 @unnumberedsubsec No_Task_Allocators
9974 @findex No_Task_Allocators
9975 [RM D.7] There are no allocators for task types
9976 or types containing task subcomponents.
9977
9978 @node No_Task_Attributes_Package
9979 @unnumberedsubsec No_Task_Attributes_Package
9980 @findex No_Task_Attributes_Package
9981 [GNAT] This restriction ensures at compile time that there are no implicit or
9982 explicit dependencies on the package @code{Ada.Task_Attributes}.
9983
9984 @findex No_Task_Attributes
9985 The restriction @code{No_Task_Attributes} is recognized as a synonym
9986 for @code{No_Task_Attributes_Package}. This is retained for historical
9987 compatibility purposes (and a warning will be generated for its use if
9988 warnings on obsolescent features are activated).
9989
9990 @node No_Task_Hierarchy
9991 @unnumberedsubsec No_Task_Hierarchy
9992 @findex No_Task_Hierarchy
9993 [RM D.7] All (non-environment) tasks depend
9994 directly on the environment task of the partition.
9995
9996 @node No_Task_Termination
9997 @unnumberedsubsec No_Task_Termination
9998 @findex No_Task_Termination
9999 [RM D.7] Tasks which terminate are erroneous.
10000
10001 @node No_Tasking
10002 @unnumberedsubsec No_Tasking
10003 @findex No_Tasking
10004 [GNAT] This restriction prevents the declaration of tasks or task types
10005 throughout the partition. It is similar in effect to the use of
10006 @code{Max_Tasks => 0} except that violations are caught at compile time
10007 and cause an error message to be output either by the compiler or
10008 binder.
10009
10010 @node No_Terminate_Alternatives
10011 @unnumberedsubsec No_Terminate_Alternatives
10012 @findex No_Terminate_Alternatives
10013 [RM D.7] There are no selective accepts with terminate alternatives.
10014
10015 @node No_Unchecked_Access
10016 @unnumberedsubsec No_Unchecked_Access
10017 @findex No_Unchecked_Access
10018 [RM H.4] This restriction ensures at compile time that there are no
10019 occurrences of the Unchecked_Access attribute.
10020
10021 @node Simple_Barriers
10022 @unnumberedsubsec Simple_Barriers
10023 @findex Simple_Barriers
10024 [RM D.7] This restriction ensures at compile time that barriers in entry
10025 declarations for protected types are restricted to either static boolean
10026 expressions or references to simple boolean variables defined in the private
10027 part of the protected type. No other form of entry barriers is permitted.
10028
10029 @findex Boolean_Entry_Barriers
10030 The restriction @code{Boolean_Entry_Barriers} is recognized as a
10031 synonym for @code{Simple_Barriers}. This is retained for historical
10032 compatibility purposes (and a warning will be generated for its use if
10033 warnings on obsolescent features are activated).
10034
10035 @node Static_Priorities
10036 @unnumberedsubsec Static_Priorities
10037 @findex Static_Priorities
10038 [GNAT] This restriction ensures at compile time that all priority expressions
10039 are static, and that there are no dependences on the package
10040 @code{Ada.Dynamic_Priorities}.
10041
10042 @node Static_Storage_Size
10043 @unnumberedsubsec Static_Storage_Size
10044 @findex Static_Storage_Size
10045 [GNAT] This restriction ensures at compile time that any expression appearing
10046 in a Storage_Size pragma or attribute definition clause is static.
10047
10048 @node Program Unit Level Restrictions
10049 @section Program Unit Level Restrictions
10050
10051 @noindent
10052 The second set of restriction identifiers
10053 does not require partition-wide consistency.
10054 The restriction may be enforced for a single
10055 compilation unit without any effect on any of the
10056 other compilation units in the partition.
10057
10058 @menu
10059 * No_Elaboration_Code::
10060 * No_Entry_Queue::
10061 * No_Implementation_Aspect_Specifications::
10062 * No_Implementation_Attributes::
10063 * No_Implementation_Identifiers::
10064 * No_Implementation_Pragmas::
10065 * No_Implementation_Restrictions::
10066 * No_Implementation_Units::
10067 * No_Implicit_Aliasing::
10068 * No_Obsolescent_Features::
10069 * No_Wide_Characters::
10070 * SPARK_05::
10071 @end menu
10072
10073 @node No_Elaboration_Code
10074 @unnumberedsubsec No_Elaboration_Code
10075 @findex No_Elaboration_Code
10076 [GNAT] This restriction ensures at compile time that no elaboration code is
10077 generated. Note that this is not the same condition as is enforced
10078 by pragma @code{Preelaborate}. There are cases in which pragma
10079 @code{Preelaborate} still permits code to be generated (e.g.@: code
10080 to initialize a large array to all zeroes), and there are cases of units
10081 which do not meet the requirements for pragma @code{Preelaborate},
10082 but for which no elaboration code is generated. Generally, it is
10083 the case that preelaborable units will meet the restrictions, with
10084 the exception of large aggregates initialized with an others_clause,
10085 and exception declarations (which generate calls to a run-time
10086 registry procedure). This restriction is enforced on
10087 a unit by unit basis, it need not be obeyed consistently
10088 throughout a partition.
10089
10090 In the case of aggregates with others, if the aggregate has a dynamic
10091 size, there is no way to eliminate the elaboration code (such dynamic
10092 bounds would be incompatible with @code{Preelaborate} in any case). If
10093 the bounds are static, then use of this restriction actually modifies
10094 the code choice of the compiler to avoid generating a loop, and instead
10095 generate the aggregate statically if possible, no matter how many times
10096 the data for the others clause must be repeatedly generated.
10097
10098 It is not possible to precisely document
10099 the constructs which are compatible with this restriction, since,
10100 unlike most other restrictions, this is not a restriction on the
10101 source code, but a restriction on the generated object code. For
10102 example, if the source contains a declaration:
10103
10104 @smallexample
10105 Val : constant Integer := X;
10106 @end smallexample
10107
10108 @noindent
10109 where X is not a static constant, it may be possible, depending
10110 on complex optimization circuitry, for the compiler to figure
10111 out the value of X at compile time, in which case this initialization
10112 can be done by the loader, and requires no initialization code. It
10113 is not possible to document the precise conditions under which the
10114 optimizer can figure this out.
10115
10116 Note that this the implementation of this restriction requires full
10117 code generation. If it is used in conjunction with "semantics only"
10118 checking, then some cases of violations may be missed.
10119
10120 @node No_Entry_Queue
10121 @unnumberedsubsec No_Entry_Queue
10122 @findex No_Entry_Queue
10123 [GNAT] This restriction is a declaration that any protected entry compiled in
10124 the scope of the restriction has at most one task waiting on the entry
10125 at any one time, and so no queue is required. This restriction is not
10126 checked at compile time. A program execution is erroneous if an attempt
10127 is made to queue a second task on such an entry.
10128
10129 @node No_Implementation_Aspect_Specifications
10130 @unnumberedsubsec No_Implementation_Aspect_Specifications
10131 @findex No_Implementation_Aspect_Specifications
10132 [RM 13.12.1] This restriction checks at compile time that no
10133 GNAT-defined aspects are present. With this restriction, the only
10134 aspects that can be used are those defined in the Ada Reference Manual.
10135
10136 @node No_Implementation_Attributes
10137 @unnumberedsubsec No_Implementation_Attributes
10138 @findex No_Implementation_Attributes
10139 [RM 13.12.1] This restriction checks at compile time that no
10140 GNAT-defined attributes are present. With this restriction, the only
10141 attributes that can be used are those defined in the Ada Reference
10142 Manual.
10143
10144 @node No_Implementation_Identifiers
10145 @unnumberedsubsec No_Implementation_Identifiers
10146 @findex No_Implementation_Identifiers
10147 [RM 13.12.1] This restriction checks at compile time that no
10148 implementation-defined identifiers (marked with pragma Implementation_Defined)
10149 occur within language-defined packages.
10150
10151 @node No_Implementation_Pragmas
10152 @unnumberedsubsec No_Implementation_Pragmas
10153 @findex No_Implementation_Pragmas
10154 [RM 13.12.1] This restriction checks at compile time that no
10155 GNAT-defined pragmas are present. With this restriction, the only
10156 pragmas that can be used are those defined in the Ada Reference Manual.
10157
10158 @node No_Implementation_Restrictions
10159 @unnumberedsubsec No_Implementation_Restrictions
10160 @findex No_Implementation_Restrictions
10161 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
10162 identifiers (other than @code{No_Implementation_Restrictions} itself)
10163 are present. With this restriction, the only other restriction identifiers
10164 that can be used are those defined in the Ada Reference Manual.
10165
10166 @node No_Implementation_Units
10167 @unnumberedsubsec No_Implementation_Units
10168 @findex No_Implementation_Units
10169 [RM 13.12.1] This restriction checks at compile time that there is no
10170 mention in the context clause of any implementation-defined descendants
10171 of packages Ada, Interfaces, or System.
10172
10173 @node No_Implicit_Aliasing
10174 @unnumberedsubsec No_Implicit_Aliasing
10175 @findex No_Implicit_Aliasing
10176 [GNAT] This restriction, which is not required to be partition-wide consistent,
10177 requires an explicit aliased keyword for an object to which 'Access,
10178 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
10179 the 'Unrestricted_Access attribute for objects. Note: the reason that
10180 Unrestricted_Access is forbidden is that it would require the prefix
10181 to be aliased, and in such cases, it can always be replaced by
10182 the standard attribute Unchecked_Access which is preferable.
10183
10184 @node No_Obsolescent_Features
10185 @unnumberedsubsec No_Obsolescent_Features
10186 @findex No_Obsolescent_Features
10187 [RM 13.12.1] This restriction checks at compile time that no obsolescent
10188 features are used, as defined in Annex J of the Ada Reference Manual.
10189
10190 @node No_Wide_Characters
10191 @unnumberedsubsec No_Wide_Characters
10192 @findex No_Wide_Characters
10193 [GNAT] This restriction ensures at compile time that no uses of the types
10194 @code{Wide_Character} or @code{Wide_String} or corresponding wide
10195 wide types
10196 appear, and that no wide or wide wide string or character literals
10197 appear in the program (that is literals representing characters not in
10198 type @code{Character}).
10199
10200 @node SPARK_05
10201 @unnumberedsubsec SPARK_05
10202 @findex SPARK_05
10203 [GNAT] This restriction checks at compile time that some constructs
10204 forbidden in SPARK 2005 are not present. Error messages related to
10205 SPARK restriction have the form:
10206
10207 @findex SPARK
10208 The restriction @code{SPARK} is recognized as a
10209 synonym for @code{SPARK_05}. This is retained for historical
10210 compatibility purposes (and an unconditional warning will be generated
10211 for its use, advising replacement by @code{SPARK}.
10212
10213 @smallexample
10214 violation of restriction "SPARK" at <file>
10215 <error message>
10216 @end smallexample
10217
10218 This is not a replacement for the semantic checks performed by the
10219 SPARK Examiner tool, as the compiler only deals currently with code,
10220 not at all with SPARK 2005 annotations and does not guarantee catching all
10221 cases of constructs forbidden by SPARK 2005.
10222
10223 Thus it may well be the case that code which passes the compiler with
10224 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
10225 the different visibility rules of the Examiner based on SPARK 2005
10226 @code{inherit} annotations.
10227
10228 This restriction can be useful in providing an initial filter for code
10229 developed using SPARK 2005, or in examining legacy code to see how far
10230 it is from meeting SPARK restrictions.
10231
10232 Note that if a unit is compiled in Ada 95 mode with SPARK restriction,
10233 violations will be reported for constructs forbidden in SPARK 95,
10234 instead of SPARK 2005.
10235
10236 @c ------------------------
10237 @node Implementation Advice
10238 @chapter Implementation Advice
10239 @noindent
10240 The main text of the Ada Reference Manual describes the required
10241 behavior of all Ada compilers, and the GNAT compiler conforms to
10242 these requirements.
10243
10244 In addition, there are sections throughout the Ada Reference Manual headed
10245 by the phrase ``Implementation advice''. These sections are not normative,
10246 i.e., they do not specify requirements that all compilers must
10247 follow. Rather they provide advice on generally desirable behavior. You
10248 may wonder why they are not requirements. The most typical answer is
10249 that they describe behavior that seems generally desirable, but cannot
10250 be provided on all systems, or which may be undesirable on some systems.
10251
10252 As far as practical, GNAT follows the implementation advice sections in
10253 the Ada Reference Manual. This chapter contains a table giving the
10254 reference manual section number, paragraph number and several keywords
10255 for each advice. Each entry consists of the text of the advice followed
10256 by the GNAT interpretation of this advice. Most often, this simply says
10257 ``followed'', which means that GNAT follows the advice. However, in a
10258 number of cases, GNAT deliberately deviates from this advice, in which
10259 case the text describes what GNAT does and why.
10260
10261 @cindex Error detection
10262 @unnumberedsec 1.1.3(20): Error Detection
10263 @sp 1
10264 @cartouche
10265 If an implementation detects the use of an unsupported Specialized Needs
10266 Annex feature at run time, it should raise @code{Program_Error} if
10267 feasible.
10268 @end cartouche
10269 Not relevant. All specialized needs annex features are either supported,
10270 or diagnosed at compile time.
10271
10272 @cindex Child Units
10273 @unnumberedsec 1.1.3(31): Child Units
10274 @sp 1
10275 @cartouche
10276 If an implementation wishes to provide implementation-defined
10277 extensions to the functionality of a language-defined library unit, it
10278 should normally do so by adding children to the library unit.
10279 @end cartouche
10280 Followed.
10281
10282 @cindex Bounded errors
10283 @unnumberedsec 1.1.5(12): Bounded Errors
10284 @sp 1
10285 @cartouche
10286 If an implementation detects a bounded error or erroneous
10287 execution, it should raise @code{Program_Error}.
10288 @end cartouche
10289 Followed in all cases in which the implementation detects a bounded
10290 error or erroneous execution. Not all such situations are detected at
10291 runtime.
10292
10293 @cindex Pragmas
10294 @unnumberedsec 2.8(16): Pragmas
10295 @sp 1
10296 @cartouche
10297 Normally, implementation-defined pragmas should have no semantic effect
10298 for error-free programs; that is, if the implementation-defined pragmas
10299 are removed from a working program, the program should still be legal,
10300 and should still have the same semantics.
10301 @end cartouche
10302 The following implementation defined pragmas are exceptions to this
10303 rule:
10304
10305 @table @code
10306 @item Abort_Defer
10307 Affects semantics
10308 @item Ada_83
10309 Affects legality
10310 @item Assert
10311 Affects semantics
10312 @item CPP_Class
10313 Affects semantics
10314 @item CPP_Constructor
10315 Affects semantics
10316 @item Debug
10317 Affects semantics
10318 @item Interface_Name
10319 Affects semantics
10320 @item Machine_Attribute
10321 Affects semantics
10322 @item Unimplemented_Unit
10323 Affects legality
10324 @item Unchecked_Union
10325 Affects semantics
10326 @end table
10327
10328 @noindent
10329 In each of the above cases, it is essential to the purpose of the pragma
10330 that this advice not be followed. For details see the separate section
10331 on implementation defined pragmas.
10332
10333 @unnumberedsec 2.8(17-19): Pragmas
10334 @sp 1
10335 @cartouche
10336 Normally, an implementation should not define pragmas that can
10337 make an illegal program legal, except as follows:
10338 @end cartouche
10339 @sp 1
10340 @cartouche
10341 A pragma used to complete a declaration, such as a pragma @code{Import};
10342 @end cartouche
10343 @sp 1
10344 @cartouche
10345 A pragma used to configure the environment by adding, removing, or
10346 replacing @code{library_items}.
10347 @end cartouche
10348 See response to paragraph 16 of this same section.
10349
10350 @cindex Character Sets
10351 @cindex Alternative Character Sets
10352 @unnumberedsec 3.5.2(5): Alternative Character Sets
10353 @sp 1
10354 @cartouche
10355 If an implementation supports a mode with alternative interpretations
10356 for @code{Character} and @code{Wide_Character}, the set of graphic
10357 characters of @code{Character} should nevertheless remain a proper
10358 subset of the set of graphic characters of @code{Wide_Character}. Any
10359 character set ``localizations'' should be reflected in the results of
10360 the subprograms defined in the language-defined package
10361 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
10362 an alternative interpretation of @code{Character}, the implementation should
10363 also support a corresponding change in what is a legal
10364 @code{identifier_letter}.
10365 @end cartouche
10366 Not all wide character modes follow this advice, in particular the JIS
10367 and IEC modes reflect standard usage in Japan, and in these encoding,
10368 the upper half of the Latin-1 set is not part of the wide-character
10369 subset, since the most significant bit is used for wide character
10370 encoding. However, this only applies to the external forms. Internally
10371 there is no such restriction.
10372
10373 @cindex Integer types
10374 @unnumberedsec 3.5.4(28): Integer Types
10375
10376 @sp 1
10377 @cartouche
10378 An implementation should support @code{Long_Integer} in addition to
10379 @code{Integer} if the target machine supports 32-bit (or longer)
10380 arithmetic. No other named integer subtypes are recommended for package
10381 @code{Standard}. Instead, appropriate named integer subtypes should be
10382 provided in the library package @code{Interfaces} (see B.2).
10383 @end cartouche
10384 @code{Long_Integer} is supported. Other standard integer types are supported
10385 so this advice is not fully followed. These types
10386 are supported for convenient interface to C, and so that all hardware
10387 types of the machine are easily available.
10388 @unnumberedsec 3.5.4(29): Integer Types
10389
10390 @sp 1
10391 @cartouche
10392 An implementation for a two's complement machine should support
10393 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
10394 implementation should support a non-binary modules up to @code{Integer'Last}.
10395 @end cartouche
10396 Followed.
10397
10398 @cindex Enumeration values
10399 @unnumberedsec 3.5.5(8): Enumeration Values
10400 @sp 1
10401 @cartouche
10402 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
10403 subtype, if the value of the operand does not correspond to the internal
10404 code for any enumeration literal of its type (perhaps due to an
10405 un-initialized variable), then the implementation should raise
10406 @code{Program_Error}. This is particularly important for enumeration
10407 types with noncontiguous internal codes specified by an
10408 enumeration_representation_clause.
10409 @end cartouche
10410 Followed.
10411
10412 @cindex Float types
10413 @unnumberedsec 3.5.7(17): Float Types
10414 @sp 1
10415 @cartouche
10416 An implementation should support @code{Long_Float} in addition to
10417 @code{Float} if the target machine supports 11 or more digits of
10418 precision. No other named floating point subtypes are recommended for
10419 package @code{Standard}. Instead, appropriate named floating point subtypes
10420 should be provided in the library package @code{Interfaces} (see B.2).
10421 @end cartouche
10422 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
10423 former provides improved compatibility with other implementations
10424 supporting this type. The latter corresponds to the highest precision
10425 floating-point type supported by the hardware. On most machines, this
10426 will be the same as @code{Long_Float}, but on some machines, it will
10427 correspond to the IEEE extended form. The notable case is all ia32
10428 (x86) implementations, where @code{Long_Long_Float} corresponds to
10429 the 80-bit extended precision format supported in hardware on this
10430 processor. Note that the 128-bit format on SPARC is not supported,
10431 since this is a software rather than a hardware format.
10432
10433 @cindex Multidimensional arrays
10434 @cindex Arrays, multidimensional
10435 @unnumberedsec 3.6.2(11): Multidimensional Arrays
10436 @sp 1
10437 @cartouche
10438 An implementation should normally represent multidimensional arrays in
10439 row-major order, consistent with the notation used for multidimensional
10440 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
10441 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
10442 column-major order should be used instead (see B.5, ``Interfacing with
10443 Fortran'').
10444 @end cartouche
10445 Followed.
10446
10447 @findex Duration'Small
10448 @unnumberedsec 9.6(30-31): Duration'Small
10449 @sp 1
10450 @cartouche
10451 Whenever possible in an implementation, the value of @code{Duration'Small}
10452 should be no greater than 100 microseconds.
10453 @end cartouche
10454 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
10455
10456 @sp 1
10457 @cartouche
10458 The time base for @code{delay_relative_statements} should be monotonic;
10459 it need not be the same time base as used for @code{Calendar.Clock}.
10460 @end cartouche
10461 Followed.
10462
10463 @unnumberedsec 10.2.1(12): Consistent Representation
10464 @sp 1
10465 @cartouche
10466 In an implementation, a type declared in a pre-elaborated package should
10467 have the same representation in every elaboration of a given version of
10468 the package, whether the elaborations occur in distinct executions of
10469 the same program, or in executions of distinct programs or partitions
10470 that include the given version.
10471 @end cartouche
10472 Followed, except in the case of tagged types. Tagged types involve
10473 implicit pointers to a local copy of a dispatch table, and these pointers
10474 have representations which thus depend on a particular elaboration of the
10475 package. It is not easy to see how it would be possible to follow this
10476 advice without severely impacting efficiency of execution.
10477
10478 @cindex Exception information
10479 @unnumberedsec 11.4.1(19): Exception Information
10480 @sp 1
10481 @cartouche
10482 @code{Exception_Message} by default and @code{Exception_Information}
10483 should produce information useful for
10484 debugging. @code{Exception_Message} should be short, about one
10485 line. @code{Exception_Information} can be long. @code{Exception_Message}
10486 should not include the
10487 @code{Exception_Name}. @code{Exception_Information} should include both
10488 the @code{Exception_Name} and the @code{Exception_Message}.
10489 @end cartouche
10490 Followed. For each exception that doesn't have a specified
10491 @code{Exception_Message}, the compiler generates one containing the location
10492 of the raise statement. This location has the form ``file:line'', where
10493 file is the short file name (without path information) and line is the line
10494 number in the file. Note that in the case of the Zero Cost Exception
10495 mechanism, these messages become redundant with the Exception_Information that
10496 contains a full backtrace of the calling sequence, so they are disabled.
10497 To disable explicitly the generation of the source location message, use the
10498 Pragma @code{Discard_Names}.
10499
10500 @cindex Suppression of checks
10501 @cindex Checks, suppression of
10502 @unnumberedsec 11.5(28): Suppression of Checks
10503 @sp 1
10504 @cartouche
10505 The implementation should minimize the code executed for checks that
10506 have been suppressed.
10507 @end cartouche
10508 Followed.
10509
10510 @cindex Representation clauses
10511 @unnumberedsec 13.1 (21-24): Representation Clauses
10512 @sp 1
10513 @cartouche
10514 The recommended level of support for all representation items is
10515 qualified as follows:
10516 @end cartouche
10517 @sp 1
10518 @cartouche
10519 An implementation need not support representation items containing
10520 non-static expressions, except that an implementation should support a
10521 representation item for a given entity if each non-static expression in
10522 the representation item is a name that statically denotes a constant
10523 declared before the entity.
10524 @end cartouche
10525 Followed. In fact, GNAT goes beyond the recommended level of support
10526 by allowing nonstatic expressions in some representation clauses even
10527 without the need to declare constants initialized with the values of
10528 such expressions.
10529 For example:
10530
10531 @smallexample @c ada
10532 X : Integer;
10533 Y : Float;
10534 for Y'Address use X'Address;>>
10535 @end smallexample
10536
10537 @sp 1
10538 @cartouche
10539 An implementation need not support a specification for the @code{Size}
10540 for a given composite subtype, nor the size or storage place for an
10541 object (including a component) of a given composite subtype, unless the
10542 constraints on the subtype and its composite subcomponents (if any) are
10543 all static constraints.
10544 @end cartouche
10545 Followed. Size Clauses are not permitted on non-static components, as
10546 described above.
10547
10548 @sp 1
10549 @cartouche
10550 An aliased component, or a component whose type is by-reference, should
10551 always be allocated at an addressable location.
10552 @end cartouche
10553 Followed.
10554
10555 @cindex Packed types
10556 @unnumberedsec 13.2(6-8): Packed Types
10557 @sp 1
10558 @cartouche
10559 If a type is packed, then the implementation should try to minimize
10560 storage allocated to objects of the type, possibly at the expense of
10561 speed of accessing components, subject to reasonable complexity in
10562 addressing calculations.
10563 @end cartouche
10564 @sp 1
10565 @cartouche
10566 The recommended level of support pragma @code{Pack} is:
10567
10568 For a packed record type, the components should be packed as tightly as
10569 possible subject to the Sizes of the component subtypes, and subject to
10570 any @code{record_representation_clause} that applies to the type; the
10571 implementation may, but need not, reorder components or cross aligned
10572 word boundaries to improve the packing. A component whose @code{Size} is
10573 greater than the word size may be allocated an integral number of words.
10574 @end cartouche
10575 Followed. Tight packing of arrays is supported for all component sizes
10576 up to 64-bits. If the array component size is 1 (that is to say, if
10577 the component is a boolean type or an enumeration type with two values)
10578 then values of the type are implicitly initialized to zero. This
10579 happens both for objects of the packed type, and for objects that have a
10580 subcomponent of the packed type.
10581
10582 @sp 1
10583 @cartouche
10584 An implementation should support Address clauses for imported
10585 subprograms.
10586 @end cartouche
10587 Followed.
10588 @cindex @code{Address} clauses
10589 @unnumberedsec 13.3(14-19): Address Clauses
10590
10591 @sp 1
10592 @cartouche
10593 For an array @var{X}, @code{@var{X}'Address} should point at the first
10594 component of the array, and not at the array bounds.
10595 @end cartouche
10596 Followed.
10597
10598 @sp 1
10599 @cartouche
10600 The recommended level of support for the @code{Address} attribute is:
10601
10602 @code{@var{X}'Address} should produce a useful result if @var{X} is an
10603 object that is aliased or of a by-reference type, or is an entity whose
10604 @code{Address} has been specified.
10605 @end cartouche
10606 Followed. A valid address will be produced even if none of those
10607 conditions have been met. If necessary, the object is forced into
10608 memory to ensure the address is valid.
10609
10610 @sp 1
10611 @cartouche
10612 An implementation should support @code{Address} clauses for imported
10613 subprograms.
10614 @end cartouche
10615 Followed.
10616
10617 @sp 1
10618 @cartouche
10619 Objects (including subcomponents) that are aliased or of a by-reference
10620 type should be allocated on storage element boundaries.
10621 @end cartouche
10622 Followed.
10623
10624 @sp 1
10625 @cartouche
10626 If the @code{Address} of an object is specified, or it is imported or exported,
10627 then the implementation should not perform optimizations based on
10628 assumptions of no aliases.
10629 @end cartouche
10630 Followed.
10631
10632 @cindex @code{Alignment} clauses
10633 @unnumberedsec 13.3(29-35): Alignment Clauses
10634 @sp 1
10635 @cartouche
10636 The recommended level of support for the @code{Alignment} attribute for
10637 subtypes is:
10638
10639 An implementation should support specified Alignments that are factors
10640 and multiples of the number of storage elements per word, subject to the
10641 following:
10642 @end cartouche
10643 Followed.
10644
10645 @sp 1
10646 @cartouche
10647 An implementation need not support specified @code{Alignment}s for
10648 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
10649 loaded and stored by available machine instructions.
10650 @end cartouche
10651 Followed.
10652
10653 @sp 1
10654 @cartouche
10655 An implementation need not support specified @code{Alignment}s that are
10656 greater than the maximum @code{Alignment} the implementation ever returns by
10657 default.
10658 @end cartouche
10659 Followed.
10660
10661 @sp 1
10662 @cartouche
10663 The recommended level of support for the @code{Alignment} attribute for
10664 objects is:
10665
10666 Same as above, for subtypes, but in addition:
10667 @end cartouche
10668 Followed.
10669
10670 @sp 1
10671 @cartouche
10672 For stand-alone library-level objects of statically constrained
10673 subtypes, the implementation should support all @code{Alignment}s
10674 supported by the target linker. For example, page alignment is likely to
10675 be supported for such objects, but not for subtypes.
10676 @end cartouche
10677 Followed.
10678
10679 @cindex @code{Size} clauses
10680 @unnumberedsec 13.3(42-43): Size Clauses
10681 @sp 1
10682 @cartouche
10683 The recommended level of support for the @code{Size} attribute of
10684 objects is:
10685
10686 A @code{Size} clause should be supported for an object if the specified
10687 @code{Size} is at least as large as its subtype's @code{Size}, and
10688 corresponds to a size in storage elements that is a multiple of the
10689 object's @code{Alignment} (if the @code{Alignment} is nonzero).
10690 @end cartouche
10691 Followed.
10692
10693 @unnumberedsec 13.3(50-56): Size Clauses
10694 @sp 1
10695 @cartouche
10696 If the @code{Size} of a subtype is specified, and allows for efficient
10697 independent addressability (see 9.10) on the target architecture, then
10698 the @code{Size} of the following objects of the subtype should equal the
10699 @code{Size} of the subtype:
10700
10701 Aliased objects (including components).
10702 @end cartouche
10703 Followed.
10704
10705 @sp 1
10706 @cartouche
10707 @code{Size} clause on a composite subtype should not affect the
10708 internal layout of components.
10709 @end cartouche
10710 Followed. But note that this can be overridden by use of the implementation
10711 pragma Implicit_Packing in the case of packed arrays.
10712
10713 @sp 1
10714 @cartouche
10715 The recommended level of support for the @code{Size} attribute of subtypes is:
10716 @end cartouche
10717 @sp 1
10718 @cartouche
10719 The @code{Size} (if not specified) of a static discrete or fixed point
10720 subtype should be the number of bits needed to represent each value
10721 belonging to the subtype using an unbiased representation, leaving space
10722 for a sign bit only if the subtype contains negative values. If such a
10723 subtype is a first subtype, then an implementation should support a
10724 specified @code{Size} for it that reflects this representation.
10725 @end cartouche
10726 Followed.
10727
10728 @sp 1
10729 @cartouche
10730 For a subtype implemented with levels of indirection, the @code{Size}
10731 should include the size of the pointers, but not the size of what they
10732 point at.
10733 @end cartouche
10734 Followed.
10735
10736 @cindex @code{Component_Size} clauses
10737 @unnumberedsec 13.3(71-73): Component Size Clauses
10738 @sp 1
10739 @cartouche
10740 The recommended level of support for the @code{Component_Size}
10741 attribute is:
10742 @end cartouche
10743 @sp 1
10744 @cartouche
10745 An implementation need not support specified @code{Component_Sizes} that are
10746 less than the @code{Size} of the component subtype.
10747 @end cartouche
10748 Followed.
10749
10750 @sp 1
10751 @cartouche
10752 An implementation should support specified @code{Component_Size}s that
10753 are factors and multiples of the word size. For such
10754 @code{Component_Size}s, the array should contain no gaps between
10755 components. For other @code{Component_Size}s (if supported), the array
10756 should contain no gaps between components when packing is also
10757 specified; the implementation should forbid this combination in cases
10758 where it cannot support a no-gaps representation.
10759 @end cartouche
10760 Followed.
10761
10762 @cindex Enumeration representation clauses
10763 @cindex Representation clauses, enumeration
10764 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
10765 @sp 1
10766 @cartouche
10767 The recommended level of support for enumeration representation clauses
10768 is:
10769
10770 An implementation need not support enumeration representation clauses
10771 for boolean types, but should at minimum support the internal codes in
10772 the range @code{System.Min_Int.System.Max_Int}.
10773 @end cartouche
10774 Followed.
10775
10776 @cindex Record representation clauses
10777 @cindex Representation clauses, records
10778 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
10779 @sp 1
10780 @cartouche
10781 The recommended level of support for
10782 @*@code{record_representation_clauses} is:
10783
10784 An implementation should support storage places that can be extracted
10785 with a load, mask, shift sequence of machine code, and set with a load,
10786 shift, mask, store sequence, given the available machine instructions
10787 and run-time model.
10788 @end cartouche
10789 Followed.
10790
10791 @sp 1
10792 @cartouche
10793 A storage place should be supported if its size is equal to the
10794 @code{Size} of the component subtype, and it starts and ends on a
10795 boundary that obeys the @code{Alignment} of the component subtype.
10796 @end cartouche
10797 Followed.
10798
10799 @sp 1
10800 @cartouche
10801 If the default bit ordering applies to the declaration of a given type,
10802 then for a component whose subtype's @code{Size} is less than the word
10803 size, any storage place that does not cross an aligned word boundary
10804 should be supported.
10805 @end cartouche
10806 Followed.
10807
10808 @sp 1
10809 @cartouche
10810 An implementation may reserve a storage place for the tag field of a
10811 tagged type, and disallow other components from overlapping that place.
10812 @end cartouche
10813 Followed. The storage place for the tag field is the beginning of the tagged
10814 record, and its size is Address'Size. GNAT will reject an explicit component
10815 clause for the tag field.
10816
10817 @sp 1
10818 @cartouche
10819 An implementation need not support a @code{component_clause} for a
10820 component of an extension part if the storage place is not after the
10821 storage places of all components of the parent type, whether or not
10822 those storage places had been specified.
10823 @end cartouche
10824 Followed. The above advice on record representation clauses is followed,
10825 and all mentioned features are implemented.
10826
10827 @cindex Storage place attributes
10828 @unnumberedsec 13.5.2(5): Storage Place Attributes
10829 @sp 1
10830 @cartouche
10831 If a component is represented using some form of pointer (such as an
10832 offset) to the actual data of the component, and this data is contiguous
10833 with the rest of the object, then the storage place attributes should
10834 reflect the place of the actual data, not the pointer. If a component is
10835 allocated discontinuously from the rest of the object, then a warning
10836 should be generated upon reference to one of its storage place
10837 attributes.
10838 @end cartouche
10839 Followed. There are no such components in GNAT@.
10840
10841 @cindex Bit ordering
10842 @unnumberedsec 13.5.3(7-8): Bit Ordering
10843 @sp 1
10844 @cartouche
10845 The recommended level of support for the non-default bit ordering is:
10846 @end cartouche
10847 @sp 1
10848 @cartouche
10849 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
10850 should support the non-default bit ordering in addition to the default
10851 bit ordering.
10852 @end cartouche
10853 Followed. Word size does not equal storage size in this implementation.
10854 Thus non-default bit ordering is not supported.
10855
10856 @cindex @code{Address}, as private type
10857 @unnumberedsec 13.7(37): Address as Private
10858 @sp 1
10859 @cartouche
10860 @code{Address} should be of a private type.
10861 @end cartouche
10862 Followed.
10863
10864 @cindex Operations, on @code{Address}
10865 @cindex @code{Address}, operations of
10866 @unnumberedsec 13.7.1(16): Address Operations
10867 @sp 1
10868 @cartouche
10869 Operations in @code{System} and its children should reflect the target
10870 environment semantics as closely as is reasonable. For example, on most
10871 machines, it makes sense for address arithmetic to ``wrap around''.
10872 Operations that do not make sense should raise @code{Program_Error}.
10873 @end cartouche
10874 Followed. Address arithmetic is modular arithmetic that wraps around. No
10875 operation raises @code{Program_Error}, since all operations make sense.
10876
10877 @cindex Unchecked conversion
10878 @unnumberedsec 13.9(14-17): Unchecked Conversion
10879 @sp 1
10880 @cartouche
10881 The @code{Size} of an array object should not include its bounds; hence,
10882 the bounds should not be part of the converted data.
10883 @end cartouche
10884 Followed.
10885
10886 @sp 1
10887 @cartouche
10888 The implementation should not generate unnecessary run-time checks to
10889 ensure that the representation of @var{S} is a representation of the
10890 target type. It should take advantage of the permission to return by
10891 reference when possible. Restrictions on unchecked conversions should be
10892 avoided unless required by the target environment.
10893 @end cartouche
10894 Followed. There are no restrictions on unchecked conversion. A warning is
10895 generated if the source and target types do not have the same size since
10896 the semantics in this case may be target dependent.
10897
10898 @sp 1
10899 @cartouche
10900 The recommended level of support for unchecked conversions is:
10901 @end cartouche
10902 @sp 1
10903 @cartouche
10904 Unchecked conversions should be supported and should be reversible in
10905 the cases where this clause defines the result. To enable meaningful use
10906 of unchecked conversion, a contiguous representation should be used for
10907 elementary subtypes, for statically constrained array subtypes whose
10908 component subtype is one of the subtypes described in this paragraph,
10909 and for record subtypes without discriminants whose component subtypes
10910 are described in this paragraph.
10911 @end cartouche
10912 Followed.
10913
10914 @cindex Heap usage, implicit
10915 @unnumberedsec 13.11(23-25): Implicit Heap Usage
10916 @sp 1
10917 @cartouche
10918 An implementation should document any cases in which it dynamically
10919 allocates heap storage for a purpose other than the evaluation of an
10920 allocator.
10921 @end cartouche
10922 Followed, the only other points at which heap storage is dynamically
10923 allocated are as follows:
10924
10925 @itemize @bullet
10926 @item
10927 At initial elaboration time, to allocate dynamically sized global
10928 objects.
10929
10930 @item
10931 To allocate space for a task when a task is created.
10932
10933 @item
10934 To extend the secondary stack dynamically when needed. The secondary
10935 stack is used for returning variable length results.
10936 @end itemize
10937
10938 @sp 1
10939 @cartouche
10940 A default (implementation-provided) storage pool for an
10941 access-to-constant type should not have overhead to support deallocation of
10942 individual objects.
10943 @end cartouche
10944 Followed.
10945
10946 @sp 1
10947 @cartouche
10948 A storage pool for an anonymous access type should be created at the
10949 point of an allocator for the type, and be reclaimed when the designated
10950 object becomes inaccessible.
10951 @end cartouche
10952 Followed.
10953
10954 @cindex Unchecked deallocation
10955 @unnumberedsec 13.11.2(17): Unchecked De-allocation
10956 @sp 1
10957 @cartouche
10958 For a standard storage pool, @code{Free} should actually reclaim the
10959 storage.
10960 @end cartouche
10961 Followed.
10962
10963 @cindex Stream oriented attributes
10964 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
10965 @sp 1
10966 @cartouche
10967 If a stream element is the same size as a storage element, then the
10968 normal in-memory representation should be used by @code{Read} and
10969 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
10970 should use the smallest number of stream elements needed to represent
10971 all values in the base range of the scalar type.
10972 @end cartouche
10973
10974 Followed. By default, GNAT uses the interpretation suggested by AI-195,
10975 which specifies using the size of the first subtype.
10976 However, such an implementation is based on direct binary
10977 representations and is therefore target- and endianness-dependent.
10978 To address this issue, GNAT also supplies an alternate implementation
10979 of the stream attributes @code{Read} and @code{Write},
10980 which uses the target-independent XDR standard representation
10981 for scalar types.
10982 @cindex XDR representation
10983 @cindex @code{Read} attribute
10984 @cindex @code{Write} attribute
10985 @cindex Stream oriented attributes
10986 The XDR implementation is provided as an alternative body of the
10987 @code{System.Stream_Attributes} package, in the file
10988 @file{s-stratt-xdr.adb} in the GNAT library.
10989 There is no @file{s-stratt-xdr.ads} file.
10990 In order to install the XDR implementation, do the following:
10991 @enumerate
10992 @item Replace the default implementation of the
10993 @code{System.Stream_Attributes} package with the XDR implementation.
10994 For example on a Unix platform issue the commands:
10995 @smallexample
10996 $ mv s-stratt.adb s-stratt-default.adb
10997 $ mv s-stratt-xdr.adb s-stratt.adb
10998 @end smallexample
10999
11000 @item
11001 Rebuild the GNAT run-time library as documented in
11002 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
11003 @end enumerate
11004
11005 @unnumberedsec A.1(52): Names of Predefined Numeric Types
11006 @sp 1
11007 @cartouche
11008 If an implementation provides additional named predefined integer types,
11009 then the names should end with @samp{Integer} as in
11010 @samp{Long_Integer}. If an implementation provides additional named
11011 predefined floating point types, then the names should end with
11012 @samp{Float} as in @samp{Long_Float}.
11013 @end cartouche
11014 Followed.
11015
11016 @findex Ada.Characters.Handling
11017 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
11018 @sp 1
11019 @cartouche
11020 If an implementation provides a localized definition of @code{Character}
11021 or @code{Wide_Character}, then the effects of the subprograms in
11022 @code{Characters.Handling} should reflect the localizations. See also
11023 3.5.2.
11024 @end cartouche
11025 Followed. GNAT provides no such localized definitions.
11026
11027 @cindex Bounded-length strings
11028 @unnumberedsec A.4.4(106): Bounded-Length String Handling
11029 @sp 1
11030 @cartouche
11031 Bounded string objects should not be implemented by implicit pointers
11032 and dynamic allocation.
11033 @end cartouche
11034 Followed. No implicit pointers or dynamic allocation are used.
11035
11036 @cindex Random number generation
11037 @unnumberedsec A.5.2(46-47): Random Number Generation
11038 @sp 1
11039 @cartouche
11040 Any storage associated with an object of type @code{Generator} should be
11041 reclaimed on exit from the scope of the object.
11042 @end cartouche
11043 Followed.
11044
11045 @sp 1
11046 @cartouche
11047 If the generator period is sufficiently long in relation to the number
11048 of distinct initiator values, then each possible value of
11049 @code{Initiator} passed to @code{Reset} should initiate a sequence of
11050 random numbers that does not, in a practical sense, overlap the sequence
11051 initiated by any other value. If this is not possible, then the mapping
11052 between initiator values and generator states should be a rapidly
11053 varying function of the initiator value.
11054 @end cartouche
11055 Followed. The generator period is sufficiently long for the first
11056 condition here to hold true.
11057
11058 @findex Get_Immediate
11059 @unnumberedsec A.10.7(23): @code{Get_Immediate}
11060 @sp 1
11061 @cartouche
11062 The @code{Get_Immediate} procedures should be implemented with
11063 unbuffered input. For a device such as a keyboard, input should be
11064 @dfn{available} if a key has already been typed, whereas for a disk
11065 file, input should always be available except at end of file. For a file
11066 associated with a keyboard-like device, any line-editing features of the
11067 underlying operating system should be disabled during the execution of
11068 @code{Get_Immediate}.
11069 @end cartouche
11070 Followed on all targets except VxWorks. For VxWorks, there is no way to
11071 provide this functionality that does not result in the input buffer being
11072 flushed before the @code{Get_Immediate} call. A special unit
11073 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
11074 this functionality.
11075
11076 @findex Export
11077 @unnumberedsec B.1(39-41): Pragma @code{Export}
11078 @sp 1
11079 @cartouche
11080 If an implementation supports pragma @code{Export} to a given language,
11081 then it should also allow the main subprogram to be written in that
11082 language. It should support some mechanism for invoking the elaboration
11083 of the Ada library units included in the system, and for invoking the
11084 finalization of the environment task. On typical systems, the
11085 recommended mechanism is to provide two subprograms whose link names are
11086 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
11087 elaboration code for library units. @code{adafinal} should contain the
11088 finalization code. These subprograms should have no effect the second
11089 and subsequent time they are called.
11090 @end cartouche
11091 Followed.
11092
11093 @sp 1
11094 @cartouche
11095 Automatic elaboration of pre-elaborated packages should be
11096 provided when pragma @code{Export} is supported.
11097 @end cartouche
11098 Followed when the main program is in Ada. If the main program is in a
11099 foreign language, then
11100 @code{adainit} must be called to elaborate pre-elaborated
11101 packages.
11102
11103 @sp 1
11104 @cartouche
11105 For each supported convention @var{L} other than @code{Intrinsic}, an
11106 implementation should support @code{Import} and @code{Export} pragmas
11107 for objects of @var{L}-compatible types and for subprograms, and pragma
11108 @code{Convention} for @var{L}-eligible types and for subprograms,
11109 presuming the other language has corresponding features. Pragma
11110 @code{Convention} need not be supported for scalar types.
11111 @end cartouche
11112 Followed.
11113
11114 @cindex Package @code{Interfaces}
11115 @findex Interfaces
11116 @unnumberedsec B.2(12-13): Package @code{Interfaces}
11117 @sp 1
11118 @cartouche
11119 For each implementation-defined convention identifier, there should be a
11120 child package of package Interfaces with the corresponding name. This
11121 package should contain any declarations that would be useful for
11122 interfacing to the language (implementation) represented by the
11123 convention. Any declarations useful for interfacing to any language on
11124 the given hardware architecture should be provided directly in
11125 @code{Interfaces}.
11126 @end cartouche
11127 Followed. An additional package not defined
11128 in the Ada Reference Manual is @code{Interfaces.CPP}, used
11129 for interfacing to C++.
11130
11131 @sp 1
11132 @cartouche
11133 An implementation supporting an interface to C, COBOL, or Fortran should
11134 provide the corresponding package or packages described in the following
11135 clauses.
11136 @end cartouche
11137 Followed. GNAT provides all the packages described in this section.
11138
11139 @cindex C, interfacing with
11140 @unnumberedsec B.3(63-71): Interfacing with C
11141 @sp 1
11142 @cartouche
11143 An implementation should support the following interface correspondences
11144 between Ada and C@.
11145 @end cartouche
11146 Followed.
11147
11148 @sp 1
11149 @cartouche
11150 An Ada procedure corresponds to a void-returning C function.
11151 @end cartouche
11152 Followed.
11153
11154 @sp 1
11155 @cartouche
11156 An Ada function corresponds to a non-void C function.
11157 @end cartouche
11158 Followed.
11159
11160 @sp 1
11161 @cartouche
11162 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
11163 function.
11164 @end cartouche
11165 Followed.
11166
11167 @sp 1
11168 @cartouche
11169 An Ada @code{in} parameter of an access-to-object type with designated
11170 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
11171 where @var{t} is the C type corresponding to the Ada type @var{T}.
11172 @end cartouche
11173 Followed.
11174
11175 @sp 1
11176 @cartouche
11177 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
11178 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
11179 argument to a C function, where @var{t} is the C type corresponding to
11180 the Ada type @var{T}. In the case of an elementary @code{out} or
11181 @code{in out} parameter, a pointer to a temporary copy is used to
11182 preserve by-copy semantics.
11183 @end cartouche
11184 Followed.
11185
11186 @sp 1
11187 @cartouche
11188 An Ada parameter of a record type @var{T}, of any mode, is passed as a
11189 @code{@var{t}*} argument to a C function, where @var{t} is the C
11190 structure corresponding to the Ada type @var{T}.
11191 @end cartouche
11192 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
11193 pragma, or Convention, or by explicitly specifying the mechanism for a given
11194 call using an extended import or export pragma.
11195
11196 @sp 1
11197 @cartouche
11198 An Ada parameter of an array type with component type @var{T}, of any
11199 mode, is passed as a @code{@var{t}*} argument to a C function, where
11200 @var{t} is the C type corresponding to the Ada type @var{T}.
11201 @end cartouche
11202 Followed.
11203
11204 @sp 1
11205 @cartouche
11206 An Ada parameter of an access-to-subprogram type is passed as a pointer
11207 to a C function whose prototype corresponds to the designated
11208 subprogram's specification.
11209 @end cartouche
11210 Followed.
11211
11212 @cindex COBOL, interfacing with
11213 @unnumberedsec B.4(95-98): Interfacing with COBOL
11214 @sp 1
11215 @cartouche
11216 An Ada implementation should support the following interface
11217 correspondences between Ada and COBOL@.
11218 @end cartouche
11219 Followed.
11220
11221 @sp 1
11222 @cartouche
11223 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
11224 the COBOL type corresponding to @var{T}.
11225 @end cartouche
11226 Followed.
11227
11228 @sp 1
11229 @cartouche
11230 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
11231 the corresponding COBOL type.
11232 @end cartouche
11233 Followed.
11234
11235 @sp 1
11236 @cartouche
11237 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
11238 COBOL type corresponding to the Ada parameter type; for scalars, a local
11239 copy is used if necessary to ensure by-copy semantics.
11240 @end cartouche
11241 Followed.
11242
11243 @cindex Fortran, interfacing with
11244 @unnumberedsec B.5(22-26): Interfacing with Fortran
11245 @sp 1
11246 @cartouche
11247 An Ada implementation should support the following interface
11248 correspondences between Ada and Fortran:
11249 @end cartouche
11250 Followed.
11251
11252 @sp 1
11253 @cartouche
11254 An Ada procedure corresponds to a Fortran subroutine.
11255 @end cartouche
11256 Followed.
11257
11258 @sp 1
11259 @cartouche
11260 An Ada function corresponds to a Fortran function.
11261 @end cartouche
11262 Followed.
11263
11264 @sp 1
11265 @cartouche
11266 An Ada parameter of an elementary, array, or record type @var{T} is
11267 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
11268 the Fortran type corresponding to the Ada type @var{T}, and where the
11269 INTENT attribute of the corresponding dummy argument matches the Ada
11270 formal parameter mode; the Fortran implementation's parameter passing
11271 conventions are used. For elementary types, a local copy is used if
11272 necessary to ensure by-copy semantics.
11273 @end cartouche
11274 Followed.
11275
11276 @sp 1
11277 @cartouche
11278 An Ada parameter of an access-to-subprogram type is passed as a
11279 reference to a Fortran procedure whose interface corresponds to the
11280 designated subprogram's specification.
11281 @end cartouche
11282 Followed.
11283
11284 @cindex Machine operations
11285 @unnumberedsec C.1(3-5): Access to Machine Operations
11286 @sp 1
11287 @cartouche
11288 The machine code or intrinsic support should allow access to all
11289 operations normally available to assembly language programmers for the
11290 target environment, including privileged instructions, if any.
11291 @end cartouche
11292 Followed.
11293
11294 @sp 1
11295 @cartouche
11296 The interfacing pragmas (see Annex B) should support interface to
11297 assembler; the default assembler should be associated with the
11298 convention identifier @code{Assembler}.
11299 @end cartouche
11300 Followed.
11301
11302 @sp 1
11303 @cartouche
11304 If an entity is exported to assembly language, then the implementation
11305 should allocate it at an addressable location, and should ensure that it
11306 is retained by the linking process, even if not otherwise referenced
11307 from the Ada code. The implementation should assume that any call to a
11308 machine code or assembler subprogram is allowed to read or update every
11309 object that is specified as exported.
11310 @end cartouche
11311 Followed.
11312
11313 @unnumberedsec C.1(10-16): Access to Machine Operations
11314 @sp 1
11315 @cartouche
11316 The implementation should ensure that little or no overhead is
11317 associated with calling intrinsic and machine-code subprograms.
11318 @end cartouche
11319 Followed for both intrinsics and machine-code subprograms.
11320
11321 @sp 1
11322 @cartouche
11323 It is recommended that intrinsic subprograms be provided for convenient
11324 access to any machine operations that provide special capabilities or
11325 efficiency and that are not otherwise available through the language
11326 constructs.
11327 @end cartouche
11328 Followed. A full set of machine operation intrinsic subprograms is provided.
11329
11330 @sp 1
11331 @cartouche
11332 Atomic read-modify-write operations---e.g.@:, test and set, compare and
11333 swap, decrement and test, enqueue/dequeue.
11334 @end cartouche
11335 Followed on any target supporting such operations.
11336
11337 @sp 1
11338 @cartouche
11339 Standard numeric functions---e.g.@:, sin, log.
11340 @end cartouche
11341 Followed on any target supporting such operations.
11342
11343 @sp 1
11344 @cartouche
11345 String manipulation operations---e.g.@:, translate and test.
11346 @end cartouche
11347 Followed on any target supporting such operations.
11348
11349 @sp 1
11350 @cartouche
11351 Vector operations---e.g.@:, compare vector against thresholds.
11352 @end cartouche
11353 Followed on any target supporting such operations.
11354
11355 @sp 1
11356 @cartouche
11357 Direct operations on I/O ports.
11358 @end cartouche
11359 Followed on any target supporting such operations.
11360
11361 @cindex Interrupt support
11362 @unnumberedsec C.3(28): Interrupt Support
11363 @sp 1
11364 @cartouche
11365 If the @code{Ceiling_Locking} policy is not in effect, the
11366 implementation should provide means for the application to specify which
11367 interrupts are to be blocked during protected actions, if the underlying
11368 system allows for a finer-grain control of interrupt blocking.
11369 @end cartouche
11370 Followed. The underlying system does not allow for finer-grain control
11371 of interrupt blocking.
11372
11373 @cindex Protected procedure handlers
11374 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
11375 @sp 1
11376 @cartouche
11377 Whenever possible, the implementation should allow interrupt handlers to
11378 be called directly by the hardware.
11379 @end cartouche
11380 Followed on any target where the underlying operating system permits
11381 such direct calls.
11382
11383 @sp 1
11384 @cartouche
11385 Whenever practical, violations of any
11386 implementation-defined restrictions should be detected before run time.
11387 @end cartouche
11388 Followed. Compile time warnings are given when possible.
11389
11390 @cindex Package @code{Interrupts}
11391 @findex Interrupts
11392 @unnumberedsec C.3.2(25): Package @code{Interrupts}
11393
11394 @sp 1
11395 @cartouche
11396 If implementation-defined forms of interrupt handler procedures are
11397 supported, such as protected procedures with parameters, then for each
11398 such form of a handler, a type analogous to @code{Parameterless_Handler}
11399 should be specified in a child package of @code{Interrupts}, with the
11400 same operations as in the predefined package Interrupts.
11401 @end cartouche
11402 Followed.
11403
11404 @cindex Pre-elaboration requirements
11405 @unnumberedsec C.4(14): Pre-elaboration Requirements
11406 @sp 1
11407 @cartouche
11408 It is recommended that pre-elaborated packages be implemented in such a
11409 way that there should be little or no code executed at run time for the
11410 elaboration of entities not already covered by the Implementation
11411 Requirements.
11412 @end cartouche
11413 Followed. Executable code is generated in some cases, e.g.@: loops
11414 to initialize large arrays.
11415
11416 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
11417 @sp 1
11418 @cartouche
11419 If the pragma applies to an entity, then the implementation should
11420 reduce the amount of storage used for storing names associated with that
11421 entity.
11422 @end cartouche
11423 Followed.
11424
11425 @cindex Package @code{Task_Attributes}
11426 @findex Task_Attributes
11427 @unnumberedsec C.7.2(30): The Package Task_Attributes
11428 @sp 1
11429 @cartouche
11430 Some implementations are targeted to domains in which memory use at run
11431 time must be completely deterministic. For such implementations, it is
11432 recommended that the storage for task attributes will be pre-allocated
11433 statically and not from the heap. This can be accomplished by either
11434 placing restrictions on the number and the size of the task's
11435 attributes, or by using the pre-allocated storage for the first @var{N}
11436 attribute objects, and the heap for the others. In the latter case,
11437 @var{N} should be documented.
11438 @end cartouche
11439 Not followed. This implementation is not targeted to such a domain.
11440
11441 @cindex Locking Policies
11442 @unnumberedsec D.3(17): Locking Policies
11443
11444 @sp 1
11445 @cartouche
11446 The implementation should use names that end with @samp{_Locking} for
11447 locking policies defined by the implementation.
11448 @end cartouche
11449 Followed. Two implementation-defined locking policies are defined,
11450 whose names (@code{Inheritance_Locking} and
11451 @code{Concurrent_Readers_Locking}) follow this suggestion.
11452
11453 @cindex Entry queuing policies
11454 @unnumberedsec D.4(16): Entry Queuing Policies
11455 @sp 1
11456 @cartouche
11457 Names that end with @samp{_Queuing} should be used
11458 for all implementation-defined queuing policies.
11459 @end cartouche
11460 Followed. No such implementation-defined queuing policies exist.
11461
11462 @cindex Preemptive abort
11463 @unnumberedsec D.6(9-10): Preemptive Abort
11464 @sp 1
11465 @cartouche
11466 Even though the @code{abort_statement} is included in the list of
11467 potentially blocking operations (see 9.5.1), it is recommended that this
11468 statement be implemented in a way that never requires the task executing
11469 the @code{abort_statement} to block.
11470 @end cartouche
11471 Followed.
11472
11473 @sp 1
11474 @cartouche
11475 On a multi-processor, the delay associated with aborting a task on
11476 another processor should be bounded; the implementation should use
11477 periodic polling, if necessary, to achieve this.
11478 @end cartouche
11479 Followed.
11480
11481 @cindex Tasking restrictions
11482 @unnumberedsec D.7(21): Tasking Restrictions
11483 @sp 1
11484 @cartouche
11485 When feasible, the implementation should take advantage of the specified
11486 restrictions to produce a more efficient implementation.
11487 @end cartouche
11488 GNAT currently takes advantage of these restrictions by providing an optimized
11489 run time when the Ravenscar profile and the GNAT restricted run time set
11490 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
11491 pragma @code{Profile (Restricted)} for more details.
11492
11493 @cindex Time, monotonic
11494 @unnumberedsec D.8(47-49): Monotonic Time
11495 @sp 1
11496 @cartouche
11497 When appropriate, implementations should provide configuration
11498 mechanisms to change the value of @code{Tick}.
11499 @end cartouche
11500 Such configuration mechanisms are not appropriate to this implementation
11501 and are thus not supported.
11502
11503 @sp 1
11504 @cartouche
11505 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
11506 be implemented as transformations of the same time base.
11507 @end cartouche
11508 Followed.
11509
11510 @sp 1
11511 @cartouche
11512 It is recommended that the @dfn{best} time base which exists in
11513 the underlying system be available to the application through
11514 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
11515 @end cartouche
11516 Followed.
11517
11518 @cindex Partition communication subsystem
11519 @cindex PCS
11520 @unnumberedsec E.5(28-29): Partition Communication Subsystem
11521 @sp 1
11522 @cartouche
11523 Whenever possible, the PCS on the called partition should allow for
11524 multiple tasks to call the RPC-receiver with different messages and
11525 should allow them to block until the corresponding subprogram body
11526 returns.
11527 @end cartouche
11528 Followed by GLADE, a separately supplied PCS that can be used with
11529 GNAT.
11530
11531 @sp 1
11532 @cartouche
11533 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
11534 should raise @code{Storage_Error} if it runs out of space trying to
11535 write the @code{Item} into the stream.
11536 @end cartouche
11537 Followed by GLADE, a separately supplied PCS that can be used with
11538 GNAT@.
11539
11540 @cindex COBOL support
11541 @unnumberedsec F(7): COBOL Support
11542 @sp 1
11543 @cartouche
11544 If COBOL (respectively, C) is widely supported in the target
11545 environment, implementations supporting the Information Systems Annex
11546 should provide the child package @code{Interfaces.COBOL} (respectively,
11547 @code{Interfaces.C}) specified in Annex B and should support a
11548 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
11549 pragmas (see Annex B), thus allowing Ada programs to interface with
11550 programs written in that language.
11551 @end cartouche
11552 Followed.
11553
11554 @cindex Decimal radix support
11555 @unnumberedsec F.1(2): Decimal Radix Support
11556 @sp 1
11557 @cartouche
11558 Packed decimal should be used as the internal representation for objects
11559 of subtype @var{S} when @var{S}'Machine_Radix = 10.
11560 @end cartouche
11561 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
11562 representations.
11563
11564 @cindex Numerics
11565 @unnumberedsec G: Numerics
11566 @sp 2
11567 @cartouche
11568 If Fortran (respectively, C) is widely supported in the target
11569 environment, implementations supporting the Numerics Annex
11570 should provide the child package @code{Interfaces.Fortran} (respectively,
11571 @code{Interfaces.C}) specified in Annex B and should support a
11572 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
11573 pragmas (see Annex B), thus allowing Ada programs to interface with
11574 programs written in that language.
11575 @end cartouche
11576 Followed.
11577
11578 @cindex Complex types
11579 @unnumberedsec G.1.1(56-58): Complex Types
11580 @sp 2
11581 @cartouche
11582 Because the usual mathematical meaning of multiplication of a complex
11583 operand and a real operand is that of the scaling of both components of
11584 the former by the latter, an implementation should not perform this
11585 operation by first promoting the real operand to complex type and then
11586 performing a full complex multiplication. In systems that, in the
11587 future, support an Ada binding to IEC 559:1989, the latter technique
11588 will not generate the required result when one of the components of the
11589 complex operand is infinite. (Explicit multiplication of the infinite
11590 component by the zero component obtained during promotion yields a NaN
11591 that propagates into the final result.) Analogous advice applies in the
11592 case of multiplication of a complex operand and a pure-imaginary
11593 operand, and in the case of division of a complex operand by a real or
11594 pure-imaginary operand.
11595 @end cartouche
11596 Not followed.
11597
11598 @sp 1
11599 @cartouche
11600 Similarly, because the usual mathematical meaning of addition of a
11601 complex operand and a real operand is that the imaginary operand remains
11602 unchanged, an implementation should not perform this operation by first
11603 promoting the real operand to complex type and then performing a full
11604 complex addition. In implementations in which the @code{Signed_Zeros}
11605 attribute of the component type is @code{True} (and which therefore
11606 conform to IEC 559:1989 in regard to the handling of the sign of zero in
11607 predefined arithmetic operations), the latter technique will not
11608 generate the required result when the imaginary component of the complex
11609 operand is a negatively signed zero. (Explicit addition of the negative
11610 zero to the zero obtained during promotion yields a positive zero.)
11611 Analogous advice applies in the case of addition of a complex operand
11612 and a pure-imaginary operand, and in the case of subtraction of a
11613 complex operand and a real or pure-imaginary operand.
11614 @end cartouche
11615 Not followed.
11616
11617 @sp 1
11618 @cartouche
11619 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
11620 attempt to provide a rational treatment of the signs of zero results and
11621 result components. As one example, the result of the @code{Argument}
11622 function should have the sign of the imaginary component of the
11623 parameter @code{X} when the point represented by that parameter lies on
11624 the positive real axis; as another, the sign of the imaginary component
11625 of the @code{Compose_From_Polar} function should be the same as
11626 (respectively, the opposite of) that of the @code{Argument} parameter when that
11627 parameter has a value of zero and the @code{Modulus} parameter has a
11628 nonnegative (respectively, negative) value.
11629 @end cartouche
11630 Followed.
11631
11632 @cindex Complex elementary functions
11633 @unnumberedsec G.1.2(49): Complex Elementary Functions
11634 @sp 1
11635 @cartouche
11636 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
11637 @code{True} should attempt to provide a rational treatment of the signs
11638 of zero results and result components. For example, many of the complex
11639 elementary functions have components that are odd functions of one of
11640 the parameter components; in these cases, the result component should
11641 have the sign of the parameter component at the origin. Other complex
11642 elementary functions have zero components whose sign is opposite that of
11643 a parameter component at the origin, or is always positive or always
11644 negative.
11645 @end cartouche
11646 Followed.
11647
11648 @cindex Accuracy requirements
11649 @unnumberedsec G.2.4(19): Accuracy Requirements
11650 @sp 1
11651 @cartouche
11652 The versions of the forward trigonometric functions without a
11653 @code{Cycle} parameter should not be implemented by calling the
11654 corresponding version with a @code{Cycle} parameter of
11655 @code{2.0*Numerics.Pi}, since this will not provide the required
11656 accuracy in some portions of the domain. For the same reason, the
11657 version of @code{Log} without a @code{Base} parameter should not be
11658 implemented by calling the corresponding version with a @code{Base}
11659 parameter of @code{Numerics.e}.
11660 @end cartouche
11661 Followed.
11662
11663 @cindex Complex arithmetic accuracy
11664 @cindex Accuracy, complex arithmetic
11665 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
11666
11667 @sp 1
11668 @cartouche
11669 The version of the @code{Compose_From_Polar} function without a
11670 @code{Cycle} parameter should not be implemented by calling the
11671 corresponding version with a @code{Cycle} parameter of
11672 @code{2.0*Numerics.Pi}, since this will not provide the required
11673 accuracy in some portions of the domain.
11674 @end cartouche
11675 Followed.
11676
11677 @cindex Sequential elaboration policy
11678 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
11679
11680 @sp 1
11681 @cartouche
11682 If the partition elaboration policy is @code{Sequential} and the
11683 Environment task becomes permanently blocked during elaboration then the
11684 partition is deadlocked and it is recommended that the partition be
11685 immediately terminated.
11686 @end cartouche
11687 Not followed.
11688
11689 @c -----------------------------------------
11690 @node Implementation Defined Characteristics
11691 @chapter Implementation Defined Characteristics
11692
11693 @noindent
11694 In addition to the implementation dependent pragmas and attributes, and the
11695 implementation advice, there are a number of other Ada features that are
11696 potentially implementation dependent and are designated as
11697 implementation-defined. These are mentioned throughout the Ada Reference
11698 Manual, and are summarized in Annex M@.
11699
11700 A requirement for conforming Ada compilers is that they provide
11701 documentation describing how the implementation deals with each of these
11702 issues. In this chapter, you will find each point in Annex M listed
11703 followed by a description in italic font of how GNAT
11704 handles the implementation dependence.
11705
11706 You can use this chapter as a guide to minimizing implementation
11707 dependent features in your programs if portability to other compilers
11708 and other operating systems is an important consideration. The numbers
11709 in each section below correspond to the paragraph number in the Ada
11710 Reference Manual.
11711
11712 @sp 1
11713 @cartouche
11714 @noindent
11715 @strong{2}. Whether or not each recommendation given in Implementation
11716 Advice is followed. See 1.1.2(37).
11717 @end cartouche
11718 @noindent
11719 @xref{Implementation Advice}.
11720
11721 @sp 1
11722 @cartouche
11723 @noindent
11724 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
11725 @end cartouche
11726 @noindent
11727 The complexity of programs that can be processed is limited only by the
11728 total amount of available virtual memory, and disk space for the
11729 generated object files.
11730
11731 @sp 1
11732 @cartouche
11733 @noindent
11734 @strong{4}. Variations from the standard that are impractical to avoid
11735 given the implementation's execution environment. See 1.1.3(6).
11736 @end cartouche
11737 @noindent
11738 There are no variations from the standard.
11739
11740 @sp 1
11741 @cartouche
11742 @noindent
11743 @strong{5}. Which @code{code_statement}s cause external
11744 interactions. See 1.1.3(10).
11745 @end cartouche
11746 @noindent
11747 Any @code{code_statement} can potentially cause external interactions.
11748
11749 @sp 1
11750 @cartouche
11751 @noindent
11752 @strong{6}. The coded representation for the text of an Ada
11753 program. See 2.1(4).
11754 @end cartouche
11755 @noindent
11756 See separate section on source representation.
11757
11758 @sp 1
11759 @cartouche
11760 @noindent
11761 @strong{7}. The control functions allowed in comments. See 2.1(14).
11762 @end cartouche
11763 @noindent
11764 See separate section on source representation.
11765
11766 @sp 1
11767 @cartouche
11768 @noindent
11769 @strong{8}. The representation for an end of line. See 2.2(2).
11770 @end cartouche
11771 @noindent
11772 See separate section on source representation.
11773
11774 @sp 1
11775 @cartouche
11776 @noindent
11777 @strong{9}. Maximum supported line length and lexical element
11778 length. See 2.2(15).
11779 @end cartouche
11780 @noindent
11781 The maximum line length is 255 characters and the maximum length of
11782 a lexical element is also 255 characters. This is the default setting
11783 if not overridden by the use of compiler switch @option{-gnaty} (which
11784 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
11785 line length to be specified to be any value up to 32767. The maximum
11786 length of a lexical element is the same as the maximum line length.
11787
11788 @sp 1
11789 @cartouche
11790 @noindent
11791 @strong{10}. Implementation defined pragmas. See 2.8(14).
11792 @end cartouche
11793 @noindent
11794
11795 @xref{Implementation Defined Pragmas}.
11796
11797 @sp 1
11798 @cartouche
11799 @noindent
11800 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
11801 @end cartouche
11802 @noindent
11803 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
11804 parameter, checks that the optimization flag is set, and aborts if it is
11805 not.
11806
11807 @sp 1
11808 @cartouche
11809 @noindent
11810 @strong{12}. The sequence of characters of the value returned by
11811 @code{@var{S}'Image} when some of the graphic characters of
11812 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
11813 3.5(37).
11814 @end cartouche
11815 @noindent
11816 The sequence of characters is as defined by the wide character encoding
11817 method used for the source. See section on source representation for
11818 further details.
11819
11820 @sp 1
11821 @cartouche
11822 @noindent
11823 @strong{13}. The predefined integer types declared in
11824 @code{Standard}. See 3.5.4(25).
11825 @end cartouche
11826 @noindent
11827 @table @code
11828 @item Short_Short_Integer
11829 8 bit signed
11830 @item Short_Integer
11831 (Short) 16 bit signed
11832 @item Integer
11833 32 bit signed
11834 @item Long_Integer
11835 64 bit signed (on most 64 bit targets, depending on the C definition of long).
11836 32 bit signed (all other targets)
11837 @item Long_Long_Integer
11838 64 bit signed
11839 @end table
11840
11841 @sp 1
11842 @cartouche
11843 @noindent
11844 @strong{14}. Any nonstandard integer types and the operators defined
11845 for them. See 3.5.4(26).
11846 @end cartouche
11847 @noindent
11848 There are no nonstandard integer types.
11849
11850 @sp 1
11851 @cartouche
11852 @noindent
11853 @strong{15}. Any nonstandard real types and the operators defined for
11854 them. See 3.5.6(8).
11855 @end cartouche
11856 @noindent
11857 There are no nonstandard real types.
11858
11859 @sp 1
11860 @cartouche
11861 @noindent
11862 @strong{16}. What combinations of requested decimal precision and range
11863 are supported for floating point types. See 3.5.7(7).
11864 @end cartouche
11865 @noindent
11866 The precision and range is as defined by the IEEE standard.
11867
11868 @sp 1
11869 @cartouche
11870 @noindent
11871 @strong{17}. The predefined floating point types declared in
11872 @code{Standard}. See 3.5.7(16).
11873 @end cartouche
11874 @noindent
11875 @table @code
11876 @item Short_Float
11877 32 bit IEEE short
11878 @item Float
11879 (Short) 32 bit IEEE short
11880 @item Long_Float
11881 64 bit IEEE long
11882 @item Long_Long_Float
11883 64 bit IEEE long (80 bit IEEE long on x86 processors)
11884 @end table
11885
11886 @sp 1
11887 @cartouche
11888 @noindent
11889 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
11890 @end cartouche
11891 @noindent
11892 @code{Fine_Delta} is 2**(@minus{}63)
11893
11894 @sp 1
11895 @cartouche
11896 @noindent
11897 @strong{19}. What combinations of small, range, and digits are
11898 supported for fixed point types. See 3.5.9(10).
11899 @end cartouche
11900 @noindent
11901 Any combinations are permitted that do not result in a small less than
11902 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
11903 If the mantissa is larger than 53 bits on machines where Long_Long_Float
11904 is 64 bits (true of all architectures except ia32), then the output from
11905 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
11906 is because floating-point conversions are used to convert fixed point.
11907
11908 @sp 1
11909 @cartouche
11910 @noindent
11911 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
11912 within an unnamed @code{block_statement}. See 3.9(10).
11913 @end cartouche
11914 @noindent
11915 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
11916 decimal integer are allocated.
11917
11918 @sp 1
11919 @cartouche
11920 @noindent
11921 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
11922 @end cartouche
11923 @noindent
11924 @xref{Implementation Defined Attributes}.
11925
11926 @sp 1
11927 @cartouche
11928 @noindent
11929 @strong{22}. Any implementation-defined time types. See 9.6(6).
11930 @end cartouche
11931 @noindent
11932 There are no implementation-defined time types.
11933
11934 @sp 1
11935 @cartouche
11936 @noindent
11937 @strong{23}. The time base associated with relative delays.
11938 @end cartouche
11939 @noindent
11940 See 9.6(20). The time base used is that provided by the C library
11941 function @code{gettimeofday}.
11942
11943 @sp 1
11944 @cartouche
11945 @noindent
11946 @strong{24}. The time base of the type @code{Calendar.Time}. See
11947 9.6(23).
11948 @end cartouche
11949 @noindent
11950 The time base used is that provided by the C library function
11951 @code{gettimeofday}.
11952
11953 @sp 1
11954 @cartouche
11955 @noindent
11956 @strong{25}. The time zone used for package @code{Calendar}
11957 operations. See 9.6(24).
11958 @end cartouche
11959 @noindent
11960 The time zone used by package @code{Calendar} is the current system time zone
11961 setting for local time, as accessed by the C library function
11962 @code{localtime}.
11963
11964 @sp 1
11965 @cartouche
11966 @noindent
11967 @strong{26}. Any limit on @code{delay_until_statements} of
11968 @code{select_statements}. See 9.6(29).
11969 @end cartouche
11970 @noindent
11971 There are no such limits.
11972
11973 @sp 1
11974 @cartouche
11975 @noindent
11976 @strong{27}. Whether or not two non-overlapping parts of a composite
11977 object are independently addressable, in the case where packing, record
11978 layout, or @code{Component_Size} is specified for the object. See
11979 9.10(1).
11980 @end cartouche
11981 @noindent
11982 Separate components are independently addressable if they do not share
11983 overlapping storage units.
11984
11985 @sp 1
11986 @cartouche
11987 @noindent
11988 @strong{28}. The representation for a compilation. See 10.1(2).
11989 @end cartouche
11990 @noindent
11991 A compilation is represented by a sequence of files presented to the
11992 compiler in a single invocation of the @command{gcc} command.
11993
11994 @sp 1
11995 @cartouche
11996 @noindent
11997 @strong{29}. Any restrictions on compilations that contain multiple
11998 compilation_units. See 10.1(4).
11999 @end cartouche
12000 @noindent
12001 No single file can contain more than one compilation unit, but any
12002 sequence of files can be presented to the compiler as a single
12003 compilation.
12004
12005 @sp 1
12006 @cartouche
12007 @noindent
12008 @strong{30}. The mechanisms for creating an environment and for adding
12009 and replacing compilation units. See 10.1.4(3).
12010 @end cartouche
12011 @noindent
12012 See separate section on compilation model.
12013
12014 @sp 1
12015 @cartouche
12016 @noindent
12017 @strong{31}. The manner of explicitly assigning library units to a
12018 partition. See 10.2(2).
12019 @end cartouche
12020 @noindent
12021 If a unit contains an Ada main program, then the Ada units for the partition
12022 are determined by recursive application of the rules in the Ada Reference
12023 Manual section 10.2(2-6). In other words, the Ada units will be those that
12024 are needed by the main program, and then this definition of need is applied
12025 recursively to those units, and the partition contains the transitive
12026 closure determined by this relationship. In short, all the necessary units
12027 are included, with no need to explicitly specify the list. If additional
12028 units are required, e.g.@: by foreign language units, then all units must be
12029 mentioned in the context clause of one of the needed Ada units.
12030
12031 If the partition contains no main program, or if the main program is in
12032 a language other than Ada, then GNAT
12033 provides the binder options @option{-z} and @option{-n} respectively, and in
12034 this case a list of units can be explicitly supplied to the binder for
12035 inclusion in the partition (all units needed by these units will also
12036 be included automatically). For full details on the use of these
12037 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
12038 @value{EDITION} User's Guide}.
12039
12040 @sp 1
12041 @cartouche
12042 @noindent
12043 @strong{32}. The implementation-defined means, if any, of specifying
12044 which compilation units are needed by a given compilation unit. See
12045 10.2(2).
12046 @end cartouche
12047 @noindent
12048 The units needed by a given compilation unit are as defined in
12049 the Ada Reference Manual section 10.2(2-6). There are no
12050 implementation-defined pragmas or other implementation-defined
12051 means for specifying needed units.
12052
12053 @sp 1
12054 @cartouche
12055 @noindent
12056 @strong{33}. The manner of designating the main subprogram of a
12057 partition. See 10.2(7).
12058 @end cartouche
12059 @noindent
12060 The main program is designated by providing the name of the
12061 corresponding @file{ALI} file as the input parameter to the binder.
12062
12063 @sp 1
12064 @cartouche
12065 @noindent
12066 @strong{34}. The order of elaboration of @code{library_items}. See
12067 10.2(18).
12068 @end cartouche
12069 @noindent
12070 The first constraint on ordering is that it meets the requirements of
12071 Chapter 10 of the Ada Reference Manual. This still leaves some
12072 implementation dependent choices, which are resolved by first
12073 elaborating bodies as early as possible (i.e., in preference to specs
12074 where there is a choice), and second by evaluating the immediate with
12075 clauses of a unit to determine the probably best choice, and
12076 third by elaborating in alphabetical order of unit names
12077 where a choice still remains.
12078
12079 @sp 1
12080 @cartouche
12081 @noindent
12082 @strong{35}. Parameter passing and function return for the main
12083 subprogram. See 10.2(21).
12084 @end cartouche
12085 @noindent
12086 The main program has no parameters. It may be a procedure, or a function
12087 returning an integer type. In the latter case, the returned integer
12088 value is the return code of the program (overriding any value that
12089 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
12090
12091 @sp 1
12092 @cartouche
12093 @noindent
12094 @strong{36}. The mechanisms for building and running partitions. See
12095 10.2(24).
12096 @end cartouche
12097 @noindent
12098 GNAT itself supports programs with only a single partition. The GNATDIST
12099 tool provided with the GLADE package (which also includes an implementation
12100 of the PCS) provides a completely flexible method for building and running
12101 programs consisting of multiple partitions. See the separate GLADE manual
12102 for details.
12103
12104 @sp 1
12105 @cartouche
12106 @noindent
12107 @strong{37}. The details of program execution, including program
12108 termination. See 10.2(25).
12109 @end cartouche
12110 @noindent
12111 See separate section on compilation model.
12112
12113 @sp 1
12114 @cartouche
12115 @noindent
12116 @strong{38}. The semantics of any non-active partitions supported by the
12117 implementation. See 10.2(28).
12118 @end cartouche
12119 @noindent
12120 Passive partitions are supported on targets where shared memory is
12121 provided by the operating system. See the GLADE reference manual for
12122 further details.
12123
12124 @sp 1
12125 @cartouche
12126 @noindent
12127 @strong{39}. The information returned by @code{Exception_Message}. See
12128 11.4.1(10).
12129 @end cartouche
12130 @noindent
12131 Exception message returns the null string unless a specific message has
12132 been passed by the program.
12133
12134 @sp 1
12135 @cartouche
12136 @noindent
12137 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
12138 declared within an unnamed @code{block_statement}. See 11.4.1(12).
12139 @end cartouche
12140 @noindent
12141 Blocks have implementation defined names of the form @code{B@var{nnn}}
12142 where @var{nnn} is an integer.
12143
12144 @sp 1
12145 @cartouche
12146 @noindent
12147 @strong{41}. The information returned by
12148 @code{Exception_Information}. See 11.4.1(13).
12149 @end cartouche
12150 @noindent
12151 @code{Exception_Information} returns a string in the following format:
12152
12153 @smallexample
12154 @emph{Exception_Name:} nnnnn
12155 @emph{Message:} mmmmm
12156 @emph{PID:} ppp
12157 @emph{Load address:} 0xhhhh
12158 @emph{Call stack traceback locations:}
12159 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
12160 @end smallexample
12161
12162 @noindent
12163 where
12164
12165 @itemize @bullet
12166 @item
12167 @code{nnnn} is the fully qualified name of the exception in all upper
12168 case letters. This line is always present.
12169
12170 @item
12171 @code{mmmm} is the message (this line present only if message is non-null)
12172
12173 @item
12174 @code{ppp} is the Process Id value as a decimal integer (this line is
12175 present only if the Process Id is nonzero). Currently we are
12176 not making use of this field.
12177
12178 @item
12179 The Load address line, the Call stack traceback locations line and the
12180 following values are present only if at least one traceback location was
12181 recorded. The Load address indicates the address at which the main executable
12182 was loaded; this line may not be present if operating system hasn't relocated
12183 the main executable. The values are given in C style format, with lower case
12184 letters for a-f, and only as many digits present as are necessary.
12185 @end itemize
12186
12187 @noindent
12188 The line terminator sequence at the end of each line, including
12189 the last line is a single @code{LF} character (@code{16#0A#}).
12190
12191 @sp 1
12192 @cartouche
12193 @noindent
12194 @strong{42}. Implementation-defined check names. See 11.5(27).
12195 @end cartouche
12196 @noindent
12197 The implementation defined check name Alignment_Check controls checking of
12198 address clause values for proper alignment (that is, the address supplied
12199 must be consistent with the alignment of the type).
12200
12201 The implementation defined check name Predicate_Check controls whether
12202 predicate checks are generated.
12203
12204 The implementation defined check name Validity_Check controls whether
12205 validity checks are generated.
12206
12207 In addition, a user program can add implementation-defined check names
12208 by means of the pragma Check_Name.
12209
12210 @sp 1
12211 @cartouche
12212 @noindent
12213 @strong{43}. The interpretation of each aspect of representation. See
12214 13.1(20).
12215 @end cartouche
12216 @noindent
12217 See separate section on data representations.
12218
12219 @sp 1
12220 @cartouche
12221 @noindent
12222 @strong{44}. Any restrictions placed upon representation items. See
12223 13.1(20).
12224 @end cartouche
12225 @noindent
12226 See separate section on data representations.
12227
12228 @sp 1
12229 @cartouche
12230 @noindent
12231 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
12232 13.3(48).
12233 @end cartouche
12234 @noindent
12235 Size for an indefinite subtype is the maximum possible size, except that
12236 for the case of a subprogram parameter, the size of the parameter object
12237 is the actual size.
12238
12239 @sp 1
12240 @cartouche
12241 @noindent
12242 @strong{46}. The default external representation for a type tag. See
12243 13.3(75).
12244 @end cartouche
12245 @noindent
12246 The default external representation for a type tag is the fully expanded
12247 name of the type in upper case letters.
12248
12249 @sp 1
12250 @cartouche
12251 @noindent
12252 @strong{47}. What determines whether a compilation unit is the same in
12253 two different partitions. See 13.3(76).
12254 @end cartouche
12255 @noindent
12256 A compilation unit is the same in two different partitions if and only
12257 if it derives from the same source file.
12258
12259 @sp 1
12260 @cartouche
12261 @noindent
12262 @strong{48}. Implementation-defined components. See 13.5.1(15).
12263 @end cartouche
12264 @noindent
12265 The only implementation defined component is the tag for a tagged type,
12266 which contains a pointer to the dispatching table.
12267
12268 @sp 1
12269 @cartouche
12270 @noindent
12271 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
12272 ordering. See 13.5.3(5).
12273 @end cartouche
12274 @noindent
12275 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
12276 implementation, so no non-default bit ordering is supported. The default
12277 bit ordering corresponds to the natural endianness of the target architecture.
12278
12279 @sp 1
12280 @cartouche
12281 @noindent
12282 @strong{50}. The contents of the visible part of package @code{System}
12283 and its language-defined children. See 13.7(2).
12284 @end cartouche
12285 @noindent
12286 See the definition of these packages in files @file{system.ads} and
12287 @file{s-stoele.ads}.
12288
12289 @sp 1
12290 @cartouche
12291 @noindent
12292 @strong{51}. The contents of the visible part of package
12293 @code{System.Machine_Code}, and the meaning of
12294 @code{code_statements}. See 13.8(7).
12295 @end cartouche
12296 @noindent
12297 See the definition and documentation in file @file{s-maccod.ads}.
12298
12299 @sp 1
12300 @cartouche
12301 @noindent
12302 @strong{52}. The effect of unchecked conversion. See 13.9(11).
12303 @end cartouche
12304 @noindent
12305 Unchecked conversion between types of the same size
12306 results in an uninterpreted transmission of the bits from one type
12307 to the other. If the types are of unequal sizes, then in the case of
12308 discrete types, a shorter source is first zero or sign extended as
12309 necessary, and a shorter target is simply truncated on the left.
12310 For all non-discrete types, the source is first copied if necessary
12311 to ensure that the alignment requirements of the target are met, then
12312 a pointer is constructed to the source value, and the result is obtained
12313 by dereferencing this pointer after converting it to be a pointer to the
12314 target type. Unchecked conversions where the target subtype is an
12315 unconstrained array are not permitted. If the target alignment is
12316 greater than the source alignment, then a copy of the result is
12317 made with appropriate alignment
12318
12319 @sp 1
12320 @cartouche
12321 @noindent
12322 @strong{53}. The semantics of operations on invalid representations.
12323 See 13.9.2(10-11).
12324 @end cartouche
12325 @noindent
12326 For assignments and other operations where the use of invalid values cannot
12327 result in erroneous behavior, the compiler ignores the possibility of invalid
12328 values. An exception is raised at the point where an invalid value would
12329 result in erroneous behavior. For example executing:
12330
12331 @smallexample @c ada
12332 procedure invalidvals is
12333 X : Integer := -1;
12334 Y : Natural range 1 .. 10;
12335 for Y'Address use X'Address;
12336 Z : Natural range 1 .. 10;
12337 A : array (Natural range 1 .. 10) of Integer;
12338 begin
12339 Z := Y; -- no exception
12340 A (Z) := 3; -- exception raised;
12341 end;
12342 @end smallexample
12343
12344 @noindent
12345 As indicated, an exception is raised on the array assignment, but not
12346 on the simple assignment of the invalid negative value from Y to Z.
12347
12348 @sp 1
12349 @cartouche
12350 @noindent
12351 @strong{53}. The manner of choosing a storage pool for an access type
12352 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
12353 @end cartouche
12354 @noindent
12355 There are 3 different standard pools used by the compiler when
12356 @code{Storage_Pool} is not specified depending whether the type is local
12357 to a subprogram or defined at the library level and whether
12358 @code{Storage_Size}is specified or not. See documentation in the runtime
12359 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
12360 @code{System.Pool_Local} in files @file{s-poosiz.ads},
12361 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
12362 default pools used.
12363
12364 @sp 1
12365 @cartouche
12366 @noindent
12367 @strong{54}. Whether or not the implementation provides user-accessible
12368 names for the standard pool type(s). See 13.11(17).
12369 @end cartouche
12370 @noindent
12371
12372 See documentation in the sources of the run time mentioned in paragraph
12373 @strong{53} . All these pools are accessible by means of @code{with}'ing
12374 these units.
12375
12376 @sp 1
12377 @cartouche
12378 @noindent
12379 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
12380 @end cartouche
12381 @noindent
12382 @code{Storage_Size} is measured in storage units, and refers to the
12383 total space available for an access type collection, or to the primary
12384 stack space for a task.
12385
12386 @sp 1
12387 @cartouche
12388 @noindent
12389 @strong{56}. Implementation-defined aspects of storage pools. See
12390 13.11(22).
12391 @end cartouche
12392 @noindent
12393 See documentation in the sources of the run time mentioned in paragraph
12394 @strong{53} for details on GNAT-defined aspects of storage pools.
12395
12396 @sp 1
12397 @cartouche
12398 @noindent
12399 @strong{57}. The set of restrictions allowed in a pragma
12400 @code{Restrictions}. See 13.12(7).
12401 @end cartouche
12402 @noindent
12403 @xref{Standard and Implementation Defined Restrictions}.
12404
12405 @sp 1
12406 @cartouche
12407 @noindent
12408 @strong{58}. The consequences of violating limitations on
12409 @code{Restrictions} pragmas. See 13.12(9).
12410 @end cartouche
12411 @noindent
12412 Restrictions that can be checked at compile time result in illegalities
12413 if violated. Currently there are no other consequences of violating
12414 restrictions.
12415
12416 @sp 1
12417 @cartouche
12418 @noindent
12419 @strong{59}. The representation used by the @code{Read} and
12420 @code{Write} attributes of elementary types in terms of stream
12421 elements. See 13.13.2(9).
12422 @end cartouche
12423 @noindent
12424 The representation is the in-memory representation of the base type of
12425 the type, using the number of bits corresponding to the
12426 @code{@var{type}'Size} value, and the natural ordering of the machine.
12427
12428 @sp 1
12429 @cartouche
12430 @noindent
12431 @strong{60}. The names and characteristics of the numeric subtypes
12432 declared in the visible part of package @code{Standard}. See A.1(3).
12433 @end cartouche
12434 @noindent
12435 See items describing the integer and floating-point types supported.
12436
12437 @sp 1
12438 @cartouche
12439 @noindent
12440 @strong{61}. The string returned by @code{Character_Set_Version}.
12441 See A.3.5(3).
12442 @end cartouche
12443 @noindent
12444 @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns
12445 the string "Unicode 6.2", referring to version 6.2.x of the
12446 Unicode specification.
12447
12448 @sp 1
12449 @cartouche
12450 @noindent
12451 @strong{62}. The accuracy actually achieved by the elementary
12452 functions. See A.5.1(1).
12453 @end cartouche
12454 @noindent
12455 The elementary functions correspond to the functions available in the C
12456 library. Only fast math mode is implemented.
12457
12458 @sp 1
12459 @cartouche
12460 @noindent
12461 @strong{63}. The sign of a zero result from some of the operators or
12462 functions in @code{Numerics.Generic_Elementary_Functions}, when
12463 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
12464 @end cartouche
12465 @noindent
12466 The sign of zeroes follows the requirements of the IEEE 754 standard on
12467 floating-point.
12468
12469 @sp 1
12470 @cartouche
12471 @noindent
12472 @strong{64}. The value of
12473 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
12474 @end cartouche
12475 @noindent
12476 Maximum image width is 6864, see library file @file{s-rannum.ads}.
12477
12478 @sp 1
12479 @cartouche
12480 @noindent
12481 @strong{65}. The value of
12482 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
12483 @end cartouche
12484 @noindent
12485 Maximum image width is 6864, see library file @file{s-rannum.ads}.
12486
12487 @sp 1
12488 @cartouche
12489 @noindent
12490 @strong{66}. The algorithms for random number generation. See
12491 A.5.2(32).
12492 @end cartouche
12493 @noindent
12494 The algorithm is the Mersenne Twister, as documented in the source file
12495 @file{s-rannum.adb}. This version of the algorithm has a period of
12496 2**19937-1.
12497
12498 @sp 1
12499 @cartouche
12500 @noindent
12501 @strong{67}. The string representation of a random number generator's
12502 state. See A.5.2(38).
12503 @end cartouche
12504 @noindent
12505 The value returned by the Image function is the concatenation of
12506 the fixed-width decimal representations of the 624 32-bit integers
12507 of the state vector.
12508
12509 @sp 1
12510 @cartouche
12511 @noindent
12512 @strong{68}. The minimum time interval between calls to the
12513 time-dependent Reset procedure that are guaranteed to initiate different
12514 random number sequences. See A.5.2(45).
12515 @end cartouche
12516 @noindent
12517 The minimum period between reset calls to guarantee distinct series of
12518 random numbers is one microsecond.
12519
12520 @sp 1
12521 @cartouche
12522 @noindent
12523 @strong{69}. The values of the @code{Model_Mantissa},
12524 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
12525 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
12526 Annex is not supported. See A.5.3(72).
12527 @end cartouche
12528 @noindent
12529 Run the compiler with @option{-gnatS} to produce a listing of package
12530 @code{Standard}, has the values of all numeric attributes.
12531
12532 @sp 1
12533 @cartouche
12534 @noindent
12535 @strong{70}. Any implementation-defined characteristics of the
12536 input-output packages. See A.7(14).
12537 @end cartouche
12538 @noindent
12539 There are no special implementation defined characteristics for these
12540 packages.
12541
12542 @sp 1
12543 @cartouche
12544 @noindent
12545 @strong{71}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
12546 A.9(10).
12547 @end cartouche
12548 @noindent
12549 All type representations are contiguous, and the @code{Buffer_Size} is
12550 the value of @code{@var{type}'Size} rounded up to the next storage unit
12551 boundary.
12552
12553 @sp 1
12554 @cartouche
12555 @noindent
12556 @strong{72}. External files for standard input, standard output, and
12557 standard error See A.10(5).
12558 @end cartouche
12559 @noindent
12560 These files are mapped onto the files provided by the C streams
12561 libraries. See source file @file{i-cstrea.ads} for further details.
12562
12563 @sp 1
12564 @cartouche
12565 @noindent
12566 @strong{73}. The accuracy of the value produced by @code{Put}. See
12567 A.10.9(36).
12568 @end cartouche
12569 @noindent
12570 If more digits are requested in the output than are represented by the
12571 precision of the value, zeroes are output in the corresponding least
12572 significant digit positions.
12573
12574 @sp 1
12575 @cartouche
12576 @noindent
12577 @strong{74}. The meaning of @code{Argument_Count}, @code{Argument}, and
12578 @code{Command_Name}. See A.15(1).
12579 @end cartouche
12580 @noindent
12581 These are mapped onto the @code{argv} and @code{argc} parameters of the
12582 main program in the natural manner.
12583
12584 @sp 1
12585 @cartouche
12586 @noindent
12587 @strong{75}. The interpretation of the @code{Form} parameter in procedure
12588 @code{Create_Directory}. See A.16(56).
12589 @end cartouche
12590 @noindent
12591 The @code{Form} parameter is not used.
12592
12593 @sp 1
12594 @cartouche
12595 @noindent
12596 @strong{76}. The interpretation of the @code{Form} parameter in procedure
12597 @code{Create_Path}. See A.16(60).
12598 @end cartouche
12599 @noindent
12600 The @code{Form} parameter is not used.
12601
12602 @sp 1
12603 @cartouche
12604 @noindent
12605 @strong{77}. The interpretation of the @code{Form} parameter in procedure
12606 @code{Copy_File}. See A.16(68).
12607 @end cartouche
12608 @noindent
12609 The @code{Form} parameter is case-insensitive.
12610
12611 Two fields are recognized in the @code{Form} parameter:
12612
12613 @table @code
12614
12615 @item preserve=<value>
12616
12617 @item mode=<value>
12618
12619 @end table
12620
12621 @noindent
12622 <value> starts immediately after the character '=' and ends with the
12623 character immediately preceding the next comma (',') or with the last
12624 character of the parameter.
12625
12626 The only possible values for preserve= are:
12627
12628 @table @code
12629
12630 @item no_attributes
12631 Do not try to preserve any file attributes. This is the default if no
12632 preserve= is found in Form.
12633
12634 @item all_attributes
12635 Try to preserve all file attributes (timestamps, access rights).
12636
12637 @item timestamps
12638 Preserve the timestamp of the copied file, but not the other file attributes.
12639
12640 @end table
12641
12642 @noindent
12643 The only possible values for mode= are:
12644
12645 @table @code
12646
12647 @item copy
12648 Only do the copy if the destination file does not already exist. If it already
12649 exists, Copy_File fails.
12650
12651 @item overwrite
12652 Copy the file in all cases. Overwrite an already existing destination file.
12653
12654 @item append
12655 Append the original file to the destination file. If the destination file does
12656 not exist, the destination file is a copy of the source file. When mode=append,
12657 the field preserve=, if it exists, is not taken into account.
12658
12659 @end table
12660
12661 @noindent
12662 If the Form parameter includes one or both of the fields and the value or
12663 values are incorrect, Copy_file fails with Use_Error.
12664
12665 Examples of correct Forms:
12666
12667 @smallexample
12668 Form => "preserve=no_attributes,mode=overwrite" (the default)
12669 Form => "mode=append"
12670 Form => "mode=copy, preserve=all_attributes"
12671 @end smallexample
12672
12673 @noindent
12674 Examples of incorrect Forms
12675
12676 @smallexample
12677 Form => "preserve=junk"
12678 Form => "mode=internal, preserve=timestamps"
12679 @end smallexample
12680
12681 @sp 1
12682 @cartouche
12683 @noindent
12684 @strong{78}. Implementation-defined convention names. See B.1(11).
12685 @end cartouche
12686 @noindent
12687 The following convention names are supported
12688
12689 @table @code
12690 @item Ada
12691 Ada
12692 @item Ada_Pass_By_Copy
12693 Allowed for any types except by-reference types such as limited
12694 records. Compatible with convention Ada, but causes any parameters
12695 with this convention to be passed by copy.
12696 @item Ada_Pass_By_Reference
12697 Allowed for any types except by-copy types such as scalars.
12698 Compatible with convention Ada, but causes any parameters
12699 with this convention to be passed by reference.
12700 @item Assembler
12701 Assembly language
12702 @item Asm
12703 Synonym for Assembler
12704 @item Assembly
12705 Synonym for Assembler
12706 @item C
12707 C
12708 @item C_Pass_By_Copy
12709 Allowed only for record types, like C, but also notes that record
12710 is to be passed by copy rather than reference.
12711 @item COBOL
12712 COBOL
12713 @item C_Plus_Plus (or CPP)
12714 C++
12715 @item Default
12716 Treated the same as C
12717 @item External
12718 Treated the same as C
12719 @item Fortran
12720 Fortran
12721 @item Intrinsic
12722 For support of pragma @code{Import} with convention Intrinsic, see
12723 separate section on Intrinsic Subprograms.
12724 @item Stdcall
12725 Stdcall (used for Windows implementations only). This convention correspond
12726 to the WINAPI (previously called Pascal convention) C/C++ convention under
12727 Windows. A routine with this convention cleans the stack before
12728 exit. This pragma cannot be applied to a dispatching call.
12729 @item DLL
12730 Synonym for Stdcall
12731 @item Win32
12732 Synonym for Stdcall
12733 @item Stubbed
12734 Stubbed is a special convention used to indicate that the body of the
12735 subprogram will be entirely ignored. Any call to the subprogram
12736 is converted into a raise of the @code{Program_Error} exception. If a
12737 pragma @code{Import} specifies convention @code{stubbed} then no body need
12738 be present at all. This convention is useful during development for the
12739 inclusion of subprograms whose body has not yet been written.
12740
12741 @end table
12742 @noindent
12743 In addition, all otherwise unrecognized convention names are also
12744 treated as being synonymous with convention C@. In all implementations
12745 except for VMS, use of such other names results in a warning. In VMS
12746 implementations, these names are accepted silently.
12747
12748 @sp 1
12749 @cartouche
12750 @noindent
12751 @strong{79}. The meaning of link names. See B.1(36).
12752 @end cartouche
12753 @noindent
12754 Link names are the actual names used by the linker.
12755
12756 @sp 1
12757 @cartouche
12758 @noindent
12759 @strong{80}. The manner of choosing link names when neither the link
12760 name nor the address of an imported or exported entity is specified. See
12761 B.1(36).
12762 @end cartouche
12763 @noindent
12764 The default linker name is that which would be assigned by the relevant
12765 external language, interpreting the Ada name as being in all lower case
12766 letters.
12767
12768 @sp 1
12769 @cartouche
12770 @noindent
12771 @strong{81}. The effect of pragma @code{Linker_Options}. See B.1(37).
12772 @end cartouche
12773 @noindent
12774 The string passed to @code{Linker_Options} is presented uninterpreted as
12775 an argument to the link command, unless it contains ASCII.NUL characters.
12776 NUL characters if they appear act as argument separators, so for example
12777
12778 @smallexample @c ada
12779 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
12780 @end smallexample
12781
12782 @noindent
12783 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
12784 linker. The order of linker options is preserved for a given unit. The final
12785 list of options passed to the linker is in reverse order of the elaboration
12786 order. For example, linker options for a body always appear before the options
12787 from the corresponding package spec.
12788
12789 @sp 1
12790 @cartouche
12791 @noindent
12792 @strong{82}. The contents of the visible part of package
12793 @code{Interfaces} and its language-defined descendants. See B.2(1).
12794 @end cartouche
12795 @noindent
12796 See files with prefix @file{i-} in the distributed library.
12797
12798 @sp 1
12799 @cartouche
12800 @noindent
12801 @strong{83}. Implementation-defined children of package
12802 @code{Interfaces}. The contents of the visible part of package
12803 @code{Interfaces}. See B.2(11).
12804 @end cartouche
12805 @noindent
12806 See files with prefix @file{i-} in the distributed library.
12807
12808 @sp 1
12809 @cartouche
12810 @noindent
12811 @strong{84}. The types @code{Floating}, @code{Long_Floating},
12812 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
12813 @code{COBOL_Character}; and the initialization of the variables
12814 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
12815 @code{Interfaces.COBOL}. See B.4(50).
12816 @end cartouche
12817 @noindent
12818 @table @code
12819 @item Floating
12820 Float
12821 @item Long_Floating
12822 (Floating) Long_Float
12823 @item Binary
12824 Integer
12825 @item Long_Binary
12826 Long_Long_Integer
12827 @item Decimal_Element
12828 Character
12829 @item COBOL_Character
12830 Character
12831 @end table
12832
12833 @noindent
12834 For initialization, see the file @file{i-cobol.ads} in the distributed library.
12835
12836 @sp 1
12837 @cartouche
12838 @noindent
12839 @strong{85}. Support for access to machine instructions. See C.1(1).
12840 @end cartouche
12841 @noindent
12842 See documentation in file @file{s-maccod.ads} in the distributed library.
12843
12844 @sp 1
12845 @cartouche
12846 @noindent
12847 @strong{86}. Implementation-defined aspects of access to machine
12848 operations. See C.1(9).
12849 @end cartouche
12850 @noindent
12851 See documentation in file @file{s-maccod.ads} in the distributed library.
12852
12853 @sp 1
12854 @cartouche
12855 @noindent
12856 @strong{87}. Implementation-defined aspects of interrupts. See C.3(2).
12857 @end cartouche
12858 @noindent
12859 Interrupts are mapped to signals or conditions as appropriate. See
12860 definition of unit
12861 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
12862 on the interrupts supported on a particular target.
12863
12864 @sp 1
12865 @cartouche
12866 @noindent
12867 @strong{88}. Implementation-defined aspects of pre-elaboration. See
12868 C.4(13).
12869 @end cartouche
12870 @noindent
12871 GNAT does not permit a partition to be restarted without reloading,
12872 except under control of the debugger.
12873
12874 @sp 1
12875 @cartouche
12876 @noindent
12877 @strong{89}. The semantics of pragma @code{Discard_Names}. See C.5(7).
12878 @end cartouche
12879 @noindent
12880 Pragma @code{Discard_Names} causes names of enumeration literals to
12881 be suppressed. In the presence of this pragma, the Image attribute
12882 provides the image of the Pos of the literal, and Value accepts
12883 Pos values.
12884
12885 @sp 1
12886 @cartouche
12887 @noindent
12888 @strong{90}. The result of the @code{Task_Identification.Image}
12889 attribute. See C.7.1(7).
12890 @end cartouche
12891 @noindent
12892 The result of this attribute is a string that identifies
12893 the object or component that denotes a given task. If a variable @code{Var}
12894 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
12895 where the suffix
12896 is the hexadecimal representation of the virtual address of the corresponding
12897 task control block. If the variable is an array of tasks, the image of each
12898 task will have the form of an indexed component indicating the position of a
12899 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
12900 component of a record, the image of the task will have the form of a selected
12901 component. These rules are fully recursive, so that the image of a task that
12902 is a subcomponent of a composite object corresponds to the expression that
12903 designates this task.
12904 @noindent
12905 If a task is created by an allocator, its image depends on the context. If the
12906 allocator is part of an object declaration, the rules described above are used
12907 to construct its image, and this image is not affected by subsequent
12908 assignments. If the allocator appears within an expression, the image
12909 includes only the name of the task type.
12910 @noindent
12911 If the configuration pragma Discard_Names is present, or if the restriction
12912 No_Implicit_Heap_Allocation is in effect, the image reduces to
12913 the numeric suffix, that is to say the hexadecimal representation of the
12914 virtual address of the control block of the task.
12915 @sp 1
12916 @cartouche
12917 @noindent
12918 @strong{91}. The value of @code{Current_Task} when in a protected entry
12919 or interrupt handler. See C.7.1(17).
12920 @end cartouche
12921 @noindent
12922 Protected entries or interrupt handlers can be executed by any
12923 convenient thread, so the value of @code{Current_Task} is undefined.
12924
12925 @sp 1
12926 @cartouche
12927 @noindent
12928 @strong{92}. The effect of calling @code{Current_Task} from an entry
12929 body or interrupt handler. See C.7.1(19).
12930 @end cartouche
12931 @noindent
12932 The effect of calling @code{Current_Task} from an entry body or
12933 interrupt handler is to return the identification of the task currently
12934 executing the code.
12935
12936 @sp 1
12937 @cartouche
12938 @noindent
12939 @strong{93}. Implementation-defined aspects of
12940 @code{Task_Attributes}. See C.7.2(19).
12941 @end cartouche
12942 @noindent
12943 There are no implementation-defined aspects of @code{Task_Attributes}.
12944
12945 @sp 1
12946 @cartouche
12947 @noindent
12948 @strong{94}. Values of all @code{Metrics}. See D(2).
12949 @end cartouche
12950 @noindent
12951 The metrics information for GNAT depends on the performance of the
12952 underlying operating system. The sources of the run-time for tasking
12953 implementation, together with the output from @option{-gnatG} can be
12954 used to determine the exact sequence of operating systems calls made
12955 to implement various tasking constructs. Together with appropriate
12956 information on the performance of the underlying operating system,
12957 on the exact target in use, this information can be used to determine
12958 the required metrics.
12959
12960 @sp 1
12961 @cartouche
12962 @noindent
12963 @strong{95}. The declarations of @code{Any_Priority} and
12964 @code{Priority}. See D.1(11).
12965 @end cartouche
12966 @noindent
12967 See declarations in file @file{system.ads}.
12968
12969 @sp 1
12970 @cartouche
12971 @noindent
12972 @strong{96}. Implementation-defined execution resources. See D.1(15).
12973 @end cartouche
12974 @noindent
12975 There are no implementation-defined execution resources.
12976
12977 @sp 1
12978 @cartouche
12979 @noindent
12980 @strong{97}. Whether, on a multiprocessor, a task that is waiting for
12981 access to a protected object keeps its processor busy. See D.2.1(3).
12982 @end cartouche
12983 @noindent
12984 On a multi-processor, a task that is waiting for access to a protected
12985 object does not keep its processor busy.
12986
12987 @sp 1
12988 @cartouche
12989 @noindent
12990 @strong{98}. The affect of implementation defined execution resources
12991 on task dispatching. See D.2.1(9).
12992 @end cartouche
12993 @noindent
12994 Tasks map to threads in the threads package used by GNAT@. Where possible
12995 and appropriate, these threads correspond to native threads of the
12996 underlying operating system.
12997
12998 @sp 1
12999 @cartouche
13000 @noindent
13001 @strong{99}. Implementation-defined @code{policy_identifiers} allowed
13002 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
13003 @end cartouche
13004 @noindent
13005 There are no implementation-defined policy-identifiers allowed in this
13006 pragma.
13007
13008 @sp 1
13009 @cartouche
13010 @noindent
13011 @strong{100}. Implementation-defined aspects of priority inversion. See
13012 D.2.2(16).
13013 @end cartouche
13014 @noindent
13015 Execution of a task cannot be preempted by the implementation processing
13016 of delay expirations for lower priority tasks.
13017
13018 @sp 1
13019 @cartouche
13020 @noindent
13021 @strong{101}. Implementation-defined task dispatching. See D.2.2(18).
13022 @end cartouche
13023 @noindent
13024 The policy is the same as that of the underlying threads implementation.
13025
13026 @sp 1
13027 @cartouche
13028 @noindent
13029 @strong{102}. Implementation-defined @code{policy_identifiers} allowed
13030 in a pragma @code{Locking_Policy}. See D.3(4).
13031 @end cartouche
13032 @noindent
13033 The two implementation defined policies permitted in GNAT are
13034 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
13035 targets that support the @code{Inheritance_Locking} policy, locking is
13036 implemented by inheritance, i.e.@: the task owning the lock operates
13037 at a priority equal to the highest priority of any task currently
13038 requesting the lock. On targets that support the
13039 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
13040 read/write lock allowing multiple propected object functions to enter
13041 concurrently.
13042
13043 @sp 1
13044 @cartouche
13045 @noindent
13046 @strong{103}. Default ceiling priorities. See D.3(10).
13047 @end cartouche
13048 @noindent
13049 The ceiling priority of protected objects of the type
13050 @code{System.Interrupt_Priority'Last} as described in the Ada
13051 Reference Manual D.3(10),
13052
13053 @sp 1
13054 @cartouche
13055 @noindent
13056 @strong{104}. The ceiling of any protected object used internally by
13057 the implementation. See D.3(16).
13058 @end cartouche
13059 @noindent
13060 The ceiling priority of internal protected objects is
13061 @code{System.Priority'Last}.
13062
13063 @sp 1
13064 @cartouche
13065 @noindent
13066 @strong{105}. Implementation-defined queuing policies. See D.4(1).
13067 @end cartouche
13068 @noindent
13069 There are no implementation-defined queuing policies.
13070
13071 @sp 1
13072 @cartouche
13073 @noindent
13074 @strong{106}. On a multiprocessor, any conditions that cause the
13075 completion of an aborted construct to be delayed later than what is
13076 specified for a single processor. See D.6(3).
13077 @end cartouche
13078 @noindent
13079 The semantics for abort on a multi-processor is the same as on a single
13080 processor, there are no further delays.
13081
13082 @sp 1
13083 @cartouche
13084 @noindent
13085 @strong{107}. Any operations that implicitly require heap storage
13086 allocation. See D.7(8).
13087 @end cartouche
13088 @noindent
13089 The only operation that implicitly requires heap storage allocation is
13090 task creation.
13091
13092 @sp 1
13093 @cartouche
13094 @noindent
13095 @strong{108}. Implementation-defined aspects of pragma
13096 @code{Restrictions}. See D.7(20).
13097 @end cartouche
13098 @noindent
13099 There are no such implementation-defined aspects.
13100
13101 @sp 1
13102 @cartouche
13103 @noindent
13104 @strong{109}. Implementation-defined aspects of package
13105 @code{Real_Time}. See D.8(17).
13106 @end cartouche
13107 @noindent
13108 There are no implementation defined aspects of package @code{Real_Time}.
13109
13110 @sp 1
13111 @cartouche
13112 @noindent
13113 @strong{110}. Implementation-defined aspects of
13114 @code{delay_statements}. See D.9(8).
13115 @end cartouche
13116 @noindent
13117 Any difference greater than one microsecond will cause the task to be
13118 delayed (see D.9(7)).
13119
13120 @sp 1
13121 @cartouche
13122 @noindent
13123 @strong{111}. The upper bound on the duration of interrupt blocking
13124 caused by the implementation. See D.12(5).
13125 @end cartouche
13126 @noindent
13127 The upper bound is determined by the underlying operating system. In
13128 no cases is it more than 10 milliseconds.
13129
13130 @sp 1
13131 @cartouche
13132 @noindent
13133 @strong{112}. The means for creating and executing distributed
13134 programs. See E(5).
13135 @end cartouche
13136 @noindent
13137 The GLADE package provides a utility GNATDIST for creating and executing
13138 distributed programs. See the GLADE reference manual for further details.
13139
13140 @sp 1
13141 @cartouche
13142 @noindent
13143 @strong{113}. Any events that can result in a partition becoming
13144 inaccessible. See E.1(7).
13145 @end cartouche
13146 @noindent
13147 See the GLADE reference manual for full details on such events.
13148
13149 @sp 1
13150 @cartouche
13151 @noindent
13152 @strong{114}. The scheduling policies, treatment of priorities, and
13153 management of shared resources between partitions in certain cases. See
13154 E.1(11).
13155 @end cartouche
13156 @noindent
13157 See the GLADE reference manual for full details on these aspects of
13158 multi-partition execution.
13159
13160 @sp 1
13161 @cartouche
13162 @noindent
13163 @strong{115}. Events that cause the version of a compilation unit to
13164 change. See E.3(5).
13165 @end cartouche
13166 @noindent
13167 Editing the source file of a compilation unit, or the source files of
13168 any units on which it is dependent in a significant way cause the version
13169 to change. No other actions cause the version number to change. All changes
13170 are significant except those which affect only layout, capitalization or
13171 comments.
13172
13173 @sp 1
13174 @cartouche
13175 @noindent
13176 @strong{116}. Whether the execution of the remote subprogram is
13177 immediately aborted as a result of cancellation. See E.4(13).
13178 @end cartouche
13179 @noindent
13180 See the GLADE reference manual for details on the effect of abort in
13181 a distributed application.
13182
13183 @sp 1
13184 @cartouche
13185 @noindent
13186 @strong{117}. Implementation-defined aspects of the PCS@. See E.5(25).
13187 @end cartouche
13188 @noindent
13189 See the GLADE reference manual for a full description of all implementation
13190 defined aspects of the PCS@.
13191
13192 @sp 1
13193 @cartouche
13194 @noindent
13195 @strong{118}. Implementation-defined interfaces in the PCS@. See
13196 E.5(26).
13197 @end cartouche
13198 @noindent
13199 See the GLADE reference manual for a full description of all
13200 implementation defined interfaces.
13201
13202 @sp 1
13203 @cartouche
13204 @noindent
13205 @strong{119}. The values of named numbers in the package
13206 @code{Decimal}. See F.2(7).
13207 @end cartouche
13208 @noindent
13209 @table @code
13210 @item Max_Scale
13211 +18
13212 @item Min_Scale
13213 -18
13214 @item Min_Delta
13215 1.0E-18
13216 @item Max_Delta
13217 1.0E+18
13218 @item Max_Decimal_Digits
13219 18
13220 @end table
13221
13222 @sp 1
13223 @cartouche
13224 @noindent
13225 @strong{120}. The value of @code{Max_Picture_Length} in the package
13226 @code{Text_IO.Editing}. See F.3.3(16).
13227 @end cartouche
13228 @noindent
13229 64
13230
13231 @sp 1
13232 @cartouche
13233 @noindent
13234 @strong{121}. The value of @code{Max_Picture_Length} in the package
13235 @code{Wide_Text_IO.Editing}. See F.3.4(5).
13236 @end cartouche
13237 @noindent
13238 64
13239
13240 @sp 1
13241 @cartouche
13242 @noindent
13243 @strong{122}. The accuracy actually achieved by the complex elementary
13244 functions and by other complex arithmetic operations. See G.1(1).
13245 @end cartouche
13246 @noindent
13247 Standard library functions are used for the complex arithmetic
13248 operations. Only fast math mode is currently supported.
13249
13250 @sp 1
13251 @cartouche
13252 @noindent
13253 @strong{123}. The sign of a zero result (or a component thereof) from
13254 any operator or function in @code{Numerics.Generic_Complex_Types}, when
13255 @code{Real'Signed_Zeros} is True. See G.1.1(53).
13256 @end cartouche
13257 @noindent
13258 The signs of zero values are as recommended by the relevant
13259 implementation advice.
13260
13261 @sp 1
13262 @cartouche
13263 @noindent
13264 @strong{124}. The sign of a zero result (or a component thereof) from
13265 any operator or function in
13266 @code{Numerics.Generic_Complex_Elementary_Functions}, when
13267 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
13268 @end cartouche
13269 @noindent
13270 The signs of zero values are as recommended by the relevant
13271 implementation advice.
13272
13273 @sp 1
13274 @cartouche
13275 @noindent
13276 @strong{125}. Whether the strict mode or the relaxed mode is the
13277 default. See G.2(2).
13278 @end cartouche
13279 @noindent
13280 The strict mode is the default. There is no separate relaxed mode. GNAT
13281 provides a highly efficient implementation of strict mode.
13282
13283 @sp 1
13284 @cartouche
13285 @noindent
13286 @strong{126}. The result interval in certain cases of fixed-to-float
13287 conversion. See G.2.1(10).
13288 @end cartouche
13289 @noindent
13290 For cases where the result interval is implementation dependent, the
13291 accuracy is that provided by performing all operations in 64-bit IEEE
13292 floating-point format.
13293
13294 @sp 1
13295 @cartouche
13296 @noindent
13297 @strong{127}. The result of a floating point arithmetic operation in
13298 overflow situations, when the @code{Machine_Overflows} attribute of the
13299 result type is @code{False}. See G.2.1(13).
13300 @end cartouche
13301 @noindent
13302 Infinite and NaN values are produced as dictated by the IEEE
13303 floating-point standard.
13304
13305 Note that on machines that are not fully compliant with the IEEE
13306 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
13307 must be used for achieving IEEE conforming behavior (although at the cost
13308 of a significant performance penalty), so infinite and NaN values are
13309 properly generated.
13310
13311 @sp 1
13312 @cartouche
13313 @noindent
13314 @strong{128}. The result interval for division (or exponentiation by a
13315 negative exponent), when the floating point hardware implements division
13316 as multiplication by a reciprocal. See G.2.1(16).
13317 @end cartouche
13318 @noindent
13319 Not relevant, division is IEEE exact.
13320
13321 @sp 1
13322 @cartouche
13323 @noindent
13324 @strong{129}. The definition of close result set, which determines the
13325 accuracy of certain fixed point multiplications and divisions. See
13326 G.2.3(5).
13327 @end cartouche
13328 @noindent
13329 Operations in the close result set are performed using IEEE long format
13330 floating-point arithmetic. The input operands are converted to
13331 floating-point, the operation is done in floating-point, and the result
13332 is converted to the target type.
13333
13334 @sp 1
13335 @cartouche
13336 @noindent
13337 @strong{130}. Conditions on a @code{universal_real} operand of a fixed
13338 point multiplication or division for which the result shall be in the
13339 perfect result set. See G.2.3(22).
13340 @end cartouche
13341 @noindent
13342 The result is only defined to be in the perfect result set if the result
13343 can be computed by a single scaling operation involving a scale factor
13344 representable in 64-bits.
13345
13346 @sp 1
13347 @cartouche
13348 @noindent
13349 @strong{131}. The result of a fixed point arithmetic operation in
13350 overflow situations, when the @code{Machine_Overflows} attribute of the
13351 result type is @code{False}. See G.2.3(27).
13352 @end cartouche
13353 @noindent
13354 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
13355 types.
13356
13357 @sp 1
13358 @cartouche
13359 @noindent
13360 @strong{132}. The result of an elementary function reference in
13361 overflow situations, when the @code{Machine_Overflows} attribute of the
13362 result type is @code{False}. See G.2.4(4).
13363 @end cartouche
13364 @noindent
13365 IEEE infinite and Nan values are produced as appropriate.
13366
13367 @sp 1
13368 @cartouche
13369 @noindent
13370 @strong{133}. The value of the angle threshold, within which certain
13371 elementary functions, complex arithmetic operations, and complex
13372 elementary functions yield results conforming to a maximum relative
13373 error bound. See G.2.4(10).
13374 @end cartouche
13375 @noindent
13376 Information on this subject is not yet available.
13377
13378 @sp 1
13379 @cartouche
13380 @noindent
13381 @strong{134}. The accuracy of certain elementary functions for
13382 parameters beyond the angle threshold. See G.2.4(10).
13383 @end cartouche
13384 @noindent
13385 Information on this subject is not yet available.
13386
13387 @sp 1
13388 @cartouche
13389 @noindent
13390 @strong{135}. The result of a complex arithmetic operation or complex
13391 elementary function reference in overflow situations, when the
13392 @code{Machine_Overflows} attribute of the corresponding real type is
13393 @code{False}. See G.2.6(5).
13394 @end cartouche
13395 @noindent
13396 IEEE infinite and Nan values are produced as appropriate.
13397
13398 @sp 1
13399 @cartouche
13400 @noindent
13401 @strong{136}. The accuracy of certain complex arithmetic operations and
13402 certain complex elementary functions for parameters (or components
13403 thereof) beyond the angle threshold. See G.2.6(8).
13404 @end cartouche
13405 @noindent
13406 Information on those subjects is not yet available.
13407
13408 @sp 1
13409 @cartouche
13410 @noindent
13411 @strong{137}. Information regarding bounded errors and erroneous
13412 execution. See H.2(1).
13413 @end cartouche
13414 @noindent
13415 Information on this subject is not yet available.
13416
13417 @sp 1
13418 @cartouche
13419 @noindent
13420 @strong{138}. Implementation-defined aspects of pragma
13421 @code{Inspection_Point}. See H.3.2(8).
13422 @end cartouche
13423 @noindent
13424 Pragma @code{Inspection_Point} ensures that the variable is live and can
13425 be examined by the debugger at the inspection point.
13426
13427 @sp 1
13428 @cartouche
13429 @noindent
13430 @strong{139}. Implementation-defined aspects of pragma
13431 @code{Restrictions}. See H.4(25).
13432 @end cartouche
13433 @noindent
13434 There are no implementation-defined aspects of pragma @code{Restrictions}. The
13435 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
13436 generated code. Checks must suppressed by use of pragma @code{Suppress}.
13437
13438 @sp 1
13439 @cartouche
13440 @noindent
13441 @strong{140}. Any restrictions on pragma @code{Restrictions}. See
13442 H.4(27).
13443 @end cartouche
13444 @noindent
13445 There are no restrictions on pragma @code{Restrictions}.
13446
13447 @node Intrinsic Subprograms
13448 @chapter Intrinsic Subprograms
13449 @cindex Intrinsic Subprograms
13450
13451 @menu
13452 * Intrinsic Operators::
13453 * Enclosing_Entity::
13454 * Exception_Information::
13455 * Exception_Message::
13456 * Exception_Name::
13457 * File::
13458 * Line::
13459 * Shifts and Rotates::
13460 * Source_Location::
13461 @end menu
13462
13463 @noindent
13464 GNAT allows a user application program to write the declaration:
13465
13466 @smallexample @c ada
13467 pragma Import (Intrinsic, name);
13468 @end smallexample
13469
13470 @noindent
13471 providing that the name corresponds to one of the implemented intrinsic
13472 subprograms in GNAT, and that the parameter profile of the referenced
13473 subprogram meets the requirements. This chapter describes the set of
13474 implemented intrinsic subprograms, and the requirements on parameter profiles.
13475 Note that no body is supplied; as with other uses of pragma Import, the
13476 body is supplied elsewhere (in this case by the compiler itself). Note
13477 that any use of this feature is potentially non-portable, since the
13478 Ada standard does not require Ada compilers to implement this feature.
13479
13480 @node Intrinsic Operators
13481 @section Intrinsic Operators
13482 @cindex Intrinsic operator
13483
13484 @noindent
13485 All the predefined numeric operators in package Standard
13486 in @code{pragma Import (Intrinsic,..)}
13487 declarations. In the binary operator case, the operands must have the same
13488 size. The operand or operands must also be appropriate for
13489 the operator. For example, for addition, the operands must
13490 both be floating-point or both be fixed-point, and the
13491 right operand for @code{"**"} must have a root type of
13492 @code{Standard.Integer'Base}.
13493 You can use an intrinsic operator declaration as in the following example:
13494
13495 @smallexample @c ada
13496 type Int1 is new Integer;
13497 type Int2 is new Integer;
13498
13499 function "+" (X1 : Int1; X2 : Int2) return Int1;
13500 function "+" (X1 : Int1; X2 : Int2) return Int2;
13501 pragma Import (Intrinsic, "+");
13502 @end smallexample
13503
13504 @noindent
13505 This declaration would permit ``mixed mode'' arithmetic on items
13506 of the differing types @code{Int1} and @code{Int2}.
13507 It is also possible to specify such operators for private types, if the
13508 full views are appropriate arithmetic types.
13509
13510 @node Enclosing_Entity
13511 @section Enclosing_Entity
13512 @cindex Enclosing_Entity
13513 @noindent
13514 This intrinsic subprogram is used in the implementation of the
13515 library routine @code{GNAT.Source_Info}. The only useful use of the
13516 intrinsic import in this case is the one in this unit, so an
13517 application program should simply call the function
13518 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
13519 the current subprogram, package, task, entry, or protected subprogram.
13520
13521 @node Exception_Information
13522 @section Exception_Information
13523 @cindex Exception_Information'
13524 @noindent
13525 This intrinsic subprogram is used in the implementation of the
13526 library routine @code{GNAT.Current_Exception}. The only useful
13527 use of the intrinsic import in this case is the one in this unit,
13528 so an application program should simply call the function
13529 @code{GNAT.Current_Exception.Exception_Information} to obtain
13530 the exception information associated with the current exception.
13531
13532 @node Exception_Message
13533 @section Exception_Message
13534 @cindex Exception_Message
13535 @noindent
13536 This intrinsic subprogram is used in the implementation of the
13537 library routine @code{GNAT.Current_Exception}. The only useful
13538 use of the intrinsic import in this case is the one in this unit,
13539 so an application program should simply call the function
13540 @code{GNAT.Current_Exception.Exception_Message} to obtain
13541 the message associated with the current exception.
13542
13543 @node Exception_Name
13544 @section Exception_Name
13545 @cindex Exception_Name
13546 @noindent
13547 This intrinsic subprogram is used in the implementation of the
13548 library routine @code{GNAT.Current_Exception}. The only useful
13549 use of the intrinsic import in this case is the one in this unit,
13550 so an application program should simply call the function
13551 @code{GNAT.Current_Exception.Exception_Name} to obtain
13552 the name of the current exception.
13553
13554 @node File
13555 @section File
13556 @cindex File
13557 @noindent
13558 This intrinsic subprogram is used in the implementation of the
13559 library routine @code{GNAT.Source_Info}. The only useful use of the
13560 intrinsic import in this case is the one in this unit, so an
13561 application program should simply call the function
13562 @code{GNAT.Source_Info.File} to obtain the name of the current
13563 file.
13564
13565 @node Line
13566 @section Line
13567 @cindex Line
13568 @noindent
13569 This intrinsic subprogram is used in the implementation of the
13570 library routine @code{GNAT.Source_Info}. The only useful use of the
13571 intrinsic import in this case is the one in this unit, so an
13572 application program should simply call the function
13573 @code{GNAT.Source_Info.Line} to obtain the number of the current
13574 source line.
13575
13576 @node Shifts and Rotates
13577 @section Shifts and Rotates
13578 @cindex Shift_Left
13579 @cindex Shift_Right
13580 @cindex Shift_Right_Arithmetic
13581 @cindex Rotate_Left
13582 @cindex Rotate_Right
13583 @noindent
13584 In standard Ada, the shift and rotate functions are available only
13585 for the predefined modular types in package @code{Interfaces}. However, in
13586 GNAT it is possible to define these functions for any integer
13587 type (signed or modular), as in this example:
13588
13589 @smallexample @c ada
13590 function Shift_Left
13591 (Value : T;
13592 Amount : Natural)
13593 return T;
13594 @end smallexample
13595
13596 @noindent
13597 The function name must be one of
13598 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
13599 Rotate_Right. T must be an integer type. T'Size must be
13600 8, 16, 32 or 64 bits; if T is modular, the modulus
13601 must be 2**8, 2**16, 2**32 or 2**64.
13602 The result type must be the same as the type of @code{Value}.
13603 The shift amount must be Natural.
13604 The formal parameter names can be anything.
13605
13606 @node Source_Location
13607 @section Source_Location
13608 @cindex Source_Location
13609 @noindent
13610 This intrinsic subprogram is used in the implementation of the
13611 library routine @code{GNAT.Source_Info}. The only useful use of the
13612 intrinsic import in this case is the one in this unit, so an
13613 application program should simply call the function
13614 @code{GNAT.Source_Info.Source_Location} to obtain the current
13615 source file location.
13616
13617 @node Representation Clauses and Pragmas
13618 @chapter Representation Clauses and Pragmas
13619 @cindex Representation Clauses
13620
13621 @menu
13622 * Alignment Clauses::
13623 * Size Clauses::
13624 * Storage_Size Clauses::
13625 * Size of Variant Record Objects::
13626 * Biased Representation ::
13627 * Value_Size and Object_Size Clauses::
13628 * Component_Size Clauses::
13629 * Bit_Order Clauses::
13630 * Effect of Bit_Order on Byte Ordering::
13631 * Pragma Pack for Arrays::
13632 * Pragma Pack for Records::
13633 * Record Representation Clauses::
13634 * Enumeration Clauses::
13635 * Address Clauses::
13636 * Effect of Convention on Representation::
13637 * Determining the Representations chosen by GNAT::
13638 @end menu
13639
13640 @noindent
13641 @cindex Representation Clause
13642 @cindex Representation Pragma
13643 @cindex Pragma, representation
13644 This section describes the representation clauses accepted by GNAT, and
13645 their effect on the representation of corresponding data objects.
13646
13647 GNAT fully implements Annex C (Systems Programming). This means that all
13648 the implementation advice sections in chapter 13 are fully implemented.
13649 However, these sections only require a minimal level of support for
13650 representation clauses. GNAT provides much more extensive capabilities,
13651 and this section describes the additional capabilities provided.
13652
13653 @node Alignment Clauses
13654 @section Alignment Clauses
13655 @cindex Alignment Clause
13656
13657 @noindent
13658 GNAT requires that all alignment clauses specify a power of 2, and all
13659 default alignments are always a power of 2. The default alignment
13660 values are as follows:
13661
13662 @itemize @bullet
13663 @item @emph{Primitive Types}.
13664 For primitive types, the alignment is the minimum of the actual size of
13665 objects of the type divided by @code{Storage_Unit},
13666 and the maximum alignment supported by the target.
13667 (This maximum alignment is given by the GNAT-specific attribute
13668 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
13669 @cindex @code{Maximum_Alignment} attribute
13670 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
13671 default alignment will be 8 on any target that supports alignments
13672 this large, but on some targets, the maximum alignment may be smaller
13673 than 8, in which case objects of type @code{Long_Float} will be maximally
13674 aligned.
13675
13676 @item @emph{Arrays}.
13677 For arrays, the alignment is equal to the alignment of the component type
13678 for the normal case where no packing or component size is given. If the
13679 array is packed, and the packing is effective (see separate section on
13680 packed arrays), then the alignment will be one for long packed arrays,
13681 or arrays whose length is not known at compile time. For short packed
13682 arrays, which are handled internally as modular types, the alignment
13683 will be as described for primitive types, e.g.@: a packed array of length
13684 31 bits will have an object size of four bytes, and an alignment of 4.
13685
13686 @item @emph{Records}.
13687 For the normal non-packed case, the alignment of a record is equal to
13688 the maximum alignment of any of its components. For tagged records, this
13689 includes the implicit access type used for the tag. If a pragma @code{Pack}
13690 is used and all components are packable (see separate section on pragma
13691 @code{Pack}), then the resulting alignment is 1, unless the layout of the
13692 record makes it profitable to increase it.
13693
13694 A special case is when:
13695 @itemize @bullet
13696 @item
13697 the size of the record is given explicitly, or a
13698 full record representation clause is given, and
13699 @item
13700 the size of the record is 2, 4, or 8 bytes.
13701 @end itemize
13702 @noindent
13703 In this case, an alignment is chosen to match the
13704 size of the record. For example, if we have:
13705
13706 @smallexample @c ada
13707 type Small is record
13708 A, B : Character;
13709 end record;
13710 for Small'Size use 16;
13711 @end smallexample
13712
13713 @noindent
13714 then the default alignment of the record type @code{Small} is 2, not 1. This
13715 leads to more efficient code when the record is treated as a unit, and also
13716 allows the type to specified as @code{Atomic} on architectures requiring
13717 strict alignment.
13718
13719 @end itemize
13720
13721 @noindent
13722 An alignment clause may specify a larger alignment than the default value
13723 up to some maximum value dependent on the target (obtainable by using the
13724 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
13725 a smaller alignment than the default value for enumeration, integer and
13726 fixed point types, as well as for record types, for example
13727
13728 @smallexample @c ada
13729 type V is record
13730 A : Integer;
13731 end record;
13732
13733 for V'alignment use 1;
13734 @end smallexample
13735
13736 @noindent
13737 @cindex Alignment, default
13738 The default alignment for the type @code{V} is 4, as a result of the
13739 Integer field in the record, but it is permissible, as shown, to
13740 override the default alignment of the record with a smaller value.
13741
13742 @cindex Alignment, subtypes
13743 Note that according to the Ada standard, an alignment clause applies only
13744 to the first named subtype. If additional subtypes are declared, then the
13745 compiler is allowed to choose any alignment it likes, and there is no way
13746 to control this choice. Consider:
13747
13748 @smallexample @c ada
13749 type R is range 1 .. 10_000;
13750 for R'Alignment use 1;
13751 subtype RS is R range 1 .. 1000;
13752 @end smallexample
13753
13754 @noindent
13755 The alignment clause specifies an alignment of 1 for the first named subtype
13756 @code{R} but this does not necessarily apply to @code{RS}. When writing
13757 portable Ada code, you should avoid writing code that explicitly or
13758 implicitly relies on the alignment of such subtypes.
13759
13760 For the GNAT compiler, if an explicit alignment clause is given, this
13761 value is also used for any subsequent subtypes. So for GNAT, in the
13762 above example, you can count on the alignment of @code{RS} being 1. But this
13763 assumption is non-portable, and other compilers may choose different
13764 alignments for the subtype @code{RS}.
13765
13766 @node Size Clauses
13767 @section Size Clauses
13768 @cindex Size Clause
13769
13770 @noindent
13771 The default size for a type @code{T} is obtainable through the
13772 language-defined attribute @code{T'Size} and also through the
13773 equivalent GNAT-defined attribute @code{T'Value_Size}.
13774 For objects of type @code{T}, GNAT will generally increase the type size
13775 so that the object size (obtainable through the GNAT-defined attribute
13776 @code{T'Object_Size})
13777 is a multiple of @code{T'Alignment * Storage_Unit}.
13778 For example
13779
13780 @smallexample @c ada
13781 type Smallint is range 1 .. 6;
13782
13783 type Rec is record
13784 Y1 : integer;
13785 Y2 : boolean;
13786 end record;
13787 @end smallexample
13788
13789 @noindent
13790 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
13791 as specified by the RM rules,
13792 but objects of this type will have a size of 8
13793 (@code{Smallint'Object_Size} = 8),
13794 since objects by default occupy an integral number
13795 of storage units. On some targets, notably older
13796 versions of the Digital Alpha, the size of stand
13797 alone objects of this type may be 32, reflecting
13798 the inability of the hardware to do byte load/stores.
13799
13800 Similarly, the size of type @code{Rec} is 40 bits
13801 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
13802 the alignment is 4, so objects of this type will have
13803 their size increased to 64 bits so that it is a multiple
13804 of the alignment (in bits). This decision is
13805 in accordance with the specific Implementation Advice in RM 13.3(43):
13806
13807 @quotation
13808 A @code{Size} clause should be supported for an object if the specified
13809 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
13810 to a size in storage elements that is a multiple of the object's
13811 @code{Alignment} (if the @code{Alignment} is nonzero).
13812 @end quotation
13813
13814 @noindent
13815 An explicit size clause may be used to override the default size by
13816 increasing it. For example, if we have:
13817
13818 @smallexample @c ada
13819 type My_Boolean is new Boolean;
13820 for My_Boolean'Size use 32;
13821 @end smallexample
13822
13823 @noindent
13824 then values of this type will always be 32 bits long. In the case of
13825 discrete types, the size can be increased up to 64 bits, with the effect
13826 that the entire specified field is used to hold the value, sign- or
13827 zero-extended as appropriate. If more than 64 bits is specified, then
13828 padding space is allocated after the value, and a warning is issued that
13829 there are unused bits.
13830
13831 Similarly the size of records and arrays may be increased, and the effect
13832 is to add padding bits after the value. This also causes a warning message
13833 to be generated.
13834
13835 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
13836 Size in bits, this corresponds to an object of size 256 megabytes (minus
13837 one). This limitation is true on all targets. The reason for this
13838 limitation is that it improves the quality of the code in many cases
13839 if it is known that a Size value can be accommodated in an object of
13840 type Integer.
13841
13842 @node Storage_Size Clauses
13843 @section Storage_Size Clauses
13844 @cindex Storage_Size Clause
13845
13846 @noindent
13847 For tasks, the @code{Storage_Size} clause specifies the amount of space
13848 to be allocated for the task stack. This cannot be extended, and if the
13849 stack is exhausted, then @code{Storage_Error} will be raised (if stack
13850 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
13851 or a @code{Storage_Size} pragma in the task definition to set the
13852 appropriate required size. A useful technique is to include in every
13853 task definition a pragma of the form:
13854
13855 @smallexample @c ada
13856 pragma Storage_Size (Default_Stack_Size);
13857 @end smallexample
13858
13859 @noindent
13860 Then @code{Default_Stack_Size} can be defined in a global package, and
13861 modified as required. Any tasks requiring stack sizes different from the
13862 default can have an appropriate alternative reference in the pragma.
13863
13864 You can also use the @option{-d} binder switch to modify the default stack
13865 size.
13866
13867 For access types, the @code{Storage_Size} clause specifies the maximum
13868 space available for allocation of objects of the type. If this space is
13869 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
13870 In the case where the access type is declared local to a subprogram, the
13871 use of a @code{Storage_Size} clause triggers automatic use of a special
13872 predefined storage pool (@code{System.Pool_Size}) that ensures that all
13873 space for the pool is automatically reclaimed on exit from the scope in
13874 which the type is declared.
13875
13876 A special case recognized by the compiler is the specification of a
13877 @code{Storage_Size} of zero for an access type. This means that no
13878 items can be allocated from the pool, and this is recognized at compile
13879 time, and all the overhead normally associated with maintaining a fixed
13880 size storage pool is eliminated. Consider the following example:
13881
13882 @smallexample @c ada
13883 procedure p is
13884 type R is array (Natural) of Character;
13885 type P is access all R;
13886 for P'Storage_Size use 0;
13887 -- Above access type intended only for interfacing purposes
13888
13889 y : P;
13890
13891 procedure g (m : P);
13892 pragma Import (C, g);
13893
13894 -- @dots{}
13895
13896 begin
13897 -- @dots{}
13898 y := new R;
13899 end;
13900 @end smallexample
13901
13902 @noindent
13903 As indicated in this example, these dummy storage pools are often useful in
13904 connection with interfacing where no object will ever be allocated. If you
13905 compile the above example, you get the warning:
13906
13907 @smallexample
13908 p.adb:16:09: warning: allocation from empty storage pool
13909 p.adb:16:09: warning: Storage_Error will be raised at run time
13910 @end smallexample
13911
13912 @noindent
13913 Of course in practice, there will not be any explicit allocators in the
13914 case of such an access declaration.
13915
13916 @node Size of Variant Record Objects
13917 @section Size of Variant Record Objects
13918 @cindex Size, variant record objects
13919 @cindex Variant record objects, size
13920
13921 @noindent
13922 In the case of variant record objects, there is a question whether Size gives
13923 information about a particular variant, or the maximum size required
13924 for any variant. Consider the following program
13925
13926 @smallexample @c ada
13927 with Text_IO; use Text_IO;
13928 procedure q is
13929 type R1 (A : Boolean := False) is record
13930 case A is
13931 when True => X : Character;
13932 when False => null;
13933 end case;
13934 end record;
13935
13936 V1 : R1 (False);
13937 V2 : R1;
13938
13939 begin
13940 Put_Line (Integer'Image (V1'Size));
13941 Put_Line (Integer'Image (V2'Size));
13942 end q;
13943 @end smallexample
13944
13945 @noindent
13946 Here we are dealing with a variant record, where the True variant
13947 requires 16 bits, and the False variant requires 8 bits.
13948 In the above example, both V1 and V2 contain the False variant,
13949 which is only 8 bits long. However, the result of running the
13950 program is:
13951
13952 @smallexample
13953 8
13954 16
13955 @end smallexample
13956
13957 @noindent
13958 The reason for the difference here is that the discriminant value of
13959 V1 is fixed, and will always be False. It is not possible to assign
13960 a True variant value to V1, therefore 8 bits is sufficient. On the
13961 other hand, in the case of V2, the initial discriminant value is
13962 False (from the default), but it is possible to assign a True
13963 variant value to V2, therefore 16 bits must be allocated for V2
13964 in the general case, even fewer bits may be needed at any particular
13965 point during the program execution.
13966
13967 As can be seen from the output of this program, the @code{'Size}
13968 attribute applied to such an object in GNAT gives the actual allocated
13969 size of the variable, which is the largest size of any of the variants.
13970 The Ada Reference Manual is not completely clear on what choice should
13971 be made here, but the GNAT behavior seems most consistent with the
13972 language in the RM@.
13973
13974 In some cases, it may be desirable to obtain the size of the current
13975 variant, rather than the size of the largest variant. This can be
13976 achieved in GNAT by making use of the fact that in the case of a
13977 subprogram parameter, GNAT does indeed return the size of the current
13978 variant (because a subprogram has no way of knowing how much space
13979 is actually allocated for the actual).
13980
13981 Consider the following modified version of the above program:
13982
13983 @smallexample @c ada
13984 with Text_IO; use Text_IO;
13985 procedure q is
13986 type R1 (A : Boolean := False) is record
13987 case A is
13988 when True => X : Character;
13989 when False => null;
13990 end case;
13991 end record;
13992
13993 V2 : R1;
13994
13995 function Size (V : R1) return Integer is
13996 begin
13997 return V'Size;
13998 end Size;
13999
14000 begin
14001 Put_Line (Integer'Image (V2'Size));
14002 Put_Line (Integer'IMage (Size (V2)));
14003 V2 := (True, 'x');
14004 Put_Line (Integer'Image (V2'Size));
14005 Put_Line (Integer'IMage (Size (V2)));
14006 end q;
14007 @end smallexample
14008
14009 @noindent
14010 The output from this program is
14011
14012 @smallexample
14013 16
14014 8
14015 16
14016 16
14017 @end smallexample
14018
14019 @noindent
14020 Here we see that while the @code{'Size} attribute always returns
14021 the maximum size, regardless of the current variant value, the
14022 @code{Size} function does indeed return the size of the current
14023 variant value.
14024
14025 @node Biased Representation
14026 @section Biased Representation
14027 @cindex Size for biased representation
14028 @cindex Biased representation
14029
14030 @noindent
14031 In the case of scalars with a range starting at other than zero, it is
14032 possible in some cases to specify a size smaller than the default minimum
14033 value, and in such cases, GNAT uses an unsigned biased representation,
14034 in which zero is used to represent the lower bound, and successive values
14035 represent successive values of the type.
14036
14037 For example, suppose we have the declaration:
14038
14039 @smallexample @c ada
14040 type Small is range -7 .. -4;
14041 for Small'Size use 2;
14042 @end smallexample
14043
14044 @noindent
14045 Although the default size of type @code{Small} is 4, the @code{Size}
14046 clause is accepted by GNAT and results in the following representation
14047 scheme:
14048
14049 @smallexample
14050 -7 is represented as 2#00#
14051 -6 is represented as 2#01#
14052 -5 is represented as 2#10#
14053 -4 is represented as 2#11#
14054 @end smallexample
14055
14056 @noindent
14057 Biased representation is only used if the specified @code{Size} clause
14058 cannot be accepted in any other manner. These reduced sizes that force
14059 biased representation can be used for all discrete types except for
14060 enumeration types for which a representation clause is given.
14061
14062 @node Value_Size and Object_Size Clauses
14063 @section Value_Size and Object_Size Clauses
14064 @findex Value_Size
14065 @findex Object_Size
14066 @cindex Size, of objects
14067
14068 @noindent
14069 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
14070 number of bits required to hold values of type @code{T}.
14071 Although this interpretation was allowed in Ada 83, it was not required,
14072 and this requirement in practice can cause some significant difficulties.
14073 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
14074 However, in Ada 95 and Ada 2005,
14075 @code{Natural'Size} is
14076 typically 31. This means that code may change in behavior when moving
14077 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
14078
14079 @smallexample @c ada
14080 type Rec is record;
14081 A : Natural;
14082 B : Natural;
14083 end record;
14084
14085 for Rec use record
14086 at 0 range 0 .. Natural'Size - 1;
14087 at 0 range Natural'Size .. 2 * Natural'Size - 1;
14088 end record;
14089 @end smallexample
14090
14091 @noindent
14092 In the above code, since the typical size of @code{Natural} objects
14093 is 32 bits and @code{Natural'Size} is 31, the above code can cause
14094 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
14095 there are cases where the fact that the object size can exceed the
14096 size of the type causes surprises.
14097
14098 To help get around this problem GNAT provides two implementation
14099 defined attributes, @code{Value_Size} and @code{Object_Size}. When
14100 applied to a type, these attributes yield the size of the type
14101 (corresponding to the RM defined size attribute), and the size of
14102 objects of the type respectively.
14103
14104 The @code{Object_Size} is used for determining the default size of
14105 objects and components. This size value can be referred to using the
14106 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
14107 the basis of the determination of the size. The backend is free to
14108 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
14109 character might be stored in 32 bits on a machine with no efficient
14110 byte access instructions such as the Alpha.
14111
14112 The default rules for the value of @code{Object_Size} for
14113 discrete types are as follows:
14114
14115 @itemize @bullet
14116 @item
14117 The @code{Object_Size} for base subtypes reflect the natural hardware
14118 size in bits (run the compiler with @option{-gnatS} to find those values
14119 for numeric types). Enumeration types and fixed-point base subtypes have
14120 8, 16, 32 or 64 bits for this size, depending on the range of values
14121 to be stored.
14122
14123 @item
14124 The @code{Object_Size} of a subtype is the same as the
14125 @code{Object_Size} of
14126 the type from which it is obtained.
14127
14128 @item
14129 The @code{Object_Size} of a derived base type is copied from the parent
14130 base type, and the @code{Object_Size} of a derived first subtype is copied
14131 from the parent first subtype.
14132 @end itemize
14133
14134 @noindent
14135 The @code{Value_Size} attribute
14136 is the (minimum) number of bits required to store a value
14137 of the type.
14138 This value is used to determine how tightly to pack
14139 records or arrays with components of this type, and also affects
14140 the semantics of unchecked conversion (unchecked conversions where
14141 the @code{Value_Size} values differ generate a warning, and are potentially
14142 target dependent).
14143
14144 The default rules for the value of @code{Value_Size} are as follows:
14145
14146 @itemize @bullet
14147 @item
14148 The @code{Value_Size} for a base subtype is the minimum number of bits
14149 required to store all values of the type (including the sign bit
14150 only if negative values are possible).
14151
14152 @item
14153 If a subtype statically matches the first subtype of a given type, then it has
14154 by default the same @code{Value_Size} as the first subtype. This is a
14155 consequence of RM 13.1(14) (``if two subtypes statically match,
14156 then their subtype-specific aspects are the same''.)
14157
14158 @item
14159 All other subtypes have a @code{Value_Size} corresponding to the minimum
14160 number of bits required to store all values of the subtype. For
14161 dynamic bounds, it is assumed that the value can range down or up
14162 to the corresponding bound of the ancestor
14163 @end itemize
14164
14165 @noindent
14166 The RM defined attribute @code{Size} corresponds to the
14167 @code{Value_Size} attribute.
14168
14169 The @code{Size} attribute may be defined for a first-named subtype. This sets
14170 the @code{Value_Size} of
14171 the first-named subtype to the given value, and the
14172 @code{Object_Size} of this first-named subtype to the given value padded up
14173 to an appropriate boundary. It is a consequence of the default rules
14174 above that this @code{Object_Size} will apply to all further subtypes. On the
14175 other hand, @code{Value_Size} is affected only for the first subtype, any
14176 dynamic subtypes obtained from it directly, and any statically matching
14177 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
14178
14179 @code{Value_Size} and
14180 @code{Object_Size} may be explicitly set for any subtype using
14181 an attribute definition clause. Note that the use of these attributes
14182 can cause the RM 13.1(14) rule to be violated. If two access types
14183 reference aliased objects whose subtypes have differing @code{Object_Size}
14184 values as a result of explicit attribute definition clauses, then it
14185 is erroneous to convert from one access subtype to the other.
14186
14187 At the implementation level, Esize stores the Object_Size and the
14188 RM_Size field stores the @code{Value_Size} (and hence the value of the
14189 @code{Size} attribute,
14190 which, as noted above, is equivalent to @code{Value_Size}).
14191
14192 To get a feel for the difference, consider the following examples (note
14193 that in each case the base is @code{Short_Short_Integer} with a size of 8):
14194
14195 @smallexample
14196 Object_Size Value_Size
14197
14198 type x1 is range 0 .. 5; 8 3
14199
14200 type x2 is range 0 .. 5;
14201 for x2'size use 12; 16 12
14202
14203 subtype x3 is x2 range 0 .. 3; 16 2
14204
14205 subtype x4 is x2'base range 0 .. 10; 8 4
14206
14207 subtype x5 is x2 range 0 .. dynamic; 16 3*
14208
14209 subtype x6 is x2'base range 0 .. dynamic; 8 3*
14210
14211 @end smallexample
14212
14213 @noindent
14214 Note: the entries marked ``3*'' are not actually specified by the Ada
14215 Reference Manual, but it seems in the spirit of the RM rules to allocate
14216 the minimum number of bits (here 3, given the range for @code{x2})
14217 known to be large enough to hold the given range of values.
14218
14219 So far, so good, but GNAT has to obey the RM rules, so the question is
14220 under what conditions must the RM @code{Size} be used.
14221 The following is a list
14222 of the occasions on which the RM @code{Size} must be used:
14223
14224 @itemize @bullet
14225 @item
14226 Component size for packed arrays or records
14227
14228 @item
14229 Value of the attribute @code{Size} for a type
14230
14231 @item
14232 Warning about sizes not matching for unchecked conversion
14233 @end itemize
14234
14235 @noindent
14236 For record types, the @code{Object_Size} is always a multiple of the
14237 alignment of the type (this is true for all types). In some cases the
14238 @code{Value_Size} can be smaller. Consider:
14239
14240 @smallexample
14241 type R is record
14242 X : Integer;
14243 Y : Character;
14244 end record;
14245 @end smallexample
14246
14247 @noindent
14248 On a typical 32-bit architecture, the X component will be four bytes, and
14249 require four-byte alignment, and the Y component will be one byte. In this
14250 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
14251 required to store a value of this type, and for example, it is permissible
14252 to have a component of type R in an outer array whose component size is
14253 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
14254 since it must be rounded up so that this value is a multiple of the
14255 alignment (4 bytes = 32 bits).
14256
14257 @noindent
14258 For all other types, the @code{Object_Size}
14259 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
14260 Only @code{Size} may be specified for such types.
14261
14262 @node Component_Size Clauses
14263 @section Component_Size Clauses
14264 @cindex Component_Size Clause
14265
14266 @noindent
14267 Normally, the value specified in a component size clause must be consistent
14268 with the subtype of the array component with regard to size and alignment.
14269 In other words, the value specified must be at least equal to the size
14270 of this subtype, and must be a multiple of the alignment value.
14271
14272 In addition, component size clauses are allowed which cause the array
14273 to be packed, by specifying a smaller value. A first case is for
14274 component size values in the range 1 through 63. The value specified
14275 must not be smaller than the Size of the subtype. GNAT will accurately
14276 honor all packing requests in this range. For example, if we have:
14277
14278 @smallexample @c ada
14279 type r is array (1 .. 8) of Natural;
14280 for r'Component_Size use 31;
14281 @end smallexample
14282
14283 @noindent
14284 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
14285 Of course access to the components of such an array is considerably
14286 less efficient than if the natural component size of 32 is used.
14287 A second case is when the subtype of the component is a record type
14288 padded because of its default alignment. For example, if we have:
14289
14290 @smallexample @c ada
14291 type r is record
14292 i : Integer;
14293 j : Integer;
14294 b : Boolean;
14295 end record;
14296
14297 type a is array (1 .. 8) of r;
14298 for a'Component_Size use 72;
14299 @end smallexample
14300
14301 @noindent
14302 then the resulting array has a length of 72 bytes, instead of 96 bytes
14303 if the alignment of the record (4) was obeyed.
14304
14305 Note that there is no point in giving both a component size clause
14306 and a pragma Pack for the same array type. if such duplicate
14307 clauses are given, the pragma Pack will be ignored.
14308
14309 @node Bit_Order Clauses
14310 @section Bit_Order Clauses
14311 @cindex Bit_Order Clause
14312 @cindex bit ordering
14313 @cindex ordering, of bits
14314
14315 @noindent
14316 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
14317 attribute. The specification may either correspond to the default bit
14318 order for the target, in which case the specification has no effect and
14319 places no additional restrictions, or it may be for the non-standard
14320 setting (that is the opposite of the default).
14321
14322 In the case where the non-standard value is specified, the effect is
14323 to renumber bits within each byte, but the ordering of bytes is not
14324 affected. There are certain
14325 restrictions placed on component clauses as follows:
14326
14327 @itemize @bullet
14328
14329 @item Components fitting within a single storage unit.
14330 @noindent
14331 These are unrestricted, and the effect is merely to renumber bits. For
14332 example if we are on a little-endian machine with @code{Low_Order_First}
14333 being the default, then the following two declarations have exactly
14334 the same effect:
14335
14336 @smallexample @c ada
14337 type R1 is record
14338 A : Boolean;
14339 B : Integer range 1 .. 120;
14340 end record;
14341
14342 for R1 use record
14343 A at 0 range 0 .. 0;
14344 B at 0 range 1 .. 7;
14345 end record;
14346
14347 type R2 is record
14348 A : Boolean;
14349 B : Integer range 1 .. 120;
14350 end record;
14351
14352 for R2'Bit_Order use High_Order_First;
14353
14354 for R2 use record
14355 A at 0 range 7 .. 7;
14356 B at 0 range 0 .. 6;
14357 end record;
14358 @end smallexample
14359
14360 @noindent
14361 The useful application here is to write the second declaration with the
14362 @code{Bit_Order} attribute definition clause, and know that it will be treated
14363 the same, regardless of whether the target is little-endian or big-endian.
14364
14365 @item Components occupying an integral number of bytes.
14366 @noindent
14367 These are components that exactly fit in two or more bytes. Such component
14368 declarations are allowed, but have no effect, since it is important to realize
14369 that the @code{Bit_Order} specification does not affect the ordering of bytes.
14370 In particular, the following attempt at getting an endian-independent integer
14371 does not work:
14372
14373 @smallexample @c ada
14374 type R2 is record
14375 A : Integer;
14376 end record;
14377
14378 for R2'Bit_Order use High_Order_First;
14379
14380 for R2 use record
14381 A at 0 range 0 .. 31;
14382 end record;
14383 @end smallexample
14384
14385 @noindent
14386 This declaration will result in a little-endian integer on a
14387 little-endian machine, and a big-endian integer on a big-endian machine.
14388 If byte flipping is required for interoperability between big- and
14389 little-endian machines, this must be explicitly programmed. This capability
14390 is not provided by @code{Bit_Order}.
14391
14392 @item Components that are positioned across byte boundaries
14393 @noindent
14394 but do not occupy an integral number of bytes. Given that bytes are not
14395 reordered, such fields would occupy a non-contiguous sequence of bits
14396 in memory, requiring non-trivial code to reassemble. They are for this
14397 reason not permitted, and any component clause specifying such a layout
14398 will be flagged as illegal by GNAT@.
14399
14400 @end itemize
14401
14402 @noindent
14403 Since the misconception that Bit_Order automatically deals with all
14404 endian-related incompatibilities is a common one, the specification of
14405 a component field that is an integral number of bytes will always
14406 generate a warning. This warning may be suppressed using @code{pragma
14407 Warnings (Off)} if desired. The following section contains additional
14408 details regarding the issue of byte ordering.
14409
14410 @node Effect of Bit_Order on Byte Ordering
14411 @section Effect of Bit_Order on Byte Ordering
14412 @cindex byte ordering
14413 @cindex ordering, of bytes
14414
14415 @noindent
14416 In this section we will review the effect of the @code{Bit_Order} attribute
14417 definition clause on byte ordering. Briefly, it has no effect at all, but
14418 a detailed example will be helpful. Before giving this
14419 example, let us review the precise
14420 definition of the effect of defining @code{Bit_Order}. The effect of a
14421 non-standard bit order is described in section 15.5.3 of the Ada
14422 Reference Manual:
14423
14424 @quotation
14425 2 A bit ordering is a method of interpreting the meaning of
14426 the storage place attributes.
14427 @end quotation
14428
14429 @noindent
14430 To understand the precise definition of storage place attributes in
14431 this context, we visit section 13.5.1 of the manual:
14432
14433 @quotation
14434 13 A record_representation_clause (without the mod_clause)
14435 specifies the layout. The storage place attributes (see 13.5.2)
14436 are taken from the values of the position, first_bit, and last_bit
14437 expressions after normalizing those values so that first_bit is
14438 less than Storage_Unit.
14439 @end quotation
14440
14441 @noindent
14442 The critical point here is that storage places are taken from
14443 the values after normalization, not before. So the @code{Bit_Order}
14444 interpretation applies to normalized values. The interpretation
14445 is described in the later part of the 15.5.3 paragraph:
14446
14447 @quotation
14448 2 A bit ordering is a method of interpreting the meaning of
14449 the storage place attributes. High_Order_First (known in the
14450 vernacular as ``big endian'') means that the first bit of a
14451 storage element (bit 0) is the most significant bit (interpreting
14452 the sequence of bits that represent a component as an unsigned
14453 integer value). Low_Order_First (known in the vernacular as
14454 ``little endian'') means the opposite: the first bit is the
14455 least significant.
14456 @end quotation
14457
14458 @noindent
14459 Note that the numbering is with respect to the bits of a storage
14460 unit. In other words, the specification affects only the numbering
14461 of bits within a single storage unit.
14462
14463 We can make the effect clearer by giving an example.
14464
14465 Suppose that we have an external device which presents two bytes, the first
14466 byte presented, which is the first (low addressed byte) of the two byte
14467 record is called Master, and the second byte is called Slave.
14468
14469 The left most (most significant bit is called Control for each byte, and
14470 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
14471 (least significant) bit.
14472
14473 On a big-endian machine, we can write the following representation clause
14474
14475 @smallexample @c ada
14476 type Data is record
14477 Master_Control : Bit;
14478 Master_V1 : Bit;
14479 Master_V2 : Bit;
14480 Master_V3 : Bit;
14481 Master_V4 : Bit;
14482 Master_V5 : Bit;
14483 Master_V6 : Bit;
14484 Master_V7 : Bit;
14485 Slave_Control : Bit;
14486 Slave_V1 : Bit;
14487 Slave_V2 : Bit;
14488 Slave_V3 : Bit;
14489 Slave_V4 : Bit;
14490 Slave_V5 : Bit;
14491 Slave_V6 : Bit;
14492 Slave_V7 : Bit;
14493 end record;
14494
14495 for Data use record
14496 Master_Control at 0 range 0 .. 0;
14497 Master_V1 at 0 range 1 .. 1;
14498 Master_V2 at 0 range 2 .. 2;
14499 Master_V3 at 0 range 3 .. 3;
14500 Master_V4 at 0 range 4 .. 4;
14501 Master_V5 at 0 range 5 .. 5;
14502 Master_V6 at 0 range 6 .. 6;
14503 Master_V7 at 0 range 7 .. 7;
14504 Slave_Control at 1 range 0 .. 0;
14505 Slave_V1 at 1 range 1 .. 1;
14506 Slave_V2 at 1 range 2 .. 2;
14507 Slave_V3 at 1 range 3 .. 3;
14508 Slave_V4 at 1 range 4 .. 4;
14509 Slave_V5 at 1 range 5 .. 5;
14510 Slave_V6 at 1 range 6 .. 6;
14511 Slave_V7 at 1 range 7 .. 7;
14512 end record;
14513 @end smallexample
14514
14515 @noindent
14516 Now if we move this to a little endian machine, then the bit ordering within
14517 the byte is backwards, so we have to rewrite the record rep clause as:
14518
14519 @smallexample @c ada
14520 for Data use record
14521 Master_Control at 0 range 7 .. 7;
14522 Master_V1 at 0 range 6 .. 6;
14523 Master_V2 at 0 range 5 .. 5;
14524 Master_V3 at 0 range 4 .. 4;
14525 Master_V4 at 0 range 3 .. 3;
14526 Master_V5 at 0 range 2 .. 2;
14527 Master_V6 at 0 range 1 .. 1;
14528 Master_V7 at 0 range 0 .. 0;
14529 Slave_Control at 1 range 7 .. 7;
14530 Slave_V1 at 1 range 6 .. 6;
14531 Slave_V2 at 1 range 5 .. 5;
14532 Slave_V3 at 1 range 4 .. 4;
14533 Slave_V4 at 1 range 3 .. 3;
14534 Slave_V5 at 1 range 2 .. 2;
14535 Slave_V6 at 1 range 1 .. 1;
14536 Slave_V7 at 1 range 0 .. 0;
14537 end record;
14538 @end smallexample
14539
14540 @noindent
14541 It is a nuisance to have to rewrite the clause, especially if
14542 the code has to be maintained on both machines. However,
14543 this is a case that we can handle with the
14544 @code{Bit_Order} attribute if it is implemented.
14545 Note that the implementation is not required on byte addressed
14546 machines, but it is indeed implemented in GNAT.
14547 This means that we can simply use the
14548 first record clause, together with the declaration
14549
14550 @smallexample @c ada
14551 for Data'Bit_Order use High_Order_First;
14552 @end smallexample
14553
14554 @noindent
14555 and the effect is what is desired, namely the layout is exactly the same,
14556 independent of whether the code is compiled on a big-endian or little-endian
14557 machine.
14558
14559 The important point to understand is that byte ordering is not affected.
14560 A @code{Bit_Order} attribute definition never affects which byte a field
14561 ends up in, only where it ends up in that byte.
14562 To make this clear, let us rewrite the record rep clause of the previous
14563 example as:
14564
14565 @smallexample @c ada
14566 for Data'Bit_Order use High_Order_First;
14567 for Data use record
14568 Master_Control at 0 range 0 .. 0;
14569 Master_V1 at 0 range 1 .. 1;
14570 Master_V2 at 0 range 2 .. 2;
14571 Master_V3 at 0 range 3 .. 3;
14572 Master_V4 at 0 range 4 .. 4;
14573 Master_V5 at 0 range 5 .. 5;
14574 Master_V6 at 0 range 6 .. 6;
14575 Master_V7 at 0 range 7 .. 7;
14576 Slave_Control at 0 range 8 .. 8;
14577 Slave_V1 at 0 range 9 .. 9;
14578 Slave_V2 at 0 range 10 .. 10;
14579 Slave_V3 at 0 range 11 .. 11;
14580 Slave_V4 at 0 range 12 .. 12;
14581 Slave_V5 at 0 range 13 .. 13;
14582 Slave_V6 at 0 range 14 .. 14;
14583 Slave_V7 at 0 range 15 .. 15;
14584 end record;
14585 @end smallexample
14586
14587 @noindent
14588 This is exactly equivalent to saying (a repeat of the first example):
14589
14590 @smallexample @c ada
14591 for Data'Bit_Order use High_Order_First;
14592 for Data use record
14593 Master_Control at 0 range 0 .. 0;
14594 Master_V1 at 0 range 1 .. 1;
14595 Master_V2 at 0 range 2 .. 2;
14596 Master_V3 at 0 range 3 .. 3;
14597 Master_V4 at 0 range 4 .. 4;
14598 Master_V5 at 0 range 5 .. 5;
14599 Master_V6 at 0 range 6 .. 6;
14600 Master_V7 at 0 range 7 .. 7;
14601 Slave_Control at 1 range 0 .. 0;
14602 Slave_V1 at 1 range 1 .. 1;
14603 Slave_V2 at 1 range 2 .. 2;
14604 Slave_V3 at 1 range 3 .. 3;
14605 Slave_V4 at 1 range 4 .. 4;
14606 Slave_V5 at 1 range 5 .. 5;
14607 Slave_V6 at 1 range 6 .. 6;
14608 Slave_V7 at 1 range 7 .. 7;
14609 end record;
14610 @end smallexample
14611
14612 @noindent
14613 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
14614 field. The storage place attributes are obtained by normalizing the
14615 values given so that the @code{First_Bit} value is less than 8. After
14616 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
14617 we specified in the other case.
14618
14619 Now one might expect that the @code{Bit_Order} attribute might affect
14620 bit numbering within the entire record component (two bytes in this
14621 case, thus affecting which byte fields end up in), but that is not
14622 the way this feature is defined, it only affects numbering of bits,
14623 not which byte they end up in.
14624
14625 Consequently it never makes sense to specify a starting bit number
14626 greater than 7 (for a byte addressable field) if an attribute
14627 definition for @code{Bit_Order} has been given, and indeed it
14628 may be actively confusing to specify such a value, so the compiler
14629 generates a warning for such usage.
14630
14631 If you do need to control byte ordering then appropriate conditional
14632 values must be used. If in our example, the slave byte came first on
14633 some machines we might write:
14634
14635 @smallexample @c ada
14636 Master_Byte_First constant Boolean := @dots{};
14637
14638 Master_Byte : constant Natural :=
14639 1 - Boolean'Pos (Master_Byte_First);
14640 Slave_Byte : constant Natural :=
14641 Boolean'Pos (Master_Byte_First);
14642
14643 for Data'Bit_Order use High_Order_First;
14644 for Data use record
14645 Master_Control at Master_Byte range 0 .. 0;
14646 Master_V1 at Master_Byte range 1 .. 1;
14647 Master_V2 at Master_Byte range 2 .. 2;
14648 Master_V3 at Master_Byte range 3 .. 3;
14649 Master_V4 at Master_Byte range 4 .. 4;
14650 Master_V5 at Master_Byte range 5 .. 5;
14651 Master_V6 at Master_Byte range 6 .. 6;
14652 Master_V7 at Master_Byte range 7 .. 7;
14653 Slave_Control at Slave_Byte range 0 .. 0;
14654 Slave_V1 at Slave_Byte range 1 .. 1;
14655 Slave_V2 at Slave_Byte range 2 .. 2;
14656 Slave_V3 at Slave_Byte range 3 .. 3;
14657 Slave_V4 at Slave_Byte range 4 .. 4;
14658 Slave_V5 at Slave_Byte range 5 .. 5;
14659 Slave_V6 at Slave_Byte range 6 .. 6;
14660 Slave_V7 at Slave_Byte range 7 .. 7;
14661 end record;
14662 @end smallexample
14663
14664 @noindent
14665 Now to switch between machines, all that is necessary is
14666 to set the boolean constant @code{Master_Byte_First} in
14667 an appropriate manner.
14668
14669 @node Pragma Pack for Arrays
14670 @section Pragma Pack for Arrays
14671 @cindex Pragma Pack (for arrays)
14672
14673 @noindent
14674 Pragma @code{Pack} applied to an array has no effect unless the component type
14675 is packable. For a component type to be packable, it must be one of the
14676 following cases:
14677
14678 @itemize @bullet
14679 @item
14680 Any scalar type
14681 @item
14682 Any type whose size is specified with a size clause
14683 @item
14684 Any packed array type with a static size
14685 @item
14686 Any record type padded because of its default alignment
14687 @end itemize
14688
14689 @noindent
14690 For all these cases, if the component subtype size is in the range
14691 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
14692 component size were specified giving the component subtype size.
14693 For example if we have:
14694
14695 @smallexample @c ada
14696 type r is range 0 .. 17;
14697
14698 type ar is array (1 .. 8) of r;
14699 pragma Pack (ar);
14700 @end smallexample
14701
14702 @noindent
14703 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
14704 and the size of the array @code{ar} will be exactly 40 bits.
14705
14706 Note that in some cases this rather fierce approach to packing can produce
14707 unexpected effects. For example, in Ada 95 and Ada 2005,
14708 subtype @code{Natural} typically has a size of 31, meaning that if you
14709 pack an array of @code{Natural}, you get 31-bit
14710 close packing, which saves a few bits, but results in far less efficient
14711 access. Since many other Ada compilers will ignore such a packing request,
14712 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
14713 might not be what is intended. You can easily remove this warning by
14714 using an explicit @code{Component_Size} setting instead, which never generates
14715 a warning, since the intention of the programmer is clear in this case.
14716
14717 GNAT treats packed arrays in one of two ways. If the size of the array is
14718 known at compile time and is less than 64 bits, then internally the array
14719 is represented as a single modular type, of exactly the appropriate number
14720 of bits. If the length is greater than 63 bits, or is not known at compile
14721 time, then the packed array is represented as an array of bytes, and the
14722 length is always a multiple of 8 bits.
14723
14724 Note that to represent a packed array as a modular type, the alignment must
14725 be suitable for the modular type involved. For example, on typical machines
14726 a 32-bit packed array will be represented by a 32-bit modular integer with
14727 an alignment of four bytes. If you explicitly override the default alignment
14728 with an alignment clause that is too small, the modular representation
14729 cannot be used. For example, consider the following set of declarations:
14730
14731 @smallexample @c ada
14732 type R is range 1 .. 3;
14733 type S is array (1 .. 31) of R;
14734 for S'Component_Size use 2;
14735 for S'Size use 62;
14736 for S'Alignment use 1;
14737 @end smallexample
14738
14739 @noindent
14740 If the alignment clause were not present, then a 62-bit modular
14741 representation would be chosen (typically with an alignment of 4 or 8
14742 bytes depending on the target). But the default alignment is overridden
14743 with the explicit alignment clause. This means that the modular
14744 representation cannot be used, and instead the array of bytes
14745 representation must be used, meaning that the length must be a multiple
14746 of 8. Thus the above set of declarations will result in a diagnostic
14747 rejecting the size clause and noting that the minimum size allowed is 64.
14748
14749 @cindex Pragma Pack (for type Natural)
14750 @cindex Pragma Pack warning
14751
14752 One special case that is worth noting occurs when the base type of the
14753 component size is 8/16/32 and the subtype is one bit less. Notably this
14754 occurs with subtype @code{Natural}. Consider:
14755
14756 @smallexample @c ada
14757 type Arr is array (1 .. 32) of Natural;
14758 pragma Pack (Arr);
14759 @end smallexample
14760
14761 @noindent
14762 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
14763 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
14764 Ada 83 compilers did not attempt 31 bit packing.
14765
14766 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
14767 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
14768 substantial unintended performance penalty when porting legacy Ada 83 code.
14769 To help prevent this, GNAT generates a warning in such cases. If you really
14770 want 31 bit packing in a case like this, you can set the component size
14771 explicitly:
14772
14773 @smallexample @c ada
14774 type Arr is array (1 .. 32) of Natural;
14775 for Arr'Component_Size use 31;
14776 @end smallexample
14777
14778 @noindent
14779 Here 31-bit packing is achieved as required, and no warning is generated,
14780 since in this case the programmer intention is clear.
14781
14782 @node Pragma Pack for Records
14783 @section Pragma Pack for Records
14784 @cindex Pragma Pack (for records)
14785
14786 @noindent
14787 Pragma @code{Pack} applied to a record will pack the components to reduce
14788 wasted space from alignment gaps and by reducing the amount of space
14789 taken by components. We distinguish between @emph{packable} components and
14790 @emph{non-packable} components.
14791 Components of the following types are considered packable:
14792 @itemize @bullet
14793 @item
14794 All primitive types are packable.
14795
14796 @item
14797 Small packed arrays, whose size does not exceed 64 bits, and where the
14798 size is statically known at compile time, are represented internally
14799 as modular integers, and so they are also packable.
14800
14801 @end itemize
14802
14803 @noindent
14804 All packable components occupy the exact number of bits corresponding to
14805 their @code{Size} value, and are packed with no padding bits, i.e.@: they
14806 can start on an arbitrary bit boundary.
14807
14808 All other types are non-packable, they occupy an integral number of
14809 storage units, and
14810 are placed at a boundary corresponding to their alignment requirements.
14811
14812 For example, consider the record
14813
14814 @smallexample @c ada
14815 type Rb1 is array (1 .. 13) of Boolean;
14816 pragma Pack (rb1);
14817
14818 type Rb2 is array (1 .. 65) of Boolean;
14819 pragma Pack (rb2);
14820
14821 type x2 is record
14822 l1 : Boolean;
14823 l2 : Duration;
14824 l3 : Float;
14825 l4 : Boolean;
14826 l5 : Rb1;
14827 l6 : Rb2;
14828 end record;
14829 pragma Pack (x2);
14830 @end smallexample
14831
14832 @noindent
14833 The representation for the record x2 is as follows:
14834
14835 @smallexample @c ada
14836 for x2'Size use 224;
14837 for x2 use record
14838 l1 at 0 range 0 .. 0;
14839 l2 at 0 range 1 .. 64;
14840 l3 at 12 range 0 .. 31;
14841 l4 at 16 range 0 .. 0;
14842 l5 at 16 range 1 .. 13;
14843 l6 at 18 range 0 .. 71;
14844 end record;
14845 @end smallexample
14846
14847 @noindent
14848 Studying this example, we see that the packable fields @code{l1}
14849 and @code{l2} are
14850 of length equal to their sizes, and placed at specific bit boundaries (and
14851 not byte boundaries) to
14852 eliminate padding. But @code{l3} is of a non-packable float type, so
14853 it is on the next appropriate alignment boundary.
14854
14855 The next two fields are fully packable, so @code{l4} and @code{l5} are
14856 minimally packed with no gaps. However, type @code{Rb2} is a packed
14857 array that is longer than 64 bits, so it is itself non-packable. Thus
14858 the @code{l6} field is aligned to the next byte boundary, and takes an
14859 integral number of bytes, i.e.@: 72 bits.
14860
14861 @node Record Representation Clauses
14862 @section Record Representation Clauses
14863 @cindex Record Representation Clause
14864
14865 @noindent
14866 Record representation clauses may be given for all record types, including
14867 types obtained by record extension. Component clauses are allowed for any
14868 static component. The restrictions on component clauses depend on the type
14869 of the component.
14870
14871 @cindex Component Clause
14872 For all components of an elementary type, the only restriction on component
14873 clauses is that the size must be at least the 'Size value of the type
14874 (actually the Value_Size). There are no restrictions due to alignment,
14875 and such components may freely cross storage boundaries.
14876
14877 Packed arrays with a size up to and including 64 bits are represented
14878 internally using a modular type with the appropriate number of bits, and
14879 thus the same lack of restriction applies. For example, if you declare:
14880
14881 @smallexample @c ada
14882 type R is array (1 .. 49) of Boolean;
14883 pragma Pack (R);
14884 for R'Size use 49;
14885 @end smallexample
14886
14887 @noindent
14888 then a component clause for a component of type R may start on any
14889 specified bit boundary, and may specify a value of 49 bits or greater.
14890
14891 For packed bit arrays that are longer than 64 bits, there are two
14892 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
14893 including the important case of single bits or boolean values, then
14894 there are no limitations on placement of such components, and they
14895 may start and end at arbitrary bit boundaries.
14896
14897 If the component size is not a power of 2 (e.g.@: 3 or 5), then
14898 an array of this type longer than 64 bits must always be placed on
14899 on a storage unit (byte) boundary and occupy an integral number
14900 of storage units (bytes). Any component clause that does not
14901 meet this requirement will be rejected.
14902
14903 Any aliased component, or component of an aliased type, must
14904 have its normal alignment and size. A component clause that
14905 does not meet this requirement will be rejected.
14906
14907 The tag field of a tagged type always occupies an address sized field at
14908 the start of the record. No component clause may attempt to overlay this
14909 tag. When a tagged type appears as a component, the tag field must have
14910 proper alignment
14911
14912 In the case of a record extension T1, of a type T, no component clause applied
14913 to the type T1 can specify a storage location that would overlap the first
14914 T'Size bytes of the record.
14915
14916 For all other component types, including non-bit-packed arrays,
14917 the component can be placed at an arbitrary bit boundary,
14918 so for example, the following is permitted:
14919
14920 @smallexample @c ada
14921 type R is array (1 .. 10) of Boolean;
14922 for R'Size use 80;
14923
14924 type Q is record
14925 G, H : Boolean;
14926 L, M : R;
14927 end record;
14928
14929 for Q use record
14930 G at 0 range 0 .. 0;
14931 H at 0 range 1 .. 1;
14932 L at 0 range 2 .. 81;
14933 R at 0 range 82 .. 161;
14934 end record;
14935 @end smallexample
14936
14937 @noindent
14938 Note: the above rules apply to recent releases of GNAT 5.
14939 In GNAT 3, there are more severe restrictions on larger components.
14940 For non-primitive types, including packed arrays with a size greater than
14941 64 bits, component clauses must respect the alignment requirement of the
14942 type, in particular, always starting on a byte boundary, and the length
14943 must be a multiple of the storage unit.
14944
14945 @node Enumeration Clauses
14946 @section Enumeration Clauses
14947
14948 The only restriction on enumeration clauses is that the range of values
14949 must be representable. For the signed case, if one or more of the
14950 representation values are negative, all values must be in the range:
14951
14952 @smallexample @c ada
14953 System.Min_Int .. System.Max_Int
14954 @end smallexample
14955
14956 @noindent
14957 For the unsigned case, where all values are nonnegative, the values must
14958 be in the range:
14959
14960 @smallexample @c ada
14961 0 .. System.Max_Binary_Modulus;
14962 @end smallexample
14963
14964 @noindent
14965 A @emph{confirming} representation clause is one in which the values range
14966 from 0 in sequence, i.e.@: a clause that confirms the default representation
14967 for an enumeration type.
14968 Such a confirming representation
14969 is permitted by these rules, and is specially recognized by the compiler so
14970 that no extra overhead results from the use of such a clause.
14971
14972 If an array has an index type which is an enumeration type to which an
14973 enumeration clause has been applied, then the array is stored in a compact
14974 manner. Consider the declarations:
14975
14976 @smallexample @c ada
14977 type r is (A, B, C);
14978 for r use (A => 1, B => 5, C => 10);
14979 type t is array (r) of Character;
14980 @end smallexample
14981
14982 @noindent
14983 The array type t corresponds to a vector with exactly three elements and
14984 has a default size equal to @code{3*Character'Size}. This ensures efficient
14985 use of space, but means that accesses to elements of the array will incur
14986 the overhead of converting representation values to the corresponding
14987 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
14988
14989 @node Address Clauses
14990 @section Address Clauses
14991 @cindex Address Clause
14992
14993 The reference manual allows a general restriction on representation clauses,
14994 as found in RM 13.1(22):
14995
14996 @quotation
14997 An implementation need not support representation
14998 items containing nonstatic expressions, except that
14999 an implementation should support a representation item
15000 for a given entity if each nonstatic expression in the
15001 representation item is a name that statically denotes
15002 a constant declared before the entity.
15003 @end quotation
15004
15005 @noindent
15006 In practice this is applicable only to address clauses, since this is the
15007 only case in which a non-static expression is permitted by the syntax. As
15008 the AARM notes in sections 13.1 (22.a-22.h):
15009
15010 @display
15011 22.a Reason: This is to avoid the following sort of thing:
15012
15013 22.b X : Integer := F(@dots{});
15014 Y : Address := G(@dots{});
15015 for X'Address use Y;
15016
15017 22.c In the above, we have to evaluate the
15018 initialization expression for X before we
15019 know where to put the result. This seems
15020 like an unreasonable implementation burden.
15021
15022 22.d The above code should instead be written
15023 like this:
15024
15025 22.e Y : constant Address := G(@dots{});
15026 X : Integer := F(@dots{});
15027 for X'Address use Y;
15028
15029 22.f This allows the expression ``Y'' to be safely
15030 evaluated before X is created.
15031
15032 22.g The constant could be a formal parameter of mode in.
15033
15034 22.h An implementation can support other nonstatic
15035 expressions if it wants to. Expressions of type
15036 Address are hardly ever static, but their value
15037 might be known at compile time anyway in many
15038 cases.
15039 @end display
15040
15041 @noindent
15042 GNAT does indeed permit many additional cases of non-static expressions. In
15043 particular, if the type involved is elementary there are no restrictions
15044 (since in this case, holding a temporary copy of the initialization value,
15045 if one is present, is inexpensive). In addition, if there is no implicit or
15046 explicit initialization, then there are no restrictions. GNAT will reject
15047 only the case where all three of these conditions hold:
15048
15049 @itemize @bullet
15050
15051 @item
15052 The type of the item is non-elementary (e.g.@: a record or array).
15053
15054 @item
15055 There is explicit or implicit initialization required for the object.
15056 Note that access values are always implicitly initialized.
15057
15058 @item
15059 The address value is non-static. Here GNAT is more permissive than the
15060 RM, and allows the address value to be the address of a previously declared
15061 stand-alone variable, as long as it does not itself have an address clause.
15062
15063 @smallexample @c ada
15064 Anchor : Some_Initialized_Type;
15065 Overlay : Some_Initialized_Type;
15066 for Overlay'Address use Anchor'Address;
15067 @end smallexample
15068
15069 @noindent
15070 However, the prefix of the address clause cannot be an array component, or
15071 a component of a discriminated record.
15072
15073 @end itemize
15074
15075 @noindent
15076 As noted above in section 22.h, address values are typically non-static. In
15077 particular the To_Address function, even if applied to a literal value, is
15078 a non-static function call. To avoid this minor annoyance, GNAT provides
15079 the implementation defined attribute 'To_Address. The following two
15080 expressions have identical values:
15081
15082 @findex Attribute
15083 @findex To_Address
15084 @smallexample @c ada
15085 To_Address (16#1234_0000#)
15086 System'To_Address (16#1234_0000#);
15087 @end smallexample
15088
15089 @noindent
15090 except that the second form is considered to be a static expression, and
15091 thus when used as an address clause value is always permitted.
15092
15093 @noindent
15094 Additionally, GNAT treats as static an address clause that is an
15095 unchecked_conversion of a static integer value. This simplifies the porting
15096 of legacy code, and provides a portable equivalent to the GNAT attribute
15097 @code{To_Address}.
15098
15099 Another issue with address clauses is the interaction with alignment
15100 requirements. When an address clause is given for an object, the address
15101 value must be consistent with the alignment of the object (which is usually
15102 the same as the alignment of the type of the object). If an address clause
15103 is given that specifies an inappropriately aligned address value, then the
15104 program execution is erroneous.
15105
15106 Since this source of erroneous behavior can have unfortunate effects, GNAT
15107 checks (at compile time if possible, generating a warning, or at execution
15108 time with a run-time check) that the alignment is appropriate. If the
15109 run-time check fails, then @code{Program_Error} is raised. This run-time
15110 check is suppressed if range checks are suppressed, or if the special GNAT
15111 check Alignment_Check is suppressed, or if
15112 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
15113
15114 Finally, GNAT does not permit overlaying of objects of controlled types or
15115 composite types containing a controlled component. In most cases, the compiler
15116 can detect an attempt at such overlays and will generate a warning at compile
15117 time and a Program_Error exception at run time.
15118
15119 @findex Export
15120 An address clause cannot be given for an exported object. More
15121 understandably the real restriction is that objects with an address
15122 clause cannot be exported. This is because such variables are not
15123 defined by the Ada program, so there is no external object to export.
15124
15125 @findex Import
15126 It is permissible to give an address clause and a pragma Import for the
15127 same object. In this case, the variable is not really defined by the
15128 Ada program, so there is no external symbol to be linked. The link name
15129 and the external name are ignored in this case. The reason that we allow this
15130 combination is that it provides a useful idiom to avoid unwanted
15131 initializations on objects with address clauses.
15132
15133 When an address clause is given for an object that has implicit or
15134 explicit initialization, then by default initialization takes place. This
15135 means that the effect of the object declaration is to overwrite the
15136 memory at the specified address. This is almost always not what the
15137 programmer wants, so GNAT will output a warning:
15138
15139 @smallexample
15140 with System;
15141 package G is
15142 type R is record
15143 M : Integer := 0;
15144 end record;
15145
15146 Ext : R;
15147 for Ext'Address use System'To_Address (16#1234_1234#);
15148 |
15149 >>> warning: implicit initialization of "Ext" may
15150 modify overlaid storage
15151 >>> warning: use pragma Import for "Ext" to suppress
15152 initialization (RM B(24))
15153
15154 end G;
15155 @end smallexample
15156
15157 @noindent
15158 As indicated by the warning message, the solution is to use a (dummy) pragma
15159 Import to suppress this initialization. The pragma tell the compiler that the
15160 object is declared and initialized elsewhere. The following package compiles
15161 without warnings (and the initialization is suppressed):
15162
15163 @smallexample @c ada
15164 with System;
15165 package G is
15166 type R is record
15167 M : Integer := 0;
15168 end record;
15169
15170 Ext : R;
15171 for Ext'Address use System'To_Address (16#1234_1234#);
15172 pragma Import (Ada, Ext);
15173 end G;
15174 @end smallexample
15175
15176 @noindent
15177 A final issue with address clauses involves their use for overlaying
15178 variables, as in the following example:
15179 @cindex Overlaying of objects
15180
15181 @smallexample @c ada
15182 A : Integer;
15183 B : Integer;
15184 for B'Address use A'Address;
15185 @end smallexample
15186
15187 @noindent
15188 or alternatively, using the form recommended by the RM:
15189
15190 @smallexample @c ada
15191 A : Integer;
15192 Addr : constant Address := A'Address;
15193 B : Integer;
15194 for B'Address use Addr;
15195 @end smallexample
15196
15197 @noindent
15198 In both of these cases, @code{A}
15199 and @code{B} become aliased to one another via the
15200 address clause. This use of address clauses to overlay
15201 variables, achieving an effect similar to unchecked
15202 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
15203 the effect is implementation defined. Furthermore, the
15204 Ada RM specifically recommends that in a situation
15205 like this, @code{B} should be subject to the following
15206 implementation advice (RM 13.3(19)):
15207
15208 @quotation
15209 19 If the Address of an object is specified, or it is imported
15210 or exported, then the implementation should not perform
15211 optimizations based on assumptions of no aliases.
15212 @end quotation
15213
15214 @noindent
15215 GNAT follows this recommendation, and goes further by also applying
15216 this recommendation to the overlaid variable (@code{A}
15217 in the above example) in this case. This means that the overlay
15218 works "as expected", in that a modification to one of the variables
15219 will affect the value of the other.
15220
15221 @node Effect of Convention on Representation
15222 @section Effect of Convention on Representation
15223 @cindex Convention, effect on representation
15224
15225 @noindent
15226 Normally the specification of a foreign language convention for a type or
15227 an object has no effect on the chosen representation. In particular, the
15228 representation chosen for data in GNAT generally meets the standard system
15229 conventions, and for example records are laid out in a manner that is
15230 consistent with C@. This means that specifying convention C (for example)
15231 has no effect.
15232
15233 There are four exceptions to this general rule:
15234
15235 @itemize @bullet
15236
15237 @item Convention Fortran and array subtypes
15238 If pragma Convention Fortran is specified for an array subtype, then in
15239 accordance with the implementation advice in section 3.6.2(11) of the
15240 Ada Reference Manual, the array will be stored in a Fortran-compatible
15241 column-major manner, instead of the normal default row-major order.
15242
15243 @item Convention C and enumeration types
15244 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
15245 to accommodate all values of the type. For example, for the enumeration
15246 type declared by:
15247
15248 @smallexample @c ada
15249 type Color is (Red, Green, Blue);
15250 @end smallexample
15251
15252 @noindent
15253 8 bits is sufficient to store all values of the type, so by default, objects
15254 of type @code{Color} will be represented using 8 bits. However, normal C
15255 convention is to use 32 bits for all enum values in C, since enum values
15256 are essentially of type int. If pragma @code{Convention C} is specified for an
15257 Ada enumeration type, then the size is modified as necessary (usually to
15258 32 bits) to be consistent with the C convention for enum values.
15259
15260 Note that this treatment applies only to types. If Convention C is given for
15261 an enumeration object, where the enumeration type is not Convention C, then
15262 Object_Size bits are allocated. For example, for a normal enumeration type,
15263 with less than 256 elements, only 8 bits will be allocated for the object.
15264 Since this may be a surprise in terms of what C expects, GNAT will issue a
15265 warning in this situation. The warning can be suppressed by giving an explicit
15266 size clause specifying the desired size.
15267
15268 @item Convention C/Fortran and Boolean types
15269 In C, the usual convention for boolean values, that is values used for
15270 conditions, is that zero represents false, and nonzero values represent
15271 true. In Ada, the normal convention is that two specific values, typically
15272 0/1, are used to represent false/true respectively.
15273
15274 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
15275 value represents true).
15276
15277 To accommodate the Fortran and C conventions, if a pragma Convention specifies
15278 C or Fortran convention for a derived Boolean, as in the following example:
15279
15280 @smallexample @c ada
15281 type C_Switch is new Boolean;
15282 pragma Convention (C, C_Switch);
15283 @end smallexample
15284
15285 @noindent
15286 then the GNAT generated code will treat any nonzero value as true. For truth
15287 values generated by GNAT, the conventional value 1 will be used for True, but
15288 when one of these values is read, any nonzero value is treated as True.
15289
15290 @item Access types on OpenVMS
15291 For 64-bit OpenVMS systems, access types (other than those for unconstrained
15292 arrays) are 64-bits long. An exception to this rule is for the case of
15293 C-convention access types where there is no explicit size clause present (or
15294 inherited for derived types). In this case, GNAT chooses to make these
15295 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
15296 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
15297
15298 @end itemize
15299
15300 @node Determining the Representations chosen by GNAT
15301 @section Determining the Representations chosen by GNAT
15302 @cindex Representation, determination of
15303 @cindex @option{-gnatR} switch
15304
15305 @noindent
15306 Although the descriptions in this section are intended to be complete, it is
15307 often easier to simply experiment to see what GNAT accepts and what the
15308 effect is on the layout of types and objects.
15309
15310 As required by the Ada RM, if a representation clause is not accepted, then
15311 it must be rejected as illegal by the compiler. However, when a
15312 representation clause or pragma is accepted, there can still be questions
15313 of what the compiler actually does. For example, if a partial record
15314 representation clause specifies the location of some components and not
15315 others, then where are the non-specified components placed? Or if pragma
15316 @code{Pack} is used on a record, then exactly where are the resulting
15317 fields placed? The section on pragma @code{Pack} in this chapter can be
15318 used to answer the second question, but it is often easier to just see
15319 what the compiler does.
15320
15321 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
15322 with this option, then the compiler will output information on the actual
15323 representations chosen, in a format similar to source representation
15324 clauses. For example, if we compile the package:
15325
15326 @smallexample @c ada
15327 package q is
15328 type r (x : boolean) is tagged record
15329 case x is
15330 when True => S : String (1 .. 100);
15331 when False => null;
15332 end case;
15333 end record;
15334
15335 type r2 is new r (false) with record
15336 y2 : integer;
15337 end record;
15338
15339 for r2 use record
15340 y2 at 16 range 0 .. 31;
15341 end record;
15342
15343 type x is record
15344 y : character;
15345 end record;
15346
15347 type x1 is array (1 .. 10) of x;
15348 for x1'component_size use 11;
15349
15350 type ia is access integer;
15351
15352 type Rb1 is array (1 .. 13) of Boolean;
15353 pragma Pack (rb1);
15354
15355 type Rb2 is array (1 .. 65) of Boolean;
15356 pragma Pack (rb2);
15357
15358 type x2 is record
15359 l1 : Boolean;
15360 l2 : Duration;
15361 l3 : Float;
15362 l4 : Boolean;
15363 l5 : Rb1;
15364 l6 : Rb2;
15365 end record;
15366 pragma Pack (x2);
15367 end q;
15368 @end smallexample
15369
15370 @noindent
15371 using the switch @option{-gnatR} we obtain the following output:
15372
15373 @smallexample
15374 Representation information for unit q
15375 -------------------------------------
15376
15377 for r'Size use ??;
15378 for r'Alignment use 4;
15379 for r use record
15380 x at 4 range 0 .. 7;
15381 _tag at 0 range 0 .. 31;
15382 s at 5 range 0 .. 799;
15383 end record;
15384
15385 for r2'Size use 160;
15386 for r2'Alignment use 4;
15387 for r2 use record
15388 x at 4 range 0 .. 7;
15389 _tag at 0 range 0 .. 31;
15390 _parent at 0 range 0 .. 63;
15391 y2 at 16 range 0 .. 31;
15392 end record;
15393
15394 for x'Size use 8;
15395 for x'Alignment use 1;
15396 for x use record
15397 y at 0 range 0 .. 7;
15398 end record;
15399
15400 for x1'Size use 112;
15401 for x1'Alignment use 1;
15402 for x1'Component_Size use 11;
15403
15404 for rb1'Size use 13;
15405 for rb1'Alignment use 2;
15406 for rb1'Component_Size use 1;
15407
15408 for rb2'Size use 72;
15409 for rb2'Alignment use 1;
15410 for rb2'Component_Size use 1;
15411
15412 for x2'Size use 224;
15413 for x2'Alignment use 4;
15414 for x2 use record
15415 l1 at 0 range 0 .. 0;
15416 l2 at 0 range 1 .. 64;
15417 l3 at 12 range 0 .. 31;
15418 l4 at 16 range 0 .. 0;
15419 l5 at 16 range 1 .. 13;
15420 l6 at 18 range 0 .. 71;
15421 end record;
15422 @end smallexample
15423
15424 @noindent
15425 The Size values are actually the Object_Size, i.e.@: the default size that
15426 will be allocated for objects of the type.
15427 The ?? size for type r indicates that we have a variant record, and the
15428 actual size of objects will depend on the discriminant value.
15429
15430 The Alignment values show the actual alignment chosen by the compiler
15431 for each record or array type.
15432
15433 The record representation clause for type r shows where all fields
15434 are placed, including the compiler generated tag field (whose location
15435 cannot be controlled by the programmer).
15436
15437 The record representation clause for the type extension r2 shows all the
15438 fields present, including the parent field, which is a copy of the fields
15439 of the parent type of r2, i.e.@: r1.
15440
15441 The component size and size clauses for types rb1 and rb2 show
15442 the exact effect of pragma @code{Pack} on these arrays, and the record
15443 representation clause for type x2 shows how pragma @code{Pack} affects
15444 this record type.
15445
15446 In some cases, it may be useful to cut and paste the representation clauses
15447 generated by the compiler into the original source to fix and guarantee
15448 the actual representation to be used.
15449
15450 @node Standard Library Routines
15451 @chapter Standard Library Routines
15452
15453 @noindent
15454 The Ada Reference Manual contains in Annex A a full description of an
15455 extensive set of standard library routines that can be used in any Ada
15456 program, and which must be provided by all Ada compilers. They are
15457 analogous to the standard C library used by C programs.
15458
15459 GNAT implements all of the facilities described in annex A, and for most
15460 purposes the description in the Ada Reference Manual, or appropriate Ada
15461 text book, will be sufficient for making use of these facilities.
15462
15463 In the case of the input-output facilities,
15464 @xref{The Implementation of Standard I/O},
15465 gives details on exactly how GNAT interfaces to the
15466 file system. For the remaining packages, the Ada Reference Manual
15467 should be sufficient. The following is a list of the packages included,
15468 together with a brief description of the functionality that is provided.
15469
15470 For completeness, references are included to other predefined library
15471 routines defined in other sections of the Ada Reference Manual (these are
15472 cross-indexed from Annex A).
15473
15474 @table @code
15475 @item Ada (A.2)
15476 This is a parent package for all the standard library packages. It is
15477 usually included implicitly in your program, and itself contains no
15478 useful data or routines.
15479
15480 @item Ada.Calendar (9.6)
15481 @code{Calendar} provides time of day access, and routines for
15482 manipulating times and durations.
15483
15484 @item Ada.Characters (A.3.1)
15485 This is a dummy parent package that contains no useful entities
15486
15487 @item Ada.Characters.Handling (A.3.2)
15488 This package provides some basic character handling capabilities,
15489 including classification functions for classes of characters (e.g.@: test
15490 for letters, or digits).
15491
15492 @item Ada.Characters.Latin_1 (A.3.3)
15493 This package includes a complete set of definitions of the characters
15494 that appear in type CHARACTER@. It is useful for writing programs that
15495 will run in international environments. For example, if you want an
15496 upper case E with an acute accent in a string, it is often better to use
15497 the definition of @code{UC_E_Acute} in this package. Then your program
15498 will print in an understandable manner even if your environment does not
15499 support these extended characters.
15500
15501 @item Ada.Command_Line (A.15)
15502 This package provides access to the command line parameters and the name
15503 of the current program (analogous to the use of @code{argc} and @code{argv}
15504 in C), and also allows the exit status for the program to be set in a
15505 system-independent manner.
15506
15507 @item Ada.Decimal (F.2)
15508 This package provides constants describing the range of decimal numbers
15509 implemented, and also a decimal divide routine (analogous to the COBOL
15510 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
15511
15512 @item Ada.Direct_IO (A.8.4)
15513 This package provides input-output using a model of a set of records of
15514 fixed-length, containing an arbitrary definite Ada type, indexed by an
15515 integer record number.
15516
15517 @item Ada.Dynamic_Priorities (D.5)
15518 This package allows the priorities of a task to be adjusted dynamically
15519 as the task is running.
15520
15521 @item Ada.Exceptions (11.4.1)
15522 This package provides additional information on exceptions, and also
15523 contains facilities for treating exceptions as data objects, and raising
15524 exceptions with associated messages.
15525
15526 @item Ada.Finalization (7.6)
15527 This package contains the declarations and subprograms to support the
15528 use of controlled types, providing for automatic initialization and
15529 finalization (analogous to the constructors and destructors of C++)
15530
15531 @item Ada.Interrupts (C.3.2)
15532 This package provides facilities for interfacing to interrupts, which
15533 includes the set of signals or conditions that can be raised and
15534 recognized as interrupts.
15535
15536 @item Ada.Interrupts.Names (C.3.2)
15537 This package provides the set of interrupt names (actually signal
15538 or condition names) that can be handled by GNAT@.
15539
15540 @item Ada.IO_Exceptions (A.13)
15541 This package defines the set of exceptions that can be raised by use of
15542 the standard IO packages.
15543
15544 @item Ada.Numerics
15545 This package contains some standard constants and exceptions used
15546 throughout the numerics packages. Note that the constants pi and e are
15547 defined here, and it is better to use these definitions than rolling
15548 your own.
15549
15550 @item Ada.Numerics.Complex_Elementary_Functions
15551 Provides the implementation of standard elementary functions (such as
15552 log and trigonometric functions) operating on complex numbers using the
15553 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
15554 created by the package @code{Numerics.Complex_Types}.
15555
15556 @item Ada.Numerics.Complex_Types
15557 This is a predefined instantiation of
15558 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
15559 build the type @code{Complex} and @code{Imaginary}.
15560
15561 @item Ada.Numerics.Discrete_Random
15562 This generic package provides a random number generator suitable for generating
15563 uniformly distributed values of a specified discrete subtype.
15564
15565 @item Ada.Numerics.Float_Random
15566 This package provides a random number generator suitable for generating
15567 uniformly distributed floating point values in the unit interval.
15568
15569 @item Ada.Numerics.Generic_Complex_Elementary_Functions
15570 This is a generic version of the package that provides the
15571 implementation of standard elementary functions (such as log and
15572 trigonometric functions) for an arbitrary complex type.
15573
15574 The following predefined instantiations of this package are provided:
15575
15576 @table @code
15577 @item Short_Float
15578 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
15579 @item Float
15580 @code{Ada.Numerics.Complex_Elementary_Functions}
15581 @item Long_Float
15582 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
15583 @end table
15584
15585 @item Ada.Numerics.Generic_Complex_Types
15586 This is a generic package that allows the creation of complex types,
15587 with associated complex arithmetic operations.
15588
15589 The following predefined instantiations of this package exist
15590 @table @code
15591 @item Short_Float
15592 @code{Ada.Numerics.Short_Complex_Complex_Types}
15593 @item Float
15594 @code{Ada.Numerics.Complex_Complex_Types}
15595 @item Long_Float
15596 @code{Ada.Numerics.Long_Complex_Complex_Types}
15597 @end table
15598
15599 @item Ada.Numerics.Generic_Elementary_Functions
15600 This is a generic package that provides the implementation of standard
15601 elementary functions (such as log an trigonometric functions) for an
15602 arbitrary float type.
15603
15604 The following predefined instantiations of this package exist
15605
15606 @table @code
15607 @item Short_Float
15608 @code{Ada.Numerics.Short_Elementary_Functions}
15609 @item Float
15610 @code{Ada.Numerics.Elementary_Functions}
15611 @item Long_Float
15612 @code{Ada.Numerics.Long_Elementary_Functions}
15613 @end table
15614
15615 @item Ada.Real_Time (D.8)
15616 This package provides facilities similar to those of @code{Calendar}, but
15617 operating with a finer clock suitable for real time control. Note that
15618 annex D requires that there be no backward clock jumps, and GNAT generally
15619 guarantees this behavior, but of course if the external clock on which
15620 the GNAT runtime depends is deliberately reset by some external event,
15621 then such a backward jump may occur.
15622
15623 @item Ada.Sequential_IO (A.8.1)
15624 This package provides input-output facilities for sequential files,
15625 which can contain a sequence of values of a single type, which can be
15626 any Ada type, including indefinite (unconstrained) types.
15627
15628 @item Ada.Storage_IO (A.9)
15629 This package provides a facility for mapping arbitrary Ada types to and
15630 from a storage buffer. It is primarily intended for the creation of new
15631 IO packages.
15632
15633 @item Ada.Streams (13.13.1)
15634 This is a generic package that provides the basic support for the
15635 concept of streams as used by the stream attributes (@code{Input},
15636 @code{Output}, @code{Read} and @code{Write}).
15637
15638 @item Ada.Streams.Stream_IO (A.12.1)
15639 This package is a specialization of the type @code{Streams} defined in
15640 package @code{Streams} together with a set of operations providing
15641 Stream_IO capability. The Stream_IO model permits both random and
15642 sequential access to a file which can contain an arbitrary set of values
15643 of one or more Ada types.
15644
15645 @item Ada.Strings (A.4.1)
15646 This package provides some basic constants used by the string handling
15647 packages.
15648
15649 @item Ada.Strings.Bounded (A.4.4)
15650 This package provides facilities for handling variable length
15651 strings. The bounded model requires a maximum length. It is thus
15652 somewhat more limited than the unbounded model, but avoids the use of
15653 dynamic allocation or finalization.
15654
15655 @item Ada.Strings.Fixed (A.4.3)
15656 This package provides facilities for handling fixed length strings.
15657
15658 @item Ada.Strings.Maps (A.4.2)
15659 This package provides facilities for handling character mappings and
15660 arbitrarily defined subsets of characters. For instance it is useful in
15661 defining specialized translation tables.
15662
15663 @item Ada.Strings.Maps.Constants (A.4.6)
15664 This package provides a standard set of predefined mappings and
15665 predefined character sets. For example, the standard upper to lower case
15666 conversion table is found in this package. Note that upper to lower case
15667 conversion is non-trivial if you want to take the entire set of
15668 characters, including extended characters like E with an acute accent,
15669 into account. You should use the mappings in this package (rather than
15670 adding 32 yourself) to do case mappings.
15671
15672 @item Ada.Strings.Unbounded (A.4.5)
15673 This package provides facilities for handling variable length
15674 strings. The unbounded model allows arbitrary length strings, but
15675 requires the use of dynamic allocation and finalization.
15676
15677 @item Ada.Strings.Wide_Bounded (A.4.7)
15678 @itemx Ada.Strings.Wide_Fixed (A.4.7)
15679 @itemx Ada.Strings.Wide_Maps (A.4.7)
15680 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
15681 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
15682 These packages provide analogous capabilities to the corresponding
15683 packages without @samp{Wide_} in the name, but operate with the types
15684 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
15685 and @code{Character}.
15686
15687 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
15688 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
15689 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
15690 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
15691 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
15692 These packages provide analogous capabilities to the corresponding
15693 packages without @samp{Wide_} in the name, but operate with the types
15694 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
15695 of @code{String} and @code{Character}.
15696
15697 @item Ada.Synchronous_Task_Control (D.10)
15698 This package provides some standard facilities for controlling task
15699 communication in a synchronous manner.
15700
15701 @item Ada.Tags
15702 This package contains definitions for manipulation of the tags of tagged
15703 values.
15704
15705 @item Ada.Task_Attributes
15706 This package provides the capability of associating arbitrary
15707 task-specific data with separate tasks.
15708
15709 @item Ada.Text_IO
15710 This package provides basic text input-output capabilities for
15711 character, string and numeric data. The subpackages of this
15712 package are listed next.
15713
15714 @item Ada.Text_IO.Decimal_IO
15715 Provides input-output facilities for decimal fixed-point types
15716
15717 @item Ada.Text_IO.Enumeration_IO
15718 Provides input-output facilities for enumeration types.
15719
15720 @item Ada.Text_IO.Fixed_IO
15721 Provides input-output facilities for ordinary fixed-point types.
15722
15723 @item Ada.Text_IO.Float_IO
15724 Provides input-output facilities for float types. The following
15725 predefined instantiations of this generic package are available:
15726
15727 @table @code
15728 @item Short_Float
15729 @code{Short_Float_Text_IO}
15730 @item Float
15731 @code{Float_Text_IO}
15732 @item Long_Float
15733 @code{Long_Float_Text_IO}
15734 @end table
15735
15736 @item Ada.Text_IO.Integer_IO
15737 Provides input-output facilities for integer types. The following
15738 predefined instantiations of this generic package are available:
15739
15740 @table @code
15741 @item Short_Short_Integer
15742 @code{Ada.Short_Short_Integer_Text_IO}
15743 @item Short_Integer
15744 @code{Ada.Short_Integer_Text_IO}
15745 @item Integer
15746 @code{Ada.Integer_Text_IO}
15747 @item Long_Integer
15748 @code{Ada.Long_Integer_Text_IO}
15749 @item Long_Long_Integer
15750 @code{Ada.Long_Long_Integer_Text_IO}
15751 @end table
15752
15753 @item Ada.Text_IO.Modular_IO
15754 Provides input-output facilities for modular (unsigned) types
15755
15756 @item Ada.Text_IO.Complex_IO (G.1.3)
15757 This package provides basic text input-output capabilities for complex
15758 data.
15759
15760 @item Ada.Text_IO.Editing (F.3.3)
15761 This package contains routines for edited output, analogous to the use
15762 of pictures in COBOL@. The picture formats used by this package are a
15763 close copy of the facility in COBOL@.
15764
15765 @item Ada.Text_IO.Text_Streams (A.12.2)
15766 This package provides a facility that allows Text_IO files to be treated
15767 as streams, so that the stream attributes can be used for writing
15768 arbitrary data, including binary data, to Text_IO files.
15769
15770 @item Ada.Unchecked_Conversion (13.9)
15771 This generic package allows arbitrary conversion from one type to
15772 another of the same size, providing for breaking the type safety in
15773 special circumstances.
15774
15775 If the types have the same Size (more accurately the same Value_Size),
15776 then the effect is simply to transfer the bits from the source to the
15777 target type without any modification. This usage is well defined, and
15778 for simple types whose representation is typically the same across
15779 all implementations, gives a portable method of performing such
15780 conversions.
15781
15782 If the types do not have the same size, then the result is implementation
15783 defined, and thus may be non-portable. The following describes how GNAT
15784 handles such unchecked conversion cases.
15785
15786 If the types are of different sizes, and are both discrete types, then
15787 the effect is of a normal type conversion without any constraint checking.
15788 In particular if the result type has a larger size, the result will be
15789 zero or sign extended. If the result type has a smaller size, the result
15790 will be truncated by ignoring high order bits.
15791
15792 If the types are of different sizes, and are not both discrete types,
15793 then the conversion works as though pointers were created to the source
15794 and target, and the pointer value is converted. The effect is that bits
15795 are copied from successive low order storage units and bits of the source
15796 up to the length of the target type.
15797
15798 A warning is issued if the lengths differ, since the effect in this
15799 case is implementation dependent, and the above behavior may not match
15800 that of some other compiler.
15801
15802 A pointer to one type may be converted to a pointer to another type using
15803 unchecked conversion. The only case in which the effect is undefined is
15804 when one or both pointers are pointers to unconstrained array types. In
15805 this case, the bounds information may get incorrectly transferred, and in
15806 particular, GNAT uses double size pointers for such types, and it is
15807 meaningless to convert between such pointer types. GNAT will issue a
15808 warning if the alignment of the target designated type is more strict
15809 than the alignment of the source designated type (since the result may
15810 be unaligned in this case).
15811
15812 A pointer other than a pointer to an unconstrained array type may be
15813 converted to and from System.Address. Such usage is common in Ada 83
15814 programs, but note that Ada.Address_To_Access_Conversions is the
15815 preferred method of performing such conversions in Ada 95 and Ada 2005.
15816 Neither
15817 unchecked conversion nor Ada.Address_To_Access_Conversions should be
15818 used in conjunction with pointers to unconstrained objects, since
15819 the bounds information cannot be handled correctly in this case.
15820
15821 @item Ada.Unchecked_Deallocation (13.11.2)
15822 This generic package allows explicit freeing of storage previously
15823 allocated by use of an allocator.
15824
15825 @item Ada.Wide_Text_IO (A.11)
15826 This package is similar to @code{Ada.Text_IO}, except that the external
15827 file supports wide character representations, and the internal types are
15828 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
15829 and @code{String}. It contains generic subpackages listed next.
15830
15831 @item Ada.Wide_Text_IO.Decimal_IO
15832 Provides input-output facilities for decimal fixed-point types
15833
15834 @item Ada.Wide_Text_IO.Enumeration_IO
15835 Provides input-output facilities for enumeration types.
15836
15837 @item Ada.Wide_Text_IO.Fixed_IO
15838 Provides input-output facilities for ordinary fixed-point types.
15839
15840 @item Ada.Wide_Text_IO.Float_IO
15841 Provides input-output facilities for float types. The following
15842 predefined instantiations of this generic package are available:
15843
15844 @table @code
15845 @item Short_Float
15846 @code{Short_Float_Wide_Text_IO}
15847 @item Float
15848 @code{Float_Wide_Text_IO}
15849 @item Long_Float
15850 @code{Long_Float_Wide_Text_IO}
15851 @end table
15852
15853 @item Ada.Wide_Text_IO.Integer_IO
15854 Provides input-output facilities for integer types. The following
15855 predefined instantiations of this generic package are available:
15856
15857 @table @code
15858 @item Short_Short_Integer
15859 @code{Ada.Short_Short_Integer_Wide_Text_IO}
15860 @item Short_Integer
15861 @code{Ada.Short_Integer_Wide_Text_IO}
15862 @item Integer
15863 @code{Ada.Integer_Wide_Text_IO}
15864 @item Long_Integer
15865 @code{Ada.Long_Integer_Wide_Text_IO}
15866 @item Long_Long_Integer
15867 @code{Ada.Long_Long_Integer_Wide_Text_IO}
15868 @end table
15869
15870 @item Ada.Wide_Text_IO.Modular_IO
15871 Provides input-output facilities for modular (unsigned) types
15872
15873 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
15874 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
15875 external file supports wide character representations.
15876
15877 @item Ada.Wide_Text_IO.Editing (F.3.4)
15878 This package is similar to @code{Ada.Text_IO.Editing}, except that the
15879 types are @code{Wide_Character} and @code{Wide_String} instead of
15880 @code{Character} and @code{String}.
15881
15882 @item Ada.Wide_Text_IO.Streams (A.12.3)
15883 This package is similar to @code{Ada.Text_IO.Streams}, except that the
15884 types are @code{Wide_Character} and @code{Wide_String} instead of
15885 @code{Character} and @code{String}.
15886
15887 @item Ada.Wide_Wide_Text_IO (A.11)
15888 This package is similar to @code{Ada.Text_IO}, except that the external
15889 file supports wide character representations, and the internal types are
15890 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
15891 and @code{String}. It contains generic subpackages listed next.
15892
15893 @item Ada.Wide_Wide_Text_IO.Decimal_IO
15894 Provides input-output facilities for decimal fixed-point types
15895
15896 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
15897 Provides input-output facilities for enumeration types.
15898
15899 @item Ada.Wide_Wide_Text_IO.Fixed_IO
15900 Provides input-output facilities for ordinary fixed-point types.
15901
15902 @item Ada.Wide_Wide_Text_IO.Float_IO
15903 Provides input-output facilities for float types. The following
15904 predefined instantiations of this generic package are available:
15905
15906 @table @code
15907 @item Short_Float
15908 @code{Short_Float_Wide_Wide_Text_IO}
15909 @item Float
15910 @code{Float_Wide_Wide_Text_IO}
15911 @item Long_Float
15912 @code{Long_Float_Wide_Wide_Text_IO}
15913 @end table
15914
15915 @item Ada.Wide_Wide_Text_IO.Integer_IO
15916 Provides input-output facilities for integer types. The following
15917 predefined instantiations of this generic package are available:
15918
15919 @table @code
15920 @item Short_Short_Integer
15921 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
15922 @item Short_Integer
15923 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
15924 @item Integer
15925 @code{Ada.Integer_Wide_Wide_Text_IO}
15926 @item Long_Integer
15927 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
15928 @item Long_Long_Integer
15929 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
15930 @end table
15931
15932 @item Ada.Wide_Wide_Text_IO.Modular_IO
15933 Provides input-output facilities for modular (unsigned) types
15934
15935 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
15936 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
15937 external file supports wide character representations.
15938
15939 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
15940 This package is similar to @code{Ada.Text_IO.Editing}, except that the
15941 types are @code{Wide_Character} and @code{Wide_String} instead of
15942 @code{Character} and @code{String}.
15943
15944 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
15945 This package is similar to @code{Ada.Text_IO.Streams}, except that the
15946 types are @code{Wide_Character} and @code{Wide_String} instead of
15947 @code{Character} and @code{String}.
15948 @end table
15949
15950 @node The Implementation of Standard I/O
15951 @chapter The Implementation of Standard I/O
15952
15953 @noindent
15954 GNAT implements all the required input-output facilities described in
15955 A.6 through A.14. These sections of the Ada Reference Manual describe the
15956 required behavior of these packages from the Ada point of view, and if
15957 you are writing a portable Ada program that does not need to know the
15958 exact manner in which Ada maps to the outside world when it comes to
15959 reading or writing external files, then you do not need to read this
15960 chapter. As long as your files are all regular files (not pipes or
15961 devices), and as long as you write and read the files only from Ada, the
15962 description in the Ada Reference Manual is sufficient.
15963
15964 However, if you want to do input-output to pipes or other devices, such
15965 as the keyboard or screen, or if the files you are dealing with are
15966 either generated by some other language, or to be read by some other
15967 language, then you need to know more about the details of how the GNAT
15968 implementation of these input-output facilities behaves.
15969
15970 In this chapter we give a detailed description of exactly how GNAT
15971 interfaces to the file system. As always, the sources of the system are
15972 available to you for answering questions at an even more detailed level,
15973 but for most purposes the information in this chapter will suffice.
15974
15975 Another reason that you may need to know more about how input-output is
15976 implemented arises when you have a program written in mixed languages
15977 where, for example, files are shared between the C and Ada sections of
15978 the same program. GNAT provides some additional facilities, in the form
15979 of additional child library packages, that facilitate this sharing, and
15980 these additional facilities are also described in this chapter.
15981
15982 @menu
15983 * Standard I/O Packages::
15984 * FORM Strings::
15985 * Direct_IO::
15986 * Sequential_IO::
15987 * Text_IO::
15988 * Wide_Text_IO::
15989 * Wide_Wide_Text_IO::
15990 * Stream_IO::
15991 * Text Translation::
15992 * Shared Files::
15993 * Filenames encoding::
15994 * Open Modes::
15995 * Operations on C Streams::
15996 * Interfacing to C Streams::
15997 @end menu
15998
15999 @node Standard I/O Packages
16000 @section Standard I/O Packages
16001
16002 @noindent
16003 The Standard I/O packages described in Annex A for
16004
16005 @itemize @bullet
16006 @item
16007 Ada.Text_IO
16008 @item
16009 Ada.Text_IO.Complex_IO
16010 @item
16011 Ada.Text_IO.Text_Streams
16012 @item
16013 Ada.Wide_Text_IO
16014 @item
16015 Ada.Wide_Text_IO.Complex_IO
16016 @item
16017 Ada.Wide_Text_IO.Text_Streams
16018 @item
16019 Ada.Wide_Wide_Text_IO
16020 @item
16021 Ada.Wide_Wide_Text_IO.Complex_IO
16022 @item
16023 Ada.Wide_Wide_Text_IO.Text_Streams
16024 @item
16025 Ada.Stream_IO
16026 @item
16027 Ada.Sequential_IO
16028 @item
16029 Ada.Direct_IO
16030 @end itemize
16031
16032 @noindent
16033 are implemented using the C
16034 library streams facility; where
16035
16036 @itemize @bullet
16037 @item
16038 All files are opened using @code{fopen}.
16039 @item
16040 All input/output operations use @code{fread}/@code{fwrite}.
16041 @end itemize
16042
16043 @noindent
16044 There is no internal buffering of any kind at the Ada library level. The only
16045 buffering is that provided at the system level in the implementation of the
16046 library routines that support streams. This facilitates shared use of these
16047 streams by mixed language programs. Note though that system level buffering is
16048 explicitly enabled at elaboration of the standard I/O packages and that can
16049 have an impact on mixed language programs, in particular those using I/O before
16050 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
16051 the Ada elaboration routine before performing any I/O or when impractical,
16052 flush the common I/O streams and in particular Standard_Output before
16053 elaborating the Ada code.
16054
16055 @node FORM Strings
16056 @section FORM Strings
16057
16058 @noindent
16059 The format of a FORM string in GNAT is:
16060
16061 @smallexample
16062 "keyword=value,keyword=value,@dots{},keyword=value"
16063 @end smallexample
16064
16065 @noindent
16066 where letters may be in upper or lower case, and there are no spaces
16067 between values. The order of the entries is not important. Currently
16068 the following keywords defined.
16069
16070 @smallexample
16071 TEXT_TRANSLATION=[YES|NO]
16072 SHARED=[YES|NO]
16073 WCEM=[n|h|u|s|e|8|b]
16074 ENCODING=[UTF8|8BITS]
16075 @end smallexample
16076
16077 @noindent
16078 The use of these parameters is described later in this section. If an
16079 unrecognized keyword appears in a form string, it is silently ignored
16080 and not considered invalid.
16081
16082 @noindent
16083 For OpenVMS additional FORM string keywords are available for use with
16084 RMS services. The syntax is:
16085
16086 @smallexample
16087 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
16088 @end smallexample
16089
16090 @noindent
16091 The following RMS keywords and values are currently defined:
16092
16093 @smallexample
16094 Context=Force_Stream_Mode|Force_Record_Mode
16095 @end smallexample
16096
16097 @noindent
16098 VMS RMS keys are silently ignored on non-VMS systems. On OpenVMS
16099 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
16100
16101 @node Direct_IO
16102 @section Direct_IO
16103
16104 @noindent
16105 Direct_IO can only be instantiated for definite types. This is a
16106 restriction of the Ada language, which means that the records are fixed
16107 length (the length being determined by @code{@var{type}'Size}, rounded
16108 up to the next storage unit boundary if necessary).
16109
16110 The records of a Direct_IO file are simply written to the file in index
16111 sequence, with the first record starting at offset zero, and subsequent
16112 records following. There is no control information of any kind. For
16113 example, if 32-bit integers are being written, each record takes
16114 4-bytes, so the record at index @var{K} starts at offset
16115 (@var{K}@minus{}1)*4.
16116
16117 There is no limit on the size of Direct_IO files, they are expanded as
16118 necessary to accommodate whatever records are written to the file.
16119
16120 @node Sequential_IO
16121 @section Sequential_IO
16122
16123 @noindent
16124 Sequential_IO may be instantiated with either a definite (constrained)
16125 or indefinite (unconstrained) type.
16126
16127 For the definite type case, the elements written to the file are simply
16128 the memory images of the data values with no control information of any
16129 kind. The resulting file should be read using the same type, no validity
16130 checking is performed on input.
16131
16132 For the indefinite type case, the elements written consist of two
16133 parts. First is the size of the data item, written as the memory image
16134 of a @code{Interfaces.C.size_t} value, followed by the memory image of
16135 the data value. The resulting file can only be read using the same
16136 (unconstrained) type. Normal assignment checks are performed on these
16137 read operations, and if these checks fail, @code{Data_Error} is
16138 raised. In particular, in the array case, the lengths must match, and in
16139 the variant record case, if the variable for a particular read operation
16140 is constrained, the discriminants must match.
16141
16142 Note that it is not possible to use Sequential_IO to write variable
16143 length array items, and then read the data back into different length
16144 arrays. For example, the following will raise @code{Data_Error}:
16145
16146 @smallexample @c ada
16147 package IO is new Sequential_IO (String);
16148 F : IO.File_Type;
16149 S : String (1..4);
16150 @dots{}
16151 IO.Create (F)
16152 IO.Write (F, "hello!")
16153 IO.Reset (F, Mode=>In_File);
16154 IO.Read (F, S);
16155 Put_Line (S);
16156
16157 @end smallexample
16158
16159 @noindent
16160 On some Ada implementations, this will print @code{hell}, but the program is
16161 clearly incorrect, since there is only one element in the file, and that
16162 element is the string @code{hello!}.
16163
16164 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
16165 using Stream_IO, and this is the preferred mechanism. In particular, the
16166 above program fragment rewritten to use Stream_IO will work correctly.
16167
16168 @node Text_IO
16169 @section Text_IO
16170
16171 @noindent
16172 Text_IO files consist of a stream of characters containing the following
16173 special control characters:
16174
16175 @smallexample
16176 LF (line feed, 16#0A#) Line Mark
16177 FF (form feed, 16#0C#) Page Mark
16178 @end smallexample
16179
16180 @noindent
16181 A canonical Text_IO file is defined as one in which the following
16182 conditions are met:
16183
16184 @itemize @bullet
16185 @item
16186 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
16187 of the line.
16188
16189 @item
16190 The character @code{FF} is used only as a page mark, i.e.@: to mark the
16191 end of a page and consequently can appear only immediately following a
16192 @code{LF} (line mark) character.
16193
16194 @item
16195 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
16196 (line mark, page mark). In the former case, the page mark is implicitly
16197 assumed to be present.
16198 @end itemize
16199
16200 @noindent
16201 A file written using Text_IO will be in canonical form provided that no
16202 explicit @code{LF} or @code{FF} characters are written using @code{Put}
16203 or @code{Put_Line}. There will be no @code{FF} character at the end of
16204 the file unless an explicit @code{New_Page} operation was performed
16205 before closing the file.
16206
16207 A canonical Text_IO file that is a regular file (i.e., not a device or a
16208 pipe) can be read using any of the routines in Text_IO@. The
16209 semantics in this case will be exactly as defined in the Ada Reference
16210 Manual, and all the routines in Text_IO are fully implemented.
16211
16212 A text file that does not meet the requirements for a canonical Text_IO
16213 file has one of the following:
16214
16215 @itemize @bullet
16216 @item
16217 The file contains @code{FF} characters not immediately following a
16218 @code{LF} character.
16219
16220 @item
16221 The file contains @code{LF} or @code{FF} characters written by
16222 @code{Put} or @code{Put_Line}, which are not logically considered to be
16223 line marks or page marks.
16224
16225 @item
16226 The file ends in a character other than @code{LF} or @code{FF},
16227 i.e.@: there is no explicit line mark or page mark at the end of the file.
16228 @end itemize
16229
16230 @noindent
16231 Text_IO can be used to read such non-standard text files but subprograms
16232 to do with line or page numbers do not have defined meanings. In
16233 particular, a @code{FF} character that does not follow a @code{LF}
16234 character may or may not be treated as a page mark from the point of
16235 view of page and line numbering. Every @code{LF} character is considered
16236 to end a line, and there is an implied @code{LF} character at the end of
16237 the file.
16238
16239 @menu
16240 * Text_IO Stream Pointer Positioning::
16241 * Text_IO Reading and Writing Non-Regular Files::
16242 * Get_Immediate::
16243 * Treating Text_IO Files as Streams::
16244 * Text_IO Extensions::
16245 * Text_IO Facilities for Unbounded Strings::
16246 @end menu
16247
16248 @node Text_IO Stream Pointer Positioning
16249 @subsection Stream Pointer Positioning
16250
16251 @noindent
16252 @code{Ada.Text_IO} has a definition of current position for a file that
16253 is being read. No internal buffering occurs in Text_IO, and usually the
16254 physical position in the stream used to implement the file corresponds
16255 to this logical position defined by Text_IO@. There are two exceptions:
16256
16257 @itemize @bullet
16258 @item
16259 After a call to @code{End_Of_Page} that returns @code{True}, the stream
16260 is positioned past the @code{LF} (line mark) that precedes the page
16261 mark. Text_IO maintains an internal flag so that subsequent read
16262 operations properly handle the logical position which is unchanged by
16263 the @code{End_Of_Page} call.
16264
16265 @item
16266 After a call to @code{End_Of_File} that returns @code{True}, if the
16267 Text_IO file was positioned before the line mark at the end of file
16268 before the call, then the logical position is unchanged, but the stream
16269 is physically positioned right at the end of file (past the line mark,
16270 and past a possible page mark following the line mark. Again Text_IO
16271 maintains internal flags so that subsequent read operations properly
16272 handle the logical position.
16273 @end itemize
16274
16275 @noindent
16276 These discrepancies have no effect on the observable behavior of
16277 Text_IO, but if a single Ada stream is shared between a C program and
16278 Ada program, or shared (using @samp{shared=yes} in the form string)
16279 between two Ada files, then the difference may be observable in some
16280 situations.
16281
16282 @node Text_IO Reading and Writing Non-Regular Files
16283 @subsection Reading and Writing Non-Regular Files
16284
16285 @noindent
16286 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
16287 can be used for reading and writing. Writing is not affected and the
16288 sequence of characters output is identical to the normal file case, but
16289 for reading, the behavior of Text_IO is modified to avoid undesirable
16290 look-ahead as follows:
16291
16292 An input file that is not a regular file is considered to have no page
16293 marks. Any @code{Ascii.FF} characters (the character normally used for a
16294 page mark) appearing in the file are considered to be data
16295 characters. In particular:
16296
16297 @itemize @bullet
16298 @item
16299 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
16300 following a line mark. If a page mark appears, it will be treated as a
16301 data character.
16302
16303 @item
16304 This avoids the need to wait for an extra character to be typed or
16305 entered from the pipe to complete one of these operations.
16306
16307 @item
16308 @code{End_Of_Page} always returns @code{False}
16309
16310 @item
16311 @code{End_Of_File} will return @code{False} if there is a page mark at
16312 the end of the file.
16313 @end itemize
16314
16315 @noindent
16316 Output to non-regular files is the same as for regular files. Page marks
16317 may be written to non-regular files using @code{New_Page}, but as noted
16318 above they will not be treated as page marks on input if the output is
16319 piped to another Ada program.
16320
16321 Another important discrepancy when reading non-regular files is that the end
16322 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
16323 pressing the @key{EOT} key,
16324 then end of file
16325 is signaled once (i.e.@: the test @code{End_Of_File}
16326 will yield @code{True}, or a read will
16327 raise @code{End_Error}), but then reading can resume
16328 to read data past that end of
16329 file indication, until another end of file indication is entered.
16330
16331 @node Get_Immediate
16332 @subsection Get_Immediate
16333 @cindex Get_Immediate
16334
16335 @noindent
16336 Get_Immediate returns the next character (including control characters)
16337 from the input file. In particular, Get_Immediate will return LF or FF
16338 characters used as line marks or page marks. Such operations leave the
16339 file positioned past the control character, and it is thus not treated
16340 as having its normal function. This means that page, line and column
16341 counts after this kind of Get_Immediate call are set as though the mark
16342 did not occur. In the case where a Get_Immediate leaves the file
16343 positioned between the line mark and page mark (which is not normally
16344 possible), it is undefined whether the FF character will be treated as a
16345 page mark.
16346
16347 @node Treating Text_IO Files as Streams
16348 @subsection Treating Text_IO Files as Streams
16349 @cindex Stream files
16350
16351 @noindent
16352 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
16353 as a stream. Data written to a Text_IO file in this stream mode is
16354 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
16355 16#0C# (@code{FF}), the resulting file may have non-standard
16356 format. Similarly if read operations are used to read from a Text_IO
16357 file treated as a stream, then @code{LF} and @code{FF} characters may be
16358 skipped and the effect is similar to that described above for
16359 @code{Get_Immediate}.
16360
16361 @node Text_IO Extensions
16362 @subsection Text_IO Extensions
16363 @cindex Text_IO extensions
16364
16365 @noindent
16366 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
16367 to the standard @code{Text_IO} package:
16368
16369 @itemize @bullet
16370 @item function File_Exists (Name : String) return Boolean;
16371 Determines if a file of the given name exists.
16372
16373 @item function Get_Line return String;
16374 Reads a string from the standard input file. The value returned is exactly
16375 the length of the line that was read.
16376
16377 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
16378 Similar, except that the parameter File specifies the file from which
16379 the string is to be read.
16380
16381 @end itemize
16382
16383 @node Text_IO Facilities for Unbounded Strings
16384 @subsection Text_IO Facilities for Unbounded Strings
16385 @cindex Text_IO for unbounded strings
16386 @cindex Unbounded_String, Text_IO operations
16387
16388 @noindent
16389 The package @code{Ada.Strings.Unbounded.Text_IO}
16390 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
16391 subprograms useful for Text_IO operations on unbounded strings:
16392
16393 @itemize @bullet
16394
16395 @item function Get_Line (File : File_Type) return Unbounded_String;
16396 Reads a line from the specified file
16397 and returns the result as an unbounded string.
16398
16399 @item procedure Put (File : File_Type; U : Unbounded_String);
16400 Writes the value of the given unbounded string to the specified file
16401 Similar to the effect of
16402 @code{Put (To_String (U))} except that an extra copy is avoided.
16403
16404 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
16405 Writes the value of the given unbounded string to the specified file,
16406 followed by a @code{New_Line}.
16407 Similar to the effect of @code{Put_Line (To_String (U))} except
16408 that an extra copy is avoided.
16409 @end itemize
16410
16411 @noindent
16412 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
16413 and is optional. If the parameter is omitted, then the standard input or
16414 output file is referenced as appropriate.
16415
16416 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
16417 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
16418 @code{Wide_Text_IO} functionality for unbounded wide strings.
16419
16420 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
16421 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
16422 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
16423
16424 @node Wide_Text_IO
16425 @section Wide_Text_IO
16426
16427 @noindent
16428 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
16429 both input and output files may contain special sequences that represent
16430 wide character values. The encoding scheme for a given file may be
16431 specified using a FORM parameter:
16432
16433 @smallexample
16434 WCEM=@var{x}
16435 @end smallexample
16436
16437 @noindent
16438 as part of the FORM string (WCEM = wide character encoding method),
16439 where @var{x} is one of the following characters
16440
16441 @table @samp
16442 @item h
16443 Hex ESC encoding
16444 @item u
16445 Upper half encoding
16446 @item s
16447 Shift-JIS encoding
16448 @item e
16449 EUC Encoding
16450 @item 8
16451 UTF-8 encoding
16452 @item b
16453 Brackets encoding
16454 @end table
16455
16456 @noindent
16457 The encoding methods match those that
16458 can be used in a source
16459 program, but there is no requirement that the encoding method used for
16460 the source program be the same as the encoding method used for files,
16461 and different files may use different encoding methods.
16462
16463 The default encoding method for the standard files, and for opened files
16464 for which no WCEM parameter is given in the FORM string matches the
16465 wide character encoding specified for the main program (the default
16466 being brackets encoding if no coding method was specified with -gnatW).
16467
16468 @table @asis
16469 @item Hex Coding
16470 In this encoding, a wide character is represented by a five character
16471 sequence:
16472
16473 @smallexample
16474 ESC a b c d
16475 @end smallexample
16476
16477 @noindent
16478 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
16479 characters (using upper case letters) of the wide character code. For
16480 example, ESC A345 is used to represent the wide character with code
16481 16#A345#. This scheme is compatible with use of the full
16482 @code{Wide_Character} set.
16483
16484 @item Upper Half Coding
16485 The wide character with encoding 16#abcd#, where the upper bit is on
16486 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
16487 16#cd#. The second byte may never be a format control character, but is
16488 not required to be in the upper half. This method can be also used for
16489 shift-JIS or EUC where the internal coding matches the external coding.
16490
16491 @item Shift JIS Coding
16492 A wide character is represented by a two character sequence 16#ab# and
16493 16#cd#, with the restrictions described for upper half encoding as
16494 described above. The internal character code is the corresponding JIS
16495 character according to the standard algorithm for Shift-JIS
16496 conversion. Only characters defined in the JIS code set table can be
16497 used with this encoding method.
16498
16499 @item EUC Coding
16500 A wide character is represented by a two character sequence 16#ab# and
16501 16#cd#, with both characters being in the upper half. The internal
16502 character code is the corresponding JIS character according to the EUC
16503 encoding algorithm. Only characters defined in the JIS code set table
16504 can be used with this encoding method.
16505
16506 @item UTF-8 Coding
16507 A wide character is represented using
16508 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
16509 10646-1/Am.2. Depending on the character value, the representation
16510 is a one, two, or three byte sequence:
16511
16512 @smallexample
16513 16#0000#-16#007f#: 2#0xxxxxxx#
16514 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
16515 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
16516 @end smallexample
16517
16518 @noindent
16519 where the @var{xxx} bits correspond to the left-padded bits of the
16520 16-bit character value. Note that all lower half ASCII characters
16521 are represented as ASCII bytes and all upper half characters and
16522 other wide characters are represented as sequences of upper-half
16523 (The full UTF-8 scheme allows for encoding 31-bit characters as
16524 6-byte sequences, but in this implementation, all UTF-8 sequences
16525 of four or more bytes length will raise a Constraint_Error, as
16526 will all invalid UTF-8 sequences.)
16527
16528 @item Brackets Coding
16529 In this encoding, a wide character is represented by the following eight
16530 character sequence:
16531
16532 @smallexample
16533 [ " a b c d " ]
16534 @end smallexample
16535
16536 @noindent
16537 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
16538 characters (using uppercase letters) of the wide character code. For
16539 example, @code{["A345"]} is used to represent the wide character with code
16540 @code{16#A345#}.
16541 This scheme is compatible with use of the full Wide_Character set.
16542 On input, brackets coding can also be used for upper half characters,
16543 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
16544 is only used for wide characters with a code greater than @code{16#FF#}.
16545
16546 Note that brackets coding is not normally used in the context of
16547 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
16548 a portable way of encoding source files. In the context of Wide_Text_IO
16549 or Wide_Wide_Text_IO, it can only be used if the file does not contain
16550 any instance of the left bracket character other than to encode wide
16551 character values using the brackets encoding method. In practice it is
16552 expected that some standard wide character encoding method such
16553 as UTF-8 will be used for text input output.
16554
16555 If brackets notation is used, then any occurrence of a left bracket
16556 in the input file which is not the start of a valid wide character
16557 sequence will cause Constraint_Error to be raised. It is possible to
16558 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
16559 input will interpret this as a left bracket.
16560
16561 However, when a left bracket is output, it will be output as a left bracket
16562 and not as ["5B"]. We make this decision because for normal use of
16563 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
16564 brackets. For example, if we write:
16565
16566 @smallexample
16567 Put_Line ("Start of output [first run]");
16568 @end smallexample
16569
16570 @noindent
16571 we really do not want to have the left bracket in this message clobbered so
16572 that the output reads:
16573
16574 @smallexample
16575 Start of output ["5B"]first run]
16576 @end smallexample
16577
16578 @noindent
16579 In practice brackets encoding is reasonably useful for normal Put_Line use
16580 since we won't get confused between left brackets and wide character
16581 sequences in the output. But for input, or when files are written out
16582 and read back in, it really makes better sense to use one of the standard
16583 encoding methods such as UTF-8.
16584
16585 @end table
16586
16587 @noindent
16588 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
16589 not all wide character
16590 values can be represented. An attempt to output a character that cannot
16591 be represented using the encoding scheme for the file causes
16592 Constraint_Error to be raised. An invalid wide character sequence on
16593 input also causes Constraint_Error to be raised.
16594
16595 @menu
16596 * Wide_Text_IO Stream Pointer Positioning::
16597 * Wide_Text_IO Reading and Writing Non-Regular Files::
16598 @end menu
16599
16600 @node Wide_Text_IO Stream Pointer Positioning
16601 @subsection Stream Pointer Positioning
16602
16603 @noindent
16604 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
16605 of stream pointer positioning (@pxref{Text_IO}). There is one additional
16606 case:
16607
16608 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
16609 normal lower ASCII set (i.e.@: a character in the range:
16610
16611 @smallexample @c ada
16612 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
16613 @end smallexample
16614
16615 @noindent
16616 then although the logical position of the file pointer is unchanged by
16617 the @code{Look_Ahead} call, the stream is physically positioned past the
16618 wide character sequence. Again this is to avoid the need for buffering
16619 or backup, and all @code{Wide_Text_IO} routines check the internal
16620 indication that this situation has occurred so that this is not visible
16621 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
16622 can be observed if the wide text file shares a stream with another file.
16623
16624 @node Wide_Text_IO Reading and Writing Non-Regular Files
16625 @subsection Reading and Writing Non-Regular Files
16626
16627 @noindent
16628 As in the case of Text_IO, when a non-regular file is read, it is
16629 assumed that the file contains no page marks (any form characters are
16630 treated as data characters), and @code{End_Of_Page} always returns
16631 @code{False}. Similarly, the end of file indication is not sticky, so
16632 it is possible to read beyond an end of file.
16633
16634 @node Wide_Wide_Text_IO
16635 @section Wide_Wide_Text_IO
16636
16637 @noindent
16638 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
16639 both input and output files may contain special sequences that represent
16640 wide wide character values. The encoding scheme for a given file may be
16641 specified using a FORM parameter:
16642
16643 @smallexample
16644 WCEM=@var{x}
16645 @end smallexample
16646
16647 @noindent
16648 as part of the FORM string (WCEM = wide character encoding method),
16649 where @var{x} is one of the following characters
16650
16651 @table @samp
16652 @item h
16653 Hex ESC encoding
16654 @item u
16655 Upper half encoding
16656 @item s
16657 Shift-JIS encoding
16658 @item e
16659 EUC Encoding
16660 @item 8
16661 UTF-8 encoding
16662 @item b
16663 Brackets encoding
16664 @end table
16665
16666 @noindent
16667 The encoding methods match those that
16668 can be used in a source
16669 program, but there is no requirement that the encoding method used for
16670 the source program be the same as the encoding method used for files,
16671 and different files may use different encoding methods.
16672
16673 The default encoding method for the standard files, and for opened files
16674 for which no WCEM parameter is given in the FORM string matches the
16675 wide character encoding specified for the main program (the default
16676 being brackets encoding if no coding method was specified with -gnatW).
16677
16678 @table @asis
16679
16680 @item UTF-8 Coding
16681 A wide character is represented using
16682 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
16683 10646-1/Am.2. Depending on the character value, the representation
16684 is a one, two, three, or four byte sequence:
16685
16686 @smallexample
16687 16#000000#-16#00007f#: 2#0xxxxxxx#
16688 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
16689 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
16690 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
16691 @end smallexample
16692
16693 @noindent
16694 where the @var{xxx} bits correspond to the left-padded bits of the
16695 21-bit character value. Note that all lower half ASCII characters
16696 are represented as ASCII bytes and all upper half characters and
16697 other wide characters are represented as sequences of upper-half
16698 characters.
16699
16700 @item Brackets Coding
16701 In this encoding, a wide wide character is represented by the following eight
16702 character sequence if is in wide character range
16703
16704 @smallexample
16705 [ " a b c d " ]
16706 @end smallexample
16707
16708 and by the following ten character sequence if not
16709
16710 @smallexample
16711 [ " a b c d e f " ]
16712 @end smallexample
16713
16714 @noindent
16715 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
16716 are the four or six hexadecimal
16717 characters (using uppercase letters) of the wide wide character code. For
16718 example, @code{["01A345"]} is used to represent the wide wide character
16719 with code @code{16#01A345#}.
16720
16721 This scheme is compatible with use of the full Wide_Wide_Character set.
16722 On input, brackets coding can also be used for upper half characters,
16723 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
16724 is only used for wide characters with a code greater than @code{16#FF#}.
16725
16726 @end table
16727
16728 @noindent
16729 If is also possible to use the other Wide_Character encoding methods,
16730 such as Shift-JIS, but the other schemes cannot support the full range
16731 of wide wide characters.
16732 An attempt to output a character that cannot
16733 be represented using the encoding scheme for the file causes
16734 Constraint_Error to be raised. An invalid wide character sequence on
16735 input also causes Constraint_Error to be raised.
16736
16737 @menu
16738 * Wide_Wide_Text_IO Stream Pointer Positioning::
16739 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
16740 @end menu
16741
16742 @node Wide_Wide_Text_IO Stream Pointer Positioning
16743 @subsection Stream Pointer Positioning
16744
16745 @noindent
16746 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
16747 of stream pointer positioning (@pxref{Text_IO}). There is one additional
16748 case:
16749
16750 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
16751 normal lower ASCII set (i.e.@: a character in the range:
16752
16753 @smallexample @c ada
16754 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
16755 @end smallexample
16756
16757 @noindent
16758 then although the logical position of the file pointer is unchanged by
16759 the @code{Look_Ahead} call, the stream is physically positioned past the
16760 wide character sequence. Again this is to avoid the need for buffering
16761 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
16762 indication that this situation has occurred so that this is not visible
16763 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
16764 can be observed if the wide text file shares a stream with another file.
16765
16766 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
16767 @subsection Reading and Writing Non-Regular Files
16768
16769 @noindent
16770 As in the case of Text_IO, when a non-regular file is read, it is
16771 assumed that the file contains no page marks (any form characters are
16772 treated as data characters), and @code{End_Of_Page} always returns
16773 @code{False}. Similarly, the end of file indication is not sticky, so
16774 it is possible to read beyond an end of file.
16775
16776 @node Stream_IO
16777 @section Stream_IO
16778
16779 @noindent
16780 A stream file is a sequence of bytes, where individual elements are
16781 written to the file as described in the Ada Reference Manual. The type
16782 @code{Stream_Element} is simply a byte. There are two ways to read or
16783 write a stream file.
16784
16785 @itemize @bullet
16786 @item
16787 The operations @code{Read} and @code{Write} directly read or write a
16788 sequence of stream elements with no control information.
16789
16790 @item
16791 The stream attributes applied to a stream file transfer data in the
16792 manner described for stream attributes.
16793 @end itemize
16794
16795 @node Text Translation
16796 @section Text Translation
16797
16798 @noindent
16799 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
16800 passed to Text_IO.Create and Text_IO.Open:
16801 @samp{Text_Translation=@var{Yes}} is the default, which means to
16802 translate LF to/from CR/LF on Windows systems.
16803 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
16804 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
16805 may be used to create Unix-style files on
16806 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
16807 systems.
16808
16809 @node Shared Files
16810 @section Shared Files
16811
16812 @noindent
16813 Section A.14 of the Ada Reference Manual allows implementations to
16814 provide a wide variety of behavior if an attempt is made to access the
16815 same external file with two or more internal files.
16816
16817 To provide a full range of functionality, while at the same time
16818 minimizing the problems of portability caused by this implementation
16819 dependence, GNAT handles file sharing as follows:
16820
16821 @itemize @bullet
16822 @item
16823 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
16824 to open two or more files with the same full name is considered an error
16825 and is not supported. The exception @code{Use_Error} will be
16826 raised. Note that a file that is not explicitly closed by the program
16827 remains open until the program terminates.
16828
16829 @item
16830 If the form parameter @samp{shared=no} appears in the form string, the
16831 file can be opened or created with its own separate stream identifier,
16832 regardless of whether other files sharing the same external file are
16833 opened. The exact effect depends on how the C stream routines handle
16834 multiple accesses to the same external files using separate streams.
16835
16836 @item
16837 If the form parameter @samp{shared=yes} appears in the form string for
16838 each of two or more files opened using the same full name, the same
16839 stream is shared between these files, and the semantics are as described
16840 in Ada Reference Manual, Section A.14.
16841 @end itemize
16842
16843 @noindent
16844 When a program that opens multiple files with the same name is ported
16845 from another Ada compiler to GNAT, the effect will be that
16846 @code{Use_Error} is raised.
16847
16848 The documentation of the original compiler and the documentation of the
16849 program should then be examined to determine if file sharing was
16850 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
16851 and @code{Create} calls as required.
16852
16853 When a program is ported from GNAT to some other Ada compiler, no
16854 special attention is required unless the @samp{shared=@var{xxx}} form
16855 parameter is used in the program. In this case, you must examine the
16856 documentation of the new compiler to see if it supports the required
16857 file sharing semantics, and form strings modified appropriately. Of
16858 course it may be the case that the program cannot be ported if the
16859 target compiler does not support the required functionality. The best
16860 approach in writing portable code is to avoid file sharing (and hence
16861 the use of the @samp{shared=@var{xxx}} parameter in the form string)
16862 completely.
16863
16864 One common use of file sharing in Ada 83 is the use of instantiations of
16865 Sequential_IO on the same file with different types, to achieve
16866 heterogeneous input-output. Although this approach will work in GNAT if
16867 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
16868 for this purpose (using the stream attributes)
16869
16870 @node Filenames encoding
16871 @section Filenames encoding
16872
16873 @noindent
16874 An encoding form parameter can be used to specify the filename
16875 encoding @samp{encoding=@var{xxx}}.
16876
16877 @itemize @bullet
16878 @item
16879 If the form parameter @samp{encoding=utf8} appears in the form string, the
16880 filename must be encoded in UTF-8.
16881
16882 @item
16883 If the form parameter @samp{encoding=8bits} appears in the form
16884 string, the filename must be a standard 8bits string.
16885 @end itemize
16886
16887 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
16888 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
16889 variable. And if not set @samp{utf8} is assumed.
16890
16891 @table @samp
16892 @item CP_ACP
16893 The current system Windows ANSI code page.
16894 @item CP_UTF8
16895 UTF-8 encoding
16896 @end table
16897
16898 This encoding form parameter is only supported on the Windows
16899 platform. On the other Operating Systems the run-time is supporting
16900 UTF-8 natively.
16901
16902 @node Open Modes
16903 @section Open Modes
16904
16905 @noindent
16906 @code{Open} and @code{Create} calls result in a call to @code{fopen}
16907 using the mode shown in the following table:
16908
16909 @sp 2
16910 @center @code{Open} and @code{Create} Call Modes
16911 @smallexample
16912 @b{OPEN } @b{CREATE}
16913 Append_File "r+" "w+"
16914 In_File "r" "w+"
16915 Out_File (Direct_IO) "r+" "w"
16916 Out_File (all other cases) "w" "w"
16917 Inout_File "r+" "w+"
16918 @end smallexample
16919
16920 @noindent
16921 If text file translation is required, then either @samp{b} or @samp{t}
16922 is added to the mode, depending on the setting of Text. Text file
16923 translation refers to the mapping of CR/LF sequences in an external file
16924 to LF characters internally. This mapping only occurs in DOS and
16925 DOS-like systems, and is not relevant to other systems.
16926
16927 A special case occurs with Stream_IO@. As shown in the above table, the
16928 file is initially opened in @samp{r} or @samp{w} mode for the
16929 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
16930 subsequently requires switching from reading to writing or vice-versa,
16931 then the file is reopened in @samp{r+} mode to permit the required operation.
16932
16933 @node Operations on C Streams
16934 @section Operations on C Streams
16935 The package @code{Interfaces.C_Streams} provides an Ada program with direct
16936 access to the C library functions for operations on C streams:
16937
16938 @smallexample @c adanocomment
16939 package Interfaces.C_Streams is
16940 -- Note: the reason we do not use the types that are in
16941 -- Interfaces.C is that we want to avoid dragging in the
16942 -- code in this unit if possible.
16943 subtype chars is System.Address;
16944 -- Pointer to null-terminated array of characters
16945 subtype FILEs is System.Address;
16946 -- Corresponds to the C type FILE*
16947 subtype voids is System.Address;
16948 -- Corresponds to the C type void*
16949 subtype int is Integer;
16950 subtype long is Long_Integer;
16951 -- Note: the above types are subtypes deliberately, and it
16952 -- is part of this spec that the above correspondences are
16953 -- guaranteed. This means that it is legitimate to, for
16954 -- example, use Integer instead of int. We provide these
16955 -- synonyms for clarity, but in some cases it may be
16956 -- convenient to use the underlying types (for example to
16957 -- avoid an unnecessary dependency of a spec on the spec
16958 -- of this unit).
16959 type size_t is mod 2 ** Standard'Address_Size;
16960 NULL_Stream : constant FILEs;
16961 -- Value returned (NULL in C) to indicate an
16962 -- fdopen/fopen/tmpfile error
16963 ----------------------------------
16964 -- Constants Defined in stdio.h --
16965 ----------------------------------
16966 EOF : constant int;
16967 -- Used by a number of routines to indicate error or
16968 -- end of file
16969 IOFBF : constant int;
16970 IOLBF : constant int;
16971 IONBF : constant int;
16972 -- Used to indicate buffering mode for setvbuf call
16973 SEEK_CUR : constant int;
16974 SEEK_END : constant int;
16975 SEEK_SET : constant int;
16976 -- Used to indicate origin for fseek call
16977 function stdin return FILEs;
16978 function stdout return FILEs;
16979 function stderr return FILEs;
16980 -- Streams associated with standard files
16981 --------------------------
16982 -- Standard C functions --
16983 --------------------------
16984 -- The functions selected below are ones that are
16985 -- available in UNIX (but not necessarily in ANSI C).
16986 -- These are very thin interfaces
16987 -- which copy exactly the C headers. For more
16988 -- documentation on these functions, see the Microsoft C
16989 -- "Run-Time Library Reference" (Microsoft Press, 1990,
16990 -- ISBN 1-55615-225-6), which includes useful information
16991 -- on system compatibility.
16992 procedure clearerr (stream : FILEs);
16993 function fclose (stream : FILEs) return int;
16994 function fdopen (handle : int; mode : chars) return FILEs;
16995 function feof (stream : FILEs) return int;
16996 function ferror (stream : FILEs) return int;
16997 function fflush (stream : FILEs) return int;
16998 function fgetc (stream : FILEs) return int;
16999 function fgets (strng : chars; n : int; stream : FILEs)
17000 return chars;
17001 function fileno (stream : FILEs) return int;
17002 function fopen (filename : chars; Mode : chars)
17003 return FILEs;
17004 -- Note: to maintain target independence, use
17005 -- text_translation_required, a boolean variable defined in
17006 -- a-sysdep.c to deal with the target dependent text
17007 -- translation requirement. If this variable is set,
17008 -- then b/t should be appended to the standard mode
17009 -- argument to set the text translation mode off or on
17010 -- as required.
17011 function fputc (C : int; stream : FILEs) return int;
17012 function fputs (Strng : chars; Stream : FILEs) return int;
17013 function fread
17014 (buffer : voids;
17015 size : size_t;
17016 count : size_t;
17017 stream : FILEs)
17018 return size_t;
17019 function freopen
17020 (filename : chars;
17021 mode : chars;
17022 stream : FILEs)
17023 return FILEs;
17024 function fseek
17025 (stream : FILEs;
17026 offset : long;
17027 origin : int)
17028 return int;
17029 function ftell (stream : FILEs) return long;
17030 function fwrite
17031 (buffer : voids;
17032 size : size_t;
17033 count : size_t;
17034 stream : FILEs)
17035 return size_t;
17036 function isatty (handle : int) return int;
17037 procedure mktemp (template : chars);
17038 -- The return value (which is just a pointer to template)
17039 -- is discarded
17040 procedure rewind (stream : FILEs);
17041 function rmtmp return int;
17042 function setvbuf
17043 (stream : FILEs;
17044 buffer : chars;
17045 mode : int;
17046 size : size_t)
17047 return int;
17048
17049 function tmpfile return FILEs;
17050 function ungetc (c : int; stream : FILEs) return int;
17051 function unlink (filename : chars) return int;
17052 ---------------------
17053 -- Extra functions --
17054 ---------------------
17055 -- These functions supply slightly thicker bindings than
17056 -- those above. They are derived from functions in the
17057 -- C Run-Time Library, but may do a bit more work than
17058 -- just directly calling one of the Library functions.
17059 function is_regular_file (handle : int) return int;
17060 -- Tests if given handle is for a regular file (result 1)
17061 -- or for a non-regular file (pipe or device, result 0).
17062 ---------------------------------
17063 -- Control of Text/Binary Mode --
17064 ---------------------------------
17065 -- If text_translation_required is true, then the following
17066 -- functions may be used to dynamically switch a file from
17067 -- binary to text mode or vice versa. These functions have
17068 -- no effect if text_translation_required is false (i.e.@: in
17069 -- normal UNIX mode). Use fileno to get a stream handle.
17070 procedure set_binary_mode (handle : int);
17071 procedure set_text_mode (handle : int);
17072 ----------------------------
17073 -- Full Path Name support --
17074 ----------------------------
17075 procedure full_name (nam : chars; buffer : chars);
17076 -- Given a NUL terminated string representing a file
17077 -- name, returns in buffer a NUL terminated string
17078 -- representing the full path name for the file name.
17079 -- On systems where it is relevant the drive is also
17080 -- part of the full path name. It is the responsibility
17081 -- of the caller to pass an actual parameter for buffer
17082 -- that is big enough for any full path name. Use
17083 -- max_path_len given below as the size of buffer.
17084 max_path_len : integer;
17085 -- Maximum length of an allowable full path name on the
17086 -- system, including a terminating NUL character.
17087 end Interfaces.C_Streams;
17088 @end smallexample
17089
17090 @node Interfacing to C Streams
17091 @section Interfacing to C Streams
17092
17093 @noindent
17094 The packages in this section permit interfacing Ada files to C Stream
17095 operations.
17096
17097 @smallexample @c ada
17098 with Interfaces.C_Streams;
17099 package Ada.Sequential_IO.C_Streams is
17100 function C_Stream (F : File_Type)
17101 return Interfaces.C_Streams.FILEs;
17102 procedure Open
17103 (File : in out File_Type;
17104 Mode : in File_Mode;
17105 C_Stream : in Interfaces.C_Streams.FILEs;
17106 Form : in String := "");
17107 end Ada.Sequential_IO.C_Streams;
17108
17109 with Interfaces.C_Streams;
17110 package Ada.Direct_IO.C_Streams is
17111 function C_Stream (F : File_Type)
17112 return Interfaces.C_Streams.FILEs;
17113 procedure Open
17114 (File : in out File_Type;
17115 Mode : in File_Mode;
17116 C_Stream : in Interfaces.C_Streams.FILEs;
17117 Form : in String := "");
17118 end Ada.Direct_IO.C_Streams;
17119
17120 with Interfaces.C_Streams;
17121 package Ada.Text_IO.C_Streams is
17122 function C_Stream (F : File_Type)
17123 return Interfaces.C_Streams.FILEs;
17124 procedure Open
17125 (File : in out File_Type;
17126 Mode : in File_Mode;
17127 C_Stream : in Interfaces.C_Streams.FILEs;
17128 Form : in String := "");
17129 end Ada.Text_IO.C_Streams;
17130
17131 with Interfaces.C_Streams;
17132 package Ada.Wide_Text_IO.C_Streams is
17133 function C_Stream (F : File_Type)
17134 return Interfaces.C_Streams.FILEs;
17135 procedure Open
17136 (File : in out File_Type;
17137 Mode : in File_Mode;
17138 C_Stream : in Interfaces.C_Streams.FILEs;
17139 Form : in String := "");
17140 end Ada.Wide_Text_IO.C_Streams;
17141
17142 with Interfaces.C_Streams;
17143 package Ada.Wide_Wide_Text_IO.C_Streams is
17144 function C_Stream (F : File_Type)
17145 return Interfaces.C_Streams.FILEs;
17146 procedure Open
17147 (File : in out File_Type;
17148 Mode : in File_Mode;
17149 C_Stream : in Interfaces.C_Streams.FILEs;
17150 Form : in String := "");
17151 end Ada.Wide_Wide_Text_IO.C_Streams;
17152
17153 with Interfaces.C_Streams;
17154 package Ada.Stream_IO.C_Streams is
17155 function C_Stream (F : File_Type)
17156 return Interfaces.C_Streams.FILEs;
17157 procedure Open
17158 (File : in out File_Type;
17159 Mode : in File_Mode;
17160 C_Stream : in Interfaces.C_Streams.FILEs;
17161 Form : in String := "");
17162 end Ada.Stream_IO.C_Streams;
17163 @end smallexample
17164
17165 @noindent
17166 In each of these six packages, the @code{C_Stream} function obtains the
17167 @code{FILE} pointer from a currently opened Ada file. It is then
17168 possible to use the @code{Interfaces.C_Streams} package to operate on
17169 this stream, or the stream can be passed to a C program which can
17170 operate on it directly. Of course the program is responsible for
17171 ensuring that only appropriate sequences of operations are executed.
17172
17173 One particular use of relevance to an Ada program is that the
17174 @code{setvbuf} function can be used to control the buffering of the
17175 stream used by an Ada file. In the absence of such a call the standard
17176 default buffering is used.
17177
17178 The @code{Open} procedures in these packages open a file giving an
17179 existing C Stream instead of a file name. Typically this stream is
17180 imported from a C program, allowing an Ada file to operate on an
17181 existing C file.
17182
17183 @node The GNAT Library
17184 @chapter The GNAT Library
17185
17186 @noindent
17187 The GNAT library contains a number of general and special purpose packages.
17188 It represents functionality that the GNAT developers have found useful, and
17189 which is made available to GNAT users. The packages described here are fully
17190 supported, and upwards compatibility will be maintained in future releases,
17191 so you can use these facilities with the confidence that the same functionality
17192 will be available in future releases.
17193
17194 The chapter here simply gives a brief summary of the facilities available.
17195 The full documentation is found in the spec file for the package. The full
17196 sources of these library packages, including both spec and body, are provided
17197 with all GNAT releases. For example, to find out the full specifications of
17198 the SPITBOL pattern matching capability, including a full tutorial and
17199 extensive examples, look in the @file{g-spipat.ads} file in the library.
17200
17201 For each entry here, the package name (as it would appear in a @code{with}
17202 clause) is given, followed by the name of the corresponding spec file in
17203 parentheses. The packages are children in four hierarchies, @code{Ada},
17204 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
17205 GNAT-specific hierarchy.
17206
17207 Note that an application program should only use packages in one of these
17208 four hierarchies if the package is defined in the Ada Reference Manual,
17209 or is listed in this section of the GNAT Programmers Reference Manual.
17210 All other units should be considered internal implementation units and
17211 should not be directly @code{with}'ed by application code. The use of
17212 a @code{with} statement that references one of these internal implementation
17213 units makes an application potentially dependent on changes in versions
17214 of GNAT, and will generate a warning message.
17215
17216 @menu
17217 * Ada.Characters.Latin_9 (a-chlat9.ads)::
17218 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
17219 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
17220 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
17221 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
17222 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
17223 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
17224 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
17225 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
17226 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
17227 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
17228 * Ada.Command_Line.Environment (a-colien.ads)::
17229 * Ada.Command_Line.Remove (a-colire.ads)::
17230 * Ada.Command_Line.Response_File (a-clrefi.ads)::
17231 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
17232 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
17233 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
17234 * Ada.Exceptions.Traceback (a-exctra.ads)::
17235 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
17236 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
17237 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
17238 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
17239 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
17240 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
17241 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
17242 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
17243 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
17244 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
17245 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
17246 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
17247 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
17248 * GNAT.Altivec (g-altive.ads)::
17249 * GNAT.Altivec.Conversions (g-altcon.ads)::
17250 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
17251 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
17252 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
17253 * GNAT.Array_Split (g-arrspl.ads)::
17254 * GNAT.AWK (g-awk.ads)::
17255 * GNAT.Bounded_Buffers (g-boubuf.ads)::
17256 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
17257 * GNAT.Bubble_Sort (g-bubsor.ads)::
17258 * GNAT.Bubble_Sort_A (g-busora.ads)::
17259 * GNAT.Bubble_Sort_G (g-busorg.ads)::
17260 * GNAT.Byte_Order_Mark (g-byorma.ads)::
17261 * GNAT.Byte_Swapping (g-bytswa.ads)::
17262 * GNAT.Calendar (g-calend.ads)::
17263 * GNAT.Calendar.Time_IO (g-catiio.ads)::
17264 * GNAT.Case_Util (g-casuti.ads)::
17265 * GNAT.CGI (g-cgi.ads)::
17266 * GNAT.CGI.Cookie (g-cgicoo.ads)::
17267 * GNAT.CGI.Debug (g-cgideb.ads)::
17268 * GNAT.Command_Line (g-comlin.ads)::
17269 * GNAT.Compiler_Version (g-comver.ads)::
17270 * GNAT.Ctrl_C (g-ctrl_c.ads)::
17271 * GNAT.CRC32 (g-crc32.ads)::
17272 * GNAT.Current_Exception (g-curexc.ads)::
17273 * GNAT.Debug_Pools (g-debpoo.ads)::
17274 * GNAT.Debug_Utilities (g-debuti.ads)::
17275 * GNAT.Decode_String (g-decstr.ads)::
17276 * GNAT.Decode_UTF8_String (g-deutst.ads)::
17277 * GNAT.Directory_Operations (g-dirope.ads)::
17278 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
17279 * GNAT.Dynamic_HTables (g-dynhta.ads)::
17280 * GNAT.Dynamic_Tables (g-dyntab.ads)::
17281 * GNAT.Encode_String (g-encstr.ads)::
17282 * GNAT.Encode_UTF8_String (g-enutst.ads)::
17283 * GNAT.Exception_Actions (g-excact.ads)::
17284 * GNAT.Exception_Traces (g-exctra.ads)::
17285 * GNAT.Exceptions (g-except.ads)::
17286 * GNAT.Expect (g-expect.ads)::
17287 * GNAT.Expect.TTY (g-exptty.ads)::
17288 * GNAT.Float_Control (g-flocon.ads)::
17289 * GNAT.Heap_Sort (g-heasor.ads)::
17290 * GNAT.Heap_Sort_A (g-hesora.ads)::
17291 * GNAT.Heap_Sort_G (g-hesorg.ads)::
17292 * GNAT.HTable (g-htable.ads)::
17293 * GNAT.IO (g-io.ads)::
17294 * GNAT.IO_Aux (g-io_aux.ads)::
17295 * GNAT.Lock_Files (g-locfil.ads)::
17296 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
17297 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
17298 * GNAT.MD5 (g-md5.ads)::
17299 * GNAT.Memory_Dump (g-memdum.ads)::
17300 * GNAT.Most_Recent_Exception (g-moreex.ads)::
17301 * GNAT.OS_Lib (g-os_lib.ads)::
17302 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
17303 * GNAT.Random_Numbers (g-rannum.ads)::
17304 * GNAT.Regexp (g-regexp.ads)::
17305 * GNAT.Registry (g-regist.ads)::
17306 * GNAT.Regpat (g-regpat.ads)::
17307 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
17308 * GNAT.Semaphores (g-semaph.ads)::
17309 * GNAT.Serial_Communications (g-sercom.ads)::
17310 * GNAT.SHA1 (g-sha1.ads)::
17311 * GNAT.SHA224 (g-sha224.ads)::
17312 * GNAT.SHA256 (g-sha256.ads)::
17313 * GNAT.SHA384 (g-sha384.ads)::
17314 * GNAT.SHA512 (g-sha512.ads)::
17315 * GNAT.Signals (g-signal.ads)::
17316 * GNAT.Sockets (g-socket.ads)::
17317 * GNAT.Source_Info (g-souinf.ads)::
17318 * GNAT.Spelling_Checker (g-speche.ads)::
17319 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
17320 * GNAT.Spitbol.Patterns (g-spipat.ads)::
17321 * GNAT.Spitbol (g-spitbo.ads)::
17322 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
17323 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
17324 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
17325 * GNAT.SSE (g-sse.ads)::
17326 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
17327 * GNAT.Strings (g-string.ads)::
17328 * GNAT.String_Split (g-strspl.ads)::
17329 * GNAT.Table (g-table.ads)::
17330 * GNAT.Task_Lock (g-tasloc.ads)::
17331 * GNAT.Threads (g-thread.ads)::
17332 * GNAT.Time_Stamp (g-timsta.ads)::
17333 * GNAT.Traceback (g-traceb.ads)::
17334 * GNAT.Traceback.Symbolic (g-trasym.ads)::
17335 * GNAT.UTF_32 (g-utf_32.ads)::
17336 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
17337 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
17338 * GNAT.Wide_String_Split (g-wistsp.ads)::
17339 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
17340 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
17341 * Interfaces.C.Extensions (i-cexten.ads)::
17342 * Interfaces.C.Streams (i-cstrea.ads)::
17343 * Interfaces.CPP (i-cpp.ads)::
17344 * Interfaces.Packed_Decimal (i-pacdec.ads)::
17345 * Interfaces.VxWorks (i-vxwork.ads)::
17346 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
17347 * System.Address_Image (s-addima.ads)::
17348 * System.Assertions (s-assert.ads)::
17349 * System.Memory (s-memory.ads)::
17350 * System.Multiprocessors (s-multip.ads)::
17351 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
17352 * System.Partition_Interface (s-parint.ads)::
17353 * System.Pool_Global (s-pooglo.ads)::
17354 * System.Pool_Local (s-pooloc.ads)::
17355 * System.Restrictions (s-restri.ads)::
17356 * System.Rident (s-rident.ads)::
17357 * System.Strings.Stream_Ops (s-ststop.ads)::
17358 * System.Task_Info (s-tasinf.ads)::
17359 * System.Wch_Cnv (s-wchcnv.ads)::
17360 * System.Wch_Con (s-wchcon.ads)::
17361 @end menu
17362
17363 @node Ada.Characters.Latin_9 (a-chlat9.ads)
17364 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
17365 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
17366 @cindex Latin_9 constants for Character
17367
17368 @noindent
17369 This child of @code{Ada.Characters}
17370 provides a set of definitions corresponding to those in the
17371 RM-defined package @code{Ada.Characters.Latin_1} but with the
17372 few modifications required for @code{Latin-9}
17373 The provision of such a package
17374 is specifically authorized by the Ada Reference Manual
17375 (RM A.3.3(27)).
17376
17377 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
17378 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
17379 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
17380 @cindex Latin_1 constants for Wide_Character
17381
17382 @noindent
17383 This child of @code{Ada.Characters}
17384 provides a set of definitions corresponding to those in the
17385 RM-defined package @code{Ada.Characters.Latin_1} but with the
17386 types of the constants being @code{Wide_Character}
17387 instead of @code{Character}. The provision of such a package
17388 is specifically authorized by the Ada Reference Manual
17389 (RM A.3.3(27)).
17390
17391 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
17392 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
17393 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
17394 @cindex Latin_9 constants for Wide_Character
17395
17396 @noindent
17397 This child of @code{Ada.Characters}
17398 provides a set of definitions corresponding to those in the
17399 GNAT defined package @code{Ada.Characters.Latin_9} but with the
17400 types of the constants being @code{Wide_Character}
17401 instead of @code{Character}. The provision of such a package
17402 is specifically authorized by the Ada Reference Manual
17403 (RM A.3.3(27)).
17404
17405 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
17406 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
17407 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
17408 @cindex Latin_1 constants for Wide_Wide_Character
17409
17410 @noindent
17411 This child of @code{Ada.Characters}
17412 provides a set of definitions corresponding to those in the
17413 RM-defined package @code{Ada.Characters.Latin_1} but with the
17414 types of the constants being @code{Wide_Wide_Character}
17415 instead of @code{Character}. The provision of such a package
17416 is specifically authorized by the Ada Reference Manual
17417 (RM A.3.3(27)).
17418
17419 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
17420 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
17421 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
17422 @cindex Latin_9 constants for Wide_Wide_Character
17423
17424 @noindent
17425 This child of @code{Ada.Characters}
17426 provides a set of definitions corresponding to those in the
17427 GNAT defined package @code{Ada.Characters.Latin_9} but with the
17428 types of the constants being @code{Wide_Wide_Character}
17429 instead of @code{Character}. The provision of such a package
17430 is specifically authorized by the Ada Reference Manual
17431 (RM A.3.3(27)).
17432
17433 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
17434 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
17435 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
17436 @cindex Formal container for doubly linked lists
17437
17438 @noindent
17439 This child of @code{Ada.Containers} defines a modified version of the
17440 Ada 2005 container for doubly linked lists, meant to facilitate formal
17441 verification of code using such containers. The specification of this
17442 unit is compatible with SPARK 2014. Note that the API of this unit may
17443 be subject to incompatible changes as SPARK 2014 evolves.
17444
17445 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
17446 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
17447 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
17448 @cindex Formal container for hashed maps
17449
17450 @noindent
17451 This child of @code{Ada.Containers} defines a modified version of the
17452 Ada 2005 container for hashed maps, meant to facilitate formal
17453 verification of code using such containers. The specification of this
17454 unit is compatible with SPARK 2014. Note that the API of this unit may
17455 be subject to incompatible changes as SPARK 2014 evolves.
17456
17457 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
17458 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
17459 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
17460 @cindex Formal container for hashed sets
17461
17462 @noindent
17463 This child of @code{Ada.Containers} defines a modified version of the
17464 Ada 2005 container for hashed sets, meant to facilitate formal
17465 verification of code using such containers. The specification of this
17466 unit is compatible with SPARK 2014. Note that the API of this unit may
17467 be subject to incompatible changes as SPARK 2014 evolves.
17468
17469 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
17470 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
17471 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
17472 @cindex Formal container for ordered maps
17473
17474 @noindent
17475 This child of @code{Ada.Containers} defines a modified version of the
17476 Ada 2005 container for ordered maps, meant to facilitate formal
17477 verification of code using such containers. The specification of this
17478 unit is compatible with SPARK 2014. Note that the API of this unit may
17479 be subject to incompatible changes as SPARK 2014 evolves.
17480
17481 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
17482 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
17483 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
17484 @cindex Formal container for ordered sets
17485
17486 @noindent
17487 This child of @code{Ada.Containers} defines a modified version of the
17488 Ada 2005 container for ordered sets, meant to facilitate formal
17489 verification of code using such containers. The specification of this
17490 unit is compatible with SPARK 2014. Note that the API of this unit may
17491 be subject to incompatible changes as SPARK 2014 evolves.
17492
17493 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
17494 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
17495 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
17496 @cindex Formal container for vectors
17497
17498 @noindent
17499 This child of @code{Ada.Containers} defines a modified version of the
17500 Ada 2005 container for vectors, meant to facilitate formal
17501 verification of code using such containers. The specification of this
17502 unit is compatible with SPARK 2014. Note that the API of this unit may
17503 be subject to incompatible changes as SPARK 2014 evolves.
17504
17505 @node Ada.Command_Line.Environment (a-colien.ads)
17506 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
17507 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
17508 @cindex Environment entries
17509
17510 @noindent
17511 This child of @code{Ada.Command_Line}
17512 provides a mechanism for obtaining environment values on systems
17513 where this concept makes sense.
17514
17515 @node Ada.Command_Line.Remove (a-colire.ads)
17516 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
17517 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
17518 @cindex Removing command line arguments
17519 @cindex Command line, argument removal
17520
17521 @noindent
17522 This child of @code{Ada.Command_Line}
17523 provides a mechanism for logically removing
17524 arguments from the argument list. Once removed, an argument is not visible
17525 to further calls on the subprograms in @code{Ada.Command_Line} will not
17526 see the removed argument.
17527
17528 @node Ada.Command_Line.Response_File (a-clrefi.ads)
17529 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
17530 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
17531 @cindex Response file for command line
17532 @cindex Command line, response file
17533 @cindex Command line, handling long command lines
17534
17535 @noindent
17536 This child of @code{Ada.Command_Line} provides a mechanism facilities for
17537 getting command line arguments from a text file, called a "response file".
17538 Using a response file allow passing a set of arguments to an executable longer
17539 than the maximum allowed by the system on the command line.
17540
17541 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
17542 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
17543 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
17544 @cindex C Streams, Interfacing with Direct_IO
17545
17546 @noindent
17547 This package provides subprograms that allow interfacing between
17548 C streams and @code{Direct_IO}. The stream identifier can be
17549 extracted from a file opened on the Ada side, and an Ada file
17550 can be constructed from a stream opened on the C side.
17551
17552 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
17553 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
17554 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
17555 @cindex Null_Occurrence, testing for
17556
17557 @noindent
17558 This child subprogram provides a way of testing for the null
17559 exception occurrence (@code{Null_Occurrence}) without raising
17560 an exception.
17561
17562 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
17563 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
17564 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
17565 @cindex Null_Occurrence, testing for
17566
17567 @noindent
17568 This child subprogram is used for handling otherwise unhandled
17569 exceptions (hence the name last chance), and perform clean ups before
17570 terminating the program. Note that this subprogram never returns.
17571
17572 @node Ada.Exceptions.Traceback (a-exctra.ads)
17573 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
17574 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
17575 @cindex Traceback for Exception Occurrence
17576
17577 @noindent
17578 This child package provides the subprogram (@code{Tracebacks}) to
17579 give a traceback array of addresses based on an exception
17580 occurrence.
17581
17582 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
17583 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
17584 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
17585 @cindex C Streams, Interfacing with Sequential_IO
17586
17587 @noindent
17588 This package provides subprograms that allow interfacing between
17589 C streams and @code{Sequential_IO}. The stream identifier can be
17590 extracted from a file opened on the Ada side, and an Ada file
17591 can be constructed from a stream opened on the C side.
17592
17593 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
17594 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
17595 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
17596 @cindex C Streams, Interfacing with Stream_IO
17597
17598 @noindent
17599 This package provides subprograms that allow interfacing between
17600 C streams and @code{Stream_IO}. The stream identifier can be
17601 extracted from a file opened on the Ada side, and an Ada file
17602 can be constructed from a stream opened on the C side.
17603
17604 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
17605 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
17606 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
17607 @cindex @code{Unbounded_String}, IO support
17608 @cindex @code{Text_IO}, extensions for unbounded strings
17609
17610 @noindent
17611 This package provides subprograms for Text_IO for unbounded
17612 strings, avoiding the necessity for an intermediate operation
17613 with ordinary strings.
17614
17615 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
17616 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
17617 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
17618 @cindex @code{Unbounded_Wide_String}, IO support
17619 @cindex @code{Text_IO}, extensions for unbounded wide strings
17620
17621 @noindent
17622 This package provides subprograms for Text_IO for unbounded
17623 wide strings, avoiding the necessity for an intermediate operation
17624 with ordinary wide strings.
17625
17626 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
17627 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
17628 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
17629 @cindex @code{Unbounded_Wide_Wide_String}, IO support
17630 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
17631
17632 @noindent
17633 This package provides subprograms for Text_IO for unbounded
17634 wide wide strings, avoiding the necessity for an intermediate operation
17635 with ordinary wide wide strings.
17636
17637 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
17638 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
17639 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
17640 @cindex C Streams, Interfacing with @code{Text_IO}
17641
17642 @noindent
17643 This package provides subprograms that allow interfacing between
17644 C streams and @code{Text_IO}. The stream identifier can be
17645 extracted from a file opened on the Ada side, and an Ada file
17646 can be constructed from a stream opened on the C side.
17647
17648 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
17649 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
17650 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
17651 @cindex @code{Text_IO} resetting standard files
17652
17653 @noindent
17654 This procedure is used to reset the status of the standard files used
17655 by Ada.Text_IO. This is useful in a situation (such as a restart in an
17656 embedded application) where the status of the files may change during
17657 execution (for example a standard input file may be redefined to be
17658 interactive).
17659
17660 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
17661 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
17662 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
17663 @cindex Unicode categorization, Wide_Character
17664
17665 @noindent
17666 This package provides subprograms that allow categorization of
17667 Wide_Character values according to Unicode categories.
17668
17669 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
17670 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
17671 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
17672 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
17673
17674 @noindent
17675 This package provides subprograms that allow interfacing between
17676 C streams and @code{Wide_Text_IO}. The stream identifier can be
17677 extracted from a file opened on the Ada side, and an Ada file
17678 can be constructed from a stream opened on the C side.
17679
17680 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
17681 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
17682 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
17683 @cindex @code{Wide_Text_IO} resetting standard files
17684
17685 @noindent
17686 This procedure is used to reset the status of the standard files used
17687 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
17688 embedded application) where the status of the files may change during
17689 execution (for example a standard input file may be redefined to be
17690 interactive).
17691
17692 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
17693 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
17694 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
17695 @cindex Unicode categorization, Wide_Wide_Character
17696
17697 @noindent
17698 This package provides subprograms that allow categorization of
17699 Wide_Wide_Character values according to Unicode categories.
17700
17701 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
17702 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
17703 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
17704 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
17705
17706 @noindent
17707 This package provides subprograms that allow interfacing between
17708 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
17709 extracted from a file opened on the Ada side, and an Ada file
17710 can be constructed from a stream opened on the C side.
17711
17712 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
17713 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
17714 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
17715 @cindex @code{Wide_Wide_Text_IO} resetting standard files
17716
17717 @noindent
17718 This procedure is used to reset the status of the standard files used
17719 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
17720 restart in an embedded application) where the status of the files may
17721 change during execution (for example a standard input file may be
17722 redefined to be interactive).
17723
17724 @node GNAT.Altivec (g-altive.ads)
17725 @section @code{GNAT.Altivec} (@file{g-altive.ads})
17726 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
17727 @cindex AltiVec
17728
17729 @noindent
17730 This is the root package of the GNAT AltiVec binding. It provides
17731 definitions of constants and types common to all the versions of the
17732 binding.
17733
17734 @node GNAT.Altivec.Conversions (g-altcon.ads)
17735 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
17736 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
17737 @cindex AltiVec
17738
17739 @noindent
17740 This package provides the Vector/View conversion routines.
17741
17742 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
17743 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
17744 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
17745 @cindex AltiVec
17746
17747 @noindent
17748 This package exposes the Ada interface to the AltiVec operations on
17749 vector objects. A soft emulation is included by default in the GNAT
17750 library. The hard binding is provided as a separate package. This unit
17751 is common to both bindings.
17752
17753 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
17754 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
17755 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
17756 @cindex AltiVec
17757
17758 @noindent
17759 This package exposes the various vector types part of the Ada binding
17760 to AltiVec facilities.
17761
17762 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
17763 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
17764 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
17765 @cindex AltiVec
17766
17767 @noindent
17768 This package provides public 'View' data types from/to which private
17769 vector representations can be converted via
17770 GNAT.Altivec.Conversions. This allows convenient access to individual
17771 vector elements and provides a simple way to initialize vector
17772 objects.
17773
17774 @node GNAT.Array_Split (g-arrspl.ads)
17775 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
17776 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
17777 @cindex Array splitter
17778
17779 @noindent
17780 Useful array-manipulation routines: given a set of separators, split
17781 an array wherever the separators appear, and provide direct access
17782 to the resulting slices.
17783
17784 @node GNAT.AWK (g-awk.ads)
17785 @section @code{GNAT.AWK} (@file{g-awk.ads})
17786 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
17787 @cindex Parsing
17788 @cindex AWK
17789
17790 @noindent
17791 Provides AWK-like parsing functions, with an easy interface for parsing one
17792 or more files containing formatted data. The file is viewed as a database
17793 where each record is a line and a field is a data element in this line.
17794
17795 @node GNAT.Bounded_Buffers (g-boubuf.ads)
17796 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
17797 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
17798 @cindex Parsing
17799 @cindex Bounded Buffers
17800
17801 @noindent
17802 Provides a concurrent generic bounded buffer abstraction. Instances are
17803 useful directly or as parts of the implementations of other abstractions,
17804 such as mailboxes.
17805
17806 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
17807 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
17808 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
17809 @cindex Parsing
17810 @cindex Mailboxes
17811
17812 @noindent
17813 Provides a thread-safe asynchronous intertask mailbox communication facility.
17814
17815 @node GNAT.Bubble_Sort (g-bubsor.ads)
17816 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
17817 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
17818 @cindex Sorting
17819 @cindex Bubble sort
17820
17821 @noindent
17822 Provides a general implementation of bubble sort usable for sorting arbitrary
17823 data items. Exchange and comparison procedures are provided by passing
17824 access-to-procedure values.
17825
17826 @node GNAT.Bubble_Sort_A (g-busora.ads)
17827 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
17828 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
17829 @cindex Sorting
17830 @cindex Bubble sort
17831
17832 @noindent
17833 Provides a general implementation of bubble sort usable for sorting arbitrary
17834 data items. Move and comparison procedures are provided by passing
17835 access-to-procedure values. This is an older version, retained for
17836 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
17837
17838 @node GNAT.Bubble_Sort_G (g-busorg.ads)
17839 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
17840 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
17841 @cindex Sorting
17842 @cindex Bubble sort
17843
17844 @noindent
17845 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
17846 are provided as generic parameters, this improves efficiency, especially
17847 if the procedures can be inlined, at the expense of duplicating code for
17848 multiple instantiations.
17849
17850 @node GNAT.Byte_Order_Mark (g-byorma.ads)
17851 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
17852 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
17853 @cindex UTF-8 representation
17854 @cindex Wide characte representations
17855
17856 @noindent
17857 Provides a routine which given a string, reads the start of the string to
17858 see whether it is one of the standard byte order marks (BOM's) which signal
17859 the encoding of the string. The routine includes detection of special XML
17860 sequences for various UCS input formats.
17861
17862 @node GNAT.Byte_Swapping (g-bytswa.ads)
17863 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
17864 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
17865 @cindex Byte swapping
17866 @cindex Endianness
17867
17868 @noindent
17869 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
17870 Machine-specific implementations are available in some cases.
17871
17872 @node GNAT.Calendar (g-calend.ads)
17873 @section @code{GNAT.Calendar} (@file{g-calend.ads})
17874 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
17875 @cindex @code{Calendar}
17876
17877 @noindent
17878 Extends the facilities provided by @code{Ada.Calendar} to include handling
17879 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
17880 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
17881 C @code{timeval} format.
17882
17883 @node GNAT.Calendar.Time_IO (g-catiio.ads)
17884 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
17885 @cindex @code{Calendar}
17886 @cindex Time
17887 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
17888
17889 @node GNAT.CRC32 (g-crc32.ads)
17890 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
17891 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
17892 @cindex CRC32
17893 @cindex Cyclic Redundancy Check
17894
17895 @noindent
17896 This package implements the CRC-32 algorithm. For a full description
17897 of this algorithm see
17898 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
17899 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
17900 Aug.@: 1988. Sarwate, D.V@.
17901
17902 @node GNAT.Case_Util (g-casuti.ads)
17903 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
17904 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
17905 @cindex Casing utilities
17906 @cindex Character handling (@code{GNAT.Case_Util})
17907
17908 @noindent
17909 A set of simple routines for handling upper and lower casing of strings
17910 without the overhead of the full casing tables
17911 in @code{Ada.Characters.Handling}.
17912
17913 @node GNAT.CGI (g-cgi.ads)
17914 @section @code{GNAT.CGI} (@file{g-cgi.ads})
17915 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
17916 @cindex CGI (Common Gateway Interface)
17917
17918 @noindent
17919 This is a package for interfacing a GNAT program with a Web server via the
17920 Common Gateway Interface (CGI)@. Basically this package parses the CGI
17921 parameters, which are a set of key/value pairs sent by the Web server. It
17922 builds a table whose index is the key and provides some services to deal
17923 with this table.
17924
17925 @node GNAT.CGI.Cookie (g-cgicoo.ads)
17926 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
17927 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
17928 @cindex CGI (Common Gateway Interface) cookie support
17929 @cindex Cookie support in CGI
17930
17931 @noindent
17932 This is a package to interface a GNAT program with a Web server via the
17933 Common Gateway Interface (CGI). It exports services to deal with Web
17934 cookies (piece of information kept in the Web client software).
17935
17936 @node GNAT.CGI.Debug (g-cgideb.ads)
17937 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
17938 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
17939 @cindex CGI (Common Gateway Interface) debugging
17940
17941 @noindent
17942 This is a package to help debugging CGI (Common Gateway Interface)
17943 programs written in Ada.
17944
17945 @node GNAT.Command_Line (g-comlin.ads)
17946 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
17947 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
17948 @cindex Command line
17949
17950 @noindent
17951 Provides a high level interface to @code{Ada.Command_Line} facilities,
17952 including the ability to scan for named switches with optional parameters
17953 and expand file names using wild card notations.
17954
17955 @node GNAT.Compiler_Version (g-comver.ads)
17956 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
17957 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
17958 @cindex Compiler Version
17959 @cindex Version, of compiler
17960
17961 @noindent
17962 Provides a routine for obtaining the version of the compiler used to
17963 compile the program. More accurately this is the version of the binder
17964 used to bind the program (this will normally be the same as the version
17965 of the compiler if a consistent tool set is used to compile all units
17966 of a partition).
17967
17968 @node GNAT.Ctrl_C (g-ctrl_c.ads)
17969 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
17970 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
17971 @cindex Interrupt
17972
17973 @noindent
17974 Provides a simple interface to handle Ctrl-C keyboard events.
17975
17976 @node GNAT.Current_Exception (g-curexc.ads)
17977 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
17978 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
17979 @cindex Current exception
17980 @cindex Exception retrieval
17981
17982 @noindent
17983 Provides access to information on the current exception that has been raised
17984 without the need for using the Ada 95 / Ada 2005 exception choice parameter
17985 specification syntax.
17986 This is particularly useful in simulating typical facilities for
17987 obtaining information about exceptions provided by Ada 83 compilers.
17988
17989 @node GNAT.Debug_Pools (g-debpoo.ads)
17990 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
17991 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
17992 @cindex Debugging
17993 @cindex Debug pools
17994 @cindex Memory corruption debugging
17995
17996 @noindent
17997 Provide a debugging storage pools that helps tracking memory corruption
17998 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
17999 @value{EDITION} User's Guide}.
18000
18001 @node GNAT.Debug_Utilities (g-debuti.ads)
18002 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
18003 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
18004 @cindex Debugging
18005
18006 @noindent
18007 Provides a few useful utilities for debugging purposes, including conversion
18008 to and from string images of address values. Supports both C and Ada formats
18009 for hexadecimal literals.
18010
18011 @node GNAT.Decode_String (g-decstr.ads)
18012 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
18013 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
18014 @cindex Decoding strings
18015 @cindex String decoding
18016 @cindex Wide character encoding
18017 @cindex UTF-8
18018 @cindex Unicode
18019
18020 @noindent
18021 A generic package providing routines for decoding wide character and wide wide
18022 character strings encoded as sequences of 8-bit characters using a specified
18023 encoding method. Includes validation routines, and also routines for stepping
18024 to next or previous encoded character in an encoded string.
18025 Useful in conjunction with Unicode character coding. Note there is a
18026 preinstantiation for UTF-8. See next entry.
18027
18028 @node GNAT.Decode_UTF8_String (g-deutst.ads)
18029 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
18030 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
18031 @cindex Decoding strings
18032 @cindex Decoding UTF-8 strings
18033 @cindex UTF-8 string decoding
18034 @cindex Wide character decoding
18035 @cindex UTF-8
18036 @cindex Unicode
18037
18038 @noindent
18039 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
18040
18041 @node GNAT.Directory_Operations (g-dirope.ads)
18042 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
18043 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
18044 @cindex Directory operations
18045
18046 @noindent
18047 Provides a set of routines for manipulating directories, including changing
18048 the current directory, making new directories, and scanning the files in a
18049 directory.
18050
18051 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
18052 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
18053 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
18054 @cindex Directory operations iteration
18055
18056 @noindent
18057 A child unit of GNAT.Directory_Operations providing additional operations
18058 for iterating through directories.
18059
18060 @node GNAT.Dynamic_HTables (g-dynhta.ads)
18061 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
18062 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
18063 @cindex Hash tables
18064
18065 @noindent
18066 A generic implementation of hash tables that can be used to hash arbitrary
18067 data. Provided in two forms, a simple form with built in hash functions,
18068 and a more complex form in which the hash function is supplied.
18069
18070 @noindent
18071 This package provides a facility similar to that of @code{GNAT.HTable},
18072 except that this package declares a type that can be used to define
18073 dynamic instances of the hash table, while an instantiation of
18074 @code{GNAT.HTable} creates a single instance of the hash table.
18075
18076 @node GNAT.Dynamic_Tables (g-dyntab.ads)
18077 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
18078 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
18079 @cindex Table implementation
18080 @cindex Arrays, extendable
18081
18082 @noindent
18083 A generic package providing a single dimension array abstraction where the
18084 length of the array can be dynamically modified.
18085
18086 @noindent
18087 This package provides a facility similar to that of @code{GNAT.Table},
18088 except that this package declares a type that can be used to define
18089 dynamic instances of the table, while an instantiation of
18090 @code{GNAT.Table} creates a single instance of the table type.
18091
18092 @node GNAT.Encode_String (g-encstr.ads)
18093 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
18094 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
18095 @cindex Encoding strings
18096 @cindex String encoding
18097 @cindex Wide character encoding
18098 @cindex UTF-8
18099 @cindex Unicode
18100
18101 @noindent
18102 A generic package providing routines for encoding wide character and wide
18103 wide character strings as sequences of 8-bit characters using a specified
18104 encoding method. Useful in conjunction with Unicode character coding.
18105 Note there is a preinstantiation for UTF-8. See next entry.
18106
18107 @node GNAT.Encode_UTF8_String (g-enutst.ads)
18108 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
18109 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
18110 @cindex Encoding strings
18111 @cindex Encoding UTF-8 strings
18112 @cindex UTF-8 string encoding
18113 @cindex Wide character encoding
18114 @cindex UTF-8
18115 @cindex Unicode
18116
18117 @noindent
18118 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
18119
18120 @node GNAT.Exception_Actions (g-excact.ads)
18121 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
18122 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
18123 @cindex Exception actions
18124
18125 @noindent
18126 Provides callbacks when an exception is raised. Callbacks can be registered
18127 for specific exceptions, or when any exception is raised. This
18128 can be used for instance to force a core dump to ease debugging.
18129
18130 @node GNAT.Exception_Traces (g-exctra.ads)
18131 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
18132 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
18133 @cindex Exception traces
18134 @cindex Debugging
18135
18136 @noindent
18137 Provides an interface allowing to control automatic output upon exception
18138 occurrences.
18139
18140 @node GNAT.Exceptions (g-except.ads)
18141 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
18142 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
18143 @cindex Exceptions, Pure
18144 @cindex Pure packages, exceptions
18145
18146 @noindent
18147 Normally it is not possible to raise an exception with
18148 a message from a subprogram in a pure package, since the
18149 necessary types and subprograms are in @code{Ada.Exceptions}
18150 which is not a pure unit. @code{GNAT.Exceptions} provides a
18151 facility for getting around this limitation for a few
18152 predefined exceptions, and for example allow raising
18153 @code{Constraint_Error} with a message from a pure subprogram.
18154
18155 @node GNAT.Expect (g-expect.ads)
18156 @section @code{GNAT.Expect} (@file{g-expect.ads})
18157 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
18158
18159 @noindent
18160 Provides a set of subprograms similar to what is available
18161 with the standard Tcl Expect tool.
18162 It allows you to easily spawn and communicate with an external process.
18163 You can send commands or inputs to the process, and compare the output
18164 with some expected regular expression. Currently @code{GNAT.Expect}
18165 is implemented on all native GNAT ports except for OpenVMS@.
18166 It is not implemented for cross ports, and in particular is not
18167 implemented for VxWorks or LynxOS@.
18168
18169 @node GNAT.Expect.TTY (g-exptty.ads)
18170 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
18171 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
18172
18173 @noindent
18174 As GNAT.Expect but using pseudo-terminal.
18175 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
18176 ports except for OpenVMS@. It is not implemented for cross ports, and
18177 in particular is not implemented for VxWorks or LynxOS@.
18178
18179 @node GNAT.Float_Control (g-flocon.ads)
18180 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
18181 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
18182 @cindex Floating-Point Processor
18183
18184 @noindent
18185 Provides an interface for resetting the floating-point processor into the
18186 mode required for correct semantic operation in Ada. Some third party
18187 library calls may cause this mode to be modified, and the Reset procedure
18188 in this package can be used to reestablish the required mode.
18189
18190 @node GNAT.Heap_Sort (g-heasor.ads)
18191 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
18192 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
18193 @cindex Sorting
18194
18195 @noindent
18196 Provides a general implementation of heap sort usable for sorting arbitrary
18197 data items. Exchange and comparison procedures are provided by passing
18198 access-to-procedure values. The algorithm used is a modified heap sort
18199 that performs approximately N*log(N) comparisons in the worst case.
18200
18201 @node GNAT.Heap_Sort_A (g-hesora.ads)
18202 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
18203 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
18204 @cindex Sorting
18205
18206 @noindent
18207 Provides a general implementation of heap sort usable for sorting arbitrary
18208 data items. Move and comparison procedures are provided by passing
18209 access-to-procedure values. The algorithm used is a modified heap sort
18210 that performs approximately N*log(N) comparisons in the worst case.
18211 This differs from @code{GNAT.Heap_Sort} in having a less convenient
18212 interface, but may be slightly more efficient.
18213
18214 @node GNAT.Heap_Sort_G (g-hesorg.ads)
18215 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
18216 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
18217 @cindex Sorting
18218
18219 @noindent
18220 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
18221 are provided as generic parameters, this improves efficiency, especially
18222 if the procedures can be inlined, at the expense of duplicating code for
18223 multiple instantiations.
18224
18225 @node GNAT.HTable (g-htable.ads)
18226 @section @code{GNAT.HTable} (@file{g-htable.ads})
18227 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
18228 @cindex Hash tables
18229
18230 @noindent
18231 A generic implementation of hash tables that can be used to hash arbitrary
18232 data. Provides two approaches, one a simple static approach, and the other
18233 allowing arbitrary dynamic hash tables.
18234
18235 @node GNAT.IO (g-io.ads)
18236 @section @code{GNAT.IO} (@file{g-io.ads})
18237 @cindex @code{GNAT.IO} (@file{g-io.ads})
18238 @cindex Simple I/O
18239 @cindex Input/Output facilities
18240
18241 @noindent
18242 A simple preelaborable input-output package that provides a subset of
18243 simple Text_IO functions for reading characters and strings from
18244 Standard_Input, and writing characters, strings and integers to either
18245 Standard_Output or Standard_Error.
18246
18247 @node GNAT.IO_Aux (g-io_aux.ads)
18248 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
18249 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
18250 @cindex Text_IO
18251 @cindex Input/Output facilities
18252
18253 Provides some auxiliary functions for use with Text_IO, including a test
18254 for whether a file exists, and functions for reading a line of text.
18255
18256 @node GNAT.Lock_Files (g-locfil.ads)
18257 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
18258 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
18259 @cindex File locking
18260 @cindex Locking using files
18261
18262 @noindent
18263 Provides a general interface for using files as locks. Can be used for
18264 providing program level synchronization.
18265
18266 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
18267 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
18268 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
18269 @cindex Random number generation
18270
18271 @noindent
18272 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
18273 a modified version of the Blum-Blum-Shub generator.
18274
18275 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
18276 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
18277 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
18278 @cindex Random number generation
18279
18280 @noindent
18281 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
18282 a modified version of the Blum-Blum-Shub generator.
18283
18284 @node GNAT.MD5 (g-md5.ads)
18285 @section @code{GNAT.MD5} (@file{g-md5.ads})
18286 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
18287 @cindex Message Digest MD5
18288
18289 @noindent
18290 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
18291
18292 @node GNAT.Memory_Dump (g-memdum.ads)
18293 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
18294 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
18295 @cindex Dump Memory
18296
18297 @noindent
18298 Provides a convenient routine for dumping raw memory to either the
18299 standard output or standard error files. Uses GNAT.IO for actual
18300 output.
18301
18302 @node GNAT.Most_Recent_Exception (g-moreex.ads)
18303 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
18304 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
18305 @cindex Exception, obtaining most recent
18306
18307 @noindent
18308 Provides access to the most recently raised exception. Can be used for
18309 various logging purposes, including duplicating functionality of some
18310 Ada 83 implementation dependent extensions.
18311
18312 @node GNAT.OS_Lib (g-os_lib.ads)
18313 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
18314 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
18315 @cindex Operating System interface
18316 @cindex Spawn capability
18317
18318 @noindent
18319 Provides a range of target independent operating system interface functions,
18320 including time/date management, file operations, subprocess management,
18321 including a portable spawn procedure, and access to environment variables
18322 and error return codes.
18323
18324 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
18325 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
18326 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
18327 @cindex Hash functions
18328
18329 @noindent
18330 Provides a generator of static minimal perfect hash functions. No
18331 collisions occur and each item can be retrieved from the table in one
18332 probe (perfect property). The hash table size corresponds to the exact
18333 size of the key set and no larger (minimal property). The key set has to
18334 be know in advance (static property). The hash functions are also order
18335 preserving. If w2 is inserted after w1 in the generator, their
18336 hashcode are in the same order. These hashing functions are very
18337 convenient for use with realtime applications.
18338
18339 @node GNAT.Random_Numbers (g-rannum.ads)
18340 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
18341 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
18342 @cindex Random number generation
18343
18344 @noindent
18345 Provides random number capabilities which extend those available in the
18346 standard Ada library and are more convenient to use.
18347
18348 @node GNAT.Regexp (g-regexp.ads)
18349 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
18350 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
18351 @cindex Regular expressions
18352 @cindex Pattern matching
18353
18354 @noindent
18355 A simple implementation of regular expressions, using a subset of regular
18356 expression syntax copied from familiar Unix style utilities. This is the
18357 simples of the three pattern matching packages provided, and is particularly
18358 suitable for ``file globbing'' applications.
18359
18360 @node GNAT.Registry (g-regist.ads)
18361 @section @code{GNAT.Registry} (@file{g-regist.ads})
18362 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
18363 @cindex Windows Registry
18364
18365 @noindent
18366 This is a high level binding to the Windows registry. It is possible to
18367 do simple things like reading a key value, creating a new key. For full
18368 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
18369 package provided with the Win32Ada binding
18370
18371 @node GNAT.Regpat (g-regpat.ads)
18372 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
18373 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
18374 @cindex Regular expressions
18375 @cindex Pattern matching
18376
18377 @noindent
18378 A complete implementation of Unix-style regular expression matching, copied
18379 from the original V7 style regular expression library written in C by
18380 Henry Spencer (and binary compatible with this C library).
18381
18382 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
18383 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
18384 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
18385 @cindex Secondary Stack Info
18386
18387 @noindent
18388 Provide the capability to query the high water mark of the current task's
18389 secondary stack.
18390
18391 @node GNAT.Semaphores (g-semaph.ads)
18392 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
18393 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
18394 @cindex Semaphores
18395
18396 @noindent
18397 Provides classic counting and binary semaphores using protected types.
18398
18399 @node GNAT.Serial_Communications (g-sercom.ads)
18400 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
18401 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
18402 @cindex Serial_Communications
18403
18404 @noindent
18405 Provides a simple interface to send and receive data over a serial
18406 port. This is only supported on GNU/Linux and Windows.
18407
18408 @node GNAT.SHA1 (g-sha1.ads)
18409 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
18410 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
18411 @cindex Secure Hash Algorithm SHA-1
18412
18413 @noindent
18414 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
18415 and RFC 3174.
18416
18417 @node GNAT.SHA224 (g-sha224.ads)
18418 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
18419 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
18420 @cindex Secure Hash Algorithm SHA-224
18421
18422 @noindent
18423 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
18424
18425 @node GNAT.SHA256 (g-sha256.ads)
18426 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
18427 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
18428 @cindex Secure Hash Algorithm SHA-256
18429
18430 @noindent
18431 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
18432
18433 @node GNAT.SHA384 (g-sha384.ads)
18434 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
18435 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
18436 @cindex Secure Hash Algorithm SHA-384
18437
18438 @noindent
18439 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
18440
18441 @node GNAT.SHA512 (g-sha512.ads)
18442 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
18443 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
18444 @cindex Secure Hash Algorithm SHA-512
18445
18446 @noindent
18447 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
18448
18449 @node GNAT.Signals (g-signal.ads)
18450 @section @code{GNAT.Signals} (@file{g-signal.ads})
18451 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
18452 @cindex Signals
18453
18454 @noindent
18455 Provides the ability to manipulate the blocked status of signals on supported
18456 targets.
18457
18458 @node GNAT.Sockets (g-socket.ads)
18459 @section @code{GNAT.Sockets} (@file{g-socket.ads})
18460 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
18461 @cindex Sockets
18462
18463 @noindent
18464 A high level and portable interface to develop sockets based applications.
18465 This package is based on the sockets thin binding found in
18466 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
18467 on all native GNAT ports except for OpenVMS@. It is not implemented
18468 for the LynxOS@ cross port.
18469
18470 @node GNAT.Source_Info (g-souinf.ads)
18471 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
18472 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
18473 @cindex Source Information
18474
18475 @noindent
18476 Provides subprograms that give access to source code information known at
18477 compile time, such as the current file name and line number.
18478
18479 @node GNAT.Spelling_Checker (g-speche.ads)
18480 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
18481 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
18482 @cindex Spell checking
18483
18484 @noindent
18485 Provides a function for determining whether one string is a plausible
18486 near misspelling of another string.
18487
18488 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
18489 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
18490 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
18491 @cindex Spell checking
18492
18493 @noindent
18494 Provides a generic function that can be instantiated with a string type for
18495 determining whether one string is a plausible near misspelling of another
18496 string.
18497
18498 @node GNAT.Spitbol.Patterns (g-spipat.ads)
18499 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
18500 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
18501 @cindex SPITBOL pattern matching
18502 @cindex Pattern matching
18503
18504 @noindent
18505 A complete implementation of SNOBOL4 style pattern matching. This is the
18506 most elaborate of the pattern matching packages provided. It fully duplicates
18507 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
18508 efficient algorithm developed by Robert Dewar for the SPITBOL system.
18509
18510 @node GNAT.Spitbol (g-spitbo.ads)
18511 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
18512 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
18513 @cindex SPITBOL interface
18514
18515 @noindent
18516 The top level package of the collection of SPITBOL-style functionality, this
18517 package provides basic SNOBOL4 string manipulation functions, such as
18518 Pad, Reverse, Trim, Substr capability, as well as a generic table function
18519 useful for constructing arbitrary mappings from strings in the style of
18520 the SNOBOL4 TABLE function.
18521
18522 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
18523 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
18524 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
18525 @cindex Sets of strings
18526 @cindex SPITBOL Tables
18527
18528 @noindent
18529 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
18530 for type @code{Standard.Boolean}, giving an implementation of sets of
18531 string values.
18532
18533 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
18534 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
18535 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
18536 @cindex Integer maps
18537 @cindex Maps
18538 @cindex SPITBOL Tables
18539
18540 @noindent
18541 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
18542 for type @code{Standard.Integer}, giving an implementation of maps
18543 from string to integer values.
18544
18545 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
18546 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
18547 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
18548 @cindex String maps
18549 @cindex Maps
18550 @cindex SPITBOL Tables
18551
18552 @noindent
18553 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
18554 a variable length string type, giving an implementation of general
18555 maps from strings to strings.
18556
18557 @node GNAT.SSE (g-sse.ads)
18558 @section @code{GNAT.SSE} (@file{g-sse.ads})
18559 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
18560
18561 @noindent
18562 Root of a set of units aimed at offering Ada bindings to a subset of
18563 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
18564 targets. It exposes vector component types together with a general
18565 introduction to the binding contents and use.
18566
18567 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
18568 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
18569 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
18570
18571 @noindent
18572 SSE vector types for use with SSE related intrinsics.
18573
18574 @node GNAT.Strings (g-string.ads)
18575 @section @code{GNAT.Strings} (@file{g-string.ads})
18576 @cindex @code{GNAT.Strings} (@file{g-string.ads})
18577
18578 @noindent
18579 Common String access types and related subprograms. Basically it
18580 defines a string access and an array of string access types.
18581
18582 @node GNAT.String_Split (g-strspl.ads)
18583 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
18584 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
18585 @cindex String splitter
18586
18587 @noindent
18588 Useful string manipulation routines: given a set of separators, split
18589 a string wherever the separators appear, and provide direct access
18590 to the resulting slices. This package is instantiated from
18591 @code{GNAT.Array_Split}.
18592
18593 @node GNAT.Table (g-table.ads)
18594 @section @code{GNAT.Table} (@file{g-table.ads})
18595 @cindex @code{GNAT.Table} (@file{g-table.ads})
18596 @cindex Table implementation
18597 @cindex Arrays, extendable
18598
18599 @noindent
18600 A generic package providing a single dimension array abstraction where the
18601 length of the array can be dynamically modified.
18602
18603 @noindent
18604 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
18605 except that this package declares a single instance of the table type,
18606 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
18607 used to define dynamic instances of the table.
18608
18609 @node GNAT.Task_Lock (g-tasloc.ads)
18610 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
18611 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
18612 @cindex Task synchronization
18613 @cindex Task locking
18614 @cindex Locking
18615
18616 @noindent
18617 A very simple facility for locking and unlocking sections of code using a
18618 single global task lock. Appropriate for use in situations where contention
18619 between tasks is very rarely expected.
18620
18621 @node GNAT.Time_Stamp (g-timsta.ads)
18622 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
18623 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
18624 @cindex Time stamp
18625 @cindex Current time
18626
18627 @noindent
18628 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
18629 represents the current date and time in ISO 8601 format. This is a very simple
18630 routine with minimal code and there are no dependencies on any other unit.
18631
18632 @node GNAT.Threads (g-thread.ads)
18633 @section @code{GNAT.Threads} (@file{g-thread.ads})
18634 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
18635 @cindex Foreign threads
18636 @cindex Threads, foreign
18637
18638 @noindent
18639 Provides facilities for dealing with foreign threads which need to be known
18640 by the GNAT run-time system. Consult the documentation of this package for
18641 further details if your program has threads that are created by a non-Ada
18642 environment which then accesses Ada code.
18643
18644 @node GNAT.Traceback (g-traceb.ads)
18645 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
18646 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
18647 @cindex Trace back facilities
18648
18649 @noindent
18650 Provides a facility for obtaining non-symbolic traceback information, useful
18651 in various debugging situations.
18652
18653 @node GNAT.Traceback.Symbolic (g-trasym.ads)
18654 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
18655 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
18656 @cindex Trace back facilities
18657
18658 @node GNAT.UTF_32 (g-utf_32.ads)
18659 @section @code{GNAT.UTF_32} (@file{g-table.ads})
18660 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
18661 @cindex Wide character codes
18662
18663 @noindent
18664 This is a package intended to be used in conjunction with the
18665 @code{Wide_Character} type in Ada 95 and the
18666 @code{Wide_Wide_Character} type in Ada 2005 (available
18667 in @code{GNAT} in Ada 2005 mode). This package contains
18668 Unicode categorization routines, as well as lexical
18669 categorization routines corresponding to the Ada 2005
18670 lexical rules for identifiers and strings, and also a
18671 lower case to upper case fold routine corresponding to
18672 the Ada 2005 rules for identifier equivalence.
18673
18674 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
18675 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
18676 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
18677 @cindex Spell checking
18678
18679 @noindent
18680 Provides a function for determining whether one wide wide string is a plausible
18681 near misspelling of another wide wide string, where the strings are represented
18682 using the UTF_32_String type defined in System.Wch_Cnv.
18683
18684 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
18685 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
18686 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
18687 @cindex Spell checking
18688
18689 @noindent
18690 Provides a function for determining whether one wide string is a plausible
18691 near misspelling of another wide string.
18692
18693 @node GNAT.Wide_String_Split (g-wistsp.ads)
18694 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
18695 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
18696 @cindex Wide_String splitter
18697
18698 @noindent
18699 Useful wide string manipulation routines: given a set of separators, split
18700 a wide string wherever the separators appear, and provide direct access
18701 to the resulting slices. This package is instantiated from
18702 @code{GNAT.Array_Split}.
18703
18704 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
18705 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
18706 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
18707 @cindex Spell checking
18708
18709 @noindent
18710 Provides a function for determining whether one wide wide string is a plausible
18711 near misspelling of another wide wide string.
18712
18713 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
18714 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
18715 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
18716 @cindex Wide_Wide_String splitter
18717
18718 @noindent
18719 Useful wide wide string manipulation routines: given a set of separators, split
18720 a wide wide string wherever the separators appear, and provide direct access
18721 to the resulting slices. This package is instantiated from
18722 @code{GNAT.Array_Split}.
18723
18724 @node Interfaces.C.Extensions (i-cexten.ads)
18725 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
18726 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
18727
18728 @noindent
18729 This package contains additional C-related definitions, intended
18730 for use with either manually or automatically generated bindings
18731 to C libraries.
18732
18733 @node Interfaces.C.Streams (i-cstrea.ads)
18734 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
18735 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
18736 @cindex C streams, interfacing
18737
18738 @noindent
18739 This package is a binding for the most commonly used operations
18740 on C streams.
18741
18742 @node Interfaces.CPP (i-cpp.ads)
18743 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
18744 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
18745 @cindex C++ interfacing
18746 @cindex Interfacing, to C++
18747
18748 @noindent
18749 This package provides facilities for use in interfacing to C++. It
18750 is primarily intended to be used in connection with automated tools
18751 for the generation of C++ interfaces.
18752
18753 @node Interfaces.Packed_Decimal (i-pacdec.ads)
18754 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
18755 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
18756 @cindex IBM Packed Format
18757 @cindex Packed Decimal
18758
18759 @noindent
18760 This package provides a set of routines for conversions to and
18761 from a packed decimal format compatible with that used on IBM
18762 mainframes.
18763
18764 @node Interfaces.VxWorks (i-vxwork.ads)
18765 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
18766 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
18767 @cindex Interfacing to VxWorks
18768 @cindex VxWorks, interfacing
18769
18770 @noindent
18771 This package provides a limited binding to the VxWorks API.
18772 In particular, it interfaces with the
18773 VxWorks hardware interrupt facilities.
18774
18775 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
18776 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
18777 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
18778 @cindex Interfacing to VxWorks' I/O
18779 @cindex VxWorks, I/O interfacing
18780 @cindex VxWorks, Get_Immediate
18781 @cindex Get_Immediate, VxWorks
18782
18783 @noindent
18784 This package provides a binding to the ioctl (IO/Control)
18785 function of VxWorks, defining a set of option values and
18786 function codes. A particular use of this package is
18787 to enable the use of Get_Immediate under VxWorks.
18788
18789 @node System.Address_Image (s-addima.ads)
18790 @section @code{System.Address_Image} (@file{s-addima.ads})
18791 @cindex @code{System.Address_Image} (@file{s-addima.ads})
18792 @cindex Address image
18793 @cindex Image, of an address
18794
18795 @noindent
18796 This function provides a useful debugging
18797 function that gives an (implementation dependent)
18798 string which identifies an address.
18799
18800 @node System.Assertions (s-assert.ads)
18801 @section @code{System.Assertions} (@file{s-assert.ads})
18802 @cindex @code{System.Assertions} (@file{s-assert.ads})
18803 @cindex Assertions
18804 @cindex Assert_Failure, exception
18805
18806 @noindent
18807 This package provides the declaration of the exception raised
18808 by an run-time assertion failure, as well as the routine that
18809 is used internally to raise this assertion.
18810
18811 @node System.Memory (s-memory.ads)
18812 @section @code{System.Memory} (@file{s-memory.ads})
18813 @cindex @code{System.Memory} (@file{s-memory.ads})
18814 @cindex Memory allocation
18815
18816 @noindent
18817 This package provides the interface to the low level routines used
18818 by the generated code for allocation and freeing storage for the
18819 default storage pool (analogous to the C routines malloc and free.
18820 It also provides a reallocation interface analogous to the C routine
18821 realloc. The body of this unit may be modified to provide alternative
18822 allocation mechanisms for the default pool, and in addition, direct
18823 calls to this unit may be made for low level allocation uses (for
18824 example see the body of @code{GNAT.Tables}).
18825
18826 @node System.Multiprocessors (s-multip.ads)
18827 @section @code{System.Multiprocessors} (@file{s-multip.ads})
18828 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
18829 @cindex Multiprocessor interface
18830 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
18831 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
18832 technically an implementation-defined addition).
18833
18834 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
18835 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
18836 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
18837 @cindex Multiprocessor interface
18838 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
18839 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
18840 technically an implementation-defined addition).
18841
18842 @node System.Partition_Interface (s-parint.ads)
18843 @section @code{System.Partition_Interface} (@file{s-parint.ads})
18844 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
18845 @cindex Partition interfacing functions
18846
18847 @noindent
18848 This package provides facilities for partition interfacing. It
18849 is used primarily in a distribution context when using Annex E
18850 with @code{GLADE}.
18851
18852 @node System.Pool_Global (s-pooglo.ads)
18853 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
18854 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
18855 @cindex Storage pool, global
18856 @cindex Global storage pool
18857
18858 @noindent
18859 This package provides a storage pool that is equivalent to the default
18860 storage pool used for access types for which no pool is specifically
18861 declared. It uses malloc/free to allocate/free and does not attempt to
18862 do any automatic reclamation.
18863
18864 @node System.Pool_Local (s-pooloc.ads)
18865 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
18866 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
18867 @cindex Storage pool, local
18868 @cindex Local storage pool
18869
18870 @noindent
18871 This package provides a storage pool that is intended for use with locally
18872 defined access types. It uses malloc/free for allocate/free, and maintains
18873 a list of allocated blocks, so that all storage allocated for the pool can
18874 be freed automatically when the pool is finalized.
18875
18876 @node System.Restrictions (s-restri.ads)
18877 @section @code{System.Restrictions} (@file{s-restri.ads})
18878 @cindex @code{System.Restrictions} (@file{s-restri.ads})
18879 @cindex Run-time restrictions access
18880
18881 @noindent
18882 This package provides facilities for accessing at run time
18883 the status of restrictions specified at compile time for
18884 the partition. Information is available both with regard
18885 to actual restrictions specified, and with regard to
18886 compiler determined information on which restrictions
18887 are violated by one or more packages in the partition.
18888
18889 @node System.Rident (s-rident.ads)
18890 @section @code{System.Rident} (@file{s-rident.ads})
18891 @cindex @code{System.Rident} (@file{s-rident.ads})
18892 @cindex Restrictions definitions
18893
18894 @noindent
18895 This package provides definitions of the restrictions
18896 identifiers supported by GNAT, and also the format of
18897 the restrictions provided in package System.Restrictions.
18898 It is not normally necessary to @code{with} this generic package
18899 since the necessary instantiation is included in
18900 package System.Restrictions.
18901
18902 @node System.Strings.Stream_Ops (s-ststop.ads)
18903 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
18904 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
18905 @cindex Stream operations
18906 @cindex String stream operations
18907
18908 @noindent
18909 This package provides a set of stream subprograms for standard string types.
18910 It is intended primarily to support implicit use of such subprograms when
18911 stream attributes are applied to string types, but the subprograms in this
18912 package can be used directly by application programs.
18913
18914 @node System.Task_Info (s-tasinf.ads)
18915 @section @code{System.Task_Info} (@file{s-tasinf.ads})
18916 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
18917 @cindex Task_Info pragma
18918
18919 @noindent
18920 This package provides target dependent functionality that is used
18921 to support the @code{Task_Info} pragma
18922
18923 @node System.Wch_Cnv (s-wchcnv.ads)
18924 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
18925 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
18926 @cindex Wide Character, Representation
18927 @cindex Wide String, Conversion
18928 @cindex Representation of wide characters
18929
18930 @noindent
18931 This package provides routines for converting between
18932 wide and wide wide characters and a representation as a value of type
18933 @code{Standard.String}, using a specified wide character
18934 encoding method. It uses definitions in
18935 package @code{System.Wch_Con}.
18936
18937 @node System.Wch_Con (s-wchcon.ads)
18938 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
18939 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
18940
18941 @noindent
18942 This package provides definitions and descriptions of
18943 the various methods used for encoding wide characters
18944 in ordinary strings. These definitions are used by
18945 the package @code{System.Wch_Cnv}.
18946
18947 @node Interfacing to Other Languages
18948 @chapter Interfacing to Other Languages
18949 @noindent
18950 The facilities in annex B of the Ada Reference Manual are fully
18951 implemented in GNAT, and in addition, a full interface to C++ is
18952 provided.
18953
18954 @menu
18955 * Interfacing to C::
18956 * Interfacing to C++::
18957 * Interfacing to COBOL::
18958 * Interfacing to Fortran::
18959 * Interfacing to non-GNAT Ada code::
18960 @end menu
18961
18962 @node Interfacing to C
18963 @section Interfacing to C
18964
18965 @noindent
18966 Interfacing to C with GNAT can use one of two approaches:
18967
18968 @itemize @bullet
18969 @item
18970 The types in the package @code{Interfaces.C} may be used.
18971 @item
18972 Standard Ada types may be used directly. This may be less portable to
18973 other compilers, but will work on all GNAT compilers, which guarantee
18974 correspondence between the C and Ada types.
18975 @end itemize
18976
18977 @noindent
18978 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
18979 effect, since this is the default. The following table shows the
18980 correspondence between Ada scalar types and the corresponding C types.
18981
18982 @table @code
18983 @item Integer
18984 @code{int}
18985 @item Short_Integer
18986 @code{short}
18987 @item Short_Short_Integer
18988 @code{signed char}
18989 @item Long_Integer
18990 @code{long}
18991 @item Long_Long_Integer
18992 @code{long long}
18993 @item Short_Float
18994 @code{float}
18995 @item Float
18996 @code{float}
18997 @item Long_Float
18998 @code{double}
18999 @item Long_Long_Float
19000 This is the longest floating-point type supported by the hardware.
19001 @end table
19002
19003 @noindent
19004 Additionally, there are the following general correspondences between Ada
19005 and C types:
19006 @itemize @bullet
19007 @item
19008 Ada enumeration types map to C enumeration types directly if pragma
19009 @code{Convention C} is specified, which causes them to have int
19010 length. Without pragma @code{Convention C}, Ada enumeration types map to
19011 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
19012 @code{int}, respectively) depending on the number of values passed.
19013 This is the only case in which pragma @code{Convention C} affects the
19014 representation of an Ada type.
19015
19016 @item
19017 Ada access types map to C pointers, except for the case of pointers to
19018 unconstrained types in Ada, which have no direct C equivalent.
19019
19020 @item
19021 Ada arrays map directly to C arrays.
19022
19023 @item
19024 Ada records map directly to C structures.
19025
19026 @item
19027 Packed Ada records map to C structures where all members are bit fields
19028 of the length corresponding to the @code{@var{type}'Size} value in Ada.
19029 @end itemize
19030
19031 @node Interfacing to C++
19032 @section Interfacing to C++
19033
19034 @noindent
19035 The interface to C++ makes use of the following pragmas, which are
19036 primarily intended to be constructed automatically using a binding generator
19037 tool, although it is possible to construct them by hand.
19038
19039 Using these pragmas it is possible to achieve complete
19040 inter-operability between Ada tagged types and C++ class definitions.
19041 See @ref{Implementation Defined Pragmas}, for more details.
19042
19043 @table @code
19044 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
19045 The argument denotes an entity in the current declarative region that is
19046 declared as a tagged or untagged record type. It indicates that the type
19047 corresponds to an externally declared C++ class type, and is to be laid
19048 out the same way that C++ would lay out the type.
19049
19050 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
19051 for backward compatibility but its functionality is available
19052 using pragma @code{Import} with @code{Convention} = @code{CPP}.
19053
19054 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
19055 This pragma identifies an imported function (imported in the usual way
19056 with pragma @code{Import}) as corresponding to a C++ constructor.
19057 @end table
19058
19059 A few restrictions are placed on the use of the @code{Access} attribute
19060 in conjunction with subprograms subject to convention @code{CPP}: the
19061 attribute may be used neither on primitive operations of a tagged
19062 record type with convention @code{CPP}, imported or not, nor on
19063 subprograms imported with pragma @code{CPP_Constructor}.
19064
19065 In addition, C++ exceptions are propagated and can be handled in an
19066 @code{others} choice of an exception handler. The corresponding Ada
19067 occurrence has no message, and the simple name of the exception identity
19068 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
19069 tasks works properly when such foreign exceptions are propagated.
19070
19071 It is also possible to import a C++ exception using the following syntax:
19072
19073 @smallexample @c ada
19074 LOCAL_NAME : exception;
19075 pragma Import (Cpp,
19076 [Entity =>] LOCAL_NAME,
19077 [External_Name =>] static_string_EXPRESSION);
19078 @end smallexample
19079
19080 @noindent
19081 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
19082 cover a specific C++ exception in an exception handler.
19083
19084 @node Interfacing to COBOL
19085 @section Interfacing to COBOL
19086
19087 @noindent
19088 Interfacing to COBOL is achieved as described in section B.4 of
19089 the Ada Reference Manual.
19090
19091 @node Interfacing to Fortran
19092 @section Interfacing to Fortran
19093
19094 @noindent
19095 Interfacing to Fortran is achieved as described in section B.5 of the
19096 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
19097 multi-dimensional array causes the array to be stored in column-major
19098 order as required for convenient interface to Fortran.
19099
19100 @node Interfacing to non-GNAT Ada code
19101 @section Interfacing to non-GNAT Ada code
19102
19103 It is possible to specify the convention @code{Ada} in a pragma
19104 @code{Import} or pragma @code{Export}. However this refers to
19105 the calling conventions used by GNAT, which may or may not be
19106 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
19107 compiler to allow interoperation.
19108
19109 If arguments types are kept simple, and if the foreign compiler generally
19110 follows system calling conventions, then it may be possible to integrate
19111 files compiled by other Ada compilers, provided that the elaboration
19112 issues are adequately addressed (for example by eliminating the
19113 need for any load time elaboration).
19114
19115 In particular, GNAT running on VMS is designed to
19116 be highly compatible with the DEC Ada 83 compiler, so this is one
19117 case in which it is possible to import foreign units of this type,
19118 provided that the data items passed are restricted to simple scalar
19119 values or simple record types without variants, or simple array
19120 types with fixed bounds.
19121
19122 @node Specialized Needs Annexes
19123 @chapter Specialized Needs Annexes
19124
19125 @noindent
19126 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
19127 required in all implementations. However, as described in this chapter,
19128 GNAT implements all of these annexes:
19129
19130 @table @asis
19131 @item Systems Programming (Annex C)
19132 The Systems Programming Annex is fully implemented.
19133
19134 @item Real-Time Systems (Annex D)
19135 The Real-Time Systems Annex is fully implemented.
19136
19137 @item Distributed Systems (Annex E)
19138 Stub generation is fully implemented in the GNAT compiler. In addition,
19139 a complete compatible PCS is available as part of the GLADE system,
19140 a separate product. When the two
19141 products are used in conjunction, this annex is fully implemented.
19142
19143 @item Information Systems (Annex F)
19144 The Information Systems annex is fully implemented.
19145
19146 @item Numerics (Annex G)
19147 The Numerics Annex is fully implemented.
19148
19149 @item Safety and Security / High-Integrity Systems (Annex H)
19150 The Safety and Security Annex (termed the High-Integrity Systems Annex
19151 in Ada 2005) is fully implemented.
19152 @end table
19153
19154 @node Implementation of Specific Ada Features
19155 @chapter Implementation of Specific Ada Features
19156
19157 @noindent
19158 This chapter describes the GNAT implementation of several Ada language
19159 facilities.
19160
19161 @menu
19162 * Machine Code Insertions::
19163 * GNAT Implementation of Tasking::
19164 * GNAT Implementation of Shared Passive Packages::
19165 * Code Generation for Array Aggregates::
19166 * The Size of Discriminated Records with Default Discriminants::
19167 * Strict Conformance to the Ada Reference Manual::
19168 @end menu
19169
19170 @node Machine Code Insertions
19171 @section Machine Code Insertions
19172 @cindex Machine Code insertions
19173
19174 @noindent
19175 Package @code{Machine_Code} provides machine code support as described
19176 in the Ada Reference Manual in two separate forms:
19177 @itemize @bullet
19178 @item
19179 Machine code statements, consisting of qualified expressions that
19180 fit the requirements of RM section 13.8.
19181 @item
19182 An intrinsic callable procedure, providing an alternative mechanism of
19183 including machine instructions in a subprogram.
19184 @end itemize
19185
19186 @noindent
19187 The two features are similar, and both are closely related to the mechanism
19188 provided by the asm instruction in the GNU C compiler. Full understanding
19189 and use of the facilities in this package requires understanding the asm
19190 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
19191 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
19192
19193 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
19194 semantic restrictions and effects as described below. Both are provided so
19195 that the procedure call can be used as a statement, and the function call
19196 can be used to form a code_statement.
19197
19198 The first example given in the GCC documentation is the C @code{asm}
19199 instruction:
19200 @smallexample
19201 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
19202 @end smallexample
19203
19204 @noindent
19205 The equivalent can be written for GNAT as:
19206
19207 @smallexample @c ada
19208 Asm ("fsinx %1 %0",
19209 My_Float'Asm_Output ("=f", result),
19210 My_Float'Asm_Input ("f", angle));
19211 @end smallexample
19212
19213 @noindent
19214 The first argument to @code{Asm} is the assembler template, and is
19215 identical to what is used in GNU C@. This string must be a static
19216 expression. The second argument is the output operand list. It is
19217 either a single @code{Asm_Output} attribute reference, or a list of such
19218 references enclosed in parentheses (technically an array aggregate of
19219 such references).
19220
19221 The @code{Asm_Output} attribute denotes a function that takes two
19222 parameters. The first is a string, the second is the name of a variable
19223 of the type designated by the attribute prefix. The first (string)
19224 argument is required to be a static expression and designates the
19225 constraint for the parameter (e.g.@: what kind of register is
19226 required). The second argument is the variable to be updated with the
19227 result. The possible values for constraint are the same as those used in
19228 the RTL, and are dependent on the configuration file used to build the
19229 GCC back end. If there are no output operands, then this argument may
19230 either be omitted, or explicitly given as @code{No_Output_Operands}.
19231
19232 The second argument of @code{@var{my_float}'Asm_Output} functions as
19233 though it were an @code{out} parameter, which is a little curious, but
19234 all names have the form of expressions, so there is no syntactic
19235 irregularity, even though normally functions would not be permitted
19236 @code{out} parameters. The third argument is the list of input
19237 operands. It is either a single @code{Asm_Input} attribute reference, or
19238 a list of such references enclosed in parentheses (technically an array
19239 aggregate of such references).
19240
19241 The @code{Asm_Input} attribute denotes a function that takes two
19242 parameters. The first is a string, the second is an expression of the
19243 type designated by the prefix. The first (string) argument is required
19244 to be a static expression, and is the constraint for the parameter,
19245 (e.g.@: what kind of register is required). The second argument is the
19246 value to be used as the input argument. The possible values for the
19247 constant are the same as those used in the RTL, and are dependent on
19248 the configuration file used to built the GCC back end.
19249
19250 If there are no input operands, this argument may either be omitted, or
19251 explicitly given as @code{No_Input_Operands}. The fourth argument, not
19252 present in the above example, is a list of register names, called the
19253 @dfn{clobber} argument. This argument, if given, must be a static string
19254 expression, and is a space or comma separated list of names of registers
19255 that must be considered destroyed as a result of the @code{Asm} call. If
19256 this argument is the null string (the default value), then the code
19257 generator assumes that no additional registers are destroyed.
19258
19259 The fifth argument, not present in the above example, called the
19260 @dfn{volatile} argument, is by default @code{False}. It can be set to
19261 the literal value @code{True} to indicate to the code generator that all
19262 optimizations with respect to the instruction specified should be
19263 suppressed, and that in particular, for an instruction that has outputs,
19264 the instruction will still be generated, even if none of the outputs are
19265 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
19266 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
19267 Generally it is strongly advisable to use Volatile for any ASM statement
19268 that is missing either input or output operands, or when two or more ASM
19269 statements appear in sequence, to avoid unwanted optimizations. A warning
19270 is generated if this advice is not followed.
19271
19272 The @code{Asm} subprograms may be used in two ways. First the procedure
19273 forms can be used anywhere a procedure call would be valid, and
19274 correspond to what the RM calls ``intrinsic'' routines. Such calls can
19275 be used to intersperse machine instructions with other Ada statements.
19276 Second, the function forms, which return a dummy value of the limited
19277 private type @code{Asm_Insn}, can be used in code statements, and indeed
19278 this is the only context where such calls are allowed. Code statements
19279 appear as aggregates of the form:
19280
19281 @smallexample @c ada
19282 Asm_Insn'(Asm (@dots{}));
19283 Asm_Insn'(Asm_Volatile (@dots{}));
19284 @end smallexample
19285
19286 @noindent
19287 In accordance with RM rules, such code statements are allowed only
19288 within subprograms whose entire body consists of such statements. It is
19289 not permissible to intermix such statements with other Ada statements.
19290
19291 Typically the form using intrinsic procedure calls is more convenient
19292 and more flexible. The code statement form is provided to meet the RM
19293 suggestion that such a facility should be made available. The following
19294 is the exact syntax of the call to @code{Asm}. As usual, if named notation
19295 is used, the arguments may be given in arbitrary order, following the
19296 normal rules for use of positional and named arguments)
19297
19298 @smallexample
19299 ASM_CALL ::= Asm (
19300 [Template =>] static_string_EXPRESSION
19301 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
19302 [,[Inputs =>] INPUT_OPERAND_LIST ]
19303 [,[Clobber =>] static_string_EXPRESSION ]
19304 [,[Volatile =>] static_boolean_EXPRESSION] )
19305
19306 OUTPUT_OPERAND_LIST ::=
19307 [PREFIX.]No_Output_Operands
19308 | OUTPUT_OPERAND_ATTRIBUTE
19309 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
19310
19311 OUTPUT_OPERAND_ATTRIBUTE ::=
19312 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
19313
19314 INPUT_OPERAND_LIST ::=
19315 [PREFIX.]No_Input_Operands
19316 | INPUT_OPERAND_ATTRIBUTE
19317 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
19318
19319 INPUT_OPERAND_ATTRIBUTE ::=
19320 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
19321 @end smallexample
19322
19323 @noindent
19324 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
19325 are declared in the package @code{Machine_Code} and must be referenced
19326 according to normal visibility rules. In particular if there is no
19327 @code{use} clause for this package, then appropriate package name
19328 qualification is required.
19329
19330 @node GNAT Implementation of Tasking
19331 @section GNAT Implementation of Tasking
19332
19333 @noindent
19334 This chapter outlines the basic GNAT approach to tasking (in particular,
19335 a multi-layered library for portability) and discusses issues related
19336 to compliance with the Real-Time Systems Annex.
19337
19338 @menu
19339 * Mapping Ada Tasks onto the Underlying Kernel Threads::
19340 * Ensuring Compliance with the Real-Time Annex::
19341 @end menu
19342
19343 @node Mapping Ada Tasks onto the Underlying Kernel Threads
19344 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
19345
19346 @noindent
19347 GNAT's run-time support comprises two layers:
19348
19349 @itemize @bullet
19350 @item GNARL (GNAT Run-time Layer)
19351 @item GNULL (GNAT Low-level Library)
19352 @end itemize
19353
19354 @noindent
19355 In GNAT, Ada's tasking services rely on a platform and OS independent
19356 layer known as GNARL@. This code is responsible for implementing the
19357 correct semantics of Ada's task creation, rendezvous, protected
19358 operations etc.
19359
19360 GNARL decomposes Ada's tasking semantics into simpler lower level
19361 operations such as create a thread, set the priority of a thread,
19362 yield, create a lock, lock/unlock, etc. The spec for these low-level
19363 operations constitutes GNULLI, the GNULL Interface. This interface is
19364 directly inspired from the POSIX real-time API@.
19365
19366 If the underlying executive or OS implements the POSIX standard
19367 faithfully, the GNULL Interface maps as is to the services offered by
19368 the underlying kernel. Otherwise, some target dependent glue code maps
19369 the services offered by the underlying kernel to the semantics expected
19370 by GNARL@.
19371
19372 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
19373 key point is that each Ada task is mapped on a thread in the underlying
19374 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
19375
19376 In addition Ada task priorities map onto the underlying thread priorities.
19377 Mapping Ada tasks onto the underlying kernel threads has several advantages:
19378
19379 @itemize @bullet
19380 @item
19381 The underlying scheduler is used to schedule the Ada tasks. This
19382 makes Ada tasks as efficient as kernel threads from a scheduling
19383 standpoint.
19384
19385 @item
19386 Interaction with code written in C containing threads is eased
19387 since at the lowest level Ada tasks and C threads map onto the same
19388 underlying kernel concept.
19389
19390 @item
19391 When an Ada task is blocked during I/O the remaining Ada tasks are
19392 able to proceed.
19393
19394 @item
19395 On multiprocessor systems Ada tasks can execute in parallel.
19396 @end itemize
19397
19398 @noindent
19399 Some threads libraries offer a mechanism to fork a new process, with the
19400 child process duplicating the threads from the parent.
19401 GNAT does not
19402 support this functionality when the parent contains more than one task.
19403 @cindex Forking a new process
19404
19405 @node Ensuring Compliance with the Real-Time Annex
19406 @subsection Ensuring Compliance with the Real-Time Annex
19407 @cindex Real-Time Systems Annex compliance
19408
19409 @noindent
19410 Although mapping Ada tasks onto
19411 the underlying threads has significant advantages, it does create some
19412 complications when it comes to respecting the scheduling semantics
19413 specified in the real-time annex (Annex D).
19414
19415 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
19416 scheduling policy states:
19417
19418 @quotation
19419 @emph{When the active priority of a ready task that is not running
19420 changes, or the setting of its base priority takes effect, the
19421 task is removed from the ready queue for its old active priority
19422 and is added at the tail of the ready queue for its new active
19423 priority, except in the case where the active priority is lowered
19424 due to the loss of inherited priority, in which case the task is
19425 added at the head of the ready queue for its new active priority.}
19426 @end quotation
19427
19428 @noindent
19429 While most kernels do put tasks at the end of the priority queue when
19430 a task changes its priority, (which respects the main
19431 FIFO_Within_Priorities requirement), almost none keep a thread at the
19432 beginning of its priority queue when its priority drops from the loss
19433 of inherited priority.
19434
19435 As a result most vendors have provided incomplete Annex D implementations.
19436
19437 The GNAT run-time, has a nice cooperative solution to this problem
19438 which ensures that accurate FIFO_Within_Priorities semantics are
19439 respected.
19440
19441 The principle is as follows. When an Ada task T is about to start
19442 running, it checks whether some other Ada task R with the same
19443 priority as T has been suspended due to the loss of priority
19444 inheritance. If this is the case, T yields and is placed at the end of
19445 its priority queue. When R arrives at the front of the queue it
19446 executes.
19447
19448 Note that this simple scheme preserves the relative order of the tasks
19449 that were ready to execute in the priority queue where R has been
19450 placed at the end.
19451
19452 @node GNAT Implementation of Shared Passive Packages
19453 @section GNAT Implementation of Shared Passive Packages
19454 @cindex Shared passive packages
19455
19456 @noindent
19457 GNAT fully implements the pragma @code{Shared_Passive} for
19458 @cindex pragma @code{Shared_Passive}
19459 the purpose of designating shared passive packages.
19460 This allows the use of passive partitions in the
19461 context described in the Ada Reference Manual; i.e., for communication
19462 between separate partitions of a distributed application using the
19463 features in Annex E.
19464 @cindex Annex E
19465 @cindex Distribution Systems Annex
19466
19467 However, the implementation approach used by GNAT provides for more
19468 extensive usage as follows:
19469
19470 @table @emph
19471 @item Communication between separate programs
19472
19473 This allows separate programs to access the data in passive
19474 partitions, using protected objects for synchronization where
19475 needed. The only requirement is that the two programs have a
19476 common shared file system. It is even possible for programs
19477 running on different machines with different architectures
19478 (e.g.@: different endianness) to communicate via the data in
19479 a passive partition.
19480
19481 @item Persistence between program runs
19482
19483 The data in a passive package can persist from one run of a
19484 program to another, so that a later program sees the final
19485 values stored by a previous run of the same program.
19486
19487 @end table
19488
19489 @noindent
19490 The implementation approach used is to store the data in files. A
19491 separate stream file is created for each object in the package, and
19492 an access to an object causes the corresponding file to be read or
19493 written.
19494
19495 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
19496 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
19497 set to the directory to be used for these files.
19498 The files in this directory
19499 have names that correspond to their fully qualified names. For
19500 example, if we have the package
19501
19502 @smallexample @c ada
19503 package X is
19504 pragma Shared_Passive (X);
19505 Y : Integer;
19506 Z : Float;
19507 end X;
19508 @end smallexample
19509
19510 @noindent
19511 and the environment variable is set to @code{/stemp/}, then the files created
19512 will have the names:
19513
19514 @smallexample
19515 /stemp/x.y
19516 /stemp/x.z
19517 @end smallexample
19518
19519 @noindent
19520 These files are created when a value is initially written to the object, and
19521 the files are retained until manually deleted. This provides the persistence
19522 semantics. If no file exists, it means that no partition has assigned a value
19523 to the variable; in this case the initial value declared in the package
19524 will be used. This model ensures that there are no issues in synchronizing
19525 the elaboration process, since elaboration of passive packages elaborates the
19526 initial values, but does not create the files.
19527
19528 The files are written using normal @code{Stream_IO} access.
19529 If you want to be able
19530 to communicate between programs or partitions running on different
19531 architectures, then you should use the XDR versions of the stream attribute
19532 routines, since these are architecture independent.
19533
19534 If active synchronization is required for access to the variables in the
19535 shared passive package, then as described in the Ada Reference Manual, the
19536 package may contain protected objects used for this purpose. In this case
19537 a lock file (whose name is @file{___lock} (three underscores)
19538 is created in the shared memory directory.
19539 @cindex @file{___lock} file (for shared passive packages)
19540 This is used to provide the required locking
19541 semantics for proper protected object synchronization.
19542
19543 As of January 2003, GNAT supports shared passive packages on all platforms
19544 except for OpenVMS.
19545
19546 @node Code Generation for Array Aggregates
19547 @section Code Generation for Array Aggregates
19548
19549 @menu
19550 * Static constant aggregates with static bounds::
19551 * Constant aggregates with unconstrained nominal types::
19552 * Aggregates with static bounds::
19553 * Aggregates with non-static bounds::
19554 * Aggregates in assignment statements::
19555 @end menu
19556
19557 @noindent
19558 Aggregates have a rich syntax and allow the user to specify the values of
19559 complex data structures by means of a single construct. As a result, the
19560 code generated for aggregates can be quite complex and involve loops, case
19561 statements and multiple assignments. In the simplest cases, however, the
19562 compiler will recognize aggregates whose components and constraints are
19563 fully static, and in those cases the compiler will generate little or no
19564 executable code. The following is an outline of the code that GNAT generates
19565 for various aggregate constructs. For further details, you will find it
19566 useful to examine the output produced by the -gnatG flag to see the expanded
19567 source that is input to the code generator. You may also want to examine
19568 the assembly code generated at various levels of optimization.
19569
19570 The code generated for aggregates depends on the context, the component values,
19571 and the type. In the context of an object declaration the code generated is
19572 generally simpler than in the case of an assignment. As a general rule, static
19573 component values and static subtypes also lead to simpler code.
19574
19575 @node Static constant aggregates with static bounds
19576 @subsection Static constant aggregates with static bounds
19577
19578 @noindent
19579 For the declarations:
19580 @smallexample @c ada
19581 type One_Dim is array (1..10) of integer;
19582 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
19583 @end smallexample
19584
19585 @noindent
19586 GNAT generates no executable code: the constant ar0 is placed in static memory.
19587 The same is true for constant aggregates with named associations:
19588
19589 @smallexample @c ada
19590 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
19591 Cr3 : constant One_Dim := (others => 7777);
19592 @end smallexample
19593
19594 @noindent
19595 The same is true for multidimensional constant arrays such as:
19596
19597 @smallexample @c ada
19598 type two_dim is array (1..3, 1..3) of integer;
19599 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
19600 @end smallexample
19601
19602 @noindent
19603 The same is true for arrays of one-dimensional arrays: the following are
19604 static:
19605
19606 @smallexample @c ada
19607 type ar1b is array (1..3) of boolean;
19608 type ar_ar is array (1..3) of ar1b;
19609 None : constant ar1b := (others => false); -- fully static
19610 None2 : constant ar_ar := (1..3 => None); -- fully static
19611 @end smallexample
19612
19613 @noindent
19614 However, for multidimensional aggregates with named associations, GNAT will
19615 generate assignments and loops, even if all associations are static. The
19616 following two declarations generate a loop for the first dimension, and
19617 individual component assignments for the second dimension:
19618
19619 @smallexample @c ada
19620 Zero1: constant two_dim := (1..3 => (1..3 => 0));
19621 Zero2: constant two_dim := (others => (others => 0));
19622 @end smallexample
19623
19624 @node Constant aggregates with unconstrained nominal types
19625 @subsection Constant aggregates with unconstrained nominal types
19626
19627 @noindent
19628 In such cases the aggregate itself establishes the subtype, so that
19629 associations with @code{others} cannot be used. GNAT determines the
19630 bounds for the actual subtype of the aggregate, and allocates the
19631 aggregate statically as well. No code is generated for the following:
19632
19633 @smallexample @c ada
19634 type One_Unc is array (natural range <>) of integer;
19635 Cr_Unc : constant One_Unc := (12,24,36);
19636 @end smallexample
19637
19638 @node Aggregates with static bounds
19639 @subsection Aggregates with static bounds
19640
19641 @noindent
19642 In all previous examples the aggregate was the initial (and immutable) value
19643 of a constant. If the aggregate initializes a variable, then code is generated
19644 for it as a combination of individual assignments and loops over the target
19645 object. The declarations
19646
19647 @smallexample @c ada
19648 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
19649 Cr_Var2 : One_Dim := (others > -1);
19650 @end smallexample
19651
19652 @noindent
19653 generate the equivalent of
19654
19655 @smallexample @c ada
19656 Cr_Var1 (1) := 2;
19657 Cr_Var1 (2) := 3;
19658 Cr_Var1 (3) := 5;
19659 Cr_Var1 (4) := 11;
19660
19661 for I in Cr_Var2'range loop
19662 Cr_Var2 (I) := -1;
19663 end loop;
19664 @end smallexample
19665
19666 @node Aggregates with non-static bounds
19667 @subsection Aggregates with non-static bounds
19668
19669 @noindent
19670 If the bounds of the aggregate are not statically compatible with the bounds
19671 of the nominal subtype of the target, then constraint checks have to be
19672 generated on the bounds. For a multidimensional array, constraint checks may
19673 have to be applied to sub-arrays individually, if they do not have statically
19674 compatible subtypes.
19675
19676 @node Aggregates in assignment statements
19677 @subsection Aggregates in assignment statements
19678
19679 @noindent
19680 In general, aggregate assignment requires the construction of a temporary,
19681 and a copy from the temporary to the target of the assignment. This is because
19682 it is not always possible to convert the assignment into a series of individual
19683 component assignments. For example, consider the simple case:
19684
19685 @smallexample @c ada
19686 A := (A(2), A(1));
19687 @end smallexample
19688
19689 @noindent
19690 This cannot be converted into:
19691
19692 @smallexample @c ada
19693 A(1) := A(2);
19694 A(2) := A(1);
19695 @end smallexample
19696
19697 @noindent
19698 So the aggregate has to be built first in a separate location, and then
19699 copied into the target. GNAT recognizes simple cases where this intermediate
19700 step is not required, and the assignments can be performed in place, directly
19701 into the target. The following sufficient criteria are applied:
19702
19703 @itemize @bullet
19704 @item
19705 The bounds of the aggregate are static, and the associations are static.
19706 @item
19707 The components of the aggregate are static constants, names of
19708 simple variables that are not renamings, or expressions not involving
19709 indexed components whose operands obey these rules.
19710 @end itemize
19711
19712 @noindent
19713 If any of these conditions are violated, the aggregate will be built in
19714 a temporary (created either by the front-end or the code generator) and then
19715 that temporary will be copied onto the target.
19716
19717 @node The Size of Discriminated Records with Default Discriminants
19718 @section The Size of Discriminated Records with Default Discriminants
19719
19720 @noindent
19721 If a discriminated type @code{T} has discriminants with default values, it is
19722 possible to declare an object of this type without providing an explicit
19723 constraint:
19724
19725 @smallexample @c ada
19726 @group
19727 type Size is range 1..100;
19728
19729 type Rec (D : Size := 15) is record
19730 Name : String (1..D);
19731 end T;
19732
19733 Word : Rec;
19734 @end group
19735 @end smallexample
19736
19737 @noindent
19738 Such an object is said to be @emph{unconstrained}.
19739 The discriminant of the object
19740 can be modified by a full assignment to the object, as long as it preserves the
19741 relation between the value of the discriminant, and the value of the components
19742 that depend on it:
19743
19744 @smallexample @c ada
19745 @group
19746 Word := (3, "yes");
19747
19748 Word := (5, "maybe");
19749
19750 Word := (5, "no"); -- raises Constraint_Error
19751 @end group
19752 @end smallexample
19753
19754 @noindent
19755 In order to support this behavior efficiently, an unconstrained object is
19756 given the maximum size that any value of the type requires. In the case
19757 above, @code{Word} has storage for the discriminant and for
19758 a @code{String} of length 100.
19759 It is important to note that unconstrained objects do not require dynamic
19760 allocation. It would be an improper implementation to place on the heap those
19761 components whose size depends on discriminants. (This improper implementation
19762 was used by some Ada83 compilers, where the @code{Name} component above
19763 would have
19764 been stored as a pointer to a dynamic string). Following the principle that
19765 dynamic storage management should never be introduced implicitly,
19766 an Ada compiler should reserve the full size for an unconstrained declared
19767 object, and place it on the stack.
19768
19769 This maximum size approach
19770 has been a source of surprise to some users, who expect the default
19771 values of the discriminants to determine the size reserved for an
19772 unconstrained object: ``If the default is 15, why should the object occupy
19773 a larger size?''
19774 The answer, of course, is that the discriminant may be later modified,
19775 and its full range of values must be taken into account. This is why the
19776 declaration:
19777
19778 @smallexample
19779 @group
19780 type Rec (D : Positive := 15) is record
19781 Name : String (1..D);
19782 end record;
19783
19784 Too_Large : Rec;
19785 @end group
19786 @end smallexample
19787
19788 @noindent
19789 is flagged by the compiler with a warning:
19790 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
19791 because the required size includes @code{Positive'Last}
19792 bytes. As the first example indicates, the proper approach is to declare an
19793 index type of ``reasonable'' range so that unconstrained objects are not too
19794 large.
19795
19796 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
19797 created in the heap by means of an allocator, then it is @emph{not}
19798 unconstrained:
19799 it is constrained by the default values of the discriminants, and those values
19800 cannot be modified by full assignment. This is because in the presence of
19801 aliasing all views of the object (which may be manipulated by different tasks,
19802 say) must be consistent, so it is imperative that the object, once created,
19803 remain invariant.
19804
19805 @node Strict Conformance to the Ada Reference Manual
19806 @section Strict Conformance to the Ada Reference Manual
19807
19808 @noindent
19809 The dynamic semantics defined by the Ada Reference Manual impose a set of
19810 run-time checks to be generated. By default, the GNAT compiler will insert many
19811 run-time checks into the compiled code, including most of those required by the
19812 Ada Reference Manual. However, there are three checks that are not enabled
19813 in the default mode for efficiency reasons: arithmetic overflow checking for
19814 integer operations (including division by zero), checks for access before
19815 elaboration on subprogram calls, and stack overflow checking (most operating
19816 systems do not perform this check by default).
19817
19818 Strict conformance to the Ada Reference Manual can be achieved by adding
19819 three compiler options for overflow checking for integer operations
19820 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
19821 calls and generic instantiations (@option{-gnatE}), and stack overflow
19822 checking (@option{-fstack-check}).
19823
19824 Note that the result of a floating point arithmetic operation in overflow and
19825 invalid situations, when the @code{Machine_Overflows} attribute of the result
19826 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
19827 case for machines compliant with the IEEE floating-point standard, but on
19828 machines that are not fully compliant with this standard, such as Alpha, the
19829 @option{-mieee} compiler flag must be used for achieving IEEE confirming
19830 behavior (although at the cost of a significant performance penalty), so
19831 infinite and NaN values are properly generated.
19832
19833
19834 @node Implementation of Ada 2012 Features
19835 @chapter Implementation of Ada 2012 Features
19836 @cindex Ada 2012 implementation status
19837
19838 This chapter contains a complete list of Ada 2012 features that have been
19839 implemented as of GNAT version 6.4. Generally, these features are only
19840 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
19841 @cindex @option{-gnat12} option
19842 or if the configuration pragma @code{Ada_2012} is used.
19843 @cindex pragma @code{Ada_2012}
19844 @cindex configuration pragma @code{Ada_2012}
19845 @cindex @code{Ada_2012} configuration pragma
19846 However, new pragmas, attributes, and restrictions are
19847 unconditionally available, since the Ada 95 standard allows the addition of
19848 new pragmas, attributes, and restrictions (there are exceptions, which are
19849 documented in the individual descriptions), and also certain packages
19850 were made available in earlier versions of Ada.
19851
19852 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
19853 This date shows the implementation date of the feature. Any wavefront
19854 subsequent to this date will contain the indicated feature, as will any
19855 subsequent releases. A date of 0000-00-00 means that GNAT has always
19856 implemented the feature, or implemented it as soon as it appeared as a
19857 binding interpretation.
19858
19859 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
19860 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
19861 The features are ordered based on the relevant sections of the Ada
19862 Reference Manual (``RM''). When a given AI relates to multiple points
19863 in the RM, the earliest is used.
19864
19865 A complete description of the AIs may be found in
19866 @url{www.ada-auth.org/ai05-summary.html}.
19867
19868 @itemize @bullet
19869
19870 @item
19871 @emph{AI-0176 Quantified expressions (2010-09-29)}
19872 @cindex AI-0176 (Ada 2012 feature)
19873
19874 @noindent
19875 Both universally and existentially quantified expressions are implemented.
19876 They use the new syntax for iterators proposed in AI05-139-2, as well as
19877 the standard Ada loop syntax.
19878
19879 @noindent
19880 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
19881
19882 @item
19883 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
19884 @cindex AI-0079 (Ada 2012 feature)
19885
19886 @noindent
19887 Wide characters in the unicode category @i{other_format} are now allowed in
19888 source programs between tokens, but not within a token such as an identifier.
19889
19890 @noindent
19891 RM References: 2.01 (4/2) 2.02 (7)
19892
19893 @item
19894 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
19895 @cindex AI-0091 (Ada 2012 feature)
19896
19897 @noindent
19898 Wide characters in the unicode category @i{other_format} are not permitted
19899 within an identifier, since this can be a security problem. The error
19900 message for this case has been improved to be more specific, but GNAT has
19901 never allowed such characters to appear in identifiers.
19902
19903 @noindent
19904 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)
19905
19906 @item
19907 @emph{AI-0100 Placement of pragmas (2010-07-01)}
19908 @cindex AI-0100 (Ada 2012 feature)
19909
19910 @noindent
19911 This AI is an earlier version of AI-163. It simplifies the rules
19912 for legal placement of pragmas. In the case of lists that allow pragmas, if
19913 the list may have no elements, then the list may consist solely of pragmas.
19914
19915 @noindent
19916 RM References: 2.08 (7)
19917
19918 @item
19919 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
19920 @cindex AI-0163 (Ada 2012 feature)
19921
19922 @noindent
19923 A statement sequence may be composed entirely of pragmas. It is no longer
19924 necessary to add a dummy @code{null} statement to make the sequence legal.
19925
19926 @noindent
19927 RM References: 2.08 (7) 2.08 (16)
19928
19929
19930 @item
19931 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
19932 @cindex AI-0080 (Ada 2012 feature)
19933
19934 @noindent
19935 This is an editorial change only, described as non-testable in the AI.
19936
19937 @noindent
19938 RM References: 3.01 (7)
19939
19940
19941 @item
19942 @emph{AI-0183 Aspect specifications (2010-08-16)}
19943 @cindex AI-0183 (Ada 2012 feature)
19944
19945 @noindent
19946 Aspect specifications have been fully implemented except for pre and post-
19947 conditions, and type invariants, which have their own separate AI's. All
19948 forms of declarations listed in the AI are supported. The following is a
19949 list of the aspects supported (with GNAT implementation aspects marked)
19950
19951 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
19952 @item @code{Ada_2005} @tab -- GNAT
19953 @item @code{Ada_2012} @tab -- GNAT
19954 @item @code{Address} @tab
19955 @item @code{Alignment} @tab
19956 @item @code{Atomic} @tab
19957 @item @code{Atomic_Components} @tab
19958 @item @code{Bit_Order} @tab
19959 @item @code{Component_Size} @tab
19960 @item @code{Contract_Cases} @tab -- GNAT
19961 @item @code{Discard_Names} @tab
19962 @item @code{External_Tag} @tab
19963 @item @code{Favor_Top_Level} @tab -- GNAT
19964 @item @code{Inline} @tab
19965 @item @code{Inline_Always} @tab -- GNAT
19966 @item @code{Invariant} @tab -- GNAT
19967 @item @code{Machine_Radix} @tab
19968 @item @code{No_Return} @tab
19969 @item @code{Object_Size} @tab -- GNAT
19970 @item @code{Pack} @tab
19971 @item @code{Persistent_BSS} @tab -- GNAT
19972 @item @code{Post} @tab
19973 @item @code{Pre} @tab
19974 @item @code{Predicate} @tab
19975 @item @code{Preelaborable_Initialization} @tab
19976 @item @code{Pure_Function} @tab -- GNAT
19977 @item @code{Remote_Access_Type} @tab -- GNAT
19978 @item @code{Shared} @tab -- GNAT
19979 @item @code{Size} @tab
19980 @item @code{Storage_Pool} @tab
19981 @item @code{Storage_Size} @tab
19982 @item @code{Stream_Size} @tab
19983 @item @code{Suppress} @tab
19984 @item @code{Suppress_Debug_Info} @tab -- GNAT
19985 @item @code{Test_Case} @tab -- GNAT
19986 @item @code{Type_Invariant} @tab
19987 @item @code{Unchecked_Union} @tab
19988 @item @code{Universal_Aliasing} @tab -- GNAT
19989 @item @code{Unmodified} @tab -- GNAT
19990 @item @code{Unreferenced} @tab -- GNAT
19991 @item @code{Unreferenced_Objects} @tab -- GNAT
19992 @item @code{Unsuppress} @tab
19993 @item @code{Value_Size} @tab -- GNAT
19994 @item @code{Volatile} @tab
19995 @item @code{Volatile_Components}
19996 @item @code{Warnings} @tab -- GNAT
19997 @end multitable
19998
19999 @noindent
20000 Note that for aspects with an expression, e.g. @code{Size}, the expression is
20001 treated like a default expression (visibility is analyzed at the point of
20002 occurrence of the aspect, but evaluation of the expression occurs at the
20003 freeze point of the entity involved).
20004
20005 @noindent
20006 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
20007 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
20008 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
20009 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
20010 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
20011 13.03.01 (0)
20012
20013
20014 @item
20015 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
20016 @cindex AI-0128 (Ada 2012 feature)
20017
20018 @noindent
20019 If an equality operator ("=") is declared for a type, then the implicitly
20020 declared inequality operator ("/=") is a primitive operation of the type.
20021 This is the only reasonable interpretation, and is the one always implemented
20022 by GNAT, but the RM was not entirely clear in making this point.
20023
20024 @noindent
20025 RM References: 3.02.03 (6) 6.06 (6)
20026
20027 @item
20028 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
20029 @cindex AI-0003 (Ada 2012 feature)
20030
20031 @noindent
20032 In Ada 2012, a qualified expression is considered to be syntactically a name,
20033 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
20034 useful in disambiguating some cases of overloading.
20035
20036 @noindent
20037 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
20038 5.04 (7)
20039
20040 @item
20041 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
20042 @cindex AI-0120 (Ada 2012 feature)
20043
20044 @noindent
20045 This is an RM editorial change only. The section that lists objects that are
20046 constant failed to include the current instance of a protected object
20047 within a protected function. This has always been treated as a constant
20048 in GNAT.
20049
20050 @noindent
20051 RM References: 3.03 (21)
20052
20053 @item
20054 @emph{AI-0008 General access to constrained objects (0000-00-00)}
20055 @cindex AI-0008 (Ada 2012 feature)
20056
20057 @noindent
20058 The wording in the RM implied that if you have a general access to a
20059 constrained object, it could be used to modify the discriminants. This was
20060 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
20061 has always done so in this situation.
20062
20063 @noindent
20064 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
20065
20066
20067 @item
20068 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
20069 @cindex AI-0093 (Ada 2012 feature)
20070
20071 @noindent
20072 This is an editorial change only, to make more widespread use of the Ada 2012
20073 ``immutably limited''.
20074
20075 @noindent
20076 RM References: 3.03 (23.4/3)
20077
20078
20079
20080 @item
20081 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
20082 @cindex AI-0096 (Ada 2012 feature)
20083
20084 @noindent
20085 In general it is illegal for a type derived from a formal limited type to be
20086 nonlimited. This AI makes an exception to this rule: derivation is legal
20087 if it appears in the private part of the generic, and the formal type is not
20088 tagged. If the type is tagged, the legality check must be applied to the
20089 private part of the package.
20090
20091 @noindent
20092 RM References: 3.04 (5.1/2) 6.02 (7)
20093
20094
20095 @item
20096 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
20097 @cindex AI-0181 (Ada 2012 feature)
20098
20099 @noindent
20100 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
20101 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
20102 @code{Image} and @code{Value} attributes for the character types. Strictly
20103 speaking this is an inconsistency with Ada 95, but in practice the use of
20104 these attributes is so obscure that it will not cause problems.
20105
20106 @noindent
20107 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
20108
20109
20110 @item
20111 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
20112 @cindex AI-0182 (Ada 2012 feature)
20113
20114 @noindent
20115 This AI allows @code{Character'Value} to accept the string @code{'?'} where
20116 @code{?} is any character including non-graphic control characters. GNAT has
20117 always accepted such strings. It also allows strings such as
20118 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
20119 permission and raises @code{Constraint_Error}, as is certainly still
20120 permitted.
20121
20122 @noindent
20123 RM References: 3.05 (56/2)
20124
20125
20126 @item
20127 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
20128 @cindex AI-0214 (Ada 2012 feature)
20129
20130 @noindent
20131 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
20132 to have default expressions by allowing them when the type is limited. It
20133 is often useful to define a default value for a discriminant even though
20134 it can't be changed by assignment.
20135
20136 @noindent
20137 RM References: 3.07 (9.1/2) 3.07.02 (3)
20138
20139
20140 @item
20141 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
20142 @cindex AI-0102 (Ada 2012 feature)
20143
20144 @noindent
20145 It is illegal to assign an anonymous access constant to an anonymous access
20146 variable. The RM did not have a clear rule to prevent this, but GNAT has
20147 always generated an error for this usage.
20148
20149 @noindent
20150 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
20151
20152
20153 @item
20154 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
20155 @cindex AI-0158 (Ada 2012 feature)
20156
20157 @noindent
20158 This AI extends the syntax of membership tests to simplify complex conditions
20159 that can be expressed as membership in a subset of values of any type. It
20160 introduces syntax for a list of expressions that may be used in loop contexts
20161 as well.
20162
20163 @noindent
20164 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
20165
20166
20167 @item
20168 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
20169 @cindex AI-0173 (Ada 2012 feature)
20170
20171 @noindent
20172 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
20173 with the tag of an abstract type, and @code{False} otherwise.
20174
20175 @noindent
20176 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
20177
20178
20179
20180 @item
20181 @emph{AI-0076 function with controlling result (0000-00-00)}
20182 @cindex AI-0076 (Ada 2012 feature)
20183
20184 @noindent
20185 This is an editorial change only. The RM defines calls with controlling
20186 results, but uses the term ``function with controlling result'' without an
20187 explicit definition.
20188
20189 @noindent
20190 RM References: 3.09.02 (2/2)
20191
20192
20193 @item
20194 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
20195 @cindex AI-0126 (Ada 2012 feature)
20196
20197 @noindent
20198 This AI clarifies dispatching rules, and simply confirms that dispatching
20199 executes the operation of the parent type when there is no explicitly or
20200 implicitly declared operation for the descendant type. This has always been
20201 the case in all versions of GNAT.
20202
20203 @noindent
20204 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
20205
20206
20207 @item
20208 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
20209 @cindex AI-0097 (Ada 2012 feature)
20210
20211 @noindent
20212 The RM as written implied that in some cases it was possible to create an
20213 object of an abstract type, by having an abstract extension inherit a non-
20214 abstract constructor from its parent type. This mistake has been corrected
20215 in GNAT and in the RM, and this construct is now illegal.
20216
20217 @noindent
20218 RM References: 3.09.03 (4/2)
20219
20220
20221 @item
20222 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
20223 @cindex AI-0203 (Ada 2012 feature)
20224
20225 @noindent
20226 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
20227 permitted such usage.
20228
20229 @noindent
20230 RM References: 3.09.03 (8/3)
20231
20232
20233 @item
20234 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
20235 @cindex AI-0198 (Ada 2012 feature)
20236
20237 @noindent
20238 This AI resolves a conflict between two rules involving inherited abstract
20239 operations and predefined operators. If a derived numeric type inherits
20240 an abstract operator, it overrides the predefined one. This interpretation
20241 was always the one implemented in GNAT.
20242
20243 @noindent
20244 RM References: 3.09.03 (4/3)
20245
20246 @item
20247 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
20248 @cindex AI-0073 (Ada 2012 feature)
20249
20250 @noindent
20251 This AI covers a number of issues regarding returning abstract types. In
20252 particular generic functions cannot have abstract result types or access
20253 result types designated an abstract type. There are some other cases which
20254 are detailed in the AI. Note that this binding interpretation has not been
20255 retrofitted to operate before Ada 2012 mode, since it caused a significant
20256 number of regressions.
20257
20258 @noindent
20259 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
20260
20261
20262 @item
20263 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
20264 @cindex AI-0070 (Ada 2012 feature)
20265
20266 @noindent
20267 This is an editorial change only, there are no testable consequences short of
20268 checking for the absence of generated code for an interface declaration.
20269
20270 @noindent
20271 RM References: 3.09.04 (18/2)
20272
20273
20274 @item
20275 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
20276 @cindex AI-0208 (Ada 2012 feature)
20277
20278 @noindent
20279 The wording in the Ada 2005 RM concerning characteristics of incomplete views
20280 was incorrect and implied that some programs intended to be legal were now
20281 illegal. GNAT had never considered such programs illegal, so it has always
20282 implemented the intent of this AI.
20283
20284 @noindent
20285 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
20286
20287
20288 @item
20289 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
20290 @cindex AI-0162 (Ada 2012 feature)
20291
20292 @noindent
20293 Incomplete types are made more useful by allowing them to be completed by
20294 private types and private extensions.
20295
20296 @noindent
20297 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
20298
20299
20300
20301 @item
20302 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
20303 @cindex AI-0098 (Ada 2012 feature)
20304
20305 @noindent
20306 An unintentional omission in the RM implied some inconsistent restrictions on
20307 the use of anonymous access to subprogram values. These restrictions were not
20308 intentional, and have never been enforced by GNAT.
20309
20310 @noindent
20311 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
20312
20313
20314 @item
20315 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
20316 @cindex AI-0199 (Ada 2012 feature)
20317
20318 @noindent
20319 A choice list in a record aggregate can include several components of
20320 (distinct) anonymous access types as long as they have matching designated
20321 subtypes.
20322
20323 @noindent
20324 RM References: 4.03.01 (16)
20325
20326
20327 @item
20328 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
20329 @cindex AI-0220 (Ada 2012 feature)
20330
20331 @noindent
20332 This AI addresses a wording problem in the RM that appears to permit some
20333 complex cases of aggregates with non-static discriminants. GNAT has always
20334 implemented the intended semantics.
20335
20336 @noindent
20337 RM References: 4.03.01 (17)
20338
20339 @item
20340 @emph{AI-0147 Conditional expressions (2009-03-29)}
20341 @cindex AI-0147 (Ada 2012 feature)
20342
20343 @noindent
20344 Conditional expressions are permitted. The form of such an expression is:
20345
20346 @smallexample
20347 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
20348 @end smallexample
20349
20350 The parentheses can be omitted in contexts where parentheses are present
20351 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
20352 clause is omitted, @b{else True} is assumed;
20353 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
20354 @emph{(A implies B)} in standard logic.
20355
20356 @noindent
20357 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
20358 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
20359
20360
20361 @item
20362 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
20363 @cindex AI-0037 (Ada 2012 feature)
20364
20365 @noindent
20366 This AI confirms that an association of the form @code{Indx => <>} in an
20367 array aggregate must raise @code{Constraint_Error} if @code{Indx}
20368 is out of range. The RM specified a range check on other associations, but
20369 not when the value of the association was defaulted. GNAT has always inserted
20370 a constraint check on the index value.
20371
20372 @noindent
20373 RM References: 4.03.03 (29)
20374
20375
20376 @item
20377 @emph{AI-0123 Composability of equality (2010-04-13)}
20378 @cindex AI-0123 (Ada 2012 feature)
20379
20380 @noindent
20381 Equality of untagged record composes, so that the predefined equality for a
20382 composite type that includes a component of some untagged record type
20383 @code{R} uses the equality operation of @code{R} (which may be user-defined
20384 or predefined). This makes the behavior of untagged records identical to that
20385 of tagged types in this respect.
20386
20387 This change is an incompatibility with previous versions of Ada, but it
20388 corrects a non-uniformity that was often a source of confusion. Analysis of
20389 a large number of industrial programs indicates that in those rare cases
20390 where a composite type had an untagged record component with a user-defined
20391 equality, either there was no use of the composite equality, or else the code
20392 expected the same composability as for tagged types, and thus had a bug that
20393 would be fixed by this change.
20394
20395 @noindent
20396 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
20397 8.05.04 (8)
20398
20399
20400 @item
20401 @emph{AI-0088 The value of exponentiation (0000-00-00)}
20402 @cindex AI-0088 (Ada 2012 feature)
20403
20404 @noindent
20405 This AI clarifies the equivalence rule given for the dynamic semantics of
20406 exponentiation: the value of the operation can be obtained by repeated
20407 multiplication, but the operation can be implemented otherwise (for example
20408 using the familiar divide-by-two-and-square algorithm, even if this is less
20409 accurate), and does not imply repeated reads of a volatile base.
20410
20411 @noindent
20412 RM References: 4.05.06 (11)
20413
20414 @item
20415 @emph{AI-0188 Case expressions (2010-01-09)}
20416 @cindex AI-0188 (Ada 2012 feature)
20417
20418 @noindent
20419 Case expressions are permitted. This allows use of constructs such as:
20420 @smallexample
20421 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
20422 @end smallexample
20423
20424 @noindent
20425 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
20426
20427 @item
20428 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
20429 @cindex AI-0104 (Ada 2012 feature)
20430
20431 @noindent
20432 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
20433 @code{Constraint_Error} because the default value of the allocated object is
20434 @b{null}. This useless construct is illegal in Ada 2012.
20435
20436 @noindent
20437 RM References: 4.08 (2)
20438
20439 @item
20440 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
20441 @cindex AI-0157 (Ada 2012 feature)
20442
20443 @noindent
20444 Allocation and Deallocation from an empty storage pool (i.e. allocation or
20445 deallocation of a pointer for which a static storage size clause of zero
20446 has been given) is now illegal and is detected as such. GNAT
20447 previously gave a warning but not an error.
20448
20449 @noindent
20450 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
20451
20452 @item
20453 @emph{AI-0179 Statement not required after label (2010-04-10)}
20454 @cindex AI-0179 (Ada 2012 feature)
20455
20456 @noindent
20457 It is not necessary to have a statement following a label, so a label
20458 can appear at the end of a statement sequence without the need for putting a
20459 null statement afterwards, but it is not allowable to have only labels and
20460 no real statements in a statement sequence.
20461
20462 @noindent
20463 RM References: 5.01 (2)
20464
20465
20466 @item
20467 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
20468 @cindex AI-139-2 (Ada 2012 feature)
20469
20470 @noindent
20471 The new syntax for iterating over arrays and containers is now implemented.
20472 Iteration over containers is for now limited to read-only iterators. Only
20473 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
20474
20475 @noindent
20476 RM References: 5.05
20477
20478 @item
20479 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
20480 @cindex AI-0134 (Ada 2012 feature)
20481
20482 @noindent
20483 For full conformance, the profiles of anonymous-access-to-subprogram
20484 parameters must match. GNAT has always enforced this rule.
20485
20486 @noindent
20487 RM References: 6.03.01 (18)
20488
20489 @item
20490 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
20491 @cindex AI-0207 (Ada 2012 feature)
20492
20493 @noindent
20494 This AI confirms that access_to_constant indication must match for mode
20495 conformance. This was implemented in GNAT when the qualifier was originally
20496 introduced in Ada 2005.
20497
20498 @noindent
20499 RM References: 6.03.01 (16/2)
20500
20501
20502 @item
20503 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
20504 @cindex AI-0046 (Ada 2012 feature)
20505
20506 @noindent
20507 For full conformance, in the case of access parameters, the null exclusion
20508 must match (either both or neither must have @code{@b{not null}}).
20509
20510 @noindent
20511 RM References: 6.03.02 (18)
20512
20513
20514 @item
20515 @emph{AI-0118 The association of parameter associations (0000-00-00)}
20516 @cindex AI-0118 (Ada 2012 feature)
20517
20518 @noindent
20519 This AI clarifies the rules for named associations in subprogram calls and
20520 generic instantiations. The rules have been in place since Ada 83.
20521
20522 @noindent
20523 RM References: 6.04.01 (2) 12.03 (9)
20524
20525
20526 @item
20527 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
20528 @cindex AI-0196 (Ada 2012 feature)
20529
20530 @noindent
20531 Null exclusion checks are not made for @code{@b{out}} parameters when
20532 evaluating the actual parameters. GNAT has never generated these checks.
20533
20534 @noindent
20535 RM References: 6.04.01 (13)
20536
20537 @item
20538 @emph{AI-0015 Constant return objects (0000-00-00)}
20539 @cindex AI-0015 (Ada 2012 feature)
20540
20541 @noindent
20542 The return object declared in an @i{extended_return_statement} may be
20543 declared constant. This was always intended, and GNAT has always allowed it.
20544
20545 @noindent
20546 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
20547 6.05 (5.7/2)
20548
20549
20550 @item
20551 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
20552 @cindex AI-0032 (Ada 2012 feature)
20553
20554 @noindent
20555 If a function returns a class-wide type, the object of an extended return
20556 statement can be declared with a specific type that is covered by the class-
20557 wide type. This has been implemented in GNAT since the introduction of
20558 extended returns. Note AI-0103 complements this AI by imposing matching
20559 rules for constrained return types.
20560
20561 @noindent
20562 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
20563 6.05 (8/2)
20564
20565 @item
20566 @emph{AI-0103 Static matching for extended return (2010-07-23)}
20567 @cindex AI-0103 (Ada 2012 feature)
20568
20569 @noindent
20570 If the return subtype of a function is an elementary type or a constrained
20571 type, the subtype indication in an extended return statement must match
20572 statically this return subtype.
20573
20574 @noindent
20575 RM References: 6.05 (5.2/2)
20576
20577
20578 @item
20579 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
20580 @cindex AI-0058 (Ada 2012 feature)
20581
20582 @noindent
20583 The RM had some incorrect wording implying wrong treatment of abnormal
20584 completion in an extended return. GNAT has always implemented the intended
20585 correct semantics as described by this AI.
20586
20587 @noindent
20588 RM References: 6.05 (22/2)
20589
20590
20591 @item
20592 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
20593 @cindex AI-0050 (Ada 2012 feature)
20594
20595 @noindent
20596 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
20597 not take advantage of these incorrect permissions in any case.
20598
20599 @noindent
20600 RM References: 6.05 (24/2)
20601
20602
20603 @item
20604 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
20605 @cindex AI-0125 (Ada 2012 feature)
20606
20607 @noindent
20608 In Ada 2012, the declaration of a primitive operation of a type extension
20609 or private extension can also override an inherited primitive that is not
20610 visible at the point of this declaration.
20611
20612 @noindent
20613 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
20614
20615 @item
20616 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
20617 @cindex AI-0062 (Ada 2012 feature)
20618
20619 @noindent
20620 A full constant may have a null exclusion even if its associated deferred
20621 constant does not. GNAT has always allowed this.
20622
20623 @noindent
20624 RM References: 7.04 (6/2) 7.04 (7.1/2)
20625
20626
20627 @item
20628 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
20629 @cindex AI-0178 (Ada 2012 feature)
20630
20631 @noindent
20632 This AI clarifies the role of incomplete views and plugs an omission in the
20633 RM. GNAT always correctly restricted the use of incomplete views and types.
20634
20635 @noindent
20636 RM References: 7.05 (3/2) 7.05 (6/2)
20637
20638 @item
20639 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
20640 @cindex AI-0087 (Ada 2012 feature)
20641
20642 @noindent
20643 The actual for a formal nonlimited derived type cannot be limited. In
20644 particular, a formal derived type that extends a limited interface but which
20645 is not explicitly limited cannot be instantiated with a limited type.
20646
20647 @noindent
20648 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
20649
20650 @item
20651 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
20652 @cindex AI-0099 (Ada 2012 feature)
20653
20654 @noindent
20655 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
20656 and therefore depends on the run-time characteristics of an object (i.e. its
20657 tag) and not on its nominal type. As the AI indicates: ``we do not expect
20658 this to affect any implementation''.
20659
20660 @noindent
20661 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
20662
20663
20664
20665 @item
20666 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
20667 @cindex AI-0064 (Ada 2012 feature)
20668
20669 @noindent
20670 This is an editorial change only. The intended behavior is already checked
20671 by an existing ACATS test, which GNAT has always executed correctly.
20672
20673 @noindent
20674 RM References: 7.06.01 (17.1/1)
20675
20676 @item
20677 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
20678 @cindex AI-0026 (Ada 2012 feature)
20679
20680 @noindent
20681 Record representation clauses concerning Unchecked_Union types cannot mention
20682 the discriminant of the type. The type of a component declared in the variant
20683 part of an Unchecked_Union cannot be controlled, have controlled components,
20684 nor have protected or task parts. If an Unchecked_Union type is declared
20685 within the body of a generic unit or its descendants, then the type of a
20686 component declared in the variant part cannot be a formal private type or a
20687 formal private extension declared within the same generic unit.
20688
20689 @noindent
20690 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
20691
20692
20693 @item
20694 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
20695 @cindex AI-0205 (Ada 2012 feature)
20696
20697 @noindent
20698 This AI corrects a simple omission in the RM. Return objects have always
20699 been visible within an extended return statement.
20700
20701 @noindent
20702 RM References: 8.03 (17)
20703
20704
20705 @item
20706 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
20707 @cindex AI-0042 (Ada 2012 feature)
20708
20709 @noindent
20710 This AI fixes a wording gap in the RM. An operation of a synchronized
20711 interface can be implemented by a protected or task entry, but the abstract
20712 operation is not being overridden in the usual sense, and it must be stated
20713 separately that this implementation is legal. This has always been the case
20714 in GNAT.
20715
20716 @noindent
20717 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
20718
20719 @item
20720 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
20721 @cindex AI-0030 (Ada 2012 feature)
20722
20723 @noindent
20724 Requeue is permitted to a protected, synchronized or task interface primitive
20725 providing it is known that the overriding operation is an entry. Otherwise
20726 the requeue statement has the same effect as a procedure call. Use of pragma
20727 @code{Implemented} provides a way to impose a static requirement on the
20728 overriding operation by adhering to one of the implementation kinds: entry,
20729 protected procedure or any of the above.
20730
20731 @noindent
20732 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
20733 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
20734
20735
20736 @item
20737 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
20738 @cindex AI-0201 (Ada 2012 feature)
20739
20740 @noindent
20741 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
20742 attribute, then individual components may not be addressable by independent
20743 tasks. However, if the representation clause has no effect (is confirming),
20744 then independence is not compromised. Furthermore, in GNAT, specification of
20745 other appropriately addressable component sizes (e.g. 16 for 8-bit
20746 characters) also preserves independence. GNAT now gives very clear warnings
20747 both for the declaration of such a type, and for any assignment to its components.
20748
20749 @noindent
20750 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
20751
20752 @item
20753 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
20754 @cindex AI-0009 (Ada 2012 feature)
20755
20756 @noindent
20757 This AI introduces the new pragmas @code{Independent} and
20758 @code{Independent_Components},
20759 which control guaranteeing independence of access to objects and components.
20760 The AI also requires independence not unaffected by confirming rep clauses.
20761
20762 @noindent
20763 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
20764 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
20765
20766
20767 @item
20768 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
20769 @cindex AI-0072 (Ada 2012 feature)
20770
20771 @noindent
20772 This AI clarifies that task signalling for reading @code{'Terminated} only
20773 occurs if the result is True. GNAT semantics has always been consistent with
20774 this notion of task signalling.
20775
20776 @noindent
20777 RM References: 9.10 (6.1/1)
20778
20779 @item
20780 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
20781 @cindex AI-0108 (Ada 2012 feature)
20782
20783 @noindent
20784 This AI confirms that an incomplete type from a limited view does not have
20785 discriminants. This has always been the case in GNAT.
20786
20787 @noindent
20788 RM References: 10.01.01 (12.3/2)
20789
20790 @item
20791 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
20792 @cindex AI-0129 (Ada 2012 feature)
20793
20794 @noindent
20795 This AI clarifies the description of limited views: a limited view of a
20796 package includes only one view of a type that has an incomplete declaration
20797 and a full declaration (there is no possible ambiguity in a client package).
20798 This AI also fixes an omission: a nested package in the private part has no
20799 limited view. GNAT always implemented this correctly.
20800
20801 @noindent
20802 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
20803
20804
20805
20806 @item
20807 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
20808 @cindex AI-0077 (Ada 2012 feature)
20809
20810 @noindent
20811 This AI clarifies that a declaration does not include a context clause,
20812 and confirms that it is illegal to have a context in which both a limited
20813 and a nonlimited view of a package are accessible. Such double visibility
20814 was always rejected by GNAT.
20815
20816 @noindent
20817 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
20818
20819 @item
20820 @emph{AI-0122 Private with and children of generics (0000-00-00)}
20821 @cindex AI-0122 (Ada 2012 feature)
20822
20823 @noindent
20824 This AI clarifies the visibility of private children of generic units within
20825 instantiations of a parent. GNAT has always handled this correctly.
20826
20827 @noindent
20828 RM References: 10.01.02 (12/2)
20829
20830
20831
20832 @item
20833 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
20834 @cindex AI-0040 (Ada 2012 feature)
20835
20836 @noindent
20837 This AI confirms that a limited with clause in a child unit cannot name
20838 an ancestor of the unit. This has always been checked in GNAT.
20839
20840 @noindent
20841 RM References: 10.01.02 (20/2)
20842
20843 @item
20844 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
20845 @cindex AI-0132 (Ada 2012 feature)
20846
20847 @noindent
20848 This AI fills a gap in the description of library unit pragmas. The pragma
20849 clearly must apply to a library unit, even if it does not carry the name
20850 of the enclosing unit. GNAT has always enforced the required check.
20851
20852 @noindent
20853 RM References: 10.01.05 (7)
20854
20855
20856 @item
20857 @emph{AI-0034 Categorization of limited views (0000-00-00)}
20858 @cindex AI-0034 (Ada 2012 feature)
20859
20860 @noindent
20861 The RM makes certain limited with clauses illegal because of categorization
20862 considerations, when the corresponding normal with would be legal. This is
20863 not intended, and GNAT has always implemented the recommended behavior.
20864
20865 @noindent
20866 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
20867
20868
20869 @item
20870 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
20871 @cindex AI-0035 (Ada 2012 feature)
20872
20873 @noindent
20874 This AI remedies some inconsistencies in the legality rules for Pure units.
20875 Derived access types are legal in a pure unit (on the assumption that the
20876 rule for a zero storage pool size has been enforced on the ancestor type).
20877 The rules are enforced in generic instances and in subunits. GNAT has always
20878 implemented the recommended behavior.
20879
20880 @noindent
20881 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)
20882
20883
20884 @item
20885 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
20886 @cindex AI-0219 (Ada 2012 feature)
20887
20888 @noindent
20889 This AI refines the rules for the cases with limited parameters which do not
20890 allow the implementations to omit ``redundant''. GNAT now properly conforms
20891 to the requirements of this binding interpretation.
20892
20893 @noindent
20894 RM References: 10.02.01 (18/2)
20895
20896 @item
20897 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
20898 @cindex AI-0043 (Ada 2012 feature)
20899
20900 @noindent
20901 This AI covers various omissions in the RM regarding the raising of
20902 exceptions. GNAT has always implemented the intended semantics.
20903
20904 @noindent
20905 RM References: 11.04.01 (10.1/2) 11 (2)
20906
20907
20908 @item
20909 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
20910 @cindex AI-0200 (Ada 2012 feature)
20911
20912 @noindent
20913 This AI plugs a gap in the RM which appeared to allow some obviously intended
20914 illegal instantiations. GNAT has never allowed these instantiations.
20915
20916 @noindent
20917 RM References: 12.07 (16)
20918
20919
20920 @item
20921 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
20922 @cindex AI-0112 (Ada 2012 feature)
20923
20924 @noindent
20925 This AI concerns giving names to various representation aspects, but the
20926 practical effect is simply to make the use of duplicate
20927 @code{Atomic}[@code{_Components}],
20928 @code{Volatile}[@code{_Components}] and
20929 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
20930 now performs this required check.
20931
20932 @noindent
20933 RM References: 13.01 (8)
20934
20935 @item
20936 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
20937 @cindex AI-0106 (Ada 2012 feature)
20938
20939 @noindent
20940 The RM appeared to allow representation pragmas on generic formal parameters,
20941 but this was not intended, and GNAT has never permitted this usage.
20942
20943 @noindent
20944 RM References: 13.01 (9.1/1)
20945
20946
20947 @item
20948 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
20949 @cindex AI-0012 (Ada 2012 feature)
20950
20951 @noindent
20952 It is now illegal to give an inappropriate component size or a pragma
20953 @code{Pack} that attempts to change the component size in the case of atomic
20954 or aliased components. Previously GNAT ignored such an attempt with a
20955 warning.
20956
20957 @noindent
20958 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
20959
20960
20961 @item
20962 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
20963 @cindex AI-0039 (Ada 2012 feature)
20964
20965 @noindent
20966 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
20967 for stream attributes, but these were never useful and are now illegal. GNAT
20968 has always regarded such expressions as illegal.
20969
20970 @noindent
20971 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
20972
20973
20974 @item
20975 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
20976 @cindex AI-0095 (Ada 2012 feature)
20977
20978 @noindent
20979 The prefix of @code{'Address} cannot statically denote a subprogram with
20980 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
20981 @code{Program_Error} if the prefix denotes a subprogram with convention
20982 @code{Intrinsic}.
20983
20984 @noindent
20985 RM References: 13.03 (11/1)
20986
20987
20988 @item
20989 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
20990 @cindex AI-0116 (Ada 2012 feature)
20991
20992 @noindent
20993 This AI requires that the alignment of a class-wide object be no greater
20994 than the alignment of any type in the class. GNAT has always followed this
20995 recommendation.
20996
20997 @noindent
20998 RM References: 13.03 (29) 13.11 (16)
20999
21000
21001 @item
21002 @emph{AI-0146 Type invariants (2009-09-21)}
21003 @cindex AI-0146 (Ada 2012 feature)
21004
21005 @noindent
21006 Type invariants may be specified for private types using the aspect notation.
21007 Aspect @code{Type_Invariant} may be specified for any private type,
21008 @code{Type_Invariant'Class} can
21009 only be specified for tagged types, and is inherited by any descendent of the
21010 tagged types. The invariant is a boolean expression that is tested for being
21011 true in the following situations: conversions to the private type, object
21012 declarations for the private type that are default initialized, and
21013 [@b{in}] @b{out}
21014 parameters and returned result on return from any primitive operation for
21015 the type that is visible to a client.
21016 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
21017 @code{Invariant'Class} for @code{Type_Invariant'Class}.
21018
21019 @noindent
21020 RM References: 13.03.03 (00)
21021
21022 @item
21023 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
21024 @cindex AI-0078 (Ada 2012 feature)
21025
21026 @noindent
21027 In Ada 2012, compilers are required to support unchecked conversion where the
21028 target alignment is a multiple of the source alignment. GNAT always supported
21029 this case (and indeed all cases of differing alignments, doing copies where
21030 required if the alignment was reduced).
21031
21032 @noindent
21033 RM References: 13.09 (7)
21034
21035
21036 @item
21037 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
21038 @cindex AI-0195 (Ada 2012 feature)
21039
21040 @noindent
21041 The handling of invalid values is now designated to be implementation
21042 defined. This is a documentation change only, requiring Annex M in the GNAT
21043 Reference Manual to document this handling.
21044 In GNAT, checks for invalid values are made
21045 only when necessary to avoid erroneous behavior. Operations like assignments
21046 which cannot cause erroneous behavior ignore the possibility of invalid
21047 values and do not do a check. The date given above applies only to the
21048 documentation change, this behavior has always been implemented by GNAT.
21049
21050 @noindent
21051 RM References: 13.09.01 (10)
21052
21053 @item
21054 @emph{AI-0193 Alignment of allocators (2010-09-16)}
21055 @cindex AI-0193 (Ada 2012 feature)
21056
21057 @noindent
21058 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
21059 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
21060 of size.
21061
21062 @noindent
21063 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
21064 13.11.01 (2) 13.11.01 (3)
21065
21066
21067 @item
21068 @emph{AI-0177 Parameterized expressions (2010-07-10)}
21069 @cindex AI-0177 (Ada 2012 feature)
21070
21071 @noindent
21072 The new Ada 2012 notion of parameterized expressions is implemented. The form
21073 is:
21074 @smallexample
21075 @i{function specification} @b{is} (@i{expression})
21076 @end smallexample
21077
21078 @noindent
21079 This is exactly equivalent to the
21080 corresponding function body that returns the expression, but it can appear
21081 in a package spec. Note that the expression must be parenthesized.
21082
21083 @noindent
21084 RM References: 13.11.01 (3/2)
21085
21086 @item
21087 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
21088 @cindex AI-0033 (Ada 2012 feature)
21089
21090 @noindent
21091 Neither of these two pragmas may appear within a generic template, because
21092 the generic might be instantiated at other than the library level.
21093
21094 @noindent
21095 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
21096
21097
21098 @item
21099 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
21100 @cindex AI-0161 (Ada 2012 feature)
21101
21102 @noindent
21103 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
21104 of the default stream attributes for elementary types. If this restriction is
21105 in force, then it is necessary to provide explicit subprograms for any
21106 stream attributes used.
21107
21108 @noindent
21109 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
21110
21111 @item
21112 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
21113 @cindex AI-0194 (Ada 2012 feature)
21114
21115 @noindent
21116 The @code{Stream_Size} attribute returns the default number of bits in the
21117 stream representation of the given type.
21118 This value is not affected by the presence
21119 of stream subprogram attributes for the type. GNAT has always implemented
21120 this interpretation.
21121
21122 @noindent
21123 RM References: 13.13.02 (1.2/2)
21124
21125 @item
21126 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
21127 @cindex AI-0109 (Ada 2012 feature)
21128
21129 @noindent
21130 This AI is an editorial change only. It removes the need for a tag check
21131 that can never fail.
21132
21133 @noindent
21134 RM References: 13.13.02 (34/2)
21135
21136 @item
21137 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
21138 @cindex AI-0007 (Ada 2012 feature)
21139
21140 @noindent
21141 The RM as written appeared to limit the possibilities of declaring read
21142 attribute procedures for private scalar types. This limitation was not
21143 intended, and has never been enforced by GNAT.
21144
21145 @noindent
21146 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
21147
21148
21149 @item
21150 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
21151 @cindex AI-0065 (Ada 2012 feature)
21152
21153 @noindent
21154 This AI clarifies the fact that all remote access types support external
21155 streaming. This fixes an obvious oversight in the definition of the
21156 language, and GNAT always implemented the intended correct rules.
21157
21158 @noindent
21159 RM References: 13.13.02 (52/2)
21160
21161 @item
21162 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
21163 @cindex AI-0019 (Ada 2012 feature)
21164
21165 @noindent
21166 The RM suggests that primitive subprograms of a specific tagged type are
21167 frozen when the tagged type is frozen. This would be an incompatible change
21168 and is not intended. GNAT has never attempted this kind of freezing and its
21169 behavior is consistent with the recommendation of this AI.
21170
21171 @noindent
21172 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)
21173
21174 @item
21175 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
21176 @cindex AI-0017 (Ada 2012 feature)
21177
21178 @noindent
21179 So-called ``Taft-amendment types'' (i.e., types that are completed in package
21180 bodies) are not frozen by the occurrence of bodies in the
21181 enclosing declarative part. GNAT always implemented this properly.
21182
21183 @noindent
21184 RM References: 13.14 (3/1)
21185
21186
21187 @item
21188 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
21189 @cindex AI-0060 (Ada 2012 feature)
21190
21191 @noindent
21192 This AI extends the definition of remote access types to include access
21193 to limited, synchronized, protected or task class-wide interface types.
21194 GNAT already implemented this extension.
21195
21196 @noindent
21197 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
21198
21199 @item
21200 @emph{AI-0114 Classification of letters (0000-00-00)}
21201 @cindex AI-0114 (Ada 2012 feature)
21202
21203 @noindent
21204 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
21205 181 (@code{MICRO SIGN}), and
21206 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
21207 lower case letters by Unicode.
21208 However, they are not allowed in identifiers, and they
21209 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
21210 This behavior is consistent with that defined in Ada 95.
21211
21212 @noindent
21213 RM References: A.03.02 (59) A.04.06 (7)
21214
21215
21216 @item
21217 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
21218 @cindex AI-0185 (Ada 2012 feature)
21219
21220 @noindent
21221 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
21222 classification functions for @code{Wide_Character} and
21223 @code{Wide_Wide_Character}, as well as providing
21224 case folding routines for @code{Wide_[Wide_]Character} and
21225 @code{Wide_[Wide_]String}.
21226
21227 @noindent
21228 RM References: A.03.05 (0) A.03.06 (0)
21229
21230
21231 @item
21232 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
21233 @cindex AI-0031 (Ada 2012 feature)
21234
21235 @noindent
21236 A new version of @code{Find_Token} is added to all relevant string packages,
21237 with an extra parameter @code{From}. Instead of starting at the first
21238 character of the string, the search for a matching Token starts at the
21239 character indexed by the value of @code{From}.
21240 These procedures are available in all versions of Ada
21241 but if used in versions earlier than Ada 2012 they will generate a warning
21242 that an Ada 2012 subprogram is being used.
21243
21244 @noindent
21245 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
21246 A.04.05 (46)
21247
21248
21249 @item
21250 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
21251 @cindex AI-0056 (Ada 2012 feature)
21252
21253 @noindent
21254 The wording in the Ada 2005 RM implied an incompatible handling of the
21255 @code{Index} functions, resulting in raising an exception instead of
21256 returning zero in some situations.
21257 This was not intended and has been corrected.
21258 GNAT always returned zero, and is thus consistent with this AI.
21259
21260 @noindent
21261 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
21262
21263
21264 @item
21265 @emph{AI-0137 String encoding package (2010-03-25)}
21266 @cindex AI-0137 (Ada 2012 feature)
21267
21268 @noindent
21269 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
21270 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
21271 and @code{Wide_Wide_Strings} have been
21272 implemented. These packages (whose documentation can be found in the spec
21273 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
21274 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
21275 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
21276 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
21277 UTF-16), as well as conversions between the different UTF encodings. With
21278 the exception of @code{Wide_Wide_Strings}, these packages are available in
21279 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
21280 The @code{Wide_Wide_Strings package}
21281 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
21282 mode since it uses @code{Wide_Wide_Character}).
21283
21284 @noindent
21285 RM References: A.04.11
21286
21287 @item
21288 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
21289 @cindex AI-0038 (Ada 2012 feature)
21290
21291 @noindent
21292 These are minor errors in the description on three points. The intent on
21293 all these points has always been clear, and GNAT has always implemented the
21294 correct intended semantics.
21295
21296 @noindent
21297 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)
21298
21299 @item
21300 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
21301 @cindex AI-0044 (Ada 2012 feature)
21302
21303 @noindent
21304 This AI places restrictions on allowed instantiations of generic containers.
21305 These restrictions are not checked by the compiler, so there is nothing to
21306 change in the implementation. This affects only the RM documentation.
21307
21308 @noindent
21309 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)
21310
21311 @item
21312 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
21313 @cindex AI-0127 (Ada 2012 feature)
21314
21315 @noindent
21316 This package provides an interface for identifying the current locale.
21317
21318 @noindent
21319 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
21320 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
21321
21322
21323
21324 @item
21325 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
21326 @cindex AI-0002 (Ada 2012 feature)
21327
21328 @noindent
21329 The compiler is not required to support exporting an Ada subprogram with
21330 convention C if there are parameters or a return type of an unconstrained
21331 array type (such as @code{String}). GNAT allows such declarations but
21332 generates warnings. It is possible, but complicated, to write the
21333 corresponding C code and certainly such code would be specific to GNAT and
21334 non-portable.
21335
21336 @noindent
21337 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
21338
21339
21340 @item
21341 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
21342 @cindex AI05-0216 (Ada 2012 feature)
21343
21344 @noindent
21345 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
21346 forbid tasks declared locally within subprograms, or functions returning task
21347 objects, and that is the implementation that GNAT has always provided.
21348 However the language in the RM was not sufficiently clear on this point.
21349 Thus this is a documentation change in the RM only.
21350
21351 @noindent
21352 RM References: D.07 (3/3)
21353
21354 @item
21355 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
21356 @cindex AI-0211 (Ada 2012 feature)
21357
21358 @noindent
21359 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
21360 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
21361
21362 @noindent
21363 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
21364
21365 @item
21366 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
21367 @cindex AI-0190 (Ada 2012 feature)
21368
21369 @noindent
21370 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
21371 used to control storage pools globally.
21372 In particular, you can force every access
21373 type that is used for allocation (@b{new}) to have an explicit storage pool,
21374 or you can declare a pool globally to be used for all access types that lack
21375 an explicit one.
21376
21377 @noindent
21378 RM References: D.07 (8)
21379
21380 @item
21381 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
21382 @cindex AI-0189 (Ada 2012 feature)
21383
21384 @noindent
21385 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
21386 which says that no dynamic allocation will occur once elaboration is
21387 completed.
21388 In general this requires a run-time check, which is not required, and which
21389 GNAT does not attempt. But the static cases of allocators in a task body or
21390 in the body of the main program are detected and flagged at compile or bind
21391 time.
21392
21393 @noindent
21394 RM References: D.07 (19.1/2) H.04 (23.3/2)
21395
21396 @item
21397 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
21398 @cindex AI-0171 (Ada 2012 feature)
21399
21400 @noindent
21401 A new package @code{System.Multiprocessors} is added, together with the
21402 definition of pragma @code{CPU} for controlling task affinity. A new no
21403 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
21404 is added to the Ravenscar profile.
21405
21406 @noindent
21407 RM References: D.13.01 (4/2) D.16
21408
21409
21410 @item
21411 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
21412 @cindex AI-0210 (Ada 2012 feature)
21413
21414 @noindent
21415 This is a documentation only issue regarding wording of metric requirements,
21416 that does not affect the implementation of the compiler.
21417
21418 @noindent
21419 RM References: D.15 (24/2)
21420
21421
21422 @item
21423 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
21424 @cindex AI-0206 (Ada 2012 feature)
21425
21426 @noindent
21427 Remote types packages are now allowed to depend on preelaborated packages.
21428 This was formerly considered illegal.
21429
21430 @noindent
21431 RM References: E.02.02 (6)
21432
21433
21434
21435 @item
21436 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
21437 @cindex AI-0152 (Ada 2012 feature)
21438
21439 @noindent
21440 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
21441 where the type of the returned value is an anonymous access type.
21442
21443 @noindent
21444 RM References: H.04 (8/1)
21445 @end itemize
21446
21447
21448 @node Obsolescent Features
21449 @chapter Obsolescent Features
21450
21451 @noindent
21452 This chapter describes features that are provided by GNAT, but are
21453 considered obsolescent since there are preferred ways of achieving
21454 the same effect. These features are provided solely for historical
21455 compatibility purposes.
21456
21457 @menu
21458 * pragma No_Run_Time::
21459 * pragma Ravenscar::
21460 * pragma Restricted_Run_Time::
21461 @end menu
21462
21463 @node pragma No_Run_Time
21464 @section pragma No_Run_Time
21465
21466 The pragma @code{No_Run_Time} is used to achieve an affect similar
21467 to the use of the "Zero Foot Print" configurable run time, but without
21468 requiring a specially configured run time. The result of using this
21469 pragma, which must be used for all units in a partition, is to restrict
21470 the use of any language features requiring run-time support code. The
21471 preferred usage is to use an appropriately configured run-time that
21472 includes just those features that are to be made accessible.
21473
21474 @node pragma Ravenscar
21475 @section pragma Ravenscar
21476
21477 The pragma @code{Ravenscar} has exactly the same effect as pragma
21478 @code{Profile (Ravenscar)}. The latter usage is preferred since it
21479 is part of the new Ada 2005 standard.
21480
21481 @node pragma Restricted_Run_Time
21482 @section pragma Restricted_Run_Time
21483
21484 The pragma @code{Restricted_Run_Time} has exactly the same effect as
21485 pragma @code{Profile (Restricted)}. The latter usage is
21486 preferred since the Ada 2005 pragma @code{Profile} is intended for
21487 this kind of implementation dependent addition.
21488
21489 @include fdl.texi
21490 @c GNU Free Documentation License
21491
21492 @node Index,,GNU Free Documentation License, Top
21493 @unnumbered Index
21494
21495 @printindex cp
21496
21497 @contents
21498
21499 @bye
21500 tablishes the following set of restrictions:
21501 Pragma Shared